int main (int argc, char *argv[]) { SnraClient *client = NULL; int ret = 1; const gchar *server = NULL; gst_init (&argc, &argv); if (argc > 1) { /* Connect directly to the requested server, no avahi */ server = argv[1]; } avahi_set_allocator (avahi_glib_allocator ()); g_timeout_add (250, sigint_check, NULL); sigint_setup (); client = snra_client_new (server); if (client == NULL) goto fail; ml = g_main_loop_new (NULL, FALSE); g_main_loop_run (ml); ret = 0; fail: if (client) g_object_unref (client); if (ml) g_main_loop_unref (ml); return ret; }
GstElement *mmsGstLaunch(const char *pipeline_description) { GError *error = NULL; gint res = 0; #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif if (!g_thread_supported ()) g_thread_init (NULL); gst_alloc_trace_set_flags_all (GST_ALLOC_TRACE_LIVE); #ifndef DISABLE_FAULT_HANDLER fault_setup (); sigint_setup (); play_signal_setup (); #endif // parse the pipeline description pipeline = gst_parse_launch(pipeline_description, &error); if (!pipeline) { if (error) { fprintf (stderr, "ERROR: pipeline could not be constructed: %s.\n", GST_STR_NULL (error->message)); g_error_free (error); } else { fprintf (stderr, "ERROR: pipeline could not be constructed.\n"); } return NULL; } else if (error) { fprintf (stderr, "WARNING: erroneous pipeline: %s\n", GST_STR_NULL (error->message)); g_error_free (error); return NULL; } GstState state; GstStateChangeReturn ret; /* If the top-level object is not a pipeline, place it in a pipeline. */ if (!GST_IS_PIPELINE (pipeline)) { GstElement *real_pipeline = gst_element_factory_make ("pipeline", NULL); if (real_pipeline == NULL) { fprintf (stderr, "ERROR: the 'pipeline' element wasn't found.\n"); return NULL; } gst_bin_add (GST_BIN (real_pipeline), pipeline); pipeline = real_pipeline; } fprintf (stderr, "Setting pipeline to PAUSED ...\n"); ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); switch (ret) { case GST_STATE_CHANGE_FAILURE: fprintf (stderr, "ERROR: Pipeline doesn't want to pause.\n"); res = -1; event_loop (pipeline, FALSE, GST_STATE_VOID_PENDING); goto end; case GST_STATE_CHANGE_NO_PREROLL: fprintf (stderr, "Pipeline is live and does not need PREROLL ...\n"); is_live = TRUE; break; case GST_STATE_CHANGE_ASYNC: fprintf (stderr, "Pipeline is PREROLLING ...\n"); caught_error = event_loop (pipeline, TRUE, GST_STATE_PAUSED); if (caught_error) { fprintf (stderr, "ERROR: pipeline doesn't want to preroll.\n"); goto end; } state = GST_STATE_PAUSED; // fallthrough case GST_STATE_CHANGE_SUCCESS: fprintf (stderr, "Pipeline is PREROLLED ...\n"); break; } // pipe successfully created return pipeline; end: mmsGstFree(); return NULL; }