[gupnp-dlna/wip/new-api: 26/46] Make guessing a profile from DLNA info directly possible.



commit 513cb6c24e4f5979480074fccb8555418619257e
Author: Krzesimir Nowak <krnowak openismus com>
Date:   Wed Jan 2 13:42:40 2013 +0100

    Make guessing a profile from DLNA info directly possible.

 libgupnp-dlna/gupnp-dlna-profile-guesser.c |   50 +++++++++++++++++++--------
 libgupnp-dlna/gupnp-dlna-profile-guesser.h |    8 ++++-
 2 files changed, 42 insertions(+), 16 deletions(-)
---
diff --git a/libgupnp-dlna/gupnp-dlna-profile-guesser.c b/libgupnp-dlna/gupnp-dlna-profile-guesser.c
index da95c94..ffe2627 100644
--- a/libgupnp-dlna/gupnp-dlna-profile-guesser.c
+++ b/libgupnp-dlna/gupnp-dlna-profile-guesser.c
@@ -246,19 +246,6 @@ unref_extractor_in_idle (GUPnPDLNAMetadataExtractor *extractor)
         return FALSE;
 }
 
-static GUPnPDLNAProfile *
-guess_profile (GUPnPDLNAProfileGuesser *guesser,
-               GUPnPDLNAInformation    *info)
-{
-        GUPnPDLNAProfileGuesserImpl *guesser_impl =
-                                 gupnp_dlna_profile_backend_get_guesser_impl ();
-        GList *profiles = gupnp_dlna_profile_guesser_list_profiles (guesser);
-
-        return gupnp_dlna_profile_guesser_impl_guess_profile (guesser_impl,
-                                                              info,
-                                                              profiles);
-}
-
 static void
 gupnp_dlna_discovered_cb (GUPnPDLNAProfileGuesser *guesser,
                           GUPnPDLNAInformation    *info,
@@ -271,7 +258,9 @@ gupnp_dlna_discovered_cb (GUPnPDLNAProfileGuesser *guesser,
         const gchar *uri = NULL;
 
         if (!error) {
-                profile = guess_profile (guesser, info);
+                profile = gupnp_dlna_profile_guesser_guess_profile_from_info
+                                        (guesser,
+                                         info);
         }
         if (info)
                 uri = gupnp_dlna_information_get_uri (info);
@@ -368,7 +357,9 @@ gupnp_dlna_profile_guesser_guess_profile_sync
                 g_propagate_error (error,
                                    extraction_error);
         else
-                profile = guess_profile (guesser, info);
+                profile = gupnp_dlna_profile_guesser_guess_profile_from_info
+                                        (guesser,
+                                         info);
 
         if (info)
                 g_object_unref (info);
@@ -379,6 +370,35 @@ gupnp_dlna_profile_guesser_guess_profile_sync
 }
 
 /**
+ * gupnp_dlna_profile_guesser_guess_profile_from_info:
+ * @guesser: The #GUPnPDLNAProfileGuesser object.
+ * @info: The #GUPnPDLNAInformation object.
+ *
+ * Guesses the profile which fits to passed @info.
+ *
+ * Returns: (transfer none): A #GUPnPDLNAProfile object on success,
+ * %NULL otherwise.
+ */
+GUPnPDLNAProfile *
+gupnp_dlna_profile_guesser_guess_profile_from_info
+                                        (GUPnPDLNAProfileGuesser *guesser,
+                                         GUPnPDLNAInformation    *info)
+{
+        GUPnPDLNAProfileGuesserImpl *guesser_impl;
+        GList *profiles;
+
+        g_return_val_if_fail (GUPNP_IS_DLNA_PROFILE_GUESSER (guesser), NULL);
+        g_return_val_if_fail (GUPNP_IS_DLNA_INFORMATION (info), NULL);
+
+        guesser_impl = gupnp_dlna_profile_backend_get_guesser_impl ();
+        profiles = gupnp_dlna_profile_guesser_list_profiles (guesser);
+
+        return gupnp_dlna_profile_guesser_impl_guess_profile (guesser_impl,
+                                                              info,
+                                                              profiles);
+}
+
+/**
  * gupnp_dlna_profile_guesser_get_profile:
  * @guesser: The #GUPnPDLNAProfileGuesser object.
  * @name: The name of the DLNA profile to be retrieved.
diff --git a/libgupnp-dlna/gupnp-dlna-profile-guesser.h b/libgupnp-dlna/gupnp-dlna-profile-guesser.h
index 53d3af6..c702172 100644
--- a/libgupnp-dlna/gupnp-dlna-profile-guesser.h
+++ b/libgupnp-dlna/gupnp-dlna-profile-guesser.h
@@ -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>
@@ -26,6 +26,7 @@
 
 #include <glib-object.h>
 #include "gupnp-dlna-profile.h"
+#include "gupnp-dlna-information.h"
 
 G_BEGIN_DECLS
 
@@ -98,6 +99,11 @@ gupnp_dlna_profile_guesser_guess_profile_sync
                                         guint                     timeout_in_ms,
                                         GError                  **error);
 
+GUPnPDLNAProfile *
+gupnp_dlna_profile_guesser_guess_profile_from_info
+                                        (GUPnPDLNAProfileGuesser *guesser,
+                                         GUPnPDLNAInformation    *info);
+
 /* Get a GUPnPDLNAProfile by name */
 GUPnPDLNAProfile *
 gupnp_dlna_profile_guesser_get_profile (GUPnPDLNAProfileGuesser *guesser,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]