After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 689845 - Encodebin API to handle multiple streams lacking
Encodebin API to handle multiple streams lacking
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
1.x
Other Linux
: Normal enhancement
: 1.1.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-12-07 14:21 UTC by Christian Fredrik Kalager Schaller
Modified: 2013-03-31 10:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
encodebin: Add action signal to get pad for a given profile (13.95 KB, patch)
2013-03-28 14:22 UTC, Edward Hervey
none Details | Review

Description Christian Fredrik Kalager Schaller 2012-12-07 14:21:05 UTC
Been looking at the API docs and I can not figure out how to do this.
So I have an encodebin where I created to audio profiles, lets say one for vorbis and one for mp3. So I have a file decoded by uridecodebin which has two audio streams and I want to use the vorbis stream with one and the mp3 stream for the other. 

I can not figure out how to ask encodebin to give me a pad connected to a specific profile. The 'request-pad' signal only offers to give you a pad which can handle your incoming caps, but that would be raw audio data for both feeds.
Comment 1 Christian Fredrik Kalager Schaller 2012-12-10 12:26:09 UTC
Suggested "workaround" code from Alessandro. I will try to test this as soon as possible.   

 def find_encodebin_pads(self, pad, pad_type):
        for sink_pad in self.encodebin.sinkpads:
            if pad.can_link(sink_pad):
                yield sink_pad

        template = Gst.PadTemplate.new(pad_type + '_%d', Gst.PadDirection.SINK,
                Gst.PadPresence.REQUEST, pad.query_caps())
        sink_pad = self.encodebin.request_pad(template,
                pad_type + '_%d', pad.query_caps())
        if sink_pad is not None:
            yield sink_pad
Comment 2 Christian Fredrik Kalager Schaller 2012-12-11 10:16:36 UTC
Realized upon trying this code that it doesn't help with this bug at all :) The challenge in this bug is having 2 audio streams and being able to choose what format to encode them into, the 'workaround' code above actually just does what the existing 'request-pad' signal already does which is provide a pad compatible with your incoming pad.
Comment 3 Christian Fredrik Kalager Schaller 2012-12-30 09:35:07 UTC
Been thinking about this bug over the holidays, I think the simplest API I can think of for this is that when you create the profile you can also give it a name, and then you should be able to use that name with the request-pad signal to request your specific profile.
Comment 4 Edward Hervey 2013-03-28 13:54:11 UTC
One way to circumvent that limitation it to specify the encoded caps when requesting a pad. Encodebin will search for a profile that can accept those encoded caps ... even if you'll be sending it raw audio/video later on.

gst_element_request_pad(encodebin, <a template>, "audio_1", gst_caps_new_simple("audio/x-vorbis");

or using the "request-pad" action signal

Note that this will only work if your various profiles use different caps. If you have several profiles with *exactly* the same caps ... you can't make the difference.

Trying to figure out a way to specify a profile another way.
Comment 5 Edward Hervey 2013-03-28 14:22:13 UTC
Created attachment 240060 [details] [review]
encodebin: Add action signal to get pad for a given profile

This allows getting a pad for a specific encoding profile, which can
be useful when there are several stream profiles of the same type.

Also update the encodebin unit tests so that we check that the returned
pad has the right caps.
Comment 6 Edward Hervey 2013-03-31 10:05:18 UTC
commit b3d94bd0e4ce735c3529a20068689a1113a85639
Author: Edward Hervey <edward@collabora.com>
Date:   Thu Mar 28 15:20:19 2013 +0100

    encodebin: Add action signal to get pad for a given profile
    
    This allows getting a pad for a specific encoding profile, which can
    be useful when there are several stream profiles of the same type.
    
    Also update the encodebin unit tests so that we check that the returned
    pad has the right caps.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=689845