Not getting GST_MESSAGE_EOS from recording bus
amar
asontakke at phonologies.com
Wed Oct 30 13:43:17 CET 2013
Hi Olivier,
I have written video recorder in a C code for audio and video recording
into mpg file using matroskamux. I can record video successfully but I
can't get GST_MESSAGE_EOS for end of streaming on bus.
C code for recorder :
#include <gst/gst.h>
static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_EOS:
g_print ("End of stream\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:{
gchar *debug;
GError *error;
gst_message_parse_error (msg, &error, &debug);
g_free (debug);
g_printerr ("Error: %s\n", error->message);
g_error_free (error);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}
int main (int argc, char *argv[])
{
GMainLoop *loop;
GstElement *pipeline, *vsource, *vcapsfilter, *h263rtpdepay, *h263dec,
*queue1;
GstElement *asource, *acapsfilter, *pcmurtpdepay, *mulawdec, *queue2;
GstElement *mux, *sink;
GstBus *bus;
guint bus_watch_id;
GstCaps *caps;
/* Initialisation */
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/* Check input arguments */
if (argc != 2) {
g_printerr ("Usage: %s <MPG filename\n", argv[0]);
return -1;
}
/* Create gstreamer elements */
pipeline = gst_pipeline_new ("av-recorder");
vsource = gst_element_factory_make ("udpsrc", "vid-source");
vcapsfilter = gst_element_factory_make ("capsfilter", "vid-caps");
h263rtpdepay = gst_element_factory_make ("rtph263pdepay",
"vrtpdepay");
h263dec = gst_element_factory_make ("avdec_h263", "vdecoder");
queue1 = gst_element_factory_make ("queue", "queue1");
asource = gst_element_factory_make ("udpsrc", "aud-source");
acapsfilter = gst_element_factory_make ("capsfilter", "audio-caps");
pcmurtpdepay = gst_element_factory_make ("rtppcmudepay", "artpdepay");
mulawdec = gst_element_factory_make ("mulawdec", "adecoder");
queue2 = gst_element_factory_make ("queue", "queue2");
mux = gst_element_factory_make ("matroskamux", "avmux");
sink = gst_element_factory_make ("filesink", "file-output");
if (!pipeline || !vsource || !vcapsfilter || !h263rtpdepay || !h263dec
|| !queue1 ||
!asource || !acapsfilter || !pcmurtpdepay || !mulawdec || !queue2 || !mux
||
!sink) {
g_printerr ("One element could not be created. Exiting.\n");
return -1;
}
g_object_set (G_OBJECT (vsource), "port", 9078, NULL);
g_object_set (G_OBJECT (asource), "port", 3333, NULL);
g_object_set (G_OBJECT (sink), "location", argv[1], NULL);
caps
=gst_caps_from_string("application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263-1998,payload=(int)96");
g_object_set (G_OBJECT (vcapsfilter), "caps", caps, NULL);
gst_caps_unref (caps);
caps =
gst_caps_from_string("application/x-rtp,encoding-name=PCMU,payload=0,clock-rate=8000");
g_object_set (G_OBJECT (acapsfilter), "caps", caps, NULL);
gst_caps_unref (caps);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
gst_bin_add_many (GST_BIN (pipeline),
vsource, vcapsfilter, h263rtpdepay, h263dec,
queue1,
asource, acapsfilter, pcmurtpdepay, mulawdec,
queue2,
mux, sink, NULL);
gst_element_link_many (vsource, vcapsfilter,h263rtpdepay,h263dec,
queue1, mux, NULL);
gst_element_link_many (asource, acapsfilter, pcmurtpdepay, mulawdec,
queue2, mux, NULL);
gst_element_link_many (mux, sink, NULL);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("Recording (or not!)...\n");
g_main_loop_run (loop);
g_print ("Returned, stopping recording\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
g_source_remove (bus_watch_id);
g_main_loop_unref (loop);
return 0;
}
I am streaming the rtp audio and video to the recorder using command :
gst-launch-1.0 -v uridecodebin uri=<url.mpg> name=demux demux. ! queue !
autovideoconvert ! avenc_h263p ! rtph263ppay ! udpsink host=127.0.0.1
port=9078 demux. ! queue ! audioconvert ! audioresample ! mulawenc !
rtppcmupay ! udpsink host=127.0.0.1 port=3333
I am getting EOS message successfully from above command but not getting
the End of Stream messege.
Please find attached recorder file same as code given above with the mail
if you need.
Any help/pointer appericiated ...
Thanks ,
Amar
**
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20131030/36388cfd/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: query.c
Type: text/x-csrc
Size: 4058 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20131030/36388cfd/attachment-0001.c>
More information about the gstreamer-devel
mailing list