diff options
Diffstat (limited to 'libgupnp-dlna')
-rw-r--r-- | libgupnp-dlna/gupnp-dlna-information.c | 22 | ||||
-rw-r--r-- | libgupnp-dlna/gupnp-dlna-information.h | 10 | ||||
-rw-r--r-- | libgupnp-dlna/gupnp-dlna-profile-guesser.c | 21 |
3 files changed, 52 insertions, 1 deletions
diff --git a/libgupnp-dlna/gupnp-dlna-information.c b/libgupnp-dlna/gupnp-dlna-information.c index 7d1ea8d..37fb023 100644 --- a/libgupnp-dlna/gupnp-dlna-information.c +++ b/libgupnp-dlna/gupnp-dlna-information.c @@ -60,6 +60,12 @@ enum { PROP_VIDEO_INFO }; +static const gchar * +gupnp_dlna_information_get_profile_name_default (GUPnPDLNAInformation *info G_GNUC_UNUSED) +{ + return NULL; +} + static void gupnp_dlna_information_dispose (GObject *object) { @@ -162,6 +168,7 @@ gupnp_dlna_information_class_init (GUPnPDLNAInformationClass *info_class) info_class->get_image_information = NULL; info_class->get_video_information = NULL; info_class->get_audio_information = NULL; + info_class->get_profile_name = gupnp_dlna_information_get_profile_name_default; /** * GUPnPDLNAInformation:uri: @@ -394,6 +401,21 @@ gupnp_dlna_information_get_video_information (GUPnPDLNAInformation *info) } /** + * gupnp_dlna_information_get_profile_name: + * @info: A #GUPnPDLNAInformation object. + * + * Returns: (transfer none): The name of a DLNA profile or %NULL. + */ +const gchar * +gupnp_dlna_information_get_profile_name (GUPnPDLNAInformation *info) +{ + g_return_val_if_fail (GUPNP_IS_DLNA_INFORMATION (info), NULL); + + return GUPNP_DLNA_INFORMATION_GET_CLASS (info)->get_profile_name (info); +} + + +/** * gupnp_dlna_information_get_uri: * @info: A #GUPnPDLNAInformation object. * diff --git a/libgupnp-dlna/gupnp-dlna-information.h b/libgupnp-dlna/gupnp-dlna-information.h index 88e6736..e9c6bf3 100644 --- a/libgupnp-dlna/gupnp-dlna-information.h +++ b/libgupnp-dlna/gupnp-dlna-information.h @@ -74,6 +74,8 @@ typedef struct { * to get an image information. * @get_video_information: This is called by #GUPnPDLNAProfileGuesser * to get a video information. + * @get_profile_name: This is called by #GUPnPDLNAProfileGuesser to + * get the name of the DLNA profile assigned with this information. * @_reserved: Padding. Ignore it. */ typedef struct { @@ -91,7 +93,10 @@ typedef struct { GUPnPDLNAVideoInformation * (* get_video_information) (GUPnPDLNAInformation *info); - gpointer _reserved[12]; + const gchar * + (* get_profile_name) (GUPnPDLNAInformation *info); + + gpointer _reserved[11]; } GUPnPDLNAInformationClass; GType @@ -110,6 +115,9 @@ GUPnPDLNAVideoInformation* gupnp_dlna_information_get_video_information (GUPnPDLNAInformation *info); const gchar * +gupnp_dlna_information_get_profile_name (GUPnPDLNAInformation *info); + +const gchar * gupnp_dlna_information_get_uri (GUPnPDLNAInformation *info); G_END_DECLS diff --git a/libgupnp-dlna/gupnp-dlna-profile-guesser.c b/libgupnp-dlna/gupnp-dlna-profile-guesser.c index b7738d5..ef9ce94 100644 --- a/libgupnp-dlna/gupnp-dlna-profile-guesser.c +++ b/libgupnp-dlna/gupnp-dlna-profile-guesser.c @@ -374,6 +374,13 @@ gupnp_dlna_profile_guesser_guess_profile_sync return profile; } +static gint +compare_profile_name (GUPnPDLNAProfile *profile, const char *name) +{ + return g_ascii_strcasecmp (gupnp_dlna_profile_get_name (profile), + name); +} + /** * gupnp_dlna_profile_guesser_guess_profile_from_info: * @guesser: The #GUPnPDLNAProfileGuesser object. @@ -394,6 +401,7 @@ gupnp_dlna_profile_guesser_guess_profile_from_info GUPnPDLNAAudioInformation *audio_info; GUPnPDLNAImageInformation *image_info; GUPnPDLNAProfile *profile; + const gchar *profile_name; g_return_val_if_fail (GUPNP_IS_DLNA_PROFILE_GUESSER (guesser), NULL); g_return_val_if_fail (GUPNP_IS_DLNA_INFORMATION (info), NULL); @@ -402,6 +410,19 @@ gupnp_dlna_profile_guesser_guess_profile_from_info video_info = gupnp_dlna_information_get_video_information (info); audio_info = gupnp_dlna_information_get_audio_information (info); image_info = gupnp_dlna_information_get_image_information (info); + profile_name = gupnp_dlna_information_get_profile_name (info); + + if (profile_name) { + GList *it = NULL; + it = g_list_find_custom (profiles, + profile_name, + (GCompareFunc) compare_profile_name); + if (it != NULL) + return it->data; + else + g_warning ("Profile '%s' provided by back-end not known to GUPnP-DLNA", + profile_name); + } if (image_info) profile = gupnp_dlna_profile_guesser_impl_guess_image_profile |