[gupnp-av] Allow OP, CI and PS params without DLNA profile



commit a5071dc435274faefbb13a80c96f8a259e065926
Author: Jens Georg <mail jensge org>
Date:   Thu Feb 16 16:41:53 2012 +0200

    Allow OP, CI and PS params without DLNA profile
    
    This is allowed according to the guidelines 7.3.32.3, 7.3.36.2 and
    7.3.35.3.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=653894

 libgupnp-av/gupnp-protocol-info.c |   31 +++++++++++++++++++++----------
 1 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/libgupnp-av/gupnp-protocol-info.c b/libgupnp-av/gupnp-protocol-info.c
index 4c0f9e8..99c7ed3 100644
--- a/libgupnp-av/gupnp-protocol-info.c
+++ b/libgupnp-av/gupnp-protocol-info.c
@@ -241,12 +241,11 @@ add_dlna_info (GString           *str,
 
         dlna_profile = gupnp_protocol_info_get_dlna_profile (info);
         if (dlna_profile == NULL) {
-                g_string_append_printf (str, ":*");
-                return;
+                g_string_append_printf (str, ":");
+        } else {
+                g_string_append_printf (str, ":DLNA.ORG_PN=%s;", dlna_profile);
         }
 
-        g_string_append_printf (str, ":DLNA.ORG_PN=%s", dlna_profile);
-
         operation = gupnp_protocol_info_get_dlna_operation (info);
         if (operation != GUPNP_DLNA_OPERATION_NONE &&
             /* the OP parameter is only allowed for the "http-get"
@@ -256,14 +255,14 @@ add_dlna_info (GString           *str,
                      "http-get") == 0 ||
              strcmp (gupnp_protocol_info_get_protocol (info),
                      "rtsp-rtp-udp") == 0))
-                g_string_append_printf (str, ";DLNA.ORG_OP=%.2x", operation);
+                g_string_append_printf (str, "DLNA.ORG_OP=%.2x;", operation);
 
         /* Specify PS parameter if list of play speeds is provided */
         speeds = gupnp_protocol_info_get_play_speeds (info);
         if (speeds != NULL) {
                 int i;
 
-                g_string_append_printf (str, ";DLNA.ORG_PS=");
+                g_string_append_printf (str, "DLNA.ORG_PS=;");
 
                 for (i = 0; speeds[i]; i++) {
                         g_string_append (str, speeds[i]);
@@ -276,17 +275,29 @@ add_dlna_info (GString           *str,
         conversion = gupnp_protocol_info_get_dlna_conversion (info);
         /* omit the CI parameter for non-converted content */
         if (conversion != GUPNP_DLNA_CONVERSION_NONE)
-                g_string_append_printf (str, ";DLNA.ORG_CI=%d", conversion);
+                g_string_append_printf (str, "DLNA.ORG_CI=%d;", conversion);
 
         flags = gupnp_protocol_info_get_dlna_flags (info);
-        /* Omit the FLAGS parameter if no flags set */
-        if (flags != GUPNP_DLNA_FLAGS_NONE) {
-                g_string_append_printf (str, ";DLNA.ORG_FLAGS=%.8x", flags);
+        /* Omit the FLAGS parameter if no or DLNA profile are set */
+        if (flags != GUPNP_DLNA_FLAGS_NONE && dlna_profile != NULL) {
+                g_string_append_printf (str, "DLNA.ORG_FLAGS=%.8x", flags);
                 /*  append 24 reserved hex-digits */
                 g_string_append_printf (str,
                                         "0000" "0000" "0000"
                                         "0000" "0000" "0000");
         }
+
+        /* if nothing of the above was set, use the "match all" rule */
+        switch (str->str[str->len - 1]) {
+                case ':':
+                        g_string_append_c (str, '*');
+                        break;
+                case ';':
+                        g_string_erase (str, str->len - 1, 1);
+                        break;
+                default:
+                        break;
+        }
 }
 
 static void



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