[longomatch] Add support for multiple cameras in the controller
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add support for multiple cameras in the controller
- Date: Tue, 31 Mar 2015 17:35:45 +0000 (UTC)
commit ae7c2b3e6b0f36d820c127bff05f8ffb94d5d2b8
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Thu Mar 26 18:05:13 2015 +0100
Add support for multiple cameras in the controller
LongoMatch.Core/Common/Enums.cs | 6 +++
.../Interfaces/Multimedia/IMultimediaToolkit.cs | 32 ++++++++-------
LongoMatch.Multimedia/Utils/MultimediaFactory.cs | 5 ++
LongoMatch.Services/Services/PlayerController.cs | 43 +++++++++++++++-----
Tests/Services/TestPlayerController.cs | 12 +++---
5 files changed, 67 insertions(+), 31 deletions(-)
---
diff --git a/LongoMatch.Core/Common/Enums.cs b/LongoMatch.Core/Common/Enums.cs
index 4287e9c..b7d20e3 100644
--- a/LongoMatch.Core/Common/Enums.cs
+++ b/LongoMatch.Core/Common/Enums.cs
@@ -427,4 +427,10 @@ namespace LongoMatch.Core.Common
LiveAnalysisReview,
Analysis,
}
+
+ public enum PlayerControllerType
+ {
+ Simple,
+ Multiple
+ }
}
diff --git a/LongoMatch.Core/Interfaces/Multimedia/IMultimediaToolkit.cs
b/LongoMatch.Core/Interfaces/Multimedia/IMultimediaToolkit.cs
index a2b48b2..60779cd 100644
--- a/LongoMatch.Core/Interfaces/Multimedia/IMultimediaToolkit.cs
+++ b/LongoMatch.Core/Interfaces/Multimedia/IMultimediaToolkit.cs
@@ -27,24 +27,26 @@ namespace LongoMatch.Core.Interfaces.Multimedia
{
void Register (int priority, Type interfac, Type elementType);
- IPlayer GetPlayer();
+ IPlayer GetPlayer ();
+
+ IMultiPlayer GetMultiPlayer ();
+
+ IVideoEditor GetVideoEditor ();
- IVideoEditor GetVideoEditor();
-
IVideoConverter GetVideoConverter (string filename);
-
- IFramesCapturer GetFramesCapturer();
-
- IRemuxer GetRemuxer(MediaFile inputFile, string outputFile, VideoMuxerType muxer);
-
- ICapturer GetCapturer();
-
- MediaFile DiscoverFile(string path, bool takeScreenshot=true);
-
- List<Device> VideoDevices {get;}
-
+
+ IFramesCapturer GetFramesCapturer ();
+
+ IRemuxer GetRemuxer (MediaFile inputFile, string outputFile, VideoMuxerType muxer);
+
+ ICapturer GetCapturer ();
+
+ MediaFile DiscoverFile (string path, bool takeScreenshot = true);
+
+ List<Device> VideoDevices { get; }
+
bool FileNeedsRemux (MediaFile file);
-
+
string RemuxFile (MediaFile file, object parent);
}
}
diff --git a/LongoMatch.Multimedia/Utils/MultimediaFactory.cs
b/LongoMatch.Multimedia/Utils/MultimediaFactory.cs
index 8ba8de6..85974bd 100644
--- a/LongoMatch.Multimedia/Utils/MultimediaFactory.cs
+++ b/LongoMatch.Multimedia/Utils/MultimediaFactory.cs
@@ -61,6 +61,11 @@ namespace LongoMatch.Video
return registry.GetDefault<IPlayer> (typeof(IPlayer));
}
+ public IMultiPlayer GetMultiPlayer ()
+ {
+ return registry.GetDefault<IMultiPlayer> (typeof(IMultiPlayer));
+ }
+
public IFramesCapturer GetFramesCapturer ()
{
return registry.GetDefault<IFramesCapturer> (typeof(IFramesCapturer));
diff --git a/LongoMatch.Services/Services/PlayerController.cs
b/LongoMatch.Services/Services/PlayerController.cs
index 692b074..08e03da 100644
--- a/LongoMatch.Services/Services/PlayerController.cs
+++ b/LongoMatch.Services/Services/PlayerController.cs
@@ -45,10 +45,12 @@ namespace LongoMatch.Services
const int SCALE_FPS = 25;
IPlayer player;
+ IMultiPlayer multiPlayer;
TimelineEvent loadedEvent;
IPlaylistElement loadedPlaylistElement;
Playlist loadedPlaylist;
List<IntPtr> windowHandles;
+ List<int> camerasVisible;
Time streamLenght, videoTS, imageLoadedTS;
bool readyToSeek, stillimageLoaded, ready, delayedOpen, disposed;
@@ -76,7 +78,7 @@ namespace LongoMatch.Services
#region Constructors
- public PlayerController ()
+ public PlayerController (bool supportsMultipleStreams = false)
{
seeker = new Seeker ();
seeker.SeekEvent += HandleSeekEvent;
@@ -89,7 +91,7 @@ namespace LongoMatch.Services
timer = new Timer (HandleTimeout);
TimerDisposed = new ManualResetEvent (false);
ready = false;
- CreatePlayer ();
+ CreatePlayer (supportsMultipleStreams);
}
#endregion
@@ -102,8 +104,15 @@ namespace LongoMatch.Services
}
public List<int> CamerasVisible {
- get;
- set;
+ set {
+ camerasVisible = value;
+ if (multiPlayer != null) {
+ multiPlayer.CamerasVisible = value;
+ }
+ }
+ get {
+ return camerasVisible;
+ }
}
public object CamerasLayout {
@@ -113,9 +122,12 @@ namespace LongoMatch.Services
public List<IntPtr> WindowHandles {
set {
- /* FIXME: handle multiple handles when IMultiplayer is implemented */
if (value != null) {
- player.WindowHandle = value [0];
+ if (multiPlayer == null) {
+ player.WindowHandle = value [0];
+ } else {
+ multiPlayer.WindowHandles = value;
+ }
}
windowHandles = value;
}
@@ -652,7 +664,11 @@ namespace LongoMatch.Services
}
try {
Log.Debug ("Opening new file set " + fileSet);
- player.Open (fileSet);
+ if (multiPlayer != null) {
+ multiPlayer.Open (fileSet);
+ } else {
+ player.Open (fileSet [0]);
+ }
FileSet = fileSet;
EmitTimeChanged (new Time (0), player.StreamLength);
} catch (Exception ex) {
@@ -782,10 +798,17 @@ namespace LongoMatch.Services
/// <summary>
/// Creates the backend video player.
/// </summary>
- void CreatePlayer ()
+ void CreatePlayer (bool supportsMultipleStreams)
{
- player = Config.MultimediaToolkit.GetPlayer ();
-
+ if (supportsMultipleStreams) {
+ player = multiPlayer = Config.MultimediaToolkit.GetMultiPlayer ();
+ if (player == null) {
+ throw new Exception ("A player that supports multiple cameras was not
found");
+ }
+ } else {
+ player = Config.MultimediaToolkit.GetPlayer ();
+ multiPlayer = null;
+ }
player.Error += HandleError;
player.StateChange += HandleStateChange;
player.Eos += HandleEndOfStream;
diff --git a/Tests/Services/TestPlayerController.cs b/Tests/Services/TestPlayerController.cs
index 4584c49..22349eb 100644
--- a/Tests/Services/TestPlayerController.cs
+++ b/Tests/Services/TestPlayerController.cs
@@ -182,7 +182,7 @@ namespace Tests.Services
/* Open but view is not ready */
player.Open (mfs);
Assert.AreEqual (mfs, player.FileSet);
- playerMock.Verify (p => p.Open (mfs), Times.Never ());
+ playerMock.Verify (p => p.Open (mfs [0]), Times.Never ());
playerMock.Verify (p => p.Play (), Times.Never ());
playerMock.Verify (p => p.Seek (new Time (0), true, false), Times.Never ());
@@ -200,7 +200,7 @@ namespace Tests.Services
streamLength = new Time { TotalSeconds = 5000 };
currentTime = new Time (0);
PreparePlayer ();
- playerMock.Verify (p => p.Open (mfs), Times.Once ());
+ playerMock.Verify (p => p.Open (mfs [0]), Times.Once ());
playerMock.Verify (p => p.Play (), Times.Never ());
playerMock.Verify (p => p.Seek (new Time (0), true, false), Times.Never ());
Assert.AreEqual (2, parCount);
@@ -587,7 +587,7 @@ namespace Tests.Services
currentTime = evt.Start;
playerMock.Raise (p => p.ReadyToSeek += null);
Assert.IsTrue (player.Playing);
- playerMock.Verify (p => p.Open (mfs));
+ playerMock.Verify (p => p.Open (mfs [0]));
playerMock.Verify (p => p.Seek (evt.Start, true, false), Times.Once ());
playerMock.Verify (p => p.Play (), Times.Once ());
playerMock.VerifySet (p => p.Rate = 1);
@@ -601,7 +601,7 @@ namespace Tests.Services
Assert.AreEqual (1, elementLoaded);
elementLoaded = 0;
Assert.AreEqual (nfs, player.FileSet);
- playerMock.Verify (p => p.Open (nfs));
+ playerMock.Verify (p => p.Open (nfs [0]));
playerMock.Verify (p => p.Play (), Times.Never ());
playerMock.Verify (p => p.Pause (), Times.Once ());
playerMock.VerifySet (p => p.Rate = 1);
@@ -619,7 +619,7 @@ namespace Tests.Services
player.LoadEvent (nfs, evt2, evt2.Start, true);
Assert.AreEqual (1, elementLoaded);
elementLoaded = 0;
- playerMock.Verify (p => p.Open (nfs), Times.Never ());
+ playerMock.Verify (p => p.Open (nfs [0]), Times.Never ());
playerMock.Verify (p => p.Seek (evt2.Start, true, false), Times.Once ());
playerMock.Verify (p => p.Play (), Times.Once ());
playerMock.VerifySet (p => p.Rate = 1);
@@ -654,7 +654,7 @@ namespace Tests.Services
elementLoaded = 0;
Assert.AreEqual (el1.CamerasVisible, player.CamerasVisible);
Assert.AreEqual (el1.CamerasLayout, player.CamerasLayout);
- playerMock.Verify (p => p.Open (nfs), Times.Once ());
+ playerMock.Verify (p => p.Open (nfs [0]), Times.Once ());
playerMock.Verify (p => p.Seek (el1.Play.Start, true, false), Times.Never ());
playerMock.Verify (p => p.Play (), Times.Never ());
playerMock.VerifySet (p => p.Rate = 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]