Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bindings for gst_element_class*() and similar class functions #28

Closed
fengalin opened this issue Aug 16, 2017 · 4 comments
Closed

Add bindings for gst_element_class*() and similar class functions #28

fengalin opened this issue Aug 16, 2017 · 4 comments

Comments

@fengalin
Copy link
Contributor

I'm following this tutorial in order to implement a tee in my audio pipeline.

To get the src pads from the tee, the tutorial proposes using:

  tee_src_pad_template = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (tee), "src_%d");
  tee_audio_pad = gst_element_request_pad (tee, tee_src_pad_template, NULL, NULL);

ElementClass is not generated, but I found get_compatible_pad_template on Element. So I tried this in the connect_pad_added callback (my source is a uridecodebin):

    [...]
    let tee = gst::ElementFactory::make("tee", None).unwrap();
    pipeline.add(&tee).unwrap();

    let tee_sink = tee.get_static_pad("sink").unwrap();
    assert_eq!(src_pad.link(&tee_sink), gst::PadLinkReturn::Ok);

    let pad_tmpl = PadTemplate::new("src_%d",
        PadDirection::Src,
        PadPresence::Request,
        &Caps::new_any()
    );
    let tee_src_pad_tmpl = tee.get_compatible_pad_template(&pad_tmpl).unwrap();
    let tee_src_pad = tee.request_pad(&tee_src_pad_tmpl, None, None)
        .expect("Couldn't get src pad from gst tee");

Which fails on tee.request_pad() with the following message:

(.:8073): GStreamer-CRITICAL **: gst_element_request_pad: assertion 'templ->presence == GST_PAD_REQUEST' failed

I can continue investigating, but if you tell me that this isn't going to work, I'd implement the binding to ElementClass instead.

@sdroege
Copy link
Owner

sdroege commented Aug 16, 2017

You can use tee.get_request_pad("src_%u") for example. But not having the gst_element_class_* functions is indeed problematic. Should add them

@sdroege
Copy link
Owner

sdroege commented Aug 16, 2017

Also for your code with get_compatible_pad_template to work, you need to create a sink pad template IIRC. It gets a pad template that can be linked to yours, so of the opposite direction.

@sdroege sdroege changed the title Question: getting "Request" pads Add bindings for gst_element_class*() and similar class functions Aug 16, 2017
@fengalin
Copy link
Contributor Author

Thank you! Using tee.get_request_pad("src_%u") works indeed! I tried it before, but with "src_%d", like in the C example and it failed.

@sdroege
Copy link
Owner

sdroege commented Aug 16, 2017

Thanks, fixed in the docs (and simplified the tutorial): http://cgit.freedesktop.org/gstreamer/gst-docs/commit/?id=1a9f0541be419798eacc6fedf50cadadebca352b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants