[rygel] core: Provide contentFeatures.dlna.org header



commit 1b83d4bf6372846df858a8d4aedd139b403b800f
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Sep 2 00:38:45 2009 +0300

    core: Provide contentFeatures.dlna.org header
    
    Provide the "contentFeatures.dlna.org" header in HTTP responses.

 src/rygel/rygel-http-identity-handler.vala  |   12 ++++++++++++
 src/rygel/rygel-http-request-handler.vala   |   19 ++++++++++++++++++-
 src/rygel/rygel-http-transcode-handler.vala |   11 +++++++++++
 3 files changed, 41 insertions(+), 1 deletions(-)
---
diff --git a/src/rygel/rygel-http-identity-handler.vala b/src/rygel/rygel-http-identity-handler.vala
index fbbe6a5..1569573 100644
--- a/src/rygel/rygel-http-identity-handler.vala
+++ b/src/rygel/rygel-http-identity-handler.vala
@@ -21,6 +21,8 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
+using GUPnP;
+
 // An HTTP request handler that passes the item content through as is.
 internal class Rygel.HTTPIdentityHandler : GLib.Object,
                                            Rygel.HTTPRequestHandler {
@@ -45,6 +47,8 @@ internal class Rygel.HTTPIdentityHandler : GLib.Object,
                 request.byte_range.add_response_header (request.msg, item.size);
             }
         }
+
+        this.add_content_features_headers (request);
     }
 
     public virtual HTTPResponse render_body (HTTPRequest request)
@@ -76,4 +80,12 @@ internal class Rygel.HTTPIdentityHandler : GLib.Object,
                                          item.size);
         }
     }
+
+    protected DIDLLiteResource add_resource (DIDLLiteItem didl_item,
+                                             HTTPRequest  request)
+                                             throws HTTPRequestError {
+        return request.item.add_resource (didl_item,
+                                          null,
+                                          request.http_server.get_protocol ());
+    }
 }
diff --git a/src/rygel/rygel-http-request-handler.vala b/src/rygel/rygel-http-request-handler.vala
index e186ee4..0054ea5 100644
--- a/src/rygel/rygel-http-request-handler.vala
+++ b/src/rygel/rygel-http-request-handler.vala
@@ -21,8 +21,8 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-
 using Rygel;
+using GUPnP;
 
 /**
  * HTTP request handler interface.
@@ -31,7 +31,24 @@ internal interface Rygel.HTTPRequestHandler: GLib.Object {
     // Add response headers.
     public abstract void add_response_headers (HTTPRequest request)
                                                throws HTTPRequestError;
+
     // Create an HTTPResponse object that will render the body.
     public abstract HTTPResponse render_body (HTTPRequest request)
                                               throws HTTPRequestError;
+
+    public void add_content_features_headers (HTTPRequest request)
+                                              throws HTTPRequestError {
+        var didl_writer = new GUPnP.DIDLLiteWriter (null);
+        var didl_item = didl_writer.add_item ();
+        var resource = this.add_resource (didl_item, request);
+        var tokens = resource.protocol_info.to_string ().split (":", 4);
+        assert (tokens.length == 4);
+
+        request.msg.response_headers.append ("contentFeatures.dlna.org",
+                                             tokens[3]);
+    }
+
+    protected abstract DIDLLiteResource add_resource (DIDLLiteItem didl_item,
+                                                      HTTPRequest  request)
+                                                      throws HTTPRequestError;
 }
diff --git a/src/rygel/rygel-http-transcode-handler.vala b/src/rygel/rygel-http-transcode-handler.vala
index 3596e7a..f8908e0 100644
--- a/src/rygel/rygel-http-transcode-handler.vala
+++ b/src/rygel/rygel-http-transcode-handler.vala
@@ -22,6 +22,7 @@
  */
 using Rygel;
 using Gst;
+using GUPnP;
 
 /**
  * The handler for HTTP transcoding requests.
@@ -40,6 +41,8 @@ internal class Rygel.HTTPTranscodeHandler : GLib.Object, HTTPRequestHandler {
         if (request.time_range != null) {
             request.time_range.add_response_header (request.msg);
         }
+
+        this.add_content_features_headers (request);
     }
 
     public virtual HTTPResponse render_body (HTTPRequest request)
@@ -58,5 +61,13 @@ internal class Rygel.HTTPTranscodeHandler : GLib.Object, HTTPRequestHandler {
                                  src,
                                  request.time_range);
     }
+
+    protected DIDLLiteResource add_resource (DIDLLiteItem didl_item,
+                                             HTTPRequest  request)
+                                             throws HTTPRequestError {
+        return this.transcoder.add_resource (didl_item,
+                                             request.item,
+                                             request.http_server);
+    }
 }
 



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