Exemple #1
0
        void PreparePlayer(bool readyToSeek = true)
        {
            var player = new VideoPlayerController();

            player.SetViewModel(videoPlayer);
            var mfs = new MediaFileSet();

            mfs.Add(new MediaFile {
                FilePath    = "test1",
                VideoWidth  = 320,
                VideoHeight = 240,
                Par         = 1,
                Duration    = new Time {
                    TotalSeconds = 5000
                }
            });
            player.CamerasConfig = new RangeObservableCollection <CameraConfig> {
                new CameraConfig(0),
                new CameraConfig(1)
            };
            Mock <IViewPort> viewPortMock = new Mock <IViewPort> ();

            viewPortMock.SetupAllProperties();
            player.ViewPorts = new List <IViewPort> {
                viewPortMock.Object, viewPortMock.Object
            };
            player.Ready(true);
            player.Open(mfs);
        }
Exemple #2
0
 void EmitMediaFileSetLoaded(MediaFileSet fileSet, List <CameraConfig> camerasVisible)
 {
     if (MediaFileSetLoadedEvent != null && !disposed)
     {
         MediaFileSetLoadedEvent(fileSet, camerasConfig);
     }
 }
Exemple #3
0
        protected virtual async void HandleSelectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            TViewModel selectedVM = ViewModel.Selection.FirstOrDefault();

            if (selectedVM != null)
            {
                if (ViewModel.LoadedProject?.Model != null && ViewModel.LoadedProject.Edited)
                {
                    await Save(ViewModel.LoadedProject, false);
                }

                // Load the model, creating a copy to edit changes in a different viewmodel in case the user
                // does not want to save them.
                ViewModel.LoadedProject = new TViewModel {
                    Model = selectedVM.Model, Stateful = true
                };
                originalMediaFileSet = ViewModel.LoadedProject.FileSet.Model.Clone();
                ViewModel.LoadedProject.IsChanged = false;
            }

            //Update commands
            ViewModel.ExportCommand.EmitCanExecuteChanged();
            ViewModel.SaveCommand.EmitCanExecuteChanged();
            ViewModel.OpenCommand.EmitCanExecuteChanged();
            ViewModel.DeleteCommand.EmitCanExecuteChanged();
        }
Exemple #4
0
        protected override int OnStart(StudyLoaderArgs studyLoaderArgs)
        {
            _sops = null;
            MediaFileSet server = studyLoaderArgs.Server as MediaFileSet;

            if (server != null)
            {
                _sops = new Queue <SopInstance>();
                foreach (var study in server.Studies)
                {
                    if (studyLoaderArgs.StudyInstanceUid != study.StudyInstanceUid)
                    {
                        continue;
                    }

                    foreach (var series in study.Series)
                    {
                        foreach (var sop in series.Sops)
                        {
                            _sops.Enqueue(sop);
                        }
                    }
                }

                return(_sops.Count);
            }

            return(0);
        }
        public void FixtureSetup()
        {
            mfs = new MediaFileSet ();
            mfs.Add (new MediaFile { FilePath = "test1", VideoWidth = 320, VideoHeight = 240, Par = 1 });
            mfs.Add (new MediaFile { FilePath = "test2", VideoWidth = 320, VideoHeight = 240, Par = 1 });

            mockAnalysisWindow = new Mock<IAnalysisWindowBase> ();
            mockPlayerController = new Mock<IPlayerController> ();
            mockPlayerController.SetupAllProperties ();
            mockPlayerController.SetupGet (x => x.CurrentTime).Returns (new Time (1000));
            MediaFileSet mf = new MediaFileSet ();
            mf.Add (new MediaFile ("path", 34000, 25, true, true, "mp4", "h264",
                "aac", 320, 240, 1.3, null, "Test asset"));
            mockPlayerController.SetupGet (m => m.FileSet).Returns (mf);
            mockAnalysisWindow.SetupGet (m => m.Player).Returns (mockPlayerController.Object);
            mockVideoRenderer = new Mock<IJobsManager> ();
            mockDiaklogs = new Mock<IDialogs> ();

            playerMock = new Mock<IPlayer> ();
            playerMock.SetupAllProperties ();
            Mock<IMultiPlayer> multiplayerMock = new Mock<IMultiPlayer> ();

            multimediaToolkitMock = new Mock<IMultimediaToolkit> ();
            multimediaToolkitMock.Setup (m => m.GetPlayer ()).Returns (playerMock.Object);
            App.Current.MultimediaToolkit = multimediaToolkitMock.Object;

            App.Current.LowerRate = 1;
            App.Current.UpperRate = 30;
            App.Current.RatePageIncrement = 3;
            App.Current.RateList = new List<double> { 0.04, 0.08, 0.12, 0.16, 0.20, 0.24, 0.28, 0.32, 0.36, 0.40, 0.44,
                    0.48, 0.52, 0.56, 0.60, 0.64, 0.68, 0.72, 0.76, 0.80, 0.84, 0.88, 0.92, 0.96, 1, 2, 3, 4, 5
                };
            App.Current.DefaultRate = 25;
        }
Exemple #6
0
 public void Load(MediaFileSet fileSet)
 {
     ClearObjects();
     this.fileSet = fileSet;
     FillCanvas();
     widget.ReDraw();
 }
Exemple #7
0
        public void TestNotEquals()
        {
            MediaFileSet mf  = new MediaFileSet();
            MediaFileSet mf2 = new MediaFileSet();

            Assert.IsFalse(mf.Equals(mf2));
        }
Exemple #8
0
        public async Task Replace_FileNotContained_Added()
        {
            dialogMock.Setup(d => d.OpenMediaFile(It.IsAny <object> ())).Returns(new MediaFile {
                FilePath = "new"
            });

            MediaFileSet   fileSet   = new MediaFileSet();
            MediaFileSetVM fileSetVM = new MediaFileSetVM {
                Model = fileSet
            };

            fileSet.Add(new MediaFile {
                FilePath = "old"
            });

            MediaFileVM newFileVM = await App.Current.EventsBroker.PublishWithReturn <ReplaceMediaFileEvent, MediaFileVM> (new ReplaceMediaFileEvent {
                OldFileSet = fileSetVM,
                OldFile    = new MediaFileVM {
                    Model = new MediaFile {
                        FilePath = "not contained"
                    }
                },
            });

            Assert.IsNotNull(newFileVM);
            Assert.IsNotNull(newFileVM.Model);
            Assert.AreEqual("new", newFileVM.FilePath);
            Assert.AreEqual("new", newFileVM.Model.FilePath);
            Assert.AreEqual(2, fileSetVM.Count());
        }
Exemple #9
0
        public void TestCheckFilesPathNotFixed()
        {
            // Arrange file with wrong path
            string path             = Path.GetTempFileName();
            string wrongDir         = "other-non-existing-path";
            string wrongFullPath    = Path.Combine(wrongDir, Path.GetFileName(path));
            string originalFullPath = Path.Combine("non-existing-path", Path.GetFileName(path));

            MediaFileSet mf = new MediaFileSet();

            mf.Add(new MediaFile {
                FilePath = originalFullPath,
                Name     = "Test asset"
            });
            try {
                // Act
                bool ret = mf.CheckFiles(wrongDir);

                // Assert path is not fixed
                Assert.IsFalse(ret);
                Assert.AreNotEqual(wrongFullPath, mf.First().FilePath);
                Assert.AreEqual(originalFullPath, mf.First().FilePath);
            } finally {
                File.Delete(path);
            }
        }
 public void Load(MediaFileSet fileSet)
 {
     ClearObjects ();
     this.fileSet = fileSet;
     FillCanvas ();
     widget?.ReDraw ();
 }
Exemple #11
0
        void HandleSelectedCameraChanged(object sender, EventArgs args)
        {
            CameraObject camera = camerasTimeline.SelectedCamera;

            if (camera != null)
            {
                // Check if we need to reopen the player
                if (!sec_cam_playerbin.Player.Opened ||
                    sec_cam_playerbin.Player.FileSet.FirstOrDefault() != camera.MediaFile)
                {
                    MediaFileSet fileSet = new MediaFileSet();
                    fileSet.Add(camera.MediaFile);

                    sec_cam_playerbin.Player.Open(fileSet);

                    // Configure audio
                    HandleAudioToggled(sec_cam_audio_button, new EventArgs());
                }
                // And update
                HandleCameraUpdate(camera);
            }
            else
            {
                // When no camera is selected show the initial didactic message.
                ShowDidactic(DidacticMessage.Initial);
            }
        }
Exemple #12
0
        public void TestEquals()
        {
            MediaFileSet mf  = new MediaFileSet();
            MediaFileSet mf2 = new MediaFileSet();

            mf2.ID = mf.ID;

            Assert.IsTrue(mf.Equals(mf2));
        }
 public PlaylistPlayElement(TimelineEvent play, MediaFileSet fileset = null)
 {
     Play = play;
     Title = play.Name;
     Rate = play.Rate;
     CamerasLayout = play.CamerasLayout;
     CamerasConfig = play.CamerasConfig.Clone ();
     FileSet = fileset;
 }
Exemple #14
0
 public PlaylistPlayElement(TimelineEvent play, MediaFileSet fileset = null)
 {
     Play          = play;
     Title         = play.Name;
     Rate          = play.Rate;
     CamerasLayout = play.CamerasLayout;
     CamerasConfig = play.CamerasConfig.Clone();
     FileSet       = fileset;
 }
Exemple #15
0
        /// <summary>
        /// Adjusts the VPaned position to accomodate up to 8 cameras.
        /// </summary>
        /// <param name="fileSet">File set.</param>
        void UpdateTimeLineSize(MediaFileSet fileSet)
        {
            // Number of media files plus period sync line
            int visibleItems = Math.Min(StyleConf.TimelineCameraMaxLines, fileSet.Count + 1);
            int height       = scrolledwindow2.HScrollbar.Requisition.Height * 2;

            height          += visibleItems * StyleConf.TimelineCameraHeight;
            vpaned2.Position = vpaned2.Allocation.Height - height;
        }
Exemple #16
0
 public void TestDuration()
 {
     MediaFileSet mf = new MediaFileSet ();
     Assert.AreEqual (mf.Duration.MSeconds, 0);
     mf.Add (new MediaFile {Duration = new Time (2000), Name = "Test asset"});
     Assert.AreEqual (mf.Duration.MSeconds, 2000);
     mf.Replace ("Test asset", new MediaFile {Duration = new Time (2001), Name = "Test asset 2"});
     Assert.AreEqual (mf.Duration.MSeconds, 2001);
 }
Exemple #17
0
        public void TestSerialization()
        {
            MediaFileSet mf = new MediaFileSet();

            mf.Add(new MediaFile("path", 34000, 25, true, true, "mp4", "h264",
                                 "aac", 320, 240, 1.3, null, "Test asset"));
            mf.Add(new MediaFile("path", 34000, 25, true, true, "mp4", "h264",
                                 "aac", 320, 240, 1.3, null, "Test asset 2"));
            Utils.CheckSerialization(mf);
        }
Exemple #18
0
        public void TestVisibleRegionRemainsIsNullAfterClear()
        {
            MediaFileSet mfs = new MediaFileSet();

            Assert.IsNull(mfs.VisibleRegion);

            mfs.Clear();

            Assert.IsNull(mfs.VisibleRegion);
        }
Exemple #19
0
        public void TestPreview()
        {
            MediaFileSet mf = new MediaFileSet();

            Assert.IsNull(mf.Preview);
            mf.Add(new MediaFile {
                Preview = Utils.LoadImageFromFile(), Name = "Test asset"
            });
            Assert.IsNotNull(mf.Preview);
        }
Exemple #20
0
        /// <summary>
        /// Open the specified file set.
        /// </summary>
        /// <param name="fileSet">the files to open.</param>
        /// <param name="seek">If set to <c>true</c>, seeks to the beginning of the stream.</param>
        /// <param name="force">If set to <c>true</c>, opens the fileset even if it was already set.</param>
        /// <param name="play">If set to <c>true</c>, sets the player to play.</param>
        /// <param name="defaultFile">If set to <c>true</c>, store this as the default file set to use.</param>
        void InternalOpen(MediaFileSet fileSet, bool seek, bool force = false, bool play = false, bool defaultFile = false)
        {
            Reset();
            // This event gives a chance to the view to define camera visibility.
            // As there might already be a configuration defined (loading an event for example), the view
            // should adapt if needed.
            skipApplyCamerasConfig = true;
            EmitMediaFileSetLoaded(fileSet, camerasConfig);
            skipApplyCamerasConfig = false;

            if (defaultFile)
            {
                defaultFileSet = fileSet;
            }

            if (fileSet != FileSet || force)
            {
                readyToSeek = false;
                FileSet     = fileSet;
                // Check if the view failed to configure a proper cam config
                if (CamerasConfig == null)
                {
                    Config.EventsBroker.EmitMultimediaError(this,
                                                            Catalog.GetString("Invalid camera configuration"));
                    FileSet = null;
                    return;
                }
                // Validate Cam config against fileset
                ValidateVisibleCameras();
                UpdatePar();
                try {
                    Log.Debug("Opening new file set " + fileSet);
                    if (multiPlayer != null)
                    {
                        multiPlayer.Open(fileSet);
                    }
                    else
                    {
                        player.Open(fileSet [0]);
                    }
                    EmitTimeChanged(new Time(0), player.StreamLength);
                } catch (Exception ex) {
                    Log.Exception(ex);
                    //We handle this error async
                }
            }
            if (seek)
            {
                Seek(new Time(0), true);
            }
            if (play)
            {
                player.Play();
            }
        }
Exemple #21
0
 public void TestCheckFiles()
 {
     string path = Path.GetTempFileName ();
     MediaFileSet mf = new MediaFileSet ();
     Assert.IsFalse (mf.CheckFiles());
     mf.Add (new MediaFile {FilePath = path, Name = "Test asset"});
     try {
         Assert.IsTrue (mf.CheckFiles ());
     } finally {
         File.Delete (path);
     }
 }
Exemple #22
0
        void LoadVideo(PlaylistVideo video)
        {
            loadedPlaylistElement = video;
            MediaFileSet fileSet = new MediaFileSet();

            fileSet.Add(video.File);
            EmitLoadDrawings(null);
            UpdateCamerasConfig(new List <CameraConfig> {
                new CameraConfig(0)
            }, null);
            InternalOpen(fileSet, false, true, true);
        }
Exemple #23
0
 public FramesSeriesCapturer(MediaFileSet fileSet, TimelineEvent evt, uint interval, string outputDir)
 {
     this.capturer    = App.Current.MultimediaToolkit.GetFramesCapturer();
     this.fileSet     = fileSet;
     this.evt         = evt;
     this.start       = evt.Start;
     this.stop        = evt.Stop;
     this.interval    = interval;
     this.outputDir   = outputDir;
     this.seriesName  = System.IO.Path.GetFileName(outputDir);
     this.totalFrames = ((int)Math.Floor((double)((stop - start).MSeconds / interval)) + 1) * evt.CamerasConfig.Count;
     this.cancel      = false;
 }
Exemple #24
0
        public bool TryRead(string filename, out MediaFileSet mediaFileSet)
        {
            try
            {
                mediaFileSet = Read(filename);
            }
            catch (Exception)
            {
                mediaFileSet = null;
            }

            return(mediaFileSet != null);
        }
Exemple #25
0
        public void TestVisibleRegionSetAfterAddingFirstElement()
        {
            MediaFileSet mfs = new MediaFileSet();

            mfs.Add(new MediaFile {
                FilePath = "/videos/test.mp4",
                Duration = new Time(5000),
            });

            Assert.IsNotNull(mfs.VisibleRegion);
            Assert.AreEqual(new Time(0), mfs.VisibleRegion.Start);
            Assert.AreEqual(new Time(5000), mfs.VisibleRegion.Stop);
        }
Exemple #26
0
        public void TestChangingStopDoesNotChangeDuration()
        {
            MediaFileSet mfs = new MediaFileSet();

            mfs.Add(new MediaFile {
                FilePath = "/videos/test.mp4",
                Duration = new Time(20000),
            });
            mfs.VisibleRegion.Stop.MSeconds += 100;

            Assert.AreEqual(new Time(20000), mfs.Duration);
            Assert.IsFalse(mfs.VisibleRegion.Stop == mfs.Duration);
        }
Exemple #27
0
 public FramesSeriesCapturer(MediaFileSet fileSet, TimelineEvent evt, uint interval, string outputDir)
 {
     this.capturer = Config.MultimediaToolkit.GetFramesCapturer ();
     this.fileSet = fileSet;
     this.evt = evt;
     this.start = evt.Start;
     this.stop = evt.Stop;
     this.interval = interval;
     this.outputDir = outputDir;
     this.seriesName = System.IO.Path.GetFileName (outputDir);
     this.totalFrames = ((int)Math.Floor ((double)((stop - start).MSeconds / interval)) + 1) * evt.CamerasConfig.Count;
     this.cancel = false;
 }
        void LoadBackgroundPlayer(MediaFileSet file)
        {
            if (backLoaded)
            {
                return;
            }

            /* The output video file is now created, it's time to
             * load it in the player */
            Player.Open(file);
            Log.Debug("Loading encoded file in the backround player");
            backLoaded = true;
        }
Exemple #29
0
        public void TestClone_CloneIgnore_Dashboard()
        {
            var mediaFileSet = new MediaFileSet();

            mediaFileSet.DocumentID = "1234567890";
            mediaFileSet.ParentID   = Guid.NewGuid();
            mediaFileSet.IsChanged  = true;
            var mediaFileSet2 = mediaFileSet.Clone();

            Assert.AreEqual(mediaFileSet.DocumentID, mediaFileSet2.DocumentID);
            Assert.AreEqual(mediaFileSet.ParentID, mediaFileSet2.ParentID);
            Assert.IsTrue(mediaFileSet2.IsChanged);
        }
Exemple #30
0
 public void Setup()
 {
     model = new MediaFileSet {
         IsStretched = false,
     };
     model.Add(new MediaFile {
         FilePath = "/videos/test.mp4",
         Duration = new Time(20000),
     });
     viewModel = new MediaFileSetVM {
         Model = model,
     };
 }
Exemple #31
0
        public void Load(List <Period> periods, MediaFileSet fileSet, Time duration)
        {
            timelines = new List <TimelineObject> ();
            // Store periods as a list of timers
            this.timers = periods.Select(p => p as Timer).ToList();
            // And the file set
            this.fileSet  = fileSet;
            this.duration = duration;

            ClearObjects();
            FillCanvas();
            widget.ReDraw();
        }
Exemple #32
0
            public LocalStudy(DirectoryRecordSequenceItem item, MediaFileSet parentMediaFileSet, string dirName)
                : base(GetUID(item), parentMediaFileSet)
            {
                foreach (var subItem in item.LowerLevelDirectoryRecordCollection)
                {
                    if (subItem.DirectoryRecordType != DirectoryRecordType.Series)
                    {
                        continue;
                    }

                    Series.Add(new LocalSeries(subItem, this, dirName));
                }
            }
Exemple #33
0
        public void TestOrderReplace()
        {
            MediaFileSet mf = new MediaFileSet();

            mf.Add(new MediaFile("path1", 34000, 25, true, true, "mp4", "h264",
                                 "aac", 320, 240, 1.3, null, "Test asset")
            {
                Offset = new Time(1)
            });
            mf.Add(new MediaFile("path2", 34000, 25, true, true, "mp4", "h264",
                                 "aac", 320, 240, 1.3, null, "Test asset 2")
            {
                Offset = new Time(2)
            });
            mf.Add(new MediaFile("path3", 34000, 25, true, true, "mp4", "h264",
                                 "aac", 320, 240, 1.3, null, "Test asset 3")
            {
                Offset = new Time(3)
            });

            Assert.AreEqual(3, mf.Count);
            Assert.AreEqual("path1", mf [0].FilePath);
            Assert.AreEqual("path2", mf [1].FilePath);
            Assert.AreEqual("path3", mf [2].FilePath);

            mf.Replace("Test asset 2", new MediaFile("path4", 34000, 25, true, true, "mp4", "h264",
                                                     "aac", 320, 240, 1.3, null, "Test asset 4")
            {
                Offset = new Time(4)
            });

            Assert.AreEqual(3, mf.Count);
            Assert.AreEqual("path1", mf [0].FilePath);
            Assert.AreEqual("path4", mf [1].FilePath);
            Assert.AreEqual("Test asset 2", mf [1].Name);
            Assert.AreEqual(new Time(2), mf [1].Offset);
            Assert.AreEqual("path3", mf [2].FilePath);

            mf.Replace(mf [1], new MediaFile("path5", 34000, 25, true, true, "mp4", "h264",
                                             "aac", 320, 240, 1.3, null, "Test asset 5")
            {
                Offset = new Time(5)
            });

            Assert.AreEqual(3, mf.Count);
            Assert.AreEqual("path1", mf [0].FilePath);
            Assert.AreEqual("path5", mf [1].FilePath);
            Assert.AreEqual("Test asset 2", mf [1].Name);
            Assert.AreEqual(new Time(2), mf [1].Offset);
            Assert.AreEqual("path3", mf [2].FilePath);
        }
Exemple #34
0
        public void TestDuration()
        {
            MediaFileSet mf = new MediaFileSet();

            Assert.AreEqual(mf.Duration.MSeconds, 0);
            mf.Add(new MediaFile {
                Duration = new Time(2000), Name = "Test asset"
            });
            Assert.AreEqual(mf.Duration.MSeconds, 2000);
            mf.Replace("Test asset", new MediaFile {
                Duration = new Time(2001), Name = "Test asset 2"
            });
            Assert.AreEqual(mf.Duration.MSeconds, 2001);
        }
Exemple #35
0
        /// <summary>
        /// Loads a video segment defined by a <see cref="TimelineEvent"/> in the player.
        /// </summary>
        /// <param name="fileSet">File set.</param>
        /// <param name="start">Start time.</param>
        /// <param name="stop">Stop time.</param>
        /// <param name="seekTime">Position to seek after loading the segment.</param>
        /// <param name="rate">Playback rate.</param>
        /// <param name="camerasConfig">Cameras configuration.</param>
        /// <param name="camerasLayout">Cameras layout.</param>
        /// <param name="playing">If set to <c>true</c> starts playing.</param>
        void LoadSegment(MediaFileSet fileSet, Time start, Time stop, Time seekTime,
                         float rate, List <CameraConfig> camerasConfig, object camerasLayout,
                         bool playing)
        {
            Log.Debug(String.Format("Update player segment {0} {1} {2}",
                                    start, stop, rate));

            if (!SegmentLoaded)
            {
                defaultCamerasConfig = CamerasConfig;
                defaultCamerasLayout = CamerasLayout;
            }

            UpdateCamerasConfig(camerasConfig, camerasLayout);

            if (fileSet != this.FileSet)
            {
                InternalOpen(fileSet, false);
            }
            else
            {
                ApplyCamerasConfig();
            }

            Pause();
            loadedSegment.Start = start;
            loadedSegment.Stop  = stop;
            StillImageLoaded    = false;
            if (readyToSeek)
            {
                Log.Debug("Player is ready to seek, seeking to " +
                          seekTime.ToMSecondsString());
                SetRate(rate);
                Seek(seekTime, true);
                if (playing)
                {
                    Play();
                }
            }
            else
            {
                Log.Debug("Delaying seek until player is ready");
                pendingSeek = new PendingSeek {
                    time     = seekTime,
                    rate     = 1.0f,
                    playing  = playing,
                    accurate = true,
                };
            }
        }
Exemple #36
0
 public void Open(MediaFileSet fileSet)
 {
     Log.Debug("Openning file set");
     if (ready)
     {
         InternalOpen(fileSet, true, true, false, true);
     }
     else
     {
         Log.Debug("Player is not ready, delaying ...");
         delayedOpen = true;
         FileSet     = fileSet;
     }
 }
Exemple #37
0
 public void SetMediaFileSet(MediaFileSet files, MediaFile file)
 {
     fileSet = files;
     SetMediaFile (file, true);
 }
Exemple #38
0
        void LoadBackgroundPlayer(MediaFileSet file)
        {
            if (backLoaded)
                return;

            /* The output video file is now created, it's time to
                 * load it in the player */
            Player.Open (file);
            Log.Debug ("Loading encoded file in the backround player");
            backLoaded = true;
        }
        public void FixtureSetup()
        {
            playerMock = new Mock<IPlayer> ();
            playerMock.SetupAllProperties ();
            /* Mock properties without setter */
            playerMock.Setup (p => p.CurrentTime).Returns (() => currentTime);
            playerMock.Setup (p => p.StreamLength).Returns (() => streamLength);
            playerMock.Setup (p => p.Play ()).Raises (p => p.StateChange += null, this, true);
            playerMock.Setup (p => p.Pause ()).Raises (p => p.StateChange += null, this, false);

            mtkMock = new Mock<IMultimediaToolkit> ();
            mtkMock.Setup (m => m.GetPlayer ()).Returns (playerMock.Object);
            mtkMock.Setup (m => m.GetMultiPlayer ()).Throws (new Exception ());
            Config.MultimediaToolkit = mtkMock.Object;

            var ftk = new Mock<IGUIToolkit> ();
            ftk.Setup (m => m.Invoke (It.IsAny<EventHandler> ())).Callback<EventHandler> (e => e (null, null));
            Config.GUIToolkit = ftk.Object;

            Config.EventsBroker = new EventsBroker ();

            mfs = new MediaFileSet ();
            mfs.Add (new MediaFile { FilePath = "test1", VideoWidth = 320, VideoHeight = 240, Par = 1 });
            mfs.Add (new MediaFile { FilePath = "test2", VideoWidth = 320, VideoHeight = 240, Par = 1 });

            evt = new TimelineEvent { Start = new Time (100), Stop = new Time (200),
                CamerasConfig = new List<CameraConfig> { new CameraConfig (0) }
            };
            plImage = new PlaylistImage (Utils.LoadImageFromFile (), new Time (5));
            playlist = new Playlist ();
            playlist.Elements.Add (new PlaylistPlayElement (evt));
            playlist.Elements.Add (plImage);
        }
        void HandleSelectedCameraChanged(object sender, EventArgs args)
        {
            CameraObject camera = camerasTimeline.SelectedCamera;
            if (camera != null) {
                // Check if we need to reopen the player
                if (!secCamPlayerVM.Opened ||
                    secCamPlayerVM.FileSet.FirstOrDefault () != camera.MediaFile) {
                    MediaFileSet fileSet = new MediaFileSet ();
                    fileSet.Add (camera.MediaFile);

                    secCamPlayerVM.OpenFileSet (fileSet);

                    // Configure audio
                    HandleAudioToggled (sec_cam_audio_button, new EventArgs ());
                }
                // And update
                HandleCameraUpdate (camera);
            } else {
                // When no camera is selected show the initial didactic message.
                ShowDidactic (DidacticMessage.Initial);
            }
        }
Exemple #41
0
 public void TestSerialization()
 {
     MediaFileSet mf = new MediaFileSet ();
     mf.Add (new MediaFile ("path", 34000, 25, true, true, "mp4", "h264",
         "aac", 320, 240, 1.3, null, "Test asset"));
     mf.Add (new MediaFile ("path", 34000, 25, true, true, "mp4", "h264",
         "aac", 320, 240, 1.3, null, "Test asset 2"));
     Utils.CheckSerialization (mf);
 }
        public void TestLoadCameraPlay_WithCameraTlEvent()
        {
            // Arrange
            MediaFileSet mfs2 = new MediaFileSet ();
            mfs2.Add (new MediaFile {
                FilePath = "test1",
                VideoWidth = 320,
                VideoHeight = 240,
                Par = 1,
                Duration = new Time (100)
            });
            LoadCameraEvent lce = new LoadCameraEvent () {
                CameraTlEvent = new TimelineEvent () {
                    FileSet = mfs2,
                    Start = new Time (0),
                    Stop = mfs2.FirstOrDefault ().Duration
                }
            };

            // Action
            App.Current.EventsBroker.Publish<LoadCameraEvent> (lce);

            // Assert
            mockPlayerController.Verify (player => player.UnloadCurrentEvent (), Times.Never ());
            mockPlayerController.Verify (player => player.Seek (It.IsAny<double> ()), Times.Never ());
        }
        public void Load(IList<Period> periods, MediaFileSet fileSet, Time duration)
        {
            timelines = new List<TimelineObject> ();
            // Store periods as a list of timers
            this.timers = periods.Select (p => p as Timer).ToList ();
            // And the file set
            this.fileSet = fileSet;
            this.duration = duration;

            ClearObjects ();
            FillCanvas ();
            widget?.ReDraw ();
        }
Exemple #44
0
        public void TestOrderReplace()
        {
            MediaFileSet mf = new MediaFileSet ();

            mf.Add (new MediaFile ("path1", 34000, 25, true, true, "mp4", "h264",
                "aac", 320, 240, 1.3, null, "Test asset") { Offset = new Time (1) });
            mf.Add (new MediaFile ("path2", 34000, 25, true, true, "mp4", "h264",
                "aac", 320, 240, 1.3, null, "Test asset 2") { Offset = new Time (2) });
            mf.Add (new MediaFile ("path3", 34000, 25, true, true, "mp4", "h264",
                "aac", 320, 240, 1.3, null, "Test asset 3") { Offset = new Time (3) });

            Assert.AreEqual (3, mf.Count);
            Assert.AreEqual ("path1", mf [0].FilePath);
            Assert.AreEqual ("path2", mf [1].FilePath);
            Assert.AreEqual ("path3", mf [2].FilePath);

            mf.Replace ("Test asset 2", new MediaFile ("path4", 34000, 25, true, true, "mp4", "h264",
                "aac", 320, 240, 1.3, null, "Test asset 4")  { Offset = new Time (4) });

            Assert.AreEqual (3, mf.Count);
            Assert.AreEqual ("path1", mf [0].FilePath);
            Assert.AreEqual ("path4", mf [1].FilePath);
            Assert.AreEqual ("Test asset 2", mf [1].Name);
            Assert.AreEqual (new Time (2), mf [1].Offset);
            Assert.AreEqual ("path3", mf [2].FilePath);

            mf.Replace (mf [1], new MediaFile ("path5", 34000, 25, true, true, "mp4", "h264",
                "aac", 320, 240, 1.3, null, "Test asset 5") { Offset = new Time (5) });

            Assert.AreEqual (3, mf.Count);
            Assert.AreEqual ("path1", mf [0].FilePath);
            Assert.AreEqual ("path5", mf [1].FilePath);
            Assert.AreEqual ("Test asset 2", mf [1].Name);
            Assert.AreEqual (new Time (2), mf [1].Offset);
            Assert.AreEqual ("path3", mf [2].FilePath);
        }
 /// <summary>
 /// Adjusts the VPaned position to accomodate up to 8 cameras.
 /// </summary>
 /// <param name="fileSet">File set.</param>
 void UpdateTimeLineSize(MediaFileSet fileSet)
 {
     // Number of media files plus period sync line
     int visibleItems = Math.Min (StyleConf.TimelineCameraMaxLines, fileSet.Count + 1);
     int height = scrolledwindow2.HScrollbar.Requisition.Height * 2;
     height += visibleItems * StyleConf.TimelineCameraHeight;
     vpaned2.Position = vpaned2.Allocation.Height - height;
 }
Exemple #46
0
 public void TestPreview()
 {
     MediaFileSet mf = new MediaFileSet ();
     Assert.IsNull (mf.Preview);
     mf.Add (new MediaFile {Preview = Utils.LoadImageFromFile (), Name = "Test asset"});
     Assert.IsNotNull (mf.Preview);
 }