LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-09-2010, 11:50 AM   #1
HarryBoy
Member
 
Registered: Apr 2008
Distribution: MontaVista Linux Version 4.0.1, Professional Edition
Posts: 215

Rep: Reputation: 16
GStreamer question - expert needed!


Hi I have a gstreamer pipeline set up like so:

/
Code:
/Create pipeline
m_pPipeline = GST_PIPELINE(gst_pipeline_new("livemjpg-player"));
 
// Create source elements
GstElement *source = gst_element_factory_make("rtspsrc", "source");
 
g_object_set(source, "location", rtspUrl.c_str(), NULL );

// Create decode element
GstElement *decode = gst_element_factory_make("decodebin2", "decode");
 
// Create jpeg encoder element
GstElement *encoder = gst_element_factory_make("jpegenc", "jpegenc");
 
 // Create sink format element
 GstElement *sink = gst_element_factory_make("fdsink", "sink");

 // Add elements to the pipeline

  gst_bin_add_many( GST_BIN(m_pPipeline), source, decode, encoder, sink, NULL);


// Link all elements except source and decoder
// The rtspsrc and decoder will automatically determine the appropriate pad
// at run time and then they will link accordingly

gst_element_link_many(encoder, sink, NULL));
 
g_signal_connect(source, "pad-added", G_CALLBACK(on_rtsppad_added),
                   decode );
g_signal_connect(decode, "new-decoded-pad", G_CALLBACK (on_pad_added),
                   encoder );
When the soruce pad is detected the on_rtsppad_added function is called:

Quote:
static void on_rtsppad_added(GstElement *element,
GstPad *pad,
gpointer data)
{
GstElement *linkElement = (GstElement *) data;
GstPad *sinkpad = gst_element_get_static_pad (linkElement, "sink");

if ( GST_PAD_IS_LINKED( sinkpad ) )
{
gst_pad_unlink (pad, sinkpad))
}
GstPadLinkReturn linkreturn = gst_pad_link (pad, sinkpad);
gst_object_unref(GST_OBJECT (sinkpad));

}
then the on_pad_added function is called:

Code:
static void on_pad_added(GstElement *element,
                         GstPad     *pad,
                         gboolean   last,
                         gpointer    data)
{
  GstElement *linkElement = (GstElement *) data;
  GstPad *sinkpad = gst_element_get_static_pad (linkElement, "sink");

  if ( GST_PAD_IS_LINKED( sinkpad ) )
  {
    g_object_unref(sinkpad);
    return;
  }
  // Link pads (decoder --> <link Element>)
  gst_pad_link (pad, sinkpad);

  gst_object_unref(GST_OBJECT (sinkpad));

}

The source is a video stream from an rtsp server. Everything works fine until the video stream changes from e.g. MJPEG to MP4. The video stops diaplaying on my output and the following happens in my debug window:

1. After a few seconds the function on_rtsppad_added is called because it detects a new input stream.
2. I check to see if the pad is already linked:
Code:
if ( GST_PAD_IS_LINKED( sinkpad ) )
  {
      gst_pad_unlink (pad, sinkpad))
  }
and it tells me that it IS linked. So I try to unlink it but the return code from gst_pad_unlink (pad, sinkpad)) is GST_PAD_LINK_WAS_LINKED.
**Note**
The unlinking code is code I have added in to try and get round the problem of the video stopping. Normally after on_rtsppad_added is called, on_pad_added gets called but what i see is that on_pad_added does not get called at all when the stream type changes.

Questions:
1. Why is it telling me that the pad is linked? Is this not a new pad that should not be linked to anything>
2. Why will it not let me unlink the pad so that I can re-link it and then hopefuly on_pad_added will get called and all will be ok.


Thanks experts.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Samba expert needed! martinlangley Linux - Networking 6 06-11-2009 12:31 PM
lm_sensors expert needed! Fezar Linux - Newbie 5 03-19-2007 03:17 PM
expert help needed with bash and bc karistouf Programming 5 06-22-2005 12:55 AM
X11 Expert Needed hilltop*Tech Linux - Hardware 4 06-10-2005 09:11 AM
bash expert help needed illtbagu Programming 15 10-05-2004 08:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration