GstPipeline and bus call
killerrats
koreysjunkmail at gmail.com
Tue Aug 15 18:54:36 UTC 2017
Looks like your using c++ so this is what is in c++. maybe this will give you
at least a start. maybe even work. I don't understand what your saying is
wrong. if its not playing or just doesn't quit after the video is done or
what but this might work for a template for ya.
#include <gst/gst.h>
#include <iostream>
/*************
global values
***** ***********/
GstElement *pipeline;
GMainLoop *loop;
GstBus *bus;
GstMessage* msg;
GstStateChangeReturn ret;
#define GST_PLAYER_UDP "udpsrc port=5555 caps=\"application/x-rtp,
media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264,
payload=(int)96\"\
! rtph264depay ! decodebin ! videoconvert ! autovideosink"
static gboolean bus_cb (GstBus *bus, GstMessage *msg, gpointer *data);
int main()
{
//debug level 1,2,3,4,5
gst_debug_set_threshold_from_string("*:3",TRUE);
/* Initialize GStreamer */
gst_init (NULL,NULL);
/* Build the pipeline */
pipeline = gst_parse_launch (GST_PLAYER_UDP, NULL);
bus = gst_element_get_bus (pipeline);
/* Start playing */
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (ret == GST_STATE_CHANGE_FAILURE) {
g_printerr ("Unable to set the pipeline to the playing state.\n");
gst_object_unref (pipeline);
return -1;
}
loop = g_main_loop_new (NULL, FALSE);
gst_bus_add_signal_watch (bus);
g_signal_connect (bus, "message", G_CALLBACK (bus_cb),NULL);
g_main_loop_run (loop);
/* Free resources */
g_main_loop_unref (loop);
gst_object_unref (bus);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
return 0;
}
/**********************
bus method
******************/
gboolean bus_cb (GstBus *bus, GstMessage *msg, gpointer *data) {
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_ERROR: {
GError *err;
gchar *debug;
gst_message_parse_error (msg, &err, &debug);
g_print ("Error: %s\n", err->message);
g_error_free (err);
g_free (debug);
gst_element_set_state (pipeline, GST_STATE_READY);
g_main_loop_quit (loop);
return FALSE;
}
case GST_MESSAGE_EOS:
/* end-of-stream */
gst_element_set_state (pipeline, GST_STATE_READY);
g_main_loop_quit (loop);
return FALSE;
default:
/* Unhandled message */
break;
}
return TRUE;
}
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/GstPipeline-and-bus-call-tp4684199p4684217.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
More information about the gstreamer-devel
mailing list