static void
generate_xml_media_descriptor (InsanityTest * test)
{
  GError *err = NULL;
  GstDiscovererInfo *info = NULL;
  gchar *sublocation = NULL, *suburi = NULL;

  GstDiscoverer *discoverer = gst_discoverer_new (5 * GST_SECOND, NULL);

  insanity_test_get_string_argument (test, "sublocation", &sublocation);

  if (G_UNLIKELY (discoverer == NULL)) {
    ERROR (test, "Error creating discoverer: %s\n", err->message);
    g_clear_error (&err);

    insanity_test_done (test);
    goto done;
  }

  suburi = gst_filename_to_uri (sublocation, &err);
  if (err) {
    ERROR (test, "Could not construct filename");
    g_clear_error (&err);
    goto done;
  }

  info = gst_discoverer_discover_uri (discoverer, suburi, &err);
  if (info == NULL) {
    ERROR (test, "Error discovering: %s\n", err->message);
    g_clear_error (&err);

    insanity_test_done (test);
    goto done;
  }

  glob_duration = gst_discoverer_info_get_duration (info);
  glob_seekable = gst_discoverer_info_get_seekable (info);

  glob_writer = media_descriptor_writer_new (test,
      sublocation, glob_duration, glob_seekable);

  glob_in_progress = TEST_SUBTTILE_DESCRIPTOR_GENERATION;

  g_idle_add ((GSourceFunc) idle_restart_pipeline, NULL);

  media_descriptor_writer_add_stream (glob_writer,
      glob_suboverlay_src_probe->pad);

done:
  if (discoverer != NULL)
    g_object_unref (discoverer);

  if (info != NULL)
    gst_discoverer_info_unref (info);

  g_free (sublocation);
  g_free (suburi);
}
コード例 #2
0
static void
print_properties (GstDiscovererInfo * info, gint tab)
{
  const GstTagList *tags;

  g_print ("%*sDuration: %" GST_TIME_FORMAT "\n", tab + 1, " ",
      GST_TIME_ARGS (gst_discoverer_info_get_duration (info)));
  g_print ("%*sSeekable: %s\n", tab + 1, " ",
      (gst_discoverer_info_get_seekable (info) ? "yes" : "no"));
  if ((tags = gst_discoverer_info_get_tags (info))) {
    g_print ("%*sTags: \n", tab + 1, " ");
    gst_structure_foreach ((const GstStructure *) tags, print_tag_each,
        GINT_TO_POINTER (tab + 5));
  }
}
コード例 #3
0
static void
print_properties (GstDiscovererInfo * info, gint tab)
{
  const GstTagList *tags;
  const GstToc *toc;

  g_print ("%*sDuration: %" GST_TIME_FORMAT "\n", tab + 1, " ",
      GST_TIME_ARGS (gst_discoverer_info_get_duration (info)));
  g_print ("%*sSeekable: %s\n", tab + 1, " ",
      (gst_discoverer_info_get_seekable (info) ? "yes" : "no"));
  if ((tags = gst_discoverer_info_get_tags (info))) {
    g_print ("%*sTags: \n", tab + 1, " ");
    gst_tag_list_foreach (tags, print_tag_foreach, GUINT_TO_POINTER (tab + 2));
  }
  if (show_toc && (toc = gst_discoverer_info_get_toc (info))) {
    GList *entries;

    g_print ("%*sTOC: \n", tab + 1, " ");
    entries = gst_toc_get_entries (toc);
    g_list_foreach (entries, print_toc_entry, GUINT_TO_POINTER (tab + 5));
  }
}
コード例 #4
0
static gboolean
check_seekable (GstValidateMediaInfo * mi, GstDiscovererInfo * info)
{
  mi->seekable = gst_discoverer_info_get_seekable (info);
  return TRUE;
}
コード例 #5
0
ファイル: mediainfo.c プロジェクト: ebumfpt/EBU-Media-Player
/* 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");
}
コード例 #6
0
ファイル: discoverer.cpp プロジェクト: kmikolaj/explayer
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()));
}