[longomatch] Export the principal camera for the event



commit 6cee0d3c175eadc684352d043942760a93aed1b9
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Thu Mar 19 15:52:41 2015 +0100

    Export the principal camera for the event

 .../Services/RenderingJobsManager.cs               |   18 ++++++++--
 Tests/Services/TestRenderingJobsManager.cs         |   38 +++++++++++++++++---
 2 files changed, 48 insertions(+), 8 deletions(-)
---
diff --git a/LongoMatch.Services/Services/RenderingJobsManager.cs 
b/LongoMatch.Services/Services/RenderingJobsManager.cs
index f3ab696..2cc3456 100644
--- a/LongoMatch.Services/Services/RenderingJobsManager.cs
+++ b/LongoMatch.Services/Services/RenderingJobsManager.cs
@@ -244,14 +244,26 @@ namespace LongoMatch.Services
                        TimelineEvent play;
                        MediaFile file;
                        IEnumerable<FrameDrawing> drawings;
+                       int cameraIndex;
 
                        play = element.Play;
                        Log.Debug (String.Format ("Adding segment with {0} drawings", play.Drawings.Count));
                        
                        lastTS = play.Start;
-                       /* FIXME: for now we only support rendering the first angle in the list */
-                       file = element.FileSet.FirstOrDefault ();
-                       drawings = play.Drawings.Where (d => d.Angle == element.Angles.FirstOrDefault ());
+                       if (element.CamerasVisible.Count == 0) {
+                               cameraIndex = 0;
+                       } else {
+                               cameraIndex = element.CamerasVisible [0];
+                       }
+                       if (cameraIndex >= element.FileSet.Count) {
+                               Log.Error (string.Format ("Camera index={0} not matching for current fileset 
count={1}",
+                                       cameraIndex, element.FileSet.Count));
+                               file = element.FileSet [0];
+                       } else {
+                               file = element.FileSet [cameraIndex];
+                       }
+                       drawings = play.Drawings.Where (d => d.CameraIndex == cameraIndex);
+
                        if (file == null || drawings == null) {
                                return false;
                        }
diff --git a/Tests/Services/TestRenderingJobsManager.cs b/Tests/Services/TestRenderingJobsManager.cs
index 4a52ac2..0074028 100644
--- a/Tests/Services/TestRenderingJobsManager.cs
+++ b/Tests/Services/TestRenderingJobsManager.cs
@@ -24,6 +24,7 @@ using LongoMatch.Core.Interfaces.Multimedia;
 using LongoMatch.Core.Store;
 using LongoMatch.Core.Store.Playlists;
 using LongoMatch.Services;
+using System.Collections.Generic;
 
 namespace Tests.Services
 {
@@ -31,12 +32,14 @@ namespace Tests.Services
        public class TestRenderingJobsManager
        {
                [Test ()]
-               public void TestMediaFileUsage ()
+               public void TestRenderedCamera ()
                {
                        Project p = Utils.CreateProject ();
 
                        try {
-                               PlaylistPlayElement element = new PlaylistPlayElement (p.Timeline [0], 
p.Description.FileSet);
+                               TimelineEvent evt = p.Timeline [0];
+                               evt.CamerasVisible = new List<int> { 0 };
+                               PlaylistPlayElement element = new PlaylistPlayElement (evt, 
p.Description.FileSet);
 
                                // Playlist with one event
                                var playlist = new Playlist ();
@@ -61,10 +64,35 @@ namespace Tests.Services
                                renderer.AddJob (job);
 
                                // Check that AddSegment is called with the right video file.
-                               var mock = Mock.Get<IVideoEditor> (mtk.GetVideoEditor ());
-                               mock.Verify (m => m.AddSegment (It.Is<string> (f => f == 
p.Description.FileSet [0].FilePath),
-                                       It.IsAny<long> (), It.IsAny<long> (), It.IsAny<double> (), 
It.IsAny<string> (), It.IsAny<bool> ()));
+                               Mock<IVideoEditor> mock = Mock.Get<IVideoEditor> (mtk.GetVideoEditor ());
+                               mock.Verify (m => m.AddSegment (p.Description.FileSet [0].FilePath,
+                                       evt.Start.MSeconds, evt.Stop.MSeconds, evt.Rate, evt.Name, true), 
Times.Once ()); 
 
+                               /* Test with a camera index bigger than the total cameras */
+                               mtk = Mock.Of<IMultimediaToolkit> (m => m.GetVideoEditor () == 
Mock.Of<IVideoEditor> ());
+                               renderer = new RenderingJobsManager (mtk, gtk);
+                               mock = Mock.Get<IVideoEditor> (mtk.GetVideoEditor ());
+                               evt = p.Timeline [1];
+                               evt.CamerasVisible = new List<int> { 1 };
+                               element = new PlaylistPlayElement (evt, p.Description.FileSet);
+                               playlist.Elements [0] = element; 
+                               job = new EditionJob (playlist, settings);
+                               renderer.AddJob (job);
+                               mock.Verify (m => m.AddSegment (p.Description.FileSet [1].FilePath,
+                                       evt.Start.MSeconds, evt.Stop.MSeconds, evt.Rate, evt.Name, true), 
Times.Once ()); 
+
+                               /* Test with the secondary camera */
+                               mtk = Mock.Of<IMultimediaToolkit> (m => m.GetVideoEditor () == 
Mock.Of<IVideoEditor> ());
+                               renderer = new RenderingJobsManager (mtk, gtk);
+                               mock = Mock.Get<IVideoEditor> (mtk.GetVideoEditor ());
+                               evt = p.Timeline [1];
+                               evt.CamerasVisible = new List<int> { 2 };
+                               element = new PlaylistPlayElement (evt, p.Description.FileSet);
+                               playlist.Elements [0] = element; 
+                               job = new EditionJob (playlist, settings);
+                               renderer.AddJob (job);
+                               mock.Verify (m => m.AddSegment (p.Description.FileSet [0].FilePath,
+                                       evt.Start.MSeconds, evt.Stop.MSeconds, evt.Rate, evt.Name, true), 
Times.Once ()); 
                        } finally {
                                Utils.DeleteProject (p);
                        }


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