[gst-devel] How can I get full information about a media file?

wl2776 wl2776 at gmail.com
Wed Mar 31 16:49:27 CEST 2010



lrn-2 wrote:
> 
> An approach that worked for me:
> 
> Create a pipeline, bus.
> Create uridecodebin, set its uri property (or create filesrc, decodebin
> and link them)
> Set up "no-more-pads", "unknown-type" handlers
> 

Thank you! This almost works. 
The problem is, the "no-more-pads" callback is not always called. It is
called only if I trace my program in a debugger. If the program runs freely,
it doesn't called.

My code is the following (error checking is omitted for brevity).
Big question is should I call gst_message_unref both in bus the cycle,
polling a bus, and in bus_watch?

parse() 
{
  gboolean r=TRUE;
  GstMessage *msg;

  m_pipeline = gst_pipeline_new("playbin");
  m_uridecodebin = gst_element_factory_make("uridecodebin","decode");

  g_object_set(G_OBJECT(m_uridecodebin),"uri",m_filename,NULL);
 
g_signal_connect(G_OBJECT(m_uridecodebin),"no-more-pads",G_CALLBACK(no_more_pads_cb),this);
 
g_signal_connect(G_OBJECT(m_uridecodebin),"unknown-type",G_CALLBACK(unknown_type_cb),this);

  gst_bin_add(GST_BIN(m_pipeline),m_uridecodebin);
  bus = gst_pipeline_get_bus(GST_PIPELINE(m_pipeline));

  gst_element_set_state(GST_ELEMENT(m_pipeline),GST_STATE_PAUSED);
	
  while ((msg = gst_bus_pop (bus)) && r) {
    r=bus_watch(bus, msg);
    gst_message_unref (msg);
  }
}

gboolean bus_watch(GstBus* bus, GstMessage *msg)
{
  if(msg->structure)
    gst_structure_foreach(msg->structure,foreach_func,msg);

  switch (GST_MESSAGE_TYPE (msg)) {
    case GST_MESSAGE_ASYNC_DONE:
      gst_message_unref(msg);
      return FALSE;
    case GST_MESSAGE_EOS:
      gst_element_set_state(GST_ELEMENT(m_pipeline),GST_STATE_NULL);
      gst_message_unref(msg);
      return FALSE;
    case GST_MESSAGE_TAG: //TODO collect tags
      break;
    default:
      break;
  }
  gst_message_unref(msg);
  return TRUE;
}

-- 
View this message in context: http://n4.nabble.com/How-can-I-get-full-information-about-a-media-file-tp1745331p1746871.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.




More information about the gstreamer-devel mailing list