How to use typefind?
roonie
mdzubair89 at yahoo.co.in
Tue Sep 2 03:20:58 PDT 2014
To stat with I am just a beginner in gstreamer and I am in the process of
development of an application which sends video data to the listener and
listener decodes it to play. For this am using gstreamer.
But before that iam trying to understand gstreamer.
I have got a standalone code which generates a pad-added signal and call
back is hit.
Iam using I.MX6 board for playback.
I used gst-launch to playback a "ts file and as well as mp4 file" using the
below command.
gst-launch-0.10 filesrc location=/opt/zubair/test/stream2.ts typefind=true !
aiurdemux name=demux demux. ! queue ! beepdec ! audioconvert ! autoaudiosink
demux. ! queue ! vpudec! mfw_v4lsink
which then i brought it into the code with perfectly using the demuxer and
the required elements.
Here i find "typefind=true" is set which I am not sure how to bring it to
the code. As far i understood typefind sets the src pads after finding the
CAP which for my file i got it as
<?xml version="1.0"?>
<Capabilities>
<Caps1>video/mpegts, systemstream=(boolean)true,
packetsize=(int)188</Caps1>
</Capabilities>
Cap = video/mpegts
Anyway the standalone which i developed is as follows. While running the
standalone i get
"Pipeline state changed from NULL to READY:" and it doesnt playback. It just
keeps running. Below is my standalone code
data.source = gst_element_factory_make ("filesrc", "source");
g_object_set (data.source, "location", argv[1], NULL);
data.typefind = gst_element_factory_make ("typefind", "typefinder");
data.demuxer = gst_element_factory_make ("aiurdemux", "demuxer");
data.audioqueue = gst_element_factory_make("queue","audioqueue");
data.videoqueue = gst_element_factory_make("queue","videoqueue");
data.audio_decoder = gst_element_factory_make ("beepdec",
"audio_decoder");
data.audio_convert = gst_element_factory_make ("audioconvert",
"audio_convert");
data.audio_sink = gst_element_factory_make ("autoaudiosink",
"audio_sink");
data.video_decoder =
gst_element_factory_make("vpudec","video_decoder");
data.video_sink =
gst_element_factory_make("mfw_v4lsink","video_sink");
if (!gst_element_link(data.source,data.demuxer)) {
g_printerr ("Elements could not be linked.\n");
gst_object_unref (data.pipeline);
return -1;
}
if (!gst_element_link_many
(data.audioqueue,data.audio_decoder,data.audio_convert,
data.audio_sink,NULL)) {
g_printerr (" audio Elements could not be linked.\n");
gst_object_unref (data.pipeline);
return -1;
}
if (!gst_element_link_many(data.videoqueue,data.video_decoder,
data.video_sink,NULL)) {
g_printerr("video Elements could not be linked.\n");
gst_object_unref(data.pipeline);
return -1;
}
//g_object_set (data.source, "location", argv[1], NULL);
g_signal_connect (data.demuxer, "pad-added", G_CALLBACK
(pad_added_handler), &data);
/* Start playing */
CALLBACK FUNCTION
static void pad_added_handler (GstElement *src, GstPad *new_pad, CustomData
*data) {
g_print("Inside the pad_added_handler method \n");
printf("Inside the pad_added_handler method \n");
GstPad *sink_pad_audio = gst_element_get_static_pad
(data->audioqueue, "sink");
GstPad *sink_pad_video = gst_element_get_static_pad
(data->videoqueue, "sink");
GstPadLinkReturn ret;
GstCaps *new_pad_caps = NULL;
GstStructure *new_pad_struct = NULL;
const gchar *new_pad_type = NULL;
g_print ("Received new pad '%s' from '%s':\n", GST_PAD_NAME
(new_pad), GST_ELEMENT_NAME (src));
new_pad_caps = gst_pad_get_caps (new_pad);
new_pad_struct = gst_caps_get_structure (new_pad_caps, 0);
new_pad_type = gst_structure_get_name (new_pad_struct);
if (g_str_has_prefix (new_pad_type,/*"audio/x-vorbis"*/
"audio/mpeg"))
{
ret = gst_pad_link (new_pad, sink_pad_audio);
if (GST_PAD_LINK_FAILED (ret))
{
g_print (" Type is '%s' but link failed.\n",
new_pad_type);
}
else
{
g_print (" Link succeeded (type '%s').\n",
new_pad_type);
}
}
//else if (g_str_has_prefix (new_pad_type,
/*"video/x-theora"*/"video/x-h264"))
else if (g_str_has_prefix (new_pad_type,
/*"video/x-theora"*/"video/mpegts"))
{
ret = gst_pad_link (new_pad, sink_pad_video);
if (GST_PAD_LINK_FAILED (ret))
{
g_print (" Type is '%s' but link failed.\n",
new_pad_type);
}
else
{
g_print (" Link succeeded (type '%s').\n",
new_pad_type);
}
}
else {
g_print (" It has type '%s' which is not raw audio.
Ignoring.\n", new_pad_type);
goto exit;
}
exit:
if (new_pad_caps != NULL)
gst_caps_unref (new_pad_caps);
gst_object_unref (sink_pad_audio);
gst_object_unref (sink_pad_video);
}
I have reduced some of the code. Can you please guide what Iam missing
here.?..
Iam not sure how to bring type find into the code.
Thanks
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/How-to-use-typefind-tp4668508.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
More information about the gstreamer-devel
mailing list