Created
June 7, 2016 13:26
-
-
Save mgalushka/68d8ee034849a7db4f1f234e73a41405 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void _send_video_init_gstreamer(NiceAgent *magent, guint stream_id, CustomData *data) | |
{ | |
GstElement *pipeline, *source, *capsfilter, *videoconvert, *h263p, *rtph263ppay, *sink; | |
GstBus *bus; | |
GstMessage *msg; | |
GstStateChangeReturn ret; | |
GSource *bus_source; | |
source = gst_element_factory_make ("wrappercamerabinsrc", "source"); | |
capsfilter = gst_element_factory_make ("capsfilter", "capsfilter"); | |
videoconvert = gst_element_factory_make ("videoconvert", "convert"); | |
h263p = gst_element_factory_make ("avenc_h263p", "h263p"); | |
rtph263ppay = gst_element_factory_make ("rtph263ppay", "rtph263ppay"); | |
sink = gst_element_factory_make ("udpsink", "sink"); | |
g_object_set (source, "mode", 2, NULL); | |
g_object_set (capsfilter, | |
"caps", | |
gst_caps_from_string( | |
"video/x-raw, width=320, height=240"), NULL); | |
g_object_set (sink, "sync", FALSE, NULL); | |
g_object_set (sink, "host", "127.0.0.1", NULL); | |
g_object_set (sink, "port", 1234, NULL); | |
if (!pipeline || !source || !videoconvert | |
|| !h263p || !rtph263ppay || !sink) | |
{ | |
g_printerr ("Not all elements could be created.\n"); | |
return; | |
} | |
gst_bin_add_many (GST_BIN (pipeline), source, | |
videoconvert, h263p, rtph263ppay, | |
sink, NULL); | |
if (gst_element_link_many (source, videoconvert, h263p, | |
rtph263ppay, sink, NULL) != TRUE) | |
{ | |
g_printerr ("Elements could not be linked.\n"); | |
gst_object_unref (pipeline); | |
return; | |
} | |
bus = gst_element_get_bus (pipeline); | |
gst_bus_enable_sync_message_emission (bus); | |
gst_bus_add_signal_watch (bus); | |
g_signal_connect (bus, "message::error", | |
(GCallback) on_error, NULL); | |
GST_INFO ("Registing pipeline on bus"); | |
data->pipeline = pipeline; | |
ret = gst_element_set_state(data->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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment