bool initializeGStreamer()
{
    if (gst_is_initialized())
        return true;

#if ENABLE(SECCOMP_FILTERS)
    // The gst-plugin-scanner helper binary will receive SIGSYS and dump core
    // when it attempts to open a file. Disable it so that plugin scanning
    // occurs in-process. The disadvantage is that a plugin that crashes while
    // loading will now crash the web process.
    gst_registry_fork_set_enabled(FALSE);
#endif

    GUniqueOutPtr<GError> error;
    // FIXME: We should probably pass the arguments from the command line.
    bool gstInitialized = gst_init_check(0, 0, &error.outPtr());
    ASSERT_WITH_MESSAGE(gstInitialized, "GStreamer initialization failed: %s", error ? error->message : "unknown error occurred");

#if ENABLE(VIDEO_TRACK) && USE(GSTREAMER_MPEGTS)
    if (gstInitialized)
        gst_mpegts_initialize();
#endif

    return gstInitialized;
}
Beispiel #2
0
int
main (int argc, gchar ** argv)
{
  GstElement *pipeline = NULL;
  GError *error = NULL;
  GstBus *bus;
  GMainLoop *mainloop;

  gst_init (&argc, &argv);

  gst_mpegts_initialize ();

  pipeline = gst_parse_launchv ((const gchar **) &argv[1], &error);
  if (error) {
    g_printf ("pipeline could not be constructed: %s\n", error->message);
    g_error_free (error);
    return 1;
  }

  /* Hack: ensure all enum type classes are loaded */
  g_type_class_ref (GST_TYPE_MPEG_TS_SECTION_TYPE);
  g_type_class_ref (GST_TYPE_MPEG_TS_SECTION_TABLE_ID);
  g_type_class_ref (GST_TYPE_MPEG_TS_RUNNING_STATUS);
  g_type_class_ref (GST_TYPE_MPEG_TS_DESCRIPTOR_TYPE);
  g_type_class_ref (GST_TYPE_MPEG_TS_DVB_DESCRIPTOR_TYPE);
  g_type_class_ref (GST_TYPE_MPEG_TS_ATSC_DESCRIPTOR_TYPE);
  g_type_class_ref (GST_TYPE_MPEG_TS_ISDB_DESCRIPTOR_TYPE);
  g_type_class_ref (GST_TYPE_MPEG_TS_MISC_DESCRIPTOR_TYPE);
  g_type_class_ref (GST_TYPE_MPEG_TS_ISO639_AUDIO_TYPE);
  g_type_class_ref (GST_TYPE_MPEG_TS_DVB_SERVICE_TYPE);
  g_type_class_ref (GST_TYPE_MPEG_TS_STREAM_TYPE);

  mainloop = g_main_loop_new (NULL, FALSE);

  /* Put a bus handler */
  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", (GCallback) _on_bus_message, mainloop);

  /* Start pipeline */
  gst_element_set_state (pipeline, GST_STATE_PLAYING);
  g_main_loop_run (mainloop);

  gst_element_set_state (pipeline, GST_STATE_NULL);

  gst_object_unref (pipeline);
  gst_object_unref (bus);

  return 0;
}