[banshee: 38/57] Hooked up video source in serversource. Added so both search and recursive browse finds and introduc



commit 62f3ad075a0f6d699da550f081e6fb3f321d4303
Author: Tobias Arrskog <topfs2 xbmc org>
Date:   Thu Jul 14 21:52:22 2011 +0200

    Hooked up video source in serversource. Added so both search and recursive browse finds and introduces videoitems to the video source

 .../Banshee.UPnPClient/UPnPServerSource.cs         |   32 ++++++++++++++++++--
 1 files changed, 29 insertions(+), 3 deletions(-)
---
diff --git a/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPServerSource.cs b/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPServerSource.cs
index 9871024..032c4d3 100644
--- a/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPServerSource.cs
+++ b/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPServerSource.cs
@@ -48,6 +48,7 @@ namespace Banshee.UPnPClient
     public class UPnPServerSource : Source
     {
         UPnPMusicSource music_source;
+        private UPnPVideoSource video_source;
         private SchemaEntry<bool> expanded_schema;
 
         public UPnPServerSource (Device device) :  base (Catalog.GetString ("UPnP Share"), device.FriendlyName, 300)
@@ -70,6 +71,9 @@ namespace Banshee.UPnPClient
             music_source = new UPnPMusicSource(device.Udn);
             AddChildSource (music_source);
 
+            video_source = new UPnPVideoSource(device.Udn);
+            AddChildSource (video_source);
+
             ThreadAssist.Spawn (delegate {
                 Parse (contentDirectory);
             });
@@ -116,6 +120,16 @@ namespace Banshee.UPnPClient
 
                                                             music_source.AddTracks (musicTracks);
                                                         });
+
+                    HandleResults<VideoItem>  (remoteContentDirectory.Search<VideoItem>(root, visitor => visitor.VisitDerivedFrom("upnp:class", "object.item.videoItem"), new ResultsSettings()),
+                                               remoteContentDirectory,
+                                               chunk => {
+                                                            List<VideoItem> videoTracks = new List<VideoItem>();
+                                                            foreach (var item in chunk)
+                                                                videoTracks.Add(item as VideoItem);
+
+                                                            video_source.AddTracks (videoTracks);
+                                                        });
                 } catch (Exception exception) {
                     Hyena.Log.Exception (exception);
                     recursiveBrowse = true;
@@ -125,9 +139,14 @@ namespace Banshee.UPnPClient
                 try {
                     Hyena.Log.Debug ("Not searchable, lets recursive browse");
                     List<MusicTrack> musicTracks = new List<MusicTrack>();
-                    ParseContainer (remoteContentDirectory, root, 0, musicTracks);
+                    List<VideoItem> videoTracks = new List<VideoItem>();
+
+                    ParseContainer (remoteContentDirectory, root, 0, musicTracks, videoTracks);
+
                     if (musicTracks.Count > 0)
                         music_source.AddTracks (musicTracks);
+                    if (videoTracks.Count > 0)
+                        video_source.AddTracks (videoTracks);
                 } catch (Exception exception) {
                     Hyena.Log.Exception (exception);
                 }
@@ -136,7 +155,7 @@ namespace Banshee.UPnPClient
             Hyena.Log.Debug ("Found all items on the service, took " + (DateTime.Now - begin).ToString());
         }
 
-        void ParseContainer (RemoteContentDirectory remoteContentDirectory, Container container, int depth, List<MusicTrack> musicTracks)
+        void ParseContainer (RemoteContentDirectory remoteContentDirectory, Container container, int depth, List<MusicTrack> musicTracks, List<VideoItem> videoTracks)
         {
             if (depth > 10 || (container.ChildCount != null && container.ChildCount == 0))
                 return;
@@ -154,16 +173,22 @@ namespace Banshee.UPnPClient
 
                                                             if (item is MusicTrack) {
                                                                 musicTracks.Add(item as MusicTrack);
+                                                            } else if (item is VideoItem) {
+                                                                videoTracks.Add(item as VideoItem);
                                                             }
                                                         }
                                                         else if (upnp_object is Container) {
-                                                            ParseContainer (remoteContentDirectory, upnp_object as Container, depth + 1, musicTracks);
+                                                            ParseContainer (remoteContentDirectory, upnp_object as Container, depth + 1, musicTracks, videoTracks);
                                                         }
 
                                                         if (musicTracks.Count > 500) {
                                                             music_source.AddTracks (musicTracks);
                                                             musicTracks.Clear();
                                                         }
+                                                        if (videoTracks.Count > 100) {
+                                                            video_source.AddTracks (videoTracks);
+                                                            videoTracks.Clear();
+                                                        }
                                                     }
                                                 });
         }
@@ -171,6 +196,7 @@ namespace Banshee.UPnPClient
         public void Disconnect ()
         {
             music_source.Disconnect ();
+            video_source.Disconnect ();
         }
 
         public override bool? AutoExpand {



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