コード例 #1
0
/**
 * gupnp_dlna_discoverer_discover_uri:
 * @discoverer: #GUPnPDLNADiscoverer object to use for discovery
 * @uri: URI to gather metadata for
 *
 * Queues @uri for metadata discovery. When discovery is completed, the
 * "discovered" signal is emitted on @discoverer.
 *
 * Returns: TRUE if @uri was successfully queued, FALSE otherwise.
 */
gboolean
gupnp_dlna_discoverer_discover_uri (GUPnPDLNADiscoverer *discoverer,
                                    const gchar         *uri)
{
        return gst_discoverer_discover_uri_async (GST_DISCOVERER (discoverer),
                                                  uri);
}
コード例 #2
0
static gboolean
backend_extract_async (GUPnPDLNAMetadataExtractor  *extractor,
                       const gchar                 *uri,
                       guint                        timeout,
                       GError                     **error)
{
        GError *gst_error = NULL;
        GstClockTime clock_time = GST_MSECOND * timeout;
        GstDiscoverer *discoverer = gst_discoverer_new (clock_time, &gst_error);

        if (gst_error) {
                g_propagate_error (error, gst_error);

                return FALSE;
        }

        g_signal_connect_swapped (discoverer,
                                  "discovered",
                                  G_CALLBACK (gupnp_dlna_discovered_cb),
                                  extractor);
        gst_discoverer_start (discoverer);

        return gst_discoverer_discover_uri_async (discoverer,
                                                  uri);
}
コード例 #3
0
static void
process_file (GstDiscoverer * dc, const gchar * filename)
{
  GError *err = NULL;
  GDir *dir;
  gchar *uri, *path;
  GstDiscovererInfo *info;

  if (!gst_uri_is_valid (filename)) {
    /* Recurse into directories */
    if ((dir = g_dir_open (filename, 0, NULL))) {
      const gchar *entry;

      while ((entry = g_dir_read_name (dir))) {
        gchar *path;
        path = g_strconcat (filename, G_DIR_SEPARATOR_S, entry, NULL);
        process_file (dc, path);
        g_free (path);
      }

      g_dir_close (dir);
      return;
    }

    if (!g_path_is_absolute (filename)) {
      gchar *cur_dir;

      cur_dir = g_get_current_dir ();
      path = g_build_filename (cur_dir, filename, NULL);
      g_free (cur_dir);
    } else {
      path = g_strdup (filename);
    }

    uri = g_filename_to_uri (path, NULL, &err);
    g_free (path);
    path = NULL;

    if (err) {
      g_warning ("Couldn't convert filename to URI: %s\n", err->message);
      g_error_free (err);
      return;
    }
  } else {
    uri = g_strdup (filename);
  }

  if (async == FALSE) {
    g_print ("Analyzing %s\n", uri);
    info = gst_discoverer_discover_uri (dc, uri, &err);
    print_info (info, err);
    if (err)
      g_error_free (err);
    gst_discoverer_info_unref (info);
  } else {
    gst_discoverer_discover_uri_async (dc, uri);
  }

  g_free (uri);
}
コード例 #4
0
ファイル: mediainfo.c プロジェクト: ebumfpt/EBU-Media-Player
 extern "C" void C_Func_MediaInfo (char * filename) {
  CustomData data;
  GError *err = NULL;
  gchar *uri = filename;
   
  /* if a URI was provided, use it instead of the default one */
//  if (argc > 1) {
 //   uri = argv[1];
 // }
   
  /* Initialize cumstom data structure */
  memset (&data, 0, sizeof (data));
   
  /* Initialize GStreamer */
 // gst_init (NULL,NULL);
   
  g_print ("Discovering '%s'\n", uri);
   
  /* Instantiate the Discoverer */
  data.discoverer = gst_discoverer_new (5 * GST_SECOND, &err);
  if (!data.discoverer) {
    g_print ("Error creating discoverer instance: %s\n", err->message);
    g_clear_error (&err);
    //return -1;
  } else {
		 
		/* Connect to the interesting signals */
		g_signal_connect (data.discoverer, "discovered", G_CALLBACK (on_discovered_cb), &data);
		g_signal_connect (data.discoverer, "finished", G_CALLBACK (on_finished_cb), &data);
		 
		/* Start the discoverer process (nothing to do yet) */
		gst_discoverer_start (data.discoverer);
		 
		/* Add a request to process asynchronously the URI passed through the command line */
		if (!gst_discoverer_discover_uri_async (data.discoverer, uri)) {
		  g_print ("Failed to start discovering URI '%s'\n", uri);
		  g_object_unref (data.discoverer);
		  
		} else {
			 
			/* Create a GLib Main Loop and set it to run, so we can wait for the signals */
			data.loop = g_main_loop_new (NULL, FALSE);
			g_main_loop_run (data.loop);
		}
	/* Stop the discoverer process */
		gst_discoverer_stop (data.discoverer);
		 
		/* Free resources */
		g_object_unref (data.discoverer);
		g_main_loop_unref (data.loop);
 	}  
//  return 0;
}