[rygel] renderer,renderer-gst: Get profiles from renderer



commit 373feccc61419f2fe08581e8d197cef0c7404f6d
Author: Jens Georg <jensg openismus com>
Date:   Thu Aug 15 13:44:15 2013 +0200

    renderer,renderer-gst: Get profiles from renderer
    
    Let the renderer return a list of supported DLNA profiles.
    
    To not break ABI/API we duplicate DLNAProfiles from server; needs to be moved
    to core in next unstable cycle.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=699698

 .../rygel-playbin-player.vala                      |   68 +++++++++++++++++++-
 src/librygel-renderer/filelist.am                  |    1 +
 src/librygel-renderer/rygel-dlna-profile.vala      |   44 +++++++++++++
 .../rygel-media-renderer-plugin.vala               |   42 ++++++++++++-
 src/plugins/playbin/rygel-playbin-plugin.vala      |    5 ++
 5 files changed, 158 insertions(+), 2 deletions(-)
---
diff --git a/src/librygel-renderer-gst/rygel-playbin-player.vala 
b/src/librygel-renderer-gst/rygel-playbin-player.vala
index cbe5427..22034a6 100644
--- a/src/librygel-renderer-gst/rygel-playbin-player.vala
+++ b/src/librygel-renderer-gst/rygel-playbin-player.vala
@@ -2,7 +2,7 @@
  * Copyright (C) 2008 OpenedHand Ltd.
  * Copyright (C) 2009,2010,2011,2012 Nokia Corporation.
  * Copyright (C) 2012 Openismus GmbH
- * Copyright (C) 2012 Intel Corporation.
+ * Copyright (C) 2012,2013 Intel Corporation.
  *
  * Author: Jorn Baayen <jorn openedhand com>
  *         Zeeshan Ali (Khattak) <zeeshanak gnome org>
@@ -26,6 +26,7 @@
 
 using Gst;
 using GUPnP;
+using Rygel.Renderer;
 
 /**
  * Implementation of RygelMediaPlayer for GStreamer.
@@ -337,6 +338,71 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
         return mime_types;
     }
 
+    private GLib.List<DLNAProfile> _supported_profiles;
+    public unowned GLib.List<DLNAProfile> supported_profiles {
+        get {
+            if (_supported_profiles == null) {
+                // FIXME: Check available decoders in registry and register
+                // profiles after that
+                _supported_profiles = new GLib.List<DLNAProfile> ();
+
+                // Image
+                _supported_profiles.prepend (new DLNAProfile ("JPEG_SM",
+                                                              "image/jpeg"));
+                _supported_profiles.prepend (new DLNAProfile ("JPEG_MED",
+                                                              "image/jpeg"));
+                _supported_profiles.prepend (new DLNAProfile ("JPEG_LRG",
+                                                              "image/jpeg"));
+                _supported_profiles.prepend (new DLNAProfile ("PNG_LRG",
+                                                              "image/png"));
+
+                // Audio
+                _supported_profiles.prepend (new DLNAProfile ("MP3",
+                                                              "audio/mpeg"));
+                _supported_profiles.prepend (new DLNAProfile ("MP3X",
+                                                              "audio/mpeg"));
+                _supported_profiles.prepend (new DLNAProfile
+                                        ("AAC_ADTS_320",
+                                         "audio/vnd.dlna.adts"));
+                _supported_profiles.prepend (new DLNAProfile ("AAC_ISO_320",
+                                                              "audio/mp4"));
+                _supported_profiles.prepend (new DLNAProfile ("AAC_ISO_320",
+                                                              "audio/3gpp"));
+                _supported_profiles.prepend (new DLNAProfile
+                                        ("LPCM",
+                                         "audio/l16;rate=44100;channels=2"));
+                _supported_profiles.prepend (new DLNAProfile
+                                        ("LPCM",
+                                         "audio/l16;rate=44100;channels=1"));
+                _supported_profiles.prepend (new DLNAProfile ("WMABASE",
+                                                              "audio/x-ms-wma"));
+                _supported_profiles.prepend (new DLNAProfile ("WMAFULL",
+                                                              "audio/x-ms-wma"));
+                _supported_profiles.prepend (new DLNAProfile ("WMAPRO",
+                                                              "audio/x-ms-wma"));
+
+                // Video
+                _supported_profiles.prepend (new DLNAProfile
+                                        ("MPEG_TS_SD_EU_ISO",
+                                         "video/mpeg"));
+                _supported_profiles.prepend (new DLNAProfile
+                                        ("MPEG_TS_HD_EU_ISO",
+                                         "video/mpeg"));
+                _supported_profiles.prepend (new DLNAProfile
+                                        ("MPEG_TS_SD_NA_ISO",
+                                         "video/mpeg"));
+                _supported_profiles.prepend (new DLNAProfile
+                                        ("MPEG_TS_HD_NA_ISO",
+                                         "video/mpeg"));
+                _supported_profiles.prepend (new DLNAProfile
+                                        ("AVC_MP4_BL_CIF15_AAC_520",
+                                         "video/mp4"));
+            }
+
+            return _supported_profiles;
+        }
+    }
+
     private bool is_rendering_image () {
         dynamic Element typefind;
 
diff --git a/src/librygel-renderer/filelist.am b/src/librygel-renderer/filelist.am
index 3f5cb08..def56e5 100644
--- a/src/librygel-renderer/filelist.am
+++ b/src/librygel-renderer/filelist.am
@@ -1,6 +1,7 @@
 LIBRYGEL_RENDERER_VAPI_SOURCE_FILES = \
        rygel-media-renderer-plugin.vala \
        rygel-media-player.vala \
+       rygel-dlna-profile.vala \
        rygel-media-renderer.vala
 
 LIBRYGEL_RENDERER_NONVAPI_SOURCE_FILES = \
diff --git a/src/librygel-renderer/rygel-dlna-profile.vala b/src/librygel-renderer/rygel-dlna-profile.vala
new file mode 100644
index 0000000..9a4743a
--- /dev/null
+++ b/src/librygel-renderer/rygel-dlna-profile.vala
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Author: Jens Georg <jensg openismus com>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/**
+ * Data class representing a DLNA profile.
+ * It contains the name and the corresponding DLNA mime type.
+ *
+ * Note: The mime type can deviate from mime types typically used elsewhere.
+ */
+public class Rygel.Renderer.DLNAProfile {
+    public string mime;
+    public string name;
+
+    public DLNAProfile (string name, string mime) {
+        this.mime = mime;
+        this.name = name;
+    }
+
+    /**
+     * Compare two DLNA profiles by name
+     */
+    public static int compare_by_name (DLNAProfile a, DLNAProfile b) {
+        return a.name.ascii_casecmp (b.name);
+    }
+}
diff --git a/src/librygel-renderer/rygel-media-renderer-plugin.vala 
b/src/librygel-renderer/rygel-media-renderer-plugin.vala
index 2e03a99..416e5ab 100644
--- a/src/librygel-renderer/rygel-media-renderer-plugin.vala
+++ b/src/librygel-renderer/rygel-media-renderer-plugin.vala
@@ -22,6 +22,8 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
+using Rygel.Renderer;
+
 /**
  * This is the base class for every Rygel UPnP renderer plugin.
  *
@@ -39,6 +41,29 @@ public class Rygel.MediaRendererPlugin : Rygel.Plugin {
     private string sink_protocol_info;
     private PlayerController controller;
 
+    private GLib.List<DLNAProfile> _supported_profiles;
+
+    /// A list of DLNA profiles the MediaRenderer in this plug-in will accept
+    /// for rendering.
+    public unowned GLib.List<unowned DLNAProfile> supported_profiles {
+        get {
+            return _supported_profiles;
+        }
+
+        construct set {
+            _supported_profiles = null;
+            if (value != null) {
+                foreach (var profile in value) {
+                    _supported_profiles.prepend (profile);
+                }
+
+                _supported_profiles.prepend (new DLNAProfile ("DIDL_S",
+                                                              "text/xml"));
+                _supported_profiles.reverse ();
+            }
+        }
+    }
+
     /**
      * Create an instance of the plugin.
      *
@@ -112,11 +137,26 @@ public class Rygel.MediaRendererPlugin : Rygel.Plugin {
 
         if (this.sink_protocol_info == null) {
             this.sink_protocol_info = "";
+
             var protocols = player.get_protocols ();
 
-            this.sink_protocol_info += "http-get:*:text/xml:DLNA.ORG_PN=DIDL_S,";
+            foreach (var protocol in protocols) {
+                if (protocols[0] != protocol) {
+                    this.sink_protocol_info += ",";
+                }
+
+                foreach (var profile in this.supported_profiles) {
+                    if (supported_profiles.data.name != profile.name) {
+                        this.sink_protocol_info += ",";
+                    }
+                    this.sink_protocol_info += protocol + ":*:" +
+                                               profile.mime +
+                                               ":DLNA.ORG_PN=" + profile.name;
+                }
+            }
 
             var mime_types = player.get_mime_types ();
+
             foreach (var protocol in protocols) {
                 if (protocols[0] != protocol) {
                     this.sink_protocol_info += ",";
diff --git a/src/plugins/playbin/rygel-playbin-plugin.vala b/src/plugins/playbin/rygel-playbin-plugin.vala
index 1f73db0..8f0e3ed 100644
--- a/src/plugins/playbin/rygel-playbin-plugin.vala
+++ b/src/plugins/playbin/rygel-playbin-plugin.vala
@@ -35,6 +35,11 @@ internal class Rygel.Playbin.Plugin : Rygel.MediaRendererPlugin {
         base (Plugin.NAME, _("GStreamer Player"));
     }
 
+    public override void constructed () {
+        base.constructed ();
+        this.supported_profiles = Player.get_default ().supported_profiles;
+    }
+
     public override MediaPlayer? get_player () {
         return Playbin.Player.get_default ();
     }


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