[rygel/wip/didl-s: 33/35] renderer: Select proper playlist resource
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/didl-s: 33/35] renderer: Select proper playlist resource
- Date: Wed, 21 Nov 2012 16:58:02 +0000 (UTC)
commit 663b53152c0f0875afe0a2e966c37efeb7fa1fc1
Author: Jens Georg <jensg openismus com>
Date: Wed Nov 21 08:40:32 2012 +0100
renderer: Select proper playlist resource
src/librygel-renderer/rygel-av-transport.vala | 6 ++-
.../rygel-media-renderer-plugin.vala | 45 ++++++++++++++++++++
src/librygel-renderer/rygel-playlist-handler.vala | 15 ++++--
.../rygel-sink-connection-manager.vala | 34 +--------------
4 files changed, 61 insertions(+), 39 deletions(-)
---
diff --git a/src/librygel-renderer/rygel-av-transport.vala b/src/librygel-renderer/rygel-av-transport.vala
index 5543477..61cffeb 100644
--- a/src/librygel-renderer/rygel-av-transport.vala
+++ b/src/librygel-renderer/rygel-av-transport.vala
@@ -36,6 +36,7 @@ internal class Rygel.AVTransport : Service {
private Session session;
private PlaylistHandler playlist_handler;
+ private string protocol_info;
// The setters below update the LastChange message
private uint _n_tracks = 0;
@@ -204,6 +205,8 @@ internal class Rygel.AVTransport : Service {
this.player.notify["metadata"].connect (this.notify_meta_data_cb);
this.session = new SessionAsync ();
+ var plugin = this.root_device.resource_factory as MediaRendererPlugin;
+ this.protocol_info = plugin.get_protocol_info ();
}
private MediaPlayer get_player () {
@@ -734,7 +737,8 @@ internal class Rygel.AVTransport : Service {
this.playlist_handler = new PlaylistHandler (collection,
this,
- this.player);
+ this.player,
+ this.protocol_info);
action.return ();
}
diff --git a/src/librygel-renderer/rygel-media-renderer-plugin.vala b/src/librygel-renderer/rygel-media-renderer-plugin.vala
index 872963b..d40f6a4 100644
--- a/src/librygel-renderer/rygel-media-renderer-plugin.vala
+++ b/src/librygel-renderer/rygel-media-renderer-plugin.vala
@@ -35,6 +35,8 @@ public class Rygel.MediaRendererPlugin : Rygel.Plugin {
BuildConfig.DATA_DIR +
"/xml/MediaRenderer2.xml";
+ private string sink_protocol_info;
+
/**
* Create an instance of the plugin.
*
@@ -71,4 +73,47 @@ public class Rygel.MediaRendererPlugin : Rygel.Plugin {
public virtual MediaPlayer? get_player () {
return null;
}
+
+ public string get_protocol_info () {
+ var player = this.get_player ();
+ if (player == null) {
+ return "";
+ }
+
+ 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,";
+ this.sink_protocol_info += "http-get:*:audio/mpeg:DLNA.ORG_PN=MP3,";
+ this.sink_protocol_info +=
+ "http-get:*:audio/L16;rate=44100;channels=2:DLNA.ORG_PN=LPCM,";
+ this.sink_protocol_info +=
+ "http-get:*:audio/mp4:DLNA.ORG_PN=AAC_ISO_320,";
+ this.sink_protocol_info +=
+ "http-get:*:audio/vnd.dlna.adts:DLNA.ORG_PN=AAC_ADTS_320,";
+ this.sink_protocol_info += "http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_SM,";
+ this.sink_protocol_info += "http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_MED,";
+ this.sink_protocol_info += "http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_LRG,";
+ this.sink_protocol_info +=
+ "http-get:*:video/mp4:DLNA.ORG_PN=AVC_MP4_BL_CIF15_AAC_520,";
+
+ var mime_types = player.get_mime_types ();
+ foreach (var protocol in protocols) {
+ if (protocols[0] != protocol) {
+ this.sink_protocol_info += ",";
+ }
+
+ foreach (var mime_type in mime_types) {
+ if (mime_types[0] != mime_type) {
+ this.sink_protocol_info += ",";
+ }
+
+ this.sink_protocol_info += protocol + ":*:" + mime_type + ":*";
+ }
+ }
+ }
+
+ return this.sink_protocol_info;
+ }
}
diff --git a/src/librygel-renderer/rygel-playlist-handler.vala b/src/librygel-renderer/rygel-playlist-handler.vala
index 84ecb68..85e47dd 100644
--- a/src/librygel-renderer/rygel-playlist-handler.vala
+++ b/src/librygel-renderer/rygel-playlist-handler.vala
@@ -15,9 +15,9 @@ internal class Rygel.PlaylistHandler : GLib.Object {
public MediaCollection collection { construct; private get; }
public unowned AVTransport transport { construct; private get; }
public unowned MediaPlayer player { construct; private get; }
- public uint current_track { construct set; get; default = 1; }
+ public string protocol_info { construct; private get; }
- public uint size { get { return items.length (); } }
+ public uint current_track { construct set; get; default = 1; }
private List<DIDLLiteItem> items;
private uint timeout_id;
@@ -26,10 +26,12 @@ internal class Rygel.PlaylistHandler : GLib.Object {
public PlaylistHandler (MediaCollection collection,
AVTransport transport,
- MediaPlayer player) {
+ MediaPlayer player,
+ string protocol_info) {
Object (collection : collection,
transport : transport,
- player : player);
+ player : player,
+ protocol_info : protocol_info);
}
public override void constructed () {
@@ -73,7 +75,10 @@ internal class Rygel.PlaylistHandler : GLib.Object {
public void set_track () {
var item = items.nth (this.current_track - 1).data;
- var res = item.get_resources().nth (0).data;
+
+ // Try to find a matching resource but use the first one if none found.
+ var res = item.get_compat_resource (this.protocol_info, true);
+
this.transport.track = this.current_track;
this.transport.track_uri = res.get_uri ();
this.transport.track_metadata = DIDL_FRAME_TEMPLATE.printf
diff --git a/src/librygel-renderer/rygel-sink-connection-manager.vala b/src/librygel-renderer/rygel-sink-connection-manager.vala
index ec26edf..beb30c0 100644
--- a/src/librygel-renderer/rygel-sink-connection-manager.vala
+++ b/src/librygel-renderer/rygel-sink-connection-manager.vala
@@ -24,8 +24,6 @@
using GUPnP;
internal class Rygel.SinkConnectionManager : Rygel.ConnectionManager {
- private MediaPlayer player;
-
public override void constructed () {
base.constructed ();
@@ -34,36 +32,6 @@ internal class Rygel.SinkConnectionManager : Rygel.ConnectionManager {
this.direction = "Input";
var plugin = this.root_device.resource_factory as MediaRendererPlugin;
- this.player = plugin.get_player ();
- var protocols = this.player.get_protocols ();
-
- this.sink_protocol_info += "http-get:*:text/xml:DLNA.ORG_PN=DIDL_S,";
- this.sink_protocol_info += "http-get:*:audio/mpeg:DLNA.ORG_PN=MP3,";
- this.sink_protocol_info +=
- "http-get:*:audio/L16;rate=44100;channels=2:DLNA.ORG_PN=LPCM,";
- this.sink_protocol_info +=
- "http-get:*:audio/mp4:DLNA.ORG_PN=AAC_ISO_320,";
- this.sink_protocol_info +=
- "http-get:*:audio/vnd.dlna.adts:DLNA.ORG_PN=AAC_ADTS_320,";
- this.sink_protocol_info += "http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_SM,";
- this.sink_protocol_info += "http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_MED,";
- this.sink_protocol_info += "http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_LRG,";
- this.sink_protocol_info +=
- "http-get:*:video/mp4:DLNA.ORG_PN=AVC_MP4_BL_CIF15_AAC_520,";
-
- foreach (var protocol in protocols) {
- if (protocols[0] != protocol) {
- this.sink_protocol_info += ",";
- }
- var mime_types = this.player.get_mime_types ();
-
- foreach (var mime_type in mime_types) {
- if (mime_types[0] != mime_type) {
- this.sink_protocol_info += ",";
- }
-
- this.sink_protocol_info += protocol + ":*:" + mime_type + ":*";
- }
- }
+ this.sink_protocol_info = plugin.get_protocol_info ();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]