Пример #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
/**
 * gupnp_dlna_gst_utils_information_from_discoverer_info:
 * @info: A #GstDiscovererInfo object.
 *
 * This utility function creates a #GUPnPDLNAInformation from
 * #GstDiscovererInfo. Its purpose is mainly to pass its result to
 * gupnp_dlna_profile_guesser_guess_profile_from_info() to avoid
 * rediscovering of a URI. Created #GUPnPDLNAInformation takes a
 * reference on @info.
 *
 * Returns: (transfer full): A #GUPnPDLNAInformation. Unref it when
 * done with it.
 */
GUPnPDLNAInformation *
gupnp_dlna_gst_utils_information_from_discoverer_info (GstDiscovererInfo *info)
{
        g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);

        return GUPNP_DLNA_INFORMATION
                            (gupnp_dlna_gst_information_new_from_discoverer_info
                                        (gst_discoverer_info_get_uri (info),
                                         info));
}
static void
gupnp_dlna_discovered_cb (GUPnPDLNAMetadataExtractor *self,
                          GstDiscovererInfo *info,
                          GError *error,
                          gpointer user_data)
{
        GstDiscoverer *discoverer = GST_DISCOVERER (user_data);
        GUPnPDLNAInformation *gupnp_info = NULL;

        if (error)
                gupnp_info = GUPNP_DLNA_INFORMATION
                                  (gupnp_dlna_gst_information_new_empty_with_uri
                                        (gst_discoverer_info_get_uri (info)));
        else
                gupnp_info = gupnp_dlna_gst_utils_information_from_discoverer_info
                                        (info);
        gupnp_dlna_metadata_extractor_emit_done (self,
                                                 gupnp_info,
                                                 error);
        g_object_unref (gupnp_info);
        g_idle_add ((GSourceFunc) unref_discoverer_in_idle, discoverer);
}
static void
print_info (GstDiscovererInfo * info, GError * err)
{
  GstDiscovererResult result;
  GstDiscovererStreamInfo *sinfo;

  if (!info) {
    g_print ("Could not discover URI\n");
    g_print (" %s\n", err->message);
    return;
  }

  result = gst_discoverer_info_get_result (info);
  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) {
        gint i = 0;
        const gchar **installer_details =
            gst_discoverer_info_get_missing_elements_installer_details (info);

        while (installer_details[i]) {
          g_print (" (%s)\n", installer_details[i]);

          i++;
        }
      }
      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");
}
Пример #5
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");
}
static void
rygel_media_export_metadata_extractor_on_done (RygelMediaExportMetadataExtractor *self,
                                               GstDiscovererInfo                 *gst_info,
                                               GError                            *err) {
  RygelMediaExportMetadataExtractorPrivate *priv;
  guint signal_id;
  const gchar *uri;
  GeeAbstractMap *abstract_file_hash;
  GstDiscovererResult result;
  GFile *file;

  g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_METADATA_EXTRACTOR (self));
  g_return_if_fail (GST_IS_DISCOVERER_INFO (gst_info));

  priv = self->priv;
  signal_id = 0;
  g_signal_parse_name ("discovered", GST_TYPE_DISCOVERER, &signal_id, NULL, FALSE);
  g_signal_handlers_disconnect_matched (priv->discoverer,
                                        G_SIGNAL_MATCH_ID |
                                        G_SIGNAL_MATCH_FUNC |
                                        G_SIGNAL_MATCH_DATA, signal_id,
                                        0,
                                        NULL,
                                        G_CALLBACK (rygel_media_export_metadata_extractor_on_done_gst_discoverer_discovered),
                                        self);

  g_object_unref (priv->discoverer);
  priv->discoverer = NULL;

  uri = gst_discoverer_info_get_uri (gst_info);
  abstract_file_hash = GEE_ABSTRACT_MAP (priv->file_hash);
  file = G_FILE (gee_abstract_map_get (abstract_file_hash, uri));
  if (!file) {
    g_warning ("File %s already handled, ignoring event", uri);
    return;
  }
  gee_abstract_map_unset (abstract_file_hash, uri, NULL);
  result = gst_discoverer_info_get_result (gst_info);

  if ((result & GST_DISCOVERER_ERROR) == GST_DISCOVERER_ERROR) {
    g_signal_emit (self, signals[ERROR], 0, file, err);
  } else {
    GUPnPDLNAProfile *dlna_profile;

    if ((result & GST_DISCOVERER_TIMEOUT) == GST_DISCOVERER_TIMEOUT) {
      gchar* file_uri = g_file_get_uri (file);

      g_debug ("Extraction timed out on %s", file_uri);
      g_free (file_uri);
      dlna_profile = NULL;
    } else {
      GUPnPDLNAInformation *dlna_info = gupnp_dlna_gst_utils_information_from_discoverer_info (gst_info);

      dlna_profile = gupnp_dlna_profile_guesser_guess_profile_from_info (priv->guesser,
                                                                         dlna_info);
      g_object_unref (dlna_info);
    }

    rygel_media_export_metadata_extractor_extract_basic_information (self,
                                                                     file,
                                                                     gst_info,
                                                                     dlna_profile);
  }

  g_object_unref (file);
}
Пример #7
0
void Discoverer::on_discovered(GstDiscoverer *discoverer, GstDiscovererInfo *info, GError *err, Gstreamer *gst)
{
    Q_UNUSED(err);
    Q_UNUSED(discoverer);

    Metadata *meta = gst->getMetadata();
    delete meta;

    GstDiscovererResult result;
    result = gst_discoverer_info_get_result(info);
    if (result != GST_DISCOVERER_OK)
    {
        gst->setMetadata(nullptr);
        return;
    }

    meta = new Metadata();

    // is seekable
    meta->setSeekable(gst_discoverer_info_get_seekable(info));
    // extract duration
    qint64 time = gst_discoverer_info_get_duration(info);
    meta->setDuration(UTime(time));
    // extract filename
    QUrl uri(gst_discoverer_info_get_uri(info));
    meta->setFilename(uri.toLocalFile());
    // set filesize
    QFile file(uri.toLocalFile());
    meta->setSize(file.size());

    // extract tags
    const GstTagList *tags;
    tags = gst_discoverer_info_get_tags(info);
    if (tags)
    {
        gst_tag_list_foreach(tags, fillTags, meta);
    }

    GList *list, *iterator;

    // extract video streams
    iterator = list = gst_discoverer_info_get_video_streams(info);
    while (iterator)
    {
        Video video;
        GstDiscovererVideoInfo *vInfo = (GstDiscovererVideoInfo *)iterator->data;
        video.Width = gst_discoverer_video_info_get_width(vInfo);
        video.Height = gst_discoverer_video_info_get_height(vInfo);
        video.Framerate = double(gst_discoverer_video_info_get_framerate_num(vInfo)) /
                          double(gst_discoverer_video_info_get_framerate_denom(vInfo));
        meta->addVideo(video);
        iterator = iterator->next;
    }
    gst_discoverer_stream_info_list_free(list);

    // extract audio streams
    iterator = list = gst_discoverer_info_get_audio_streams(info);
    while (iterator)
    {
        Audio audio;
        GstDiscovererAudioInfo *aInfo = (GstDiscovererAudioInfo *)iterator->data;
        audio.Channels = gst_discoverer_audio_info_get_channels(aInfo);
        audio.SampleRate = gst_discoverer_audio_info_get_sample_rate(aInfo);
        audio.Language = gst_discoverer_audio_info_get_language(aInfo);
        meta->addAudio(audio);
        iterator = iterator->next;
    }
    gst_discoverer_stream_info_list_free(list);

    // extract subtitle streams
    iterator = list = gst_discoverer_info_get_subtitle_streams(info);
    while (iterator)
    {
        Subtitle subtitle;
        GstDiscovererSubtitleInfo *sInfo = (GstDiscovererSubtitleInfo *)iterator->data;
        gst_discoverer_subtitle_info_get_language(sInfo);
        subtitle.Language = gst_discoverer_subtitle_info_get_language(sInfo);
        meta->addSubtitles(subtitle);
        iterator = iterator->next;
    }
    gst_discoverer_stream_info_list_free(list);

    // fill metadata
    gst->setMetadata(meta);
    QObject::connect(gst->getMetadata(), SIGNAL(updated()), gst, SLOT(on_metadata_update()));
}