GStreamerInitializer::GStreamerInitializer()
{
    gst_init(nullptr, nullptr);

    char buffer[MAX_PATH];
    GetModuleFileNameA(nullptr, buffer, MAX_PATH);
    auto fileName = std::string(buffer);
    auto path = fileName.substr(0, fileName.find_last_of('\\')) + "\\plugins\\gstreamer-plugins\\";

    gst_registry_scan_path(gst_registry_get(), path.c_str());
}
예제 #2
0
// *** main
int main() {
  //makeing a follower
  ShmdataLogger logger = shmdata_make_logger(&mylog, 
                                             &mylog, 
                                             &mylog, 
                                             &mylog, 
                                             &mylog, 
                                             &mylog, 
                                             NULL); 
  assert(NULL != logger); 
  ShmdataFollower follower = shmdata_make_follower("/tmp/check-shmdatasink", 
                                                   &on_data, 
                                                   &on_server_connect, 
                                                   &on_server_disconnect, 
                                                   NULL, 
                                                   logger); 
  assert(NULL != follower); 
  //gstreamer shmdatasink for writing
  GstElement *pipeline, *audiosource, *shmdatasink;
  GstBus *bus;
  guint bus_watch_id;
  gst_init(NULL, NULL);
#ifdef HAVE_CONFIG_H
  GstRegistry *registry = gst_registry_get();
  gst_registry_scan_path(registry, "./" LT_OBJDIR);
#else
  g_printerr("shmdatasink plugin not found");
return -1;
#endif
  loop = g_main_loop_new(NULL, FALSE);
  /* Create gstreamer elements */
  pipeline = gst_pipeline_new("audio-player");
  audiosource = gst_element_factory_make("audiotestsrc", "audiosource");
  shmdatasink = gst_element_factory_make("shmdatasink", "shmdata-output");
  if (!pipeline || !audiosource || !shmdatasink) {
    g_printerr("One element could not be created. Exiting.\n"); return -1; }
  g_object_set(G_OBJECT(shmdatasink), "socket-path", "/tmp/check-shmdatasink", NULL);
  bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
  bus_watch_id = gst_bus_add_watch(bus, bus_call, loop);
  gst_object_unref(bus);
  gst_bin_add_many(GST_BIN(pipeline), audiosource, shmdatasink, NULL);
  gst_element_link(audiosource, shmdatasink);
  gst_element_set_state(pipeline, GST_STATE_PLAYING);
  g_main_loop_run(loop);
  // cleaning gst
  gst_element_set_state(pipeline, GST_STATE_NULL);
  gst_object_unref(GST_OBJECT(pipeline));
  g_source_remove(bus_watch_id);
  g_main_loop_unref(loop);
  // cleaning follower 
  shmdata_delete_follower(follower); 
  shmdata_delete_logger(logger); 
  return res;
}
예제 #3
0
gint main (int argc, char *argv[])
{
    options(argc, argv);
    loop = g_main_loop_new(NULL, FALSE);
    GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    /*Tell gstreamer to look locally for the plugin*/
    GstRegistry *registry;
    registry = gst_registry_get();
    gst_registry_scan_path(registry, "plugins");

    GError *parse_error = NULL;
    GstElement *pipeline = make_pipeline(&parse_error, loop);
    DEBUG("pipeline is %p", pipeline);
    DEBUG("template is '%s'", PIPELINE_TEMPLATE);

    GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
    gst_bus_set_sync_handler(bus, (GstBusSyncHandler)sync_bus_call, NULL, NULL);
    gst_bus_add_watch(bus, (GstBusFunc)bus_callback, pipeline);
    gst_object_unref(bus);

    gst_element_set_state(pipeline, GST_STATE_PLAYING);

    g_signal_connect(G_OBJECT(window), "key-press-event",
                     G_CALLBACK(key_press_event_cb), pipeline);

    STDERR_DEBUG("pipeline is %p", pipeline);

    g_signal_connect(G_OBJECT(window), "destroy",
                     G_CALLBACK(destroy_cb), loop);

    g_signal_connect(window, "realize",
                     G_CALLBACK(video_widget_realize_cb), NULL);

    gtk_widget_show_all(window);

    g_main_loop_run(loop);

    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (pipeline);
    return 0;
}
static void
gst_validate_init_plugins (void)
{
  GstRegistry *registry;
  const gchar *plugin_path;

  gst_registry_fork_set_enabled (FALSE);
  registry = gst_validate_registry_get ();

  plugin_path = g_getenv ("GST_VALIDATE_PLUGIN_PATH");
  if (plugin_path) {
    char **list;
    int i;

    GST_DEBUG ("GST_VALIDATE_PLUGIN_PATH set to %s", plugin_path);
    list = g_strsplit (plugin_path, G_SEARCHPATH_SEPARATOR_S, 0);
    for (i = 0; list[i]; i++) {
      gst_registry_scan_path (registry, list[i]);
    }
    g_strfreev (list);
  } else {
    GST_DEBUG ("GST_VALIDATE_PLUGIN_PATH not set");
  }

  if (plugin_path == NULL) {
    char *home_plugins;

    /* plugins in the user's home directory take precedence over
     * system-installed ones */
    home_plugins = g_build_filename (g_get_user_data_dir (),
        "gstreamer-" GST_API_VERSION, "plugins", NULL);

    GST_DEBUG ("scanning home plugins %s", home_plugins);
    gst_registry_scan_path (registry, home_plugins);
    g_free (home_plugins);

    /* add the main (installed) library path */

#ifdef G_OS_WIN32
    {
      char *base_dir;
      char *dir;

      base_dir =
          g_win32_get_package_installation_directory_of_module
          (_priv_gstvalidate_dll_handle);

      dir = g_build_filename (base_dir,
          "lib", "gstreamer-" GST_API_VERSION, "validate", NULL);

      GST_DEBUG ("scanning DLL dir %s", dir);

      gst_registry_scan_path (registry, dir);

      g_free (dir);
      g_free (base_dir);
    }
#else
    gst_registry_scan_path (registry, PLUGINDIR);
#endif
  }
  gst_registry_fork_set_enabled (TRUE);
}