Пример #1
0
static void
print_info (GstDiscovererInfo * info, GError * err)
{
  GstDiscovererResult result = gst_discoverer_info_get_result (info);
  GstDiscovererStreamInfo *sinfo;

  g_print ("Done discovering %s\n", gst_discoverer_info_get_uri (info));
  switch (result) {
    case GST_DISCOVERER_OK:
    {
      break;
    }
    case GST_DISCOVERER_URI_INVALID:
    {
      g_print ("URI is not valid\n");
      break;
    }
    case GST_DISCOVERER_ERROR:
    {
      g_print ("An error was encountered while discovering the file\n");
      g_print (" %s\n", err->message);
      break;
    }
    case GST_DISCOVERER_TIMEOUT:
    {
      g_print ("Analyzing URI timed out\n");
      break;
    }
    case GST_DISCOVERER_BUSY:
    {
      g_print ("Discoverer was busy\n");
      break;
    }
    case GST_DISCOVERER_MISSING_PLUGINS:
    {
      g_print ("Missing plugins\n");
      if (verbose) {
        gchar *tmp =
            gst_structure_to_string (gst_discoverer_info_get_misc (info));
        g_print (" (%s)\n", tmp);
        g_free (tmp);
      }
      break;
    }
  }

  if ((sinfo = gst_discoverer_info_get_stream_info (info))) {
    g_print ("\nTopology:\n");
    print_topology (sinfo, 1);
    g_print ("\nProperties:\n");
    print_properties (info, 1);
    gst_discoverer_stream_info_unref (sinfo);
  }

  g_print ("\n");
}
Пример #2
0
GUPnPDLNAFractionValue
gupnp_dlna_gst_get_fraction_value (GstCaps* caps,
                                   GstDiscovererStreamInfo *stream,
                                   GstDiscovererInfo *info,
                                   const gchar *name)
{
        GUPnPDLNAFractionValue value = GUPNP_DLNA_FRACTION_VALUE_UNSET;

        if (caps != NULL) {
                guint caps_size = gst_caps_get_size (caps);
                guint iter;

                for (iter = 0; iter < caps_size; ++iter) {
                        const GstStructure *st = gst_caps_get_structure (caps,
                                                                         iter);

                        value = get_fraction_value_from_structure (st, name);
                        if (value.state == GUPNP_DLNA_VALUE_STATE_SET)
                                return value;
                }
        }

        if (stream != NULL) {
                const GstStructure *st =
                                   gst_discoverer_stream_info_get_misc (stream);

                value = get_fraction_value_from_structure (st, name);
                if (value.state == GUPNP_DLNA_VALUE_STATE_SET)
                        return value;
        }

        if (info != NULL) {
                const GstStructure *st = gst_discoverer_info_get_misc (info);

                value = get_fraction_value_from_structure (st, name);
                if (value.state == GUPNP_DLNA_VALUE_STATE_SET)
                        return value;
        }

        if (stream != NULL) {
                const GstTagList *tags =
                                   gst_discoverer_stream_info_get_tags (stream);

                value = get_fraction_value_from_tag_list (tags, name);
                if (value.state == GUPNP_DLNA_VALUE_STATE_SET)
                        return value;
        }

        return value;
}
Пример #3
0
/* This function is called every time the discoverer has information regarding
 * one of the URIs we provided.*/
void on_discovered_cb (GstDiscoverer *discoverer, GstDiscovererInfo *info, GError *err, CustomData *data) {
  GstDiscovererResult result;
  const gchar *uri;
  const GstTagList *tags;
  GstDiscovererStreamInfo *sinfo;
   
  uri = gst_discoverer_info_get_uri (info);
  result = gst_discoverer_info_get_result (info);
  switch (result) {
    case GST_DISCOVERER_URI_INVALID:
      g_print ("Invalid URI '%s'\n", uri);
      break;
    case GST_DISCOVERER_ERROR:
      g_print ("Discoverer error: %s\n", err->message);
      break;
    case GST_DISCOVERER_TIMEOUT:
      g_print ("Timeout\n");
      break;
    case GST_DISCOVERER_BUSY:
      g_print ("Busy\n");
      break;
    case GST_DISCOVERER_MISSING_PLUGINS:{
      const GstStructure *s;
      gchar *str;
       
      s = gst_discoverer_info_get_misc (info);
      str = gst_structure_to_string (s);
       
      g_print ("Missing plugins: %s\n", str);
      g_free (str);
      break;
    }
    case GST_DISCOVERER_OK:
      g_print ("Discovered '%s'\n", uri);
      break;
  }
   
  if (result != GST_DISCOVERER_OK) {
    g_printerr ("This URI cannot be played\n");
    //return;
  }
   
  /* If we got no error, show the retrieved information */
   
  g_print ("\nDuration: %" GST_TIME_FORMAT "\n", GST_TIME_ARGS (gst_discoverer_info_get_duration (info)));
   
  tags = gst_discoverer_info_get_tags (info);
  if (tags) {
    g_print ("Tags:\n");
    gst_tag_list_foreach (tags, print_tag_foreach, GINT_TO_POINTER (1));
  }
   
  g_print ("Seekable: %s\n", (gst_discoverer_info_get_seekable (info) ? "yes" : "no"));
   
  g_print ("\n");
   
  sinfo = gst_discoverer_info_get_stream_info (info);
  if (!sinfo)
    return;
   
  g_print ("Stream information:\n");
   
  print_topology (sinfo, 1);
   
  gst_discoverer_stream_info_unref (sinfo);
   
  g_print ("\n");
}