[longomatch] Add a new method to aplly cameras configuration
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add a new method to aplly cameras configuration
- Date: Tue, 31 Mar 2015 17:38:07 +0000 (UTC)
commit 367c6b376b03ce04d1e0ce85fa67da0c8f1301b0
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Mon Mar 30 12:14:23 2015 +0200
Add a new method to aplly cameras configuration
LongoMatch.Core/Handlers/Multimedia.cs | 4 +-
LongoMatch.Core/Interfaces/Multimedia/IPlayer.cs | 2 +
LongoMatch.Services/Services/PlayerController.cs | 52 +++++++++++++---------
Tests/Services/TestPlayerController.cs | 2 +-
4 files changed, 36 insertions(+), 24 deletions(-)
---
diff --git a/LongoMatch.Core/Handlers/Multimedia.cs b/LongoMatch.Core/Handlers/Multimedia.cs
index 33de06f..6cc0b38 100644
--- a/LongoMatch.Core/Handlers/Multimedia.cs
+++ b/LongoMatch.Core/Handlers/Multimedia.cs
@@ -17,7 +17,7 @@
//
using System;
-
+using System.Collections.Generic;
using LongoMatch.Core.Common;
using LongoMatch.Core.Store;
@@ -47,7 +47,7 @@ namespace LongoMatch.Core.Handlers
public delegate void LoadDrawingsHandler (FrameDrawing frameDrawing);
public delegate void ElementLoadedHandler (object element,bool hasNext);
public delegate void PARChangedHandler (IntPtr windowHandle,float par);
- public delegate void MediaFileSetLoadedHandler (MediaFileSet fileset);
+ public delegate void MediaFileSetLoadedHandler (MediaFileSet fileset,List<int> camerasVisible = null);
public delegate void ErrorHandler (object sender,string message);
public delegate void EosHandler (object sender);
diff --git a/LongoMatch.Core/Interfaces/Multimedia/IPlayer.cs
b/LongoMatch.Core/Interfaces/Multimedia/IPlayer.cs
index e4f42ba..27d8f36 100644
--- a/LongoMatch.Core/Interfaces/Multimedia/IPlayer.cs
+++ b/LongoMatch.Core/Interfaces/Multimedia/IPlayer.cs
@@ -170,5 +170,7 @@ namespace LongoMatch.Core.Interfaces.Multimedia
/// </summary>
List<int> CamerasVisible { set; }
+ void ApplyCamerasConfig ();
+
}
}
diff --git a/LongoMatch.Services/Services/PlayerController.cs
b/LongoMatch.Services/Services/PlayerController.cs
index ccc8185..c511432 100644
--- a/LongoMatch.Services/Services/PlayerController.cs
+++ b/LongoMatch.Services/Services/PlayerController.cs
@@ -53,7 +53,7 @@ namespace LongoMatch.Services
List<int> camerasVisible;
Time streamLength, videoTS, imageLoadedTS;
- bool readyToSeek, stillimageLoaded, ready, delayedOpen, disposed;
+ bool readyToSeek, stillimageLoaded, ready, delayedOpen, disposed, ignoreCameras;
Seeker seeker;
Segment loadedSegment;
PendingSeek pendingSeek;
@@ -109,6 +109,10 @@ namespace LongoMatch.Services
ValidateVisibleCameras ();
if (multiPlayer != null) {
multiPlayer.CamerasVisible = camerasVisible;
+ if (!ignoreCameras && Opened) {
+ multiPlayer.ApplyCamerasConfig ();
+ UpdatePar ();
+ }
}
}
get {
@@ -565,10 +569,10 @@ namespace LongoMatch.Services
}
}
- void EmitMediaFileSetLoaded (MediaFileSet fileSet)
+ void EmitMediaFileSetLoaded (MediaFileSet fileSet, List<int> camerasVisible)
{
if (MediaFileSetLoadedEvent != null) {
- MediaFileSetLoadedEvent (fileSet);
+ MediaFileSetLoadedEvent (fileSet, camerasVisible);
}
}
@@ -637,6 +641,26 @@ namespace LongoMatch.Services
}
}
+ void UpdatePar ()
+ {
+ foreach (int index in CamerasVisible) {
+ try {
+ MediaFile file = FileSet [index];
+ IntPtr windowHandle = WindowHandles [index];
+ if (file.VideoHeight != 0) {
+ EmitPARChanged (windowHandle, (float)(file.VideoWidth *
file.Par / file.VideoHeight));
+ } else {
+ EmitPARChanged (windowHandle, 1);
+ }
+ } catch (Exception ex) {
+ Config.EventsBroker.EmitMultimediaError (this, Catalog.GetString
("Invalid camera configuration"));
+ FileSet = null;
+ Log.Exception (ex);
+ return;
+ }
+ }
+ }
+
/// <summary>
/// Open the specified file set.
/// </summary>
@@ -647,10 +671,12 @@ namespace LongoMatch.Services
void Open (MediaFileSet fileSet, bool seek, bool force = false, bool play = false)
{
Reset ();
+ ignoreCameras = true;
// 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.
- EmitMediaFileSetLoaded (fileSet);
+ EmitMediaFileSetLoaded (fileSet, camerasVisible);
+ ignoreCameras = false;
if (fileSet != this.FileSet || force) {
readyToSeek = false;
FileSet = fileSet;
@@ -663,23 +689,7 @@ namespace LongoMatch.Services
}
// Validate Cam config against fileset
ValidateVisibleCameras ();
- foreach (int index in CamerasVisible) {
- try {
- MediaFile file = fileSet [index];
- IntPtr windowHandle = WindowHandles [index];
- if (file.VideoHeight != 0) {
- EmitPARChanged (windowHandle, (float)(file.VideoWidth
* file.Par / file.VideoHeight));
- } else {
- EmitPARChanged (windowHandle, 1);
- }
- } catch (Exception ex) {
- Config.EventsBroker.EmitMultimediaError (this,
- Catalog.GetString ("Invalid camera configuration"));
- FileSet = null;
- Log.Exception (ex);
- return;
- }
- }
+ UpdatePar ();
try {
Log.Debug ("Opening new file set " + fileSet);
if (multiPlayer != null) {
diff --git a/Tests/Services/TestPlayerController.cs b/Tests/Services/TestPlayerController.cs
index e6fa868..7a81e8d 100644
--- a/Tests/Services/TestPlayerController.cs
+++ b/Tests/Services/TestPlayerController.cs
@@ -177,7 +177,7 @@ namespace Tests.Services
duration = d;
timeCount++;
};
- player.MediaFileSetLoadedEvent += (fileset) => {
+ player.MediaFileSetLoadedEvent += (fileset, cameras) => {
fileSet = fileset;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]