[gst-devel] unable to use bus events
florian iragne
florian.iragne at viewsurf.com
Thu Jun 25 11:05:47 CEST 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
i've made a little program to grab video from an ip camera. The problem
is that the pipeline won't stop, even if the EOS message is well sent (i
see it in the log).
My code is almost the same as the one provided in the hello wolrd
example of the documentation.
here you can find the relevant parts
#########################################################################
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;
}
void* grabVideo( void* source ){
char _gstCmd[ 1024 << 2 ];
/* do the work */
GMainLoop* loop;
GstElement *pipeline, *src, *depay, *muxer, *sink;
GstBus* bus;
/* Initialisation */
gst_init ( NULL, NULL );
gst_debug_set_active (false);
gst_debug_set_default_threshold (GST_LEVEL_INFO);
loop = g_main_loop_new ( NULL, false );
/* Create gstreamer elements */
pipeline = gst_pipeline_new ( "video_recorder" );
sprintf( _gstCmd,
"rtspsrc location=\"%s\" ! queue2 ! rtph264depay
byte-stream=false !"
" capsfilter
caps=\"video/x-h264,width=%d,height=%d,framerate=(fraction)25/1\" !"
" ffmux_mp4 ! filesink location=%s",
source, 768, 576, "/tmp/totototototot.mp4" );
/* Set up the pipeline */
/* we set the input filename to the source element */
/* we add a message handler */
bus = gst_pipeline_get_bus ( GST_PIPELINE ( pipeline ) );
gst_bus_add_watch ( bus, bus_call, loop );
gst_object_unref ( bus );
/* we add all elements into the pipeline */
pipeline = gst_parse_launch( _gstCmd, NULL );
/* Set the pipeline to "playing" state*/
g_print ( "Now playing: %s\n", _gstCmd );
gst_element_set_state ( pipeline, GST_STATE_PLAYING );
/* Iterate */
g_print ( "Running...\n" );
g_main_loop_run ( loop );
/* Out of the main loop, clean up nicely */
g_print ( "Returned, stopping playback\n" );
gst_element_set_state ( pipeline, GST_STATE_NULL );
g_print ( "Deleting pipeline\n" );
gst_object_unref ( GST_OBJECT ( pipeline ) );
return NULL;
}
######################################################################
thanks for your help
Florian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkpDPesACgkQO8DE9K7b370jnwCglIVcRMm+zO8rCM4okbmoMONk
IVoAoNn5cgrm18ELOCDBUNvI8M3D1ZT4
=H3zN
-----END PGP SIGNATURE-----
More information about the gstreamer-devel
mailing list