diff options
author | Jens Georg <jensg@openismus.org> | 2012-08-30 13:36:20 +0200 |
---|---|---|
committer | Jens Georg <jensg@openismus.com> | 2012-10-05 17:33:27 +0200 |
commit | 2c34dd2aef3a7be82bd74611231130dfb85b4bc2 (patch) | |
tree | d41dede7fd51d9ea4cb09ba976158c5a2b1fd3d7 /src | |
parent | 020b7ec85d91baccf6ec7e953787bfa34fe95ecc (diff) | |
download | rygel-2c34dd2aef3a7be82bd74611231130dfb85b4bc2.tar.gz |
core: Move DLNA profile lookup to MediaEngine
Diffstat (limited to 'src')
-rw-r--r-- | src/librygel-server/filelist.am | 6 | ||||
-rw-r--r-- | src/librygel-server/rygel-gst-media-engine.vala | 43 | ||||
-rw-r--r-- | src/librygel-server/rygel-item-creator.vala | 23 | ||||
-rw-r--r-- | src/librygel-server/rygel-media-engine.vala | 73 | ||||
-rw-r--r-- | src/librygel-server/rygel-source-connection-manager.vala | 13 | ||||
-rw-r--r-- | src/plugins/tracker/rygel-tracker-item-factory.vala | 1 |
6 files changed, 137 insertions, 22 deletions
diff --git a/src/librygel-server/filelist.am b/src/librygel-server/filelist.am index 7e01d856..9bea5f83 100644 --- a/src/librygel-server/filelist.am +++ b/src/librygel-server/filelist.am @@ -20,7 +20,8 @@ LIBRYGEL_SERVER_VAPI_SOURCE_FILES = \ rygel-searchable-container.vala \ rygel-visual-item.vala \ rygel-writable-container.vala \ - rygel-media-server.vala + rygel-media-server.vala \ + rygel-media-engine.vala LIBRYGEL_SERVER_NONVAPI_SOURCE_FILES = \ rygel-aac-transcoder.vala \ @@ -66,7 +67,8 @@ LIBRYGEL_SERVER_NONVAPI_SOURCE_FILES = \ rygel-wmp-hacks.vala \ rygel-wmv-transcoder.vala \ rygel-xbmc-hacks.vala \ - rygel-xbox-hacks.vala + rygel-xbox-hacks.vala \ + rygel-gst-media-engine.vala LIBRYGEL_SERVER_VALAFLAGS_PKG = \ --pkg gstreamer-0.10 \ diff --git a/src/librygel-server/rygel-gst-media-engine.vala b/src/librygel-server/rygel-gst-media-engine.vala new file mode 100644 index 00000000..e8de758c --- /dev/null +++ b/src/librygel-server/rygel-gst-media-engine.vala @@ -0,0 +1,43 @@ +/* + * 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. + */ + +using Gst; + +internal class Rygel.GstMediaEngine : Rygel.MediaEngine { + private GLib.List<DLNAProfile> dlna_profiles = null; + + public GstMediaEngine () { + var discoverer = new GUPnP.DLNADiscoverer ((ClockTime) SECOND, + true, + false); + foreach (var profile in discoverer.list_profiles ()) { + var p = new DLNAProfile (profile.mime, profile.name); + this.dlna_profiles.prepend (p); + } + + this.dlna_profiles.reverse (); + } + + public override unowned GLib.List<DLNAProfile> get_dlna_profiles () { + return this.dlna_profiles; + } +} diff --git a/src/librygel-server/rygel-item-creator.vala b/src/librygel-server/rygel-item-creator.vala index 65183a92..1f5dd705 100644 --- a/src/librygel-server/rygel-item-creator.vala +++ b/src/librygel-server/rygel-item-creator.vala @@ -1,7 +1,9 @@ /* - * Copyright (C) 2010 Nokia Corporation. + * Copyright (C) 2010-2011 Nokia Corporation. + * Copyright (C) 2012 Intel Corporation. * * Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org> + * Jens Georg <jensg@openismus.com> * * This file is part of Rygel. * @@ -21,7 +23,6 @@ */ using GUPnP; -using Gst; /** * CreateObject action implementation. @@ -593,26 +594,20 @@ internal class Rygel.ItemCreator: GLib.Object, Rygel.StateMachine { /** * Check if the profile is supported. * - * The check is performed against GUPnP-DLNA's database explicitly excluding + * The check is performed against the MediaEngine's database explicitly excluding * the transcoders. * * @param profile to check * @returns true if the profile is supported, false otherwise. */ private bool is_profile_valid (string profile) { - var discoverer = new GUPnP.DLNADiscoverer ((ClockTime) SECOND, - true, - false); + unowned GLib.List<DLNAProfile> profiles, result; - var valid = false; - foreach (var known_profile in discoverer.list_profiles ()) { - if (known_profile.name == profile) { - valid = true; + profiles = MediaEngine.get_default ().get_dlna_profiles (); + var p = new DLNAProfile (profile, ""); - break; - } - } + result = profiles.find_custom (p, DLNAProfile.compare_by_name); - return valid; + return result != null; } } diff --git a/src/librygel-server/rygel-media-engine.vala b/src/librygel-server/rygel-media-engine.vala new file mode 100644 index 00000000..79fbacf5 --- /dev/null +++ b/src/librygel-server/rygel-media-engine.vala @@ -0,0 +1,73 @@ +/* + * 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.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); + } +} + +/** + * Base class for the media engine that will contain knowledge about streaming + * and transcoding capabilites of the media library in use. + */ +public abstract class Rygel.MediaEngine : GLib.Object { + private static MediaEngine instance; + + /** + * Get the singleton instance of the currently used media engine. + * + * @return An instance of a concreate #MediaEngine implementation. + */ + public static MediaEngine get_default () { + if (instance == null) { + instance = new GstMediaEngine (); + } + + return instance; + } + + /** + * Get a list of the DLNA profiles that are supported by this media + * engine. + * + * @return A list of #DLNAProfile<!-- -->s + */ + public abstract unowned List<DLNAProfile> get_dlna_profiles (); +} diff --git a/src/librygel-server/rygel-source-connection-manager.vala b/src/librygel-server/rygel-source-connection-manager.vala index 9903c6ff..77031bd1 100644 --- a/src/librygel-server/rygel-source-connection-manager.vala +++ b/src/librygel-server/rygel-source-connection-manager.vala @@ -1,8 +1,10 @@ /* - * Copyright (C) 2009 Nokia Corporation. + * Copyright (C) 2012 Intel Corporation. + * Copyright (C) 2009-2011 Nokia Corporation. * Copyright (C) 2008 Zeeshan Ali (Khattak) <zeeshanak@gnome.org>. * * Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org> + * Jens Georg <jensg@openismus.com> * * This file is part of Rygel. * @@ -22,7 +24,6 @@ */ using GUPnP; -using Gst; using Gee; /** @@ -50,12 +51,12 @@ internal class Rygel.SourceConnectionManager : Rygel.ConnectionManager { var server = this.get_http_server (); var protocol_infos = server.get_protocol_info (); - var discoverer = new GUPnP.DLNADiscoverer ((ClockTime) SECOND, - true, - false); + unowned GLib.List<DLNAProfile> profiles = MediaEngine.get_default (). + get_dlna_profiles (); + var protocol = server.get_protocol (); - foreach (var profile in discoverer.list_profiles ()) { + foreach (var profile in profiles) { var protocol_info = new ProtocolInfo (); protocol_info.protocol = protocol; diff --git a/src/plugins/tracker/rygel-tracker-item-factory.vala b/src/plugins/tracker/rygel-tracker-item-factory.vala index a91ca6f8..8ee28a32 100644 --- a/src/plugins/tracker/rygel-tracker-item-factory.vala +++ b/src/plugins/tracker/rygel-tracker-item-factory.vala @@ -2,6 +2,7 @@ * Copyright (C) 2008 Zeeshan Ali <zeenix@gmail.com>. * Copyright (C) 2008-2012 Nokia Corporation. * Copyright (C) 2010 MediaNet Inh. + * Copyright (C) 2012 Intel Corporation. * * Authors: Zeeshan Ali <zeenix@gmail.com> * Sunil Mohan Adapa <sunil@medhas.org> |