diff options
author | Christian Pointner <equinox@spreadspace.org> | 2014-09-04 23:15:02 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2014-09-04 23:15:02 +0200 |
commit | 2eb158e6a56064198bf75d3ba77913175d9115cb (patch) | |
tree | 86b58831985c2bdd64966f77b1578212c9d7af21 /src/sydra.c | |
parent | removed custom sighandler code in favor of glib based signal handling (diff) |
small refactoring
Diffstat (limited to 'src/sydra.c')
-rw-r--r-- | src/sydra.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/sydra.c b/src/sydra.c index b45ef3c..25cc4fe 100644 --- a/src/sydra.c +++ b/src/sydra.c @@ -147,17 +147,8 @@ static gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data) return TRUE; } - -int main_loop(options_t* opt) +static char* build_sender_pipeline_desc(options_t* opt) { - log_printf(INFO, "entering main loop"); - - GMainLoop *loop; - GstElement *pipeline; - GstBus *bus; - - loop = g_main_loop_new(NULL, FALSE); - struct timespec now; clock_gettime(CLOCK_REALTIME, &now); struct tm bd_time; @@ -186,8 +177,22 @@ int main_loop(options_t* opt) opt->audio_src_, opt->audio_enc_stream_, opt->audio_payloader_, rtp_port_a, opt->rtp_host_, rtcp_port_a, opt->rtp_host_, opt->videosink_); - if(slen < 0) { - log_printf(ERROR, "memory error while constructing sender pipeline description"); + return (slen < 0) ? NULL : sender_desc; +} + +int main_loop(options_t* opt) +{ + log_printf(INFO, "entering main loop"); + + GMainLoop *loop; + GstElement *pipeline; + GstBus *bus; + + loop = g_main_loop_new(NULL, FALSE); + + char* sender_desc = build_sender_pipeline_desc(opt); + if(!sender_desc) { + log_printf(ERROR, "memory error while building sender pipeline description"); gst_object_unref(GST_OBJECT(loop)); return -1; } @@ -198,6 +203,8 @@ int main_loop(options_t* opt) log_printf(ERROR, "Pipeline parser Error: %s", error ? error->message : "unknown"); g_error_free(error); free(sender_desc); + if(pipeline) + gst_object_unref(GST_OBJECT(pipeline)); gst_object_unref(GST_OBJECT(loop)); return -1; } |