[gupnp-dlna/wip/new-api: 24/48] Send GUPnPDLNAInformation when discovery is done instead of URI.
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp-dlna/wip/new-api: 24/48] Send GUPnPDLNAInformation when discovery is done instead of URI.
- Date: Wed, 16 Jan 2013 10:42:41 +0000 (UTC)
commit 9dc43ea0b96a0fae23d2f31d548831ea8c80657d
Author: Krzesimir Nowak <krnowak openismus com>
Date: Wed Jan 2 14:02:14 2013 +0100
Send GUPnPDLNAInformation when discovery is done instead of URI.
The GUPnPDLNAInformation already contains URI. Additionally it holds
metadata information that can be useful (for example for
gupnp-dlna-info-2.0).
Also, metadata extractors are now required to always return a
meaningful GUPnPDLNAInformation objects when they finished extracting.
libgupnp-dlna/gupnp-dlna-profile-guesser.c | 27 +++++++++++--------
libgupnp-dlna/gupnp-dlna-profile-guesser.h | 1 +
.../gstreamer/gupnp-dlna-gst-metadata-extractor.c | 15 +++++------
.../metadata/gupnp-dlna-metadata-extractor.c | 21 ++++++++-------
tools/gupnp-dlna-info.c | 6 +++-
5 files changed, 39 insertions(+), 31 deletions(-)
---
diff --git a/libgupnp-dlna/gupnp-dlna-profile-guesser.c b/libgupnp-dlna/gupnp-dlna-profile-guesser.c
index ffe2627..8c73c50 100644
--- a/libgupnp-dlna/gupnp-dlna-profile-guesser.c
+++ b/libgupnp-dlna/gupnp-dlna-profile-guesser.c
@@ -163,9 +163,9 @@ gupnp_dlna_profile_guesser_class_init
/**
* GUPnPDLNAProfileGuesser::done:
* @profile_guesser: The #GUPnPDLNAProfileGuesser.
- * @uri: URI for which profile was guessed.
- * @dlna:(allow-none)(transfer none): The results as #GUPnPDLNAProfile.
- * @error:(allow-none): Contains details of the error if discovery failed,
+ * @info: (transfer none): URI metadata as #GUPnPDLNAInformation.
+ * @dlna: (allow-none) (transfer none): The results as #GUPnPDLNAProfile.
+ * @error: (allow-none): Contains details of the error if discovery failed,
* else is %NULL.
*
* Will be emitted when guessing DLNA profile for a URI has finished.
@@ -180,7 +180,7 @@ gupnp_dlna_profile_guesser_class_init
g_cclosure_marshal_generic,
G_TYPE_NONE,
3,
- G_TYPE_STRING,
+ GUPNP_TYPE_DLNA_INFORMATION,
GUPNP_TYPE_DLNA_PROFILE,
G_TYPE_ERROR);
@@ -255,16 +255,13 @@ gupnp_dlna_discovered_cb (GUPnPDLNAProfileGuesser *guesser,
GUPnPDLNAProfile *profile = NULL;
GUPnPDLNAMetadataExtractor *extractor =
GUPNP_DLNA_METADATA_EXTRACTOR (user_data);
- const gchar *uri = NULL;
if (!error) {
profile = gupnp_dlna_profile_guesser_guess_profile_from_info
(guesser,
info);
}
- if (info)
- uri = gupnp_dlna_information_get_uri (info);
- g_signal_emit (guesser, signals[DONE], 0, uri, profile, error);
+ g_signal_emit (guesser, signals[DONE], 0, info, profile, error);
g_idle_add ((GSourceFunc) unref_extractor_in_idle, extractor);
}
@@ -323,7 +320,9 @@ gupnp_dlna_profile_guesser_guess_profile_async
* @guesser: #GUPnPDLNAProfileGuesser object to use for guessing.
* @uri: URI of media.
* @timeout_in_ms: Timeout of guessing in miliseconds.
- * @error: #GError object or %NULL.
+ * @dlna_info: (allow-none) (transfer full) (out): A place where to
+ * store DLNA information or %NULL.
+ * @error: (allow-none): #GError object or %NULL.
*
* Synchronously guesses DLNA profile for given @uri.
*
@@ -334,6 +333,7 @@ gupnp_dlna_profile_guesser_guess_profile_sync
(GUPnPDLNAProfileGuesser *guesser,
const gchar *uri,
guint timeout_in_ms,
+ GUPnPDLNAInformation **dlna_info,
GError **error)
{
GError *extraction_error;
@@ -343,6 +343,7 @@ gupnp_dlna_profile_guesser_guess_profile_sync
g_return_val_if_fail (GUPNP_IS_DLNA_PROFILE_GUESSER (guesser), NULL);
g_return_val_if_fail (uri != NULL, NULL);
+ g_return_val_if_fail (dlna_info == NULL || *dlna_info == NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
extraction_error = NULL;
@@ -361,8 +362,12 @@ gupnp_dlna_profile_guesser_guess_profile_sync
(guesser,
info);
- if (info)
- g_object_unref (info);
+ if (info) {
+ if (dlna_info)
+ *dlna_info = info;
+ else
+ g_object_unref (info);
+ }
if (extractor)
g_object_unref (extractor);
diff --git a/libgupnp-dlna/gupnp-dlna-profile-guesser.h b/libgupnp-dlna/gupnp-dlna-profile-guesser.h
index c702172..c6f20b0 100644
--- a/libgupnp-dlna/gupnp-dlna-profile-guesser.h
+++ b/libgupnp-dlna/gupnp-dlna-profile-guesser.h
@@ -97,6 +97,7 @@ gupnp_dlna_profile_guesser_guess_profile_sync
(GUPnPDLNAProfileGuesser *guesser,
const gchar *uri,
guint timeout_in_ms,
+ GUPnPDLNAInformation **dlna_info,
GError **error);
GUPnPDLNAProfile *
diff --git a/libgupnp-dlna/metadata-backends/gstreamer/gupnp-dlna-gst-metadata-extractor.c b/libgupnp-dlna/metadata-backends/gstreamer/gupnp-dlna-gst-metadata-extractor.c
index b30b42b..7ad924c 100644
--- a/libgupnp-dlna/metadata-backends/gstreamer/gupnp-dlna-gst-metadata-extractor.c
+++ b/libgupnp-dlna/metadata-backends/gstreamer/gupnp-dlna-gst-metadata-extractor.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 Nokia Corporation.
- * Copyright (C) 2012 Intel Corporation.
+ * Copyright (C) 2012, 2013 Intel Corporation.
*
* Authors: Arun Raghavan <arun raghavan collabora co uk>
* Krzesimir Nowak <krnowak openismus com>
@@ -71,20 +71,19 @@ gupnp_dlna_discovered_cb (GUPnPDLNAMetadataExtractor *self,
GstDiscoverer *discoverer = GST_DISCOVERER (user_data);
GUPnPDLNAInformation *gupnp_info = NULL;
- if (!error)
+ 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_INFORMATION
(gupnp_dlna_gst_information_new_from_discoverer_info
(gst_discoverer_info_get_uri (info),
info));
- else
- gupnp_info = GUPNP_DLNA_INFORMATION
- (gupnp_dlna_gst_information_new_empty_with_uri
- (gst_discoverer_info_get_uri (info)));
gupnp_dlna_metadata_extractor_emit_done (self,
gupnp_info,
error);
- if (gupnp_info)
- g_object_unref (gupnp_info);
+ g_object_unref (gupnp_info);
g_idle_add ((GSourceFunc) unref_discoverer_in_idle, discoverer);
}
diff --git a/libgupnp-dlna/metadata/gupnp-dlna-metadata-extractor.c b/libgupnp-dlna/metadata/gupnp-dlna-metadata-extractor.c
index 65c2524..2337548 100644
--- a/libgupnp-dlna/metadata/gupnp-dlna-metadata-extractor.c
+++ b/libgupnp-dlna/metadata/gupnp-dlna-metadata-extractor.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 Nokia Corporation.
- * Copyright (C) 2012 Intel Corporation.
+ * Copyright (C) 2012, 2013 Intel Corporation.
*
* Authors: Arun Raghavan <arun raghavan collabora co uk>
* Krzesimir Nowak <krnowak openismus com>
@@ -82,9 +82,9 @@ gupnp_dlna_metadata_extractor_class_init
/**
* GUPnPDLNAMetadataExtractor::done:
* @extractor: The #GUPnPDLNAMetadataExtractor.
- * @info: The results as #GUPnPDLNAInformation.
- * @error: contains details of the error if discovery fails,
- * else is %NULL.
+ * @info: (transfer none): The results as #GUPnPDLNAInformation.
+ * @error: (allow-none) (transfer none): Contains details of
+ * the error if discovery fails, otherwise is %NULL.
*
* Will be emitted when all information on a URI could be
* discovered.
@@ -196,14 +196,14 @@ gupnp_dlna_metadata_extractor_extract_sync
/**
* gupnp_dlna_metadata_extractor_emit_done:
* @extractor: A #GUPnPDLNAMetadataExtractor object.
- * @info: A #GUPnPDLNAInformation about discovered URI.
- * @error: A #GError.
+ * @info: (transfer none): A #GUPnPDLNAInformation about discovered URI.
+ * @error: (allow-none) (transfer none): A #GError.
*
* Emits ::done signal. This function is intended to be used by
- * subclasses of #GUPnPDLNAMetadataExtractor. It would be good to
- * always pass a meaningful @info, even in case of error. That way a
- * receiver of this signal can know which URI discovery failed by
- * using gupnp_dlna_information_get_uri().
+ * subclasses of #GUPnPDLNAMetadataExtractor. It is required to always
+ * pass a meaningful @info, even in case of error. That way a receiver
+ * of this signal can know which URI discovery failed by using
+ * gupnp_dlna_information_get_uri().
*/
void
gupnp_dlna_metadata_extractor_emit_done (GUPnPDLNAMetadataExtractor *extractor,
@@ -211,6 +211,7 @@ gupnp_dlna_metadata_extractor_emit_done (GUPnPDLNAMetadataExtractor *extractor,
GError *error)
{
g_return_if_fail (GUPNP_IS_DLNA_METADATA_EXTRACTOR (extractor));
+ g_return_if_fail (GUPNP_IS_DLNA_INFORMATION (info));
g_signal_emit (extractor, signals[DONE], 0, info, error);
}
diff --git a/tools/gupnp-dlna-info.c b/tools/gupnp-dlna-info.c
index abeb625..7fc0fb4 100644
--- a/tools/gupnp-dlna-info.c
+++ b/tools/gupnp-dlna-info.c
@@ -72,11 +72,13 @@ print_dlna_profile (GUPnPDLNAProfile *profile,
static void
guesser_done (GUPnPDLNAProfileGuesser *guesser G_GNUC_UNUSED,
- const gchar *uri
+ GUPnPDLNAInformation *info,
GUPnPDLNAProfile *profile,
GError *err,
GMainLoop *ml)
{
+ const gchar *uri = gupnp_dlna_information_get_uri (info);
+
print_dlna_profile (profile, uri, err);
--files_to_guess;
if (!files_to_guess)
@@ -188,7 +190,7 @@ process_file (GUPnPDLNAProfileGuesser *guesser,
}
} else {
GError *err = NULL;
- GUPnPDLNAProfile *profile = gupnp_dlna_profile_guesser_guess_profile_sync (guesser, uri, timeout, &err);
+ GUPnPDLNAProfile *profile = gupnp_dlna_profile_guesser_guess_profile_sync (guesser, uri, timeout, NULL, &err);
if (err) {
g_warning ("Unable to read file: %s\n",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]