[banshee: 37/57] Added UPnPVideoSource
- From: Bertrand Lorentz <blorentz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee: 37/57] Added UPnPVideoSource
- Date: Mon, 13 Feb 2012 20:30:56 +0000 (UTC)
commit f53879c08ef2cd0f940da9521420d473210f6daf
Author: Tobias Arrskog <topfs2 xbmc org>
Date: Thu Jul 14 21:51:19 2011 +0200
Added UPnPVideoSource
.../Banshee.UPnPClient/Banshee.UPnPClient.csproj | 1 +
.../Banshee.UPnPClient/UPnPVideoSource.cs | 132 ++++++++++++++++++++
src/Extensions/Banshee.UPnPClient/Makefile.am | 1 +
3 files changed, 134 insertions(+), 0 deletions(-)
---
diff --git a/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient.csproj b/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient.csproj
index e13cfd1..cdd776c 100644
--- a/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient.csproj
+++ b/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient.csproj
@@ -84,6 +84,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Banshee.UPnPClient\UPnPMusicSource.cs" />
+ <Compile Include="Banshee.UPnPClient\UPnPVideoSource.cs" />
<Compile Include="Banshee.UPnPClient\UPnPServerSource.cs" />
<Compile Include="Banshee.UPnPClient\UPnPService.cs" />
<Compile Include="Banshee.UPnPClient\UPnPContainerSource.cs" />
diff --git a/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPVideoSource.cs b/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPVideoSource.cs
new file mode 100644
index 0000000..e2d4488
--- /dev/null
+++ b/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPVideoSource.cs
@@ -0,0 +1,132 @@
+//
+// UPnPClientSource.cs
+//
+// Authors:
+// Tobias 'topfs2' Arrskog <tobias arrskog gmail com>
+//
+// Copyright (C) 2011 Tobias 'topfs2' Arrskog
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+
+using Mono.Unix;
+using Mono.Addins;
+
+using Mono.Upnp;
+using Mono.Upnp.Dcp.MediaServer1.ContentDirectory1;
+using Mono.Upnp.Dcp.MediaServer1.ContentDirectory1.AV;
+
+using Hyena.Collections;
+
+using Banshee.Base;
+using Banshee.Sources;
+using Banshee.Sources.Gui;
+using Banshee.Collection.Database;
+using Banshee.ServiceStack;
+using Banshee.Preferences;
+using Banshee.MediaEngine;
+using Banshee.PlaybackController;
+
+namespace Banshee.UPnPClient
+{
+ public class UPnPVideoSource : PrimarySource
+ {
+ const int sort_order = 190;
+ private Dictionary<string, UPnPTrackInfo> video_tracks;
+
+ public UPnPVideoSource (string udn) : base (Catalog.GetString ("Video"), Catalog.GetString ("Video"), udn + "-video", sort_order)
+ {
+ Properties.SetStringList ("Icon.Name", "video-x-generic", "video", "source-library");
+ Properties.Set<string> ("SearchEntryDescription", Catalog.GetString ("Search your videos"));
+ Properties.SetString ("TrackView.ColumnControllerXml", String.Format (@"
+ <column-controller>
+ <add-all-defaults />
+ <remove-default column=""DiscColumn"" />
+ <remove-default column=""AlbumColumn"" />
+ <remove-default column=""ComposerColumn"" />
+ <remove-default column=""AlbumArtistColumn"" />
+ <remove-default column=""ConductorColumn"" />
+ <remove-default column=""ComposerColumn"" />
+ <remove-default column=""BpmColumn"" />
+ <sort-column direction=""asc"">track_title</sort-column>
+ <column modify-default=""ArtistColumn"">
+ <title>{0}</title>
+ <long-title>{0}</long-title>
+ </column>
+ </column-controller>
+ ", Catalog.GetString ("Produced By")));
+
+ video_tracks = new Dictionary<string, UPnPTrackInfo>();
+
+ // Remove tracks previously associated with this source, we do this to be sure they are non-existant before we refresh.
+ PurgeTracks();
+ AfterInitialized ();
+ OnTracksRemoved ();
+ }
+
+ ~UPnPVideoSource ()
+ {
+ Dispose ();
+ }
+
+ public override void Dispose ()
+ {
+ Disconnect ();
+ base.Dispose ();
+ }
+
+ public void Disconnect ()
+ {
+ // Stop currently playing track if its from us.
+ try {
+ if (ServiceManager.PlayerEngine.CurrentState == Banshee.MediaEngine.PlayerState.Playing) {
+ DatabaseTrackInfo track = ServiceManager.PlayerEngine.CurrentTrack as DatabaseTrackInfo;
+ if (track != null && track.PrimarySource == this) {
+ ServiceManager.PlayerEngine.Close ();
+ }
+ }
+ } catch {}
+
+ // Remove tracks associated with this source, we will refetch them on next connect
+ PurgeTracks();
+ }
+
+ public override bool CanDeleteTracks
+ {
+ get { return false; }
+ }
+
+ public void AddTracks (List<VideoItem> tracks)
+ {
+ foreach (var track in tracks) {
+ if (video_tracks.ContainsKey(track.Id))
+ continue;
+
+ UPnPTrackInfo track_info = new UPnPTrackInfo (track, this);
+ track_info.Save (false);
+ }
+
+ OnTracksAdded ();
+ }
+ }
+}
diff --git a/src/Extensions/Banshee.UPnPClient/Makefile.am b/src/Extensions/Banshee.UPnPClient/Makefile.am
index 2749aa8..2f529cf 100644
--- a/src/Extensions/Banshee.UPnPClient/Makefile.am
+++ b/src/Extensions/Banshee.UPnPClient/Makefile.am
@@ -8,6 +8,7 @@ SOURCES = \
Banshee.UPnPClient/UPnPService.cs \
Banshee.UPnPClient/UPnPServerSource.cs \
Banshee.UPnPClient/UPnPMusicSource.cs \
+ Banshee.UPnPClient/UPnPVideoSource.cs \
Banshee.UPnPClient/UPnPTrackInfo.cs
RESOURCES = Banshee.UPnPClient.addin.xml
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]