AW: tcpclientsrc and mpegtsdemux

Nathanael D. Noblet nathanael at gnat.ca
Sat Jun 4 08:14:57 PDT 2011


On 06/04/2011 03:04 AM, Bernhard Graaf wrote:
> Hi,
>
> thanks' a lot for helping. I've change the code with handle the dynamic-pads
> between muxer/audio-dec and audio-dec/audio-sink and it work great with only
> audio data.
> If I try to use the queue-pad, I have a problem to understand this.
> Should I define two queues? One for video and one for audio? Or is there
> only one queue and I link this to both? But then, how could I handle the
> dynamic-pads? Do you have an example for using the queue-element to split a
> stream (e.g Mpeg2) to video/audio-data in a C-program?
>
> I know: there are a lot of questions about using the queue-element.
> But I'm sure that there is a person, who can help me to fix this problem!

queue's don't split data. Their main purpose (from my understanding) is 
as a thread/syncronization point. Most often used when splitting a 
stream like video into multiple streams, so for example

                    tee- queue - xv
                   /   \ queue - filesink
	      /video
src -> demux -
	      \audio
                   \tee - queue - pulsesink
                       \  queue - filesink


So for your situation you want an on_pad_added call that figures out 
whether you're getting an audio or video pad/stream. Here's one I have 
for a very specific use case (not expecting to get different types of 
streams/pads etc).. You can see that since I find the other matching 
side of the pipeline with a very specific name.


void on_recording_pad_added (GstElement *decoder, GstPad *pad, gpointer 
data)
{
     GstCaps      *caps      = gst_pad_get_caps(pad);
     GstBin       *bin       = (GstBin *)data;
     GstStructure *structure = gst_caps_get_structure(caps,0);
     int ret                 = 0;

     GstElement *element;
     GstPad     *targetsink;

     gchar       *structure_g = gst_structure_to_string(structure);
     g_free(structure_g);
     if(g_strrstr(gst_structure_get_string(structure,"media"), "video"))
     {
         element    = gst_bin_get_by_name (bin,"recording-rtspvdepay");
         targetsink = gst_element_get_pad(element,"sink");

         ret = gst_pad_link(pad,targetsink);
         if(ret != GST_PAD_LINK_OK)
             log_pad_added(ret,pad,targetsink,"Unable to link video");

         gst_object_unref(targetsink);
         gst_object_unref(element);
     }

     if(g_strrstr(gst_structure_get_string(structure,"media"), "audio"))
     {
         element    = gst_bin_get_by_name (bin,"recording-rtpmp4gdepay");
         targetsink = gst_element_get_pad(element,"sink");

         ret     = gst_pad_link(pad,targetsink);
         if(ret != GST_PAD_LINK_OK)
             log_pad_added(ret,pad,targetsink,"Unable to link audio");

         gst_object_unref(targetsink);//MW#11 unrefed here
         gst_object_unref(element);
     }

     gst_caps_unref (caps);

     return;
}


More information about the gstreamer-devel mailing list