[gst-devel] Help Decodeb program.in

giorgio giorgio at ketron.it
Mon Apr 26 11:46:57 CEST 2010


Hi,
I am trying to realize a simple program to play video file using
decodebin as decoder on my embedded platform with Gstreamer installed.

Those are some code fragment of my test program:
//------------------------------------------------------------------------------------------------------------------
static void
typefound_cb (GstElement *typefind,
	      guint       probability,
	      GstCaps    *caps,
	      gpointer    data)
{
  GMainLoop *loop = (GMainLoop *)data;
  gchar *type;
  type = gst_caps_to_string (caps);
  printf ("Media type %s found, probability %d%%\n", type, probability);
  g_free (type);    
}
//------------------------------------------------------------------------------------------------------------------
static gboolean
cb_print_position (GstElement *pipeline)
{
  GstFormat fmt = GST_FORMAT_TIME;
  gint64 pos, len;

  if (gst_element_query_position (pW->pipeline, &fmt, &pos)
    && gst_element_query_duration (pW->pipeline, &fmt, &len)) {
    printf ("Time: %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT "\r",
	     GST_TIME_ARGS (pos), GST_TIME_ARGS (len));
  }

  /* call me again */
  return TRUE;
}

//------------------------------------------------------------------------------------------------------------------
static void cb_newpad (GstElement *decodebin,
       GstPad     *pad,
       gboolean    last,
       gpointer    data)
{

	GstCaps *caps;
	GstStructure *str;
	GstPad *audiopad,*videopad;
	gchar *tex;

	/* check media type */
	caps = gst_pad_get_caps (pad);
	str = gst_caps_get_structure (caps, 0);
	tex = (gchar *)gst_structure_get_name(str);

	if(g_strrstr(tex,"audio"))
	{
		audiopad = gst_element_get_static_pad (pW->audio, "sink");
		if(GST_PAD_IS_LINKED(audiopad))
		{
			g_object_unref(audiopad);
			return;
		}
		else
		{
			gst_pad_link(pad,audiopad);
			g_object_unref(audiopad);
		}
		return;
	}

	/* link videopad */
	videopad = gst_element_get_static_pad(pW->video,"sink");
	if (!GST_PAD_IS_LINKED (videopad)) {
		gst_pad_link(pad,videopad);
		gst_element_link(pW->videoqueue,pW->video);
		g_object_unref (videopad);
		return;
	}

}
//------------------------------------------------------------------------------------------------------------------
void PlayerTest::VideoPlayerGst(char* pName){

	gst_init (NULL, NULL);
	loop = g_main_loop_new (NULL, FALSE);

	pipeline = gst_pipeline_new ("pipeline");
	bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
	gst_bus_add_watch (bus, my_bus_callback, loop);
	//gst_bus_add_watch (bus, NULL, loop);
	gst_object_unref (bus);

src = gst_element_factory_make ("filesrc", "source");
	g_object_set (G_OBJECT (src), "location", pName, NULL);

	typefind = gst_element_factory_make("typefind","typefinder");
	g_signal_connect(typefind,"have-type",G_CALLBACK(typefound_cb),loop);

	decoder	 = gst_element_factory_make ("decodebin2", "decoder");
	g_signal_connect (decoder, "new-decoded-pad", G_CALLBACK (cb_newpad),
NULL);

	audioqueue = gst_element_factory_make("queue","audioqueue");
	videoqueue = gst_element_factory_make("queue","videoqueue");

	gst_bin_add_many (GST_BIN (pipeline), src,typefind,decoder,NULL);
	gst_element_link_many (src,typefind,decoder,NULL);

	// create audio output
	audio 		= gst_bin_new ("audiobin");
	conv 		= gst_element_factory_make ("audioconvert", "aconv");

	typefind2 	= gst_element_factory_make("typefind","typefinder2");
	g_signal_connect(typefind2,"have-type",G_CALLBACK(typefound_cb),loop);

	audiopad 	= gst_element_get_static_pad (audioqueue, "sink");
	sink 		= gst_element_factory_make ("alsasink", "sink");

	gst_bin_add_many (GST_BIN (audio),audioqueue,conv,typefind2, sink,
NULL);
	gst_element_link_many (audioqueue,conv,typefind2, sink,NULL);

	gst_element_add_pad (audio, gst_ghost_pad_new ("sink", audiopad));
	gst_object_unref (audiopad);

	gst_bin_add (GST_BIN (pipeline), audio);

	// create video output
	video 		= gst_bin_new("videobin");
	convVid 	= gst_element_factory_make("ffmpegcolorspace","converter");
	videopad 	= gst_element_get_static_pad(videoqueue,"sink");
	videosink 	= gst_element_factory_make("mfw_v4lsink","videosink");

	gst_bin_add_many(GST_BIN(video),videoqueue,convVid,videosink,NULL);
	gst_element_link_many(videoqueue,convVid,videosink,NULL);
	gst_element_add_pad(video,gst_ghost_pad_new("sink",videopad));
	gst_object_unref(videopad);

	gst_bin_add(GST_BIN(pipeline),video);

	// run
	gst_element_set_state (pipeline, GST_STATE_PLAYING);
	g_timeout_add (200, (GSourceFunc) cb_print_position, pipeline);

	g_main_loop_run (loop);

	// cleanup
	gst_element_set_state (pipeline, GST_STATE_NULL);
	gst_object_unref (GST_OBJECT (pipeline));
}

//-----------------------------------------------------------------------------------------

Where mfw_v4lsink is my Video rendering device plugin.

When I try to play a video file, nothing happens.
>From may output console I can read this messages:

---
---

MFW_GST_V4LSINK_PLUGIN 1.7.1 build on Apr  7 2010 09:23:18.
MPEG4PARSER_05.14.02  build on Sep 16 2009 15:48:34.
MFW_GST_MP4_PARSER_PLUGIN 1.7.1 build on Apr  7 2010 09:23:01.[0mvideo
type(0):33.
[INFO]\0x09Product Info: i.MX51
VPU Version: firmware 15.2.2; libvpu: 4.7.4 
MFW_GST_VPU_DECODER_PLUGIN 1.7.1 build on Apr  7 2010 09:22:32.
BLN_MAD-MMCODECS_AACD_ARM_03.05.00  build on Nov 25 2009 
Unhandled fault: external abort on non-linefetch (0x1018) at 0x44433054

15:02:24.
MFW_GST_AAC_PLUGIN 1.7.1 build on Apr  7 2010 09:22:01.
Got state-changed message
Got state-changed message
Got state-changed message
Got state-changed message
...
...
Got tag message
Got stream-status message
Got stream-status message
Got stream-status message
Got state-changed message
Got state-changed message
Got stream-status message
Got state-changed message
Got state-changed message

(<unknown>:2067): GLib-GObject-CRITICAL **: g_value_get_boolean:
assertion `G_VALUE_HOLDS_BOOLEAN (value)' failed
Got state-changed message
Media type audio/x-raw-int, endianness=(int)1234, signed=(boolean)true,
width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2,
channel-positions=(GstAudioChannelPosition)<
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER,
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER > found, probability
100%
[V4L Update Display]: left=0, top=0, width=640, height=360
[0m>>V4L_SINK: Actually buffer status:
hardware buffer : 6
software buffer : 0

Time: 0:00:00.000000000 / 0:01:31.985633280
Time: 0:00:00.000000000 / 0:01:31.985633280
Got stream-status message
Got warning message
Got state-changed message
Got state-changed message

Time: 0:00:00.000000000 / 0:01:31.985633280
Time: 0:00:00.000000000 / 0:01:31.985633280
Time: 0:00:00.000000000 / 0:01:31.985633280
....
....
 

>From this output messages seems that the dedecoder pipeline is not
playing (like Pause).

Could this be a problem with my board or it could be caused by an error
in my code?
What can I do to understand why playing the file does not start?


Giorgio.

 








More information about the gstreamer-devel mailing list