From 1af31f8ea42f5a8eed4dd281bfd74dfb8ecbfa69 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Mon, 22 Sep 2014 04:10:28 +0200 Subject: preview works now --- src/sydra.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'src/sydra.c') diff --git a/src/sydra.c b/src/sydra.c index e366ba4..49951aa 100644 --- a/src/sydra.c +++ b/src/sydra.c @@ -312,13 +312,37 @@ static gboolean create_udp_elements(options_t* opt, GstElement* pipeline, GstEle return TRUE; } -static GstElement* create_pipeline(options_t* opt) +static gboolean create_preview_elements(const char* preview_bin_desc, GstElement* pipeline, GstElement* tee) { - log_printf(DEBUG, "creating pipeline"); + GstElement *qr = sydra_create_element("queue", NULL); + GstElement *to = sydra_create_element("textoverlay", NULL); + GstElement *preview_bin = sydra_create_bin_from_desc("preview sink", preview_bin_desc); + + if(!qr || !to || !preview_bin) { + return FALSE; + } + + log_printf(DEBUG, "preview path created successfully!"); + + g_object_set(G_OBJECT(to), "text", " local ", "halignment", "center" , "valignment", "baseline", + "shaded-background", TRUE, "font-desc", "Sans 18", NULL); + + gst_bin_add_many (GST_BIN(pipeline), qr, to, preview_bin, NULL); + gst_element_link_many(qr, to, preview_bin, NULL); + + if(!sydra_link_request_static(tee, "src_%u", qr, "sink")) { + return FALSE; + } + + log_printf(DEBUG, "preview path linked successfully!"); + return TRUE; +} +static GstElement* create_pipeline(options_t* opt) +{ GstElement *pipeline = gst_pipeline_new ("sydra"); if(!pipeline) { - log_printf(ERROR, "Creating pipeline failed"); + log_printf(ERROR, "Creating pipeline failed!"); return NULL; } GstElement *rtp = sydra_create_element("rtpbin", "rtpbin"); @@ -326,7 +350,7 @@ static GstElement* create_pipeline(options_t* opt) return NULL; } - log_printf(DEBUG, "rtpbin created"); + log_printf(DEBUG, "rtpbin created successfully!"); struct media_elements video = { "video", opt->video_src_, NULL, NULL, opt->video_enc_, NULL, NULL, @@ -340,6 +364,12 @@ static GstElement* create_pipeline(options_t* opt) return NULL; } + if(opt->preview_videosink_) { + if(!create_preview_elements(opt->preview_videosink_, pipeline, video.tee_raw_)) + return NULL; + } + + log_printf(DEBUG, "pipeline created successfully!"); return pipeline; } -- cgit v1.2.3