static void
rygel_media_export_metadata_extractor_extract_basic_information (RygelMediaExportMetadataExtractor *self,
                                                                 GFile                             *file,
                                                                 GstDiscovererInfo                 *info,
                                                                 GUPnPDLNAProfile                  *profile) {
  GError *error;
  GFileInfo *file_info;

  g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_METADATA_EXTRACTOR (self));
  g_return_if_fail (G_IS_FILE (file));
  g_return_if_fail (info == NULL || GST_IS_DISCOVERER_INFO (info));
  g_return_if_fail (profile == NULL || GUPNP_IS_DLNA_PROFILE (profile));

  error = NULL;
  file_info = g_file_query_info (file,
                                 G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
                                 G_FILE_ATTRIBUTE_STANDARD_SIZE ","
                                 G_FILE_ATTRIBUTE_TIME_MODIFIED ","
                                 G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
                                 G_FILE_QUERY_INFO_NONE,
                                 NULL,
                                 &error);
  if (error) {
    gchar *uri = g_file_get_uri (file);

    g_warning (_("Failed to query content type for '%s'"), uri);
    g_debug ("Failed to extract basic metadata from %s: %s", uri, error->message);
    g_signal_emit (self, signals[ERROR], 0, file, error);
    g_error_free (error);
    return;
  }
  g_signal_emit (self, signals[EXTRACTION_DONE], 0, file, info, profile, file_info);
  g_object_unref (file_info);
}
GUPnPDLNAGstImageInformation *
gupnp_dlna_gst_image_information_new_from_discoverer_info
(GstDiscovererInfo *info)
{
    GList* image_list;
    GUPnPDLNAGstImageInformation *image_info = NULL;

    g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);

    image_list = gst_discoverer_info_get_video_streams (info);

    if (image_list) {
        if ((image_list->next == NULL) &&
                gst_discoverer_video_info_is_image
                (GST_DISCOVERER_VIDEO_INFO (image_list->data)))
            image_info = GUPNP_DLNA_GST_IMAGE_INFORMATION
                         (g_object_new
                          (GUPNP_TYPE_DLNA_GST_IMAGE_INFORMATION,
                           "info", info,
                           NULL));
        gst_discoverer_stream_info_list_free (image_list);
    }

    return image_info;
}
GstDiscovererStreamInfo *
gst_discoverer_info_get_stream_info (GstDiscovererInfo * info)
{
  g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);

  if (info->stream_info)
    return gst_discoverer_stream_info_ref (info->stream_info);
  return NULL;
}
Exemplo n.º 4
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));
}
Exemplo n.º 5
0
static void
asset_added_cb (GESProject * project, GESAsset * asset, void *mainloop)
{
  GstDiscovererInfo *info;

  info = ges_uri_clip_asset_get_info (GES_URI_CLIP_ASSET (asset));
  fail_unless (GST_IS_DISCOVERER_INFO (info));

  g_main_loop_quit ((GMainLoop *) mainloop);
}
/**
 * gst_discoverer_info_get_stream_list:
 * @info: a #GstDiscovererInfo
 *
 * Returns: (transfer full) (element-type Gst.DiscovererStreamInfo): the list of
 * all streams contained in the #info. Free after usage
 * with gst_discoverer_stream_info_list_free().
 *
 * Since: 0.10.31
 */
GList *
gst_discoverer_info_get_stream_list (GstDiscovererInfo * info)
{
  GList *res = NULL, *tmp;

  g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);

  for (tmp = info->stream_list; tmp; tmp = tmp->next)
    res =
        g_list_append (res,
        gst_discoverer_stream_info_ref ((GstDiscovererStreamInfo *) tmp->data));

  return res;
}
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);
}