[longomatch] Add new API to select the visible cameras and their layout
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add new API to select the visible cameras and their layout
- Date: Tue, 31 Mar 2015 17:28:52 +0000 (UTC)
commit de285b0e3e073c550e5d75feb35cd301f554c462
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Thu Mar 19 15:51:37 2015 +0100
Add new API to select the visible cameras and their layout
LongoMatch.Core/Common/Enums.cs | 1 +
LongoMatch.Core/Handlers/Multimedia.cs | 2 +-
LongoMatch.Core/Interfaces/GUI/IPlayerBin.cs | 5 +
LongoMatch.Core/Store/FrameDrawing.cs | 2 +-
.../Store/Playlists/PlaylistPlayElement.cs | 37 +++++++-
LongoMatch.Core/Store/Project.cs | 1 +
LongoMatch.Core/Store/TimelineEvent.cs | 104 ++++++++++++++++----
LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs | 15 ++-
LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs | 14 ++-
.../Gui/Utils/FramesCapturer.cs | 30 +++---
LongoMatch.GUI/Gui/Menu/PlaysMenu.cs | 2 +-
LongoMatch.Migration/Converter.cs | 2 +-
LongoMatch.Services/Services/EventsManager.cs | 6 +-
LongoMatch.Services/Services/PlaylistManager.cs | 2 +-
.../Store/Playlists/TestPlaylistPlayElement.cs | 70 +++++++++++++
Tests/Core/Store/TestFrameDrawing.cs | 10 +-
Tests/Core/Store/TestTimelineEvent.cs | 77 ++++++++-------
Tests/Makefile.am | 1 +
Tests/Tests.csproj | 2 +
19 files changed, 289 insertions(+), 94 deletions(-)
---
diff --git a/LongoMatch.Core/Common/Enums.cs b/LongoMatch.Core/Common/Enums.cs
index 67eab22..2a15eaf 100644
--- a/LongoMatch.Core/Common/Enums.cs
+++ b/LongoMatch.Core/Common/Enums.cs
@@ -364,6 +364,7 @@ namespace LongoMatch.Core.Common
Directory,
}
+ [Obsolete]
public enum MediaFileAngle
{
Angle1,
diff --git a/LongoMatch.Core/Handlers/Multimedia.cs b/LongoMatch.Core/Handlers/Multimedia.cs
index 6d9e2ce..1711500 100644
--- a/LongoMatch.Core/Handlers/Multimedia.cs
+++ b/LongoMatch.Core/Handlers/Multimedia.cs
@@ -33,7 +33,7 @@ namespace LongoMatch.Core.Handlers
public delegate void PrevButtonClickedHandler ();
public delegate void ProgressHandler (float progress);
public delegate void FramesProgressHandler (int actual,int total,Image frame);
- public delegate void DrawFrameHandler (TimelineEvent play,int drawingIndex,MediaFileAngle angle,bool
current);
+ public delegate void DrawFrameHandler (TimelineEvent play,int drawingIndex,int cameraIndex,bool
current);
public delegate void EllpasedTimeHandler (Time ellapsedTime);
public delegate void PlaybackRateChangedHandler (float rate);
diff --git a/LongoMatch.Core/Interfaces/GUI/IPlayerBin.cs b/LongoMatch.Core/Interfaces/GUI/IPlayerBin.cs
index fbacdfe..1eb8c32 100644
--- a/LongoMatch.Core/Interfaces/GUI/IPlayerBin.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IPlayerBin.cs
@@ -16,6 +16,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
//
using System;
+using System.Collections.Generic;
using LongoMatch.Core.Common;
using LongoMatch.Core.Handlers;
using LongoMatch.Core.Store;
@@ -44,6 +45,10 @@ namespace LongoMatch.Core.Interfaces.GUI
bool Playing { get; }
+ object CamerasLayout { get; }
+
+ List<int> CamerasVisible { get; }
+
void Open (MediaFileSet fileSet);
void Close ();
diff --git a/LongoMatch.Core/Store/FrameDrawing.cs b/LongoMatch.Core/Store/FrameDrawing.cs
index 967d81e..19202a2 100644
--- a/LongoMatch.Core/Store/FrameDrawing.cs
+++ b/LongoMatch.Core/Store/FrameDrawing.cs
@@ -77,7 +77,7 @@ namespace LongoMatch.Core.Store
get;
}
- public MediaFileAngle Angle {
+ public int CameraIndex {
get;
set;
}
diff --git a/LongoMatch.Core/Store/Playlists/PlaylistPlayElement.cs
b/LongoMatch.Core/Store/Playlists/PlaylistPlayElement.cs
index e6a389b..6967c1b 100644
--- a/LongoMatch.Core/Store/Playlists/PlaylistPlayElement.cs
+++ b/LongoMatch.Core/Store/Playlists/PlaylistPlayElement.cs
@@ -27,15 +27,19 @@ namespace LongoMatch.Core.Store.Playlists
[Serializable]
public class PlaylistPlayElement: IPlaylistElement
{
- public PlaylistPlayElement (TimelineEvent play, MediaFileSet fileset=null)
+ public PlaylistPlayElement (TimelineEvent play, MediaFileSet fileset = null)
{
Play = play;
Title = play.Name;
Rate = play.Rate;
- Angles = new HashSet<MediaFileAngle> (play.ActiveViews);
+ CamerasLayout = play.CamerasLayout;
+ CamerasVisible = play.CamerasVisible.ToList ();
FileSet = fileset;
}
+ /// <summary>
+ /// The event associated to this playlist element
+ /// </summary>
public TimelineEvent Play {
get;
set;
@@ -47,22 +51,35 @@ namespace LongoMatch.Core.Store.Playlists
set;
}
+ /// <summary>
+ /// The duration of the playlist element
+ /// </summary>
public Time Duration {
get {
return Play.Duration;
}
}
+ /// <summary>
+ /// The title of the playlist element
+ /// </summary>
public string Title {
get;
set;
}
+ /// <summary>
+ /// Override the default <see cref="TimelineEvent.Rate"/>
+ /// defined by the <see cref="TimelineEvent"/>
+ /// </summary>
public float Rate {
get;
set;
}
+ /// <summary>
+ /// A string representing this playback rate
+ /// </summary>
public string RateString {
get {
return String.Format ("{0}X", Rate);
@@ -74,11 +91,25 @@ namespace LongoMatch.Core.Store.Playlists
set;
}
- public HashSet<MediaFileAngle> Angles {
+ /// <summary>
+ /// Override the default <see cref="TimelineEvent.CamerasLayout"/>
+ /// defined by the <see cref="TimelineEvent"/>
+ /// </summary>
+ public object CamerasLayout {
get;
set;
}
+ /// <summary>
+ /// Override the default <see cref="TimelineEvent.CamerasVisible"/>
+ /// defined by the <see cref="TimelineEvent"/>
+ /// </summary>
+ public List<int> CamerasVisible {
+ get;
+ set;
+ }
+
+
[JsonIgnore]
public string Description {
get {
diff --git a/LongoMatch.Core/Store/Project.cs b/LongoMatch.Core/Store/Project.cs
index 20bc4f0..9b44eff 100644
--- a/LongoMatch.Core/Store/Project.cs
+++ b/LongoMatch.Core/Store/Project.cs
@@ -248,6 +248,7 @@ namespace LongoMatch.Core.Store
evt.EventType = type;
evt.Notes = "";
evt.Miniature = miniature;
+ evt.CamerasVisible = new List<int> { 0 };
if (addToTimeline) {
Timeline.Add (evt);
diff --git a/LongoMatch.Core/Store/TimelineEvent.cs b/LongoMatch.Core/Store/TimelineEvent.cs
index 187cf55..03a435a 100644
--- a/LongoMatch.Core/Store/TimelineEvent.cs
+++ b/LongoMatch.Core/Store/TimelineEvent.cs
@@ -24,11 +24,12 @@ using Mono.Unix;
using LongoMatch.Core.Common;
using LongoMatch.Core.Interfaces;
using Newtonsoft.Json;
+using System.Runtime.Serialization;
namespace LongoMatch.Core.Store
{
/// <summary>
- /// Represents a Play in the game.
+ /// Represents a tagged event in the game at a specific position in the timeline.
/// </summary>
[Serializable]
@@ -44,18 +45,39 @@ namespace LongoMatch.Core.Store
Tags = new List<Tag> ();
Rate = 1.0f;
ID = Guid.NewGuid ();
- ActiveViews = new HashSet<MediaFileAngle>();
- ActiveViews.Add (MediaFileAngle.Angle1);
+ CamerasVisible = new List<int> ();
}
+
+ internal void InitializeLists ()
+ {
+ if (CamerasVisible.Count == 0) {
+ CamerasVisible.Add (0);
+ }
+ }
+
+ [OnDeserialized]
+ internal void OnDeserializedMethod (StreamingContext context)
+ {
+ InitializeLists ();
+ }
+
+ [OnSerializing]
+ internal void OnSerializingMethod (StreamingContext context)
+ {
+ InitializeLists ();
+ }
+
#endregion
+
#region Properties
+
public Guid ID {
get;
set;
}
/// <summary>
- /// Category in which this play is tagged
+ /// The <see cref="EventType"/> in wich this event is tagged
/// </summary>
public EventType EventType {
get;
@@ -63,7 +85,7 @@ namespace LongoMatch.Core.Store
}
/// <summary>
- /// A string with the play's notes
+ /// Event notes
/// </summary>
public string Notes {
get;
@@ -71,7 +93,7 @@ namespace LongoMatch.Core.Store
}
/// <summary>
- /// Get/Set wheter this play is actually loaded. Used in <see
cref="LongoMatch.Gui.Component.TimeScale">
+ /// Whether this event is currently selected.
/// </summary>
[JsonIgnore]
public bool Selected {
@@ -80,7 +102,7 @@ namespace LongoMatch.Core.Store
}
/// <summary>
- /// List of drawings for this play
+ /// List of drawings for this event
/// </summary>
public List<FrameDrawing> Drawings {
get;
@@ -88,7 +110,7 @@ namespace LongoMatch.Core.Store
}
/// <summary>
- /// Get wether the play has at least a frame drawing
+ /// Whether this event has at least one <see cref="FrameDrawing"/>
/// </summary>
[JsonIgnore]
public bool HasDrawings {
@@ -97,37 +119,70 @@ namespace LongoMatch.Core.Store
}
}
+ /// <summary>
+ /// List of players tagged in this event.
+ /// </summary>
public List<Player> Players {
get;
set;
}
+ /// <summary>
+ /// The team tagged in this event.
+ /// </summary>
+ /// <value>The team.</value>
public TeamType Team {
get;
set;
}
+ /// <summary>
+ /// List of tags describing this event.
+ /// </summary>
+ /// <value>The tags.</value>
public List<Tag> Tags {
get;
set;
}
+ /// <summary>
+ /// Position of this event in the field.
+ /// </summary>
+ /// <value>The field position.</value>
public Coordinates FieldPosition {
get;
set;
}
+ /// <summary>
+ /// Position of this event in the half field.
+ /// </summary>
public Coordinates HalfFieldPosition {
get;
set;
}
+ /// <summary>
+ /// Position of this event in the goal.
+ /// </summary>
public Coordinates GoalPosition {
get;
set;
}
- public HashSet<MediaFileAngle> ActiveViews {
+ /// <summary>
+ /// An opaque object used by the view to describe the cameras layout.
+ /// </summary>
+ public object CamerasLayout {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// A list of camera indexes visible for this event, where the index
+ /// is the position of the camera in the <see cref="MediaFileSet"/>
+ /// </summary>
+ public List<int> CamerasVisible {
get;
set;
}
@@ -137,8 +192,8 @@ namespace LongoMatch.Core.Store
get {
return
(Name + "\n" +
- TagsDescription () + "\n" +
- TimesDesription ());
+ TagsDescription () + "\n" +
+ TimesDesription ());
}
}
@@ -148,8 +203,11 @@ namespace LongoMatch.Core.Store
return EventType.Color;
}
}
+
#endregion
+
#region Public methods
+
public string TagsDescription ()
{
return String.Join ("-", Tags.Select (t => t.Value));
@@ -175,7 +233,7 @@ namespace LongoMatch.Core.Store
if (Drawings.Count == 0) {
Miniature = null;
} else {
- Miniature = Drawings[0].Miniature;
+ Miniature = Drawings [0].Miniature;
}
}
@@ -243,9 +301,13 @@ namespace LongoMatch.Core.Store
{
return Description;
}
+
#endregion
}
+ /// <summary>
+ /// An event in the game for a penalty.
+ /// </summary>
[Serializable]
public class PenaltyCardEvent: TimelineEvent
{
@@ -281,8 +343,8 @@ namespace LongoMatch.Core.Store
public override string Description {
get {
return String.Format ("{0} - {1}\n{2}\n{3}\n", Score.Points, Name,
- TagsDescription (), Start.ToMSecondsString (),
- Stop.ToMSecondsString ());
+ TagsDescription (), Start.ToMSecondsString (),
+ Stop.ToMSecondsString ());
}
}
}
@@ -298,7 +360,7 @@ namespace LongoMatch.Core.Store
EventTime = value;
}
}
-
+
public override Time Stop {
get {
return EventTime;
@@ -308,7 +370,7 @@ namespace LongoMatch.Core.Store
}
}
}
-
+
[Serializable]
public class SubstitutionEvent: StatEvent
{
@@ -321,10 +383,10 @@ namespace LongoMatch.Core.Store
get;
set;
}
-
+
public override string Name {
get {
- return Reason.ToString();
+ return Reason.ToString ();
}
set {
}
@@ -358,17 +420,17 @@ namespace LongoMatch.Core.Store
get;
set;
}
-
+
public List<Player> HomeBenchPlayers {
get;
set;
}
-
+
public List<Player> AwayStartingPlayers {
get;
set;
}
-
+
public List<Player> AwayBenchPlayers {
get;
set;
diff --git a/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs b/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
index b878e32..d449d62 100644
--- a/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
@@ -68,7 +68,7 @@ namespace LongoMatch.Gui
bool ignoreTick, stillimageLoaded, delayedOpen;
MediaFileSet fileSet;
MediaFile activeFile;
- MediaFileAngle angle;
+ int cameraIndex;
double previousVLevel = 1;
double[] seeksQueue;
object[] pendingSeek;
@@ -172,11 +172,18 @@ namespace LongoMatch.Gui
}
}
- public MediaFileAngle ActiveAngle {
+ public object CamerasLayout {
get {
- return angle;
+ return 0;
}
}
+
+ public List<int> CamerasVisible {
+ get {
+ return new List<int> { 0 };
+ }
+ }
+
public bool SeekingEnabled {
set {
timescale.Sensitive = value;
@@ -1001,7 +1008,7 @@ namespace LongoMatch.Gui
void OnDrawButtonClicked (object sender, System.EventArgs e)
{
- Config.EventsBroker.EmitDrawFrame (null, -1, angle, true);
+ Config.EventsBroker.EmitDrawFrame (null, -1, CamerasVisible [0], true);
}
void HandleReady (object sender, EventArgs e)
diff --git a/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
b/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
index 0f8cc18..05404cc 100644
--- a/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
@@ -207,13 +207,19 @@ namespace LongoMatch.Gui
return playerbin.Playing;
}
}
-
- public MediaFileAngle ActiveAngle {
+
+ public object CamerasLayout {
get {
- return playerbin.ActiveAngle;
+ return playerbin.CamerasLayout;
}
}
-
+
+ public List<int> CamerasVisible {
+ get {
+ return playerbin.CamerasVisible;
+ }
+ }
+
public bool SeekingEnabled {
set {
playerbin.SeekingEnabled = value;
diff --git a/LongoMatch.GUI.Multimedia/Gui/Utils/FramesCapturer.cs
b/LongoMatch.GUI.Multimedia/Gui/Utils/FramesCapturer.cs
index 47ad1d5..2e8c94f 100644
--- a/LongoMatch.GUI.Multimedia/Gui/Utils/FramesCapturer.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/Utils/FramesCapturer.cs
@@ -19,14 +19,12 @@
//
using System;
+using System.Collections.Generic;
using System.Threading;
using System.Linq;
using LongoMatch.Core.Common;
using LongoMatch.Core.Interfaces.Multimedia;
-using LongoMatch.Video;
-using LongoMatch.Video.Common;
using LongoMatch.Core.Store;
-using LongoMatch.Multimedia.Utils;
using Gtk;
namespace LongoMatch.Video.Utils
@@ -59,8 +57,8 @@ namespace LongoMatch.Video.Utils
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.ActiveViews.Count;
+ this.seriesName = System.IO.Path.GetFileName (outputDir);
+ this.totalFrames = ((int)Math.Floor ((double)((stop - start).MSeconds / interval)) +
1) * evt.CamerasVisible.Count;
this.cancel = false;
}
@@ -77,6 +75,7 @@ namespace LongoMatch.Video.Utils
{
Time pos;
LongoMatch.Core.Common.Image frame;
+ List<int> cameras;
bool quit = false;
int i = 0;
int j = 0;
@@ -85,11 +84,16 @@ namespace LongoMatch.Video.Utils
Log.Debug ("Start frames series capture with interval: " + interval);
Log.Debug ("Total frames to be captured: " + totalFrames);
- foreach (MediaFileAngle angle in evt.ActiveViews) {
+ if (evt.CamerasVisible.Count == 0) {
+ cameras = new List<int> { 0 };
+ } else {
+ cameras = evt.CamerasVisible;
+ }
+ foreach (int cameraIndex in cameras) {
if (quit) {
break;
}
- Log.Debug ("Start frames series capture for angle " + angle);
+ Log.Debug ("Start frames series capture for angle " + cameraIndex);
MediaFile file = fileSet.First ();
capturer.Open (file.FilePath);
pos = new Time {MSeconds = start.MSeconds};
@@ -102,12 +106,12 @@ namespace LongoMatch.Video.Utils
j = 0;
while(pos <= stop) {
Log.Debug ("Capturing fame " + j);
- if(!cancel) {
- frame = capturer.GetFrame(pos + file.Offset, true);
- if(frame != null) {
- string path = String.Format("{0}_angle{1}_{2}.png",
seriesName, angle, j);
- frame.Save(System.IO.Path.Combine(outputDir, path));
- frame.ScaleInplace(THUMBNAIL_MAX_WIDTH,
THUMBNAIL_MAX_HEIGHT);
+ if (!cancel) {
+ frame = capturer.GetFrame (pos + file.Offset, true);
+ if (frame != null) {
+ string path = String.Format ("{0}_angle{1}_{2}.png",
seriesName, cameraIndex, j);
+ frame.Save (System.IO.Path.Combine (outputDir, path));
+ frame.ScaleInplace (THUMBNAIL_MAX_WIDTH,
THUMBNAIL_MAX_HEIGHT);
}
if(Progress != null) {
diff --git a/LongoMatch.GUI/Gui/Menu/PlaysMenu.cs b/LongoMatch.GUI/Gui/Menu/PlaysMenu.cs
index 854b745..c71bc38 100644
--- a/LongoMatch.GUI/Gui/Menu/PlaysMenu.cs
+++ b/LongoMatch.GUI/Gui/Menu/PlaysMenu.cs
@@ -138,7 +138,7 @@ namespace LongoMatch.Gui.Menus
drawingMenu.Append (deleteItem);
editItem.Activated += (sender, e) => {
Config.EventsBroker.EmitDrawFrame (plays [0], index,
-
plays[0].Drawings[index].Angle, false);
+ plays [0].Drawings [index].CameraIndex, false);
};
deleteItem.Activated += (sender, e) => {
plays [0].Drawings.RemoveAt (index);
diff --git a/LongoMatch.Migration/Converter.cs b/LongoMatch.Migration/Converter.cs
index a86b5fc..ce53d51 100644
--- a/LongoMatch.Migration/Converter.cs
+++ b/LongoMatch.Migration/Converter.cs
@@ -315,7 +315,7 @@ namespace LongoMatch.Migration
LongoMatch.Core.Common.Coordinates c;
var newplay = new LongoMatch.Core.Store.TimelineEvent ();
- newplay.ActiveViews.Add (LongoMatch.Core.Common.MediaFileAngle.Angle1);
+ newplay.CamerasVisible.Add (0);
var fd = ConvertFrameDrawing (play.KeyFrameDrawing);
if (fd != null) {
newplay.Drawings.Add (fd);
diff --git a/LongoMatch.Services/Services/EventsManager.cs b/LongoMatch.Services/Services/EventsManager.cs
index 1306eb4..a90ae7e 100644
--- a/LongoMatch.Services/Services/EventsManager.cs
+++ b/LongoMatch.Services/Services/EventsManager.cs
@@ -174,7 +174,7 @@ namespace LongoMatch.Services
guiToolkit.ShowProjectStats (project);
}
- void HandleDrawFrame (TimelineEvent play, int drawingIndex, MediaFileAngle angle, bool
current)
+ void HandleDrawFrame (TimelineEvent play, int drawingIndex, int cameraIndex, bool current)
{
Image pixbuf;
FrameDrawing drawing = null;
@@ -188,7 +188,7 @@ namespace LongoMatch.Services
if (drawingIndex == -1) {
drawing = new FrameDrawing ();
drawing.Render = player.CurrentTime;
- drawing.Angle = angle;
+ drawing.CameraIndex = cameraIndex;
} else {
drawing = play.Drawings [drawingIndex];
}
@@ -268,6 +268,8 @@ namespace LongoMatch.Services
if (projectType == ProjectType.FileProject) {
play.Stop.MSeconds = Math.Min (player.StreamLength.MSeconds,
play.Stop.MSeconds);
}
+ play.CamerasLayout = player.CamerasLayout;
+ play.CamerasVisible = player.CamerasVisible;
filter.Update ();
analysisWindow.AddPlay (play);
diff --git a/LongoMatch.Services/Services/PlaylistManager.cs b/LongoMatch.Services/Services/PlaylistManager.cs
index dd695d0..af1e970 100644
--- a/LongoMatch.Services/Services/PlaylistManager.cs
+++ b/LongoMatch.Services/Services/PlaylistManager.cs
@@ -280,7 +280,7 @@ namespace LongoMatch.Services
evt = (loadedElement as PlaylistPlayElement).Play;
}
if (evt != null) {
- Config.EventsBroker.EmitDrawFrame (evt, -1,
player.ActiveAngle, true);
+ Config.EventsBroker.EmitDrawFrame (evt, -1,
player.CamerasVisible [0], true);
}
return;
case KeyAction.TogglePlay:
diff --git a/Tests/Core/Store/Playlists/TestPlaylistPlayElement.cs
b/Tests/Core/Store/Playlists/TestPlaylistPlayElement.cs
new file mode 100644
index 0000000..4ef613e
--- /dev/null
+++ b/Tests/Core/Store/Playlists/TestPlaylistPlayElement.cs
@@ -0,0 +1,70 @@
+//
+// Copyright (C) 2015 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+using NUnit.Framework;
+using System;
+using LongoMatch.Core.Store.Playlists;
+using LongoMatch.Core.Store;
+using System.Collections.Generic;
+
+namespace Tests.Core.Store.Playlists
+{
+ [TestFixture ()]
+ public class TestPlaylistPlayElement
+ {
+ [Test ()]
+ public void TestSerialization ()
+ {
+ TimelineEvent evt = new TimelineEvent ();
+ evt.Start = new Time (1000);
+ evt.Stop = new Time (2000);
+ evt.CamerasLayout = 1;
+ evt.CamerasVisible.Add (0);
+
+ PlaylistPlayElement element = new PlaylistPlayElement (evt);
+ Utils.CheckSerialization (element);
+
+ PlaylistPlayElement element2 = Utils.SerializeDeserialize (element);
+ Assert.AreEqual (element.Description, element2.Description);
+ Assert.AreEqual (element.Duration, element2.Duration);
+ Assert.AreEqual (element.Rate, element2.Rate);
+ Assert.AreEqual (element.RateString, element2.RateString);
+ Assert.AreEqual (element.Title, element2.Title);
+ Assert.AreEqual (new List<int> { 0 }, element2.CamerasVisible);
+ Assert.AreEqual (element.CamerasLayout, element2.CamerasLayout);
+ }
+
+ [Test ()]
+ public void TestPropertiesProxy ()
+ {
+ TimelineEvent evt = new TimelineEvent ();
+ evt.Start = new Time (1000);
+ evt.Stop = new Time (2000);
+ evt.CamerasLayout = 1;
+ evt.CamerasVisible = new List<int> { 2, 4 };
+
+ PlaylistPlayElement element = new PlaylistPlayElement (evt);
+
+ Assert.AreEqual (evt.Duration, element.Duration);
+ Assert.AreEqual (evt.CamerasLayout, element.CamerasLayout);
+ Assert.AreEqual (evt.CamerasVisible, element.CamerasVisible);
+ Assert.AreEqual (evt.Rate, element.Rate);
+ Assert.AreEqual (evt.Name, element.Title);
+ }
+ }
+}
+
diff --git a/Tests/Core/Store/TestFrameDrawing.cs b/Tests/Core/Store/TestFrameDrawing.cs
index 3ce6b8e..f1cb9af 100644
--- a/Tests/Core/Store/TestFrameDrawing.cs
+++ b/Tests/Core/Store/TestFrameDrawing.cs
@@ -24,17 +24,17 @@ using NUnit.Framework;
namespace Tests.Core.Store
{
- [TestFixture()]
+ [TestFixture ()]
public class TestFrameDrawing
{
- [Test()]
+ [Test ()]
public void TestSerialization ()
{
FrameDrawing d = new FrameDrawing ();
d.Miniature = Utils.LoadImageFromFile ();
d.Freehand = Utils.LoadImageFromFile ();
- d.Drawables = new List<Drawable> {new Line (), new Rectangle()};
- d.Angle = MediaFileAngle.Angle2;
+ d.Drawables = new List<Drawable> { new Line (), new Rectangle () };
+ d.CameraIndex = 2;
d.Render = new Time (1000);
d.Pause = new Time (2000);
Utils.CheckSerialization (d);
@@ -42,7 +42,7 @@ namespace Tests.Core.Store
FrameDrawing d2 = Utils.SerializeDeserialize (d);
Assert.AreEqual (d.Render, d2.Render);
Assert.AreEqual (d.Pause, d2.Pause);
- Assert.AreEqual (d.Angle, d2.Angle);
+ Assert.AreEqual (d.CameraIndex, d2.CameraIndex);
Assert.AreEqual (d2.Drawables.Count, d.Drawables.Count);
Assert.IsNotNull (d2.Freehand);
Assert.IsNotNull (d2.Miniature);
diff --git a/Tests/Core/Store/TestTimelineEvent.cs b/Tests/Core/Store/TestTimelineEvent.cs
index 2e9c36a..40399a2 100644
--- a/Tests/Core/Store/TestTimelineEvent.cs
+++ b/Tests/Core/Store/TestTimelineEvent.cs
@@ -23,37 +23,38 @@ using NUnit.Framework;
namespace Tests.Core.Store
{
- [TestFixture()]
+ [TestFixture ()]
public class TestTimelineEvent
{
EventType evtType1;
-
- public TimelineEvent CreateTimelineEvent () {
- TimelineEvent evt = new TimelineEvent();
- evtType1 = new EventType {Name="Cat1"};
+
+ public TimelineEvent CreateTimelineEvent ()
+ {
+ TimelineEvent evt = new TimelineEvent ();
+ evtType1 = new EventType { Name = "Cat1" };
evt.EventType = evtType1;
evt.Notes = "notes";
evt.Selected = true;
evt.Team = TeamType.LOCAL;
- evt.FieldPosition = new Coordinates();
+ evt.FieldPosition = new Coordinates ();
evt.FieldPosition.Points.Add (new Point (1, 2));
evt.HalfFieldPosition = new Coordinates ();
- evt.HalfFieldPosition.Points.Add (new Point (4,5));
+ evt.HalfFieldPosition.Points.Add (new Point (4, 5));
evt.GoalPosition = new Coordinates ();
evt.GoalPosition.Points.Add (new Point (6, 7));
evt.Rate = 1.5f;
evt.Name = "Play";
- evt.Start = new Time(1000);
- evt.EventTime = new Time(1500);
- evt.Stop = new Time(2000);
+ evt.Start = new Time (1000);
+ evt.EventTime = new Time (1500);
+ evt.Stop = new Time (2000);
evt.Rate = 2.3f;
-
- evt.Tags.Add(new Tag ("test"));
+
+ evt.Tags.Add (new Tag ("test"));
return evt;
}
-
- [Test()]
+
+ [Test ()]
public void TestSerialization ()
{
TimelineEvent p = new TimelineEvent ();
@@ -73,9 +74,11 @@ namespace Tests.Core.Store
Assert.AreEqual (p.Start, newp.Start);
Assert.AreEqual (p.Stop, newp.Stop);
Assert.AreEqual (p.Rate, newp.Rate);
+ Assert.AreEqual (p.CamerasVisible, new List<int> { 0 });
+ Assert.IsNull (p.CamerasLayout);
}
-
- [Test()]
+
+ [Test ()]
public void TestProperties ()
{
TimelineEvent evt = CreateTimelineEvent ();
@@ -84,8 +87,8 @@ namespace Tests.Core.Store
Assert.AreEqual (evt.Description,
String.Format ("Play\ntest\n0:01,000 - 0:02,000 ({0}X)", 2.3));
}
-
- [Test()]
+
+ [Test ()]
public void TestTagsDescription ()
{
TimelineEvent evt = CreateTimelineEvent ();
@@ -96,7 +99,7 @@ namespace Tests.Core.Store
Assert.AreEqual (evt.TagsDescription (), "");
}
- [Test()]
+ [Test ()]
public void TestTimesDescription ()
{
TimelineEvent evt = CreateTimelineEvent ();
@@ -106,10 +109,10 @@ namespace Tests.Core.Store
Assert.AreEqual (evt.TimesDesription (), "0:01,000 - 0:02,000");
}
- [Test()]
+ [Test ()]
public void TestAddDefaultPositions ()
{
- TimelineEvent evt = new TimelineEvent();
+ TimelineEvent evt = new TimelineEvent ();
evt.EventType = new EventType ();
evt.EventType.TagFieldPosition = false;
evt.EventType.TagHalfFieldPosition = false;
@@ -144,34 +147,34 @@ namespace Tests.Core.Store
Assert.IsNotNull (evt.HalfFieldPosition);
Assert.IsNotNull (evt.GoalPosition);
}
-
- [Test()]
+
+ [Test ()]
public void TestCoordinatesInFieldPosition ()
{
TimelineEvent evt = CreateTimelineEvent ();
Assert.AreEqual (evt.CoordinatesInFieldPosition (FieldPositionType.Field),
- evt.FieldPosition);
+ evt.FieldPosition);
Assert.AreEqual (evt.CoordinatesInFieldPosition (FieldPositionType.HalfField),
- evt.HalfFieldPosition);
+ evt.HalfFieldPosition);
Assert.AreEqual (evt.CoordinatesInFieldPosition (FieldPositionType.Goal),
- evt.GoalPosition);
+ evt.GoalPosition);
}
-
- [Test()]
+
+ [Test ()]
public void TestUpdateCoordinates ()
{
TimelineEvent evt = CreateTimelineEvent ();
- evt.UpdateCoordinates (FieldPositionType.Field, new List<Point> {new Point (4, 5)});
- Assert.AreEqual (evt.FieldPosition.Points[0].X, 4);
- Assert.AreEqual (evt.FieldPosition.Points[0].Y, 5);
+ evt.UpdateCoordinates (FieldPositionType.Field, new List<Point> { new Point (4, 5) });
+ Assert.AreEqual (evt.FieldPosition.Points [0].X, 4);
+ Assert.AreEqual (evt.FieldPosition.Points [0].Y, 5);
- evt.UpdateCoordinates (FieldPositionType.HalfField, new List<Point> {new Point (4,
5)});
- Assert.AreEqual (evt.HalfFieldPosition.Points[0].X, 4);
- Assert.AreEqual (evt.HalfFieldPosition.Points[0].Y, 5);
+ evt.UpdateCoordinates (FieldPositionType.HalfField, new List<Point> { new Point (4,
5) });
+ Assert.AreEqual (evt.HalfFieldPosition.Points [0].X, 4);
+ Assert.AreEqual (evt.HalfFieldPosition.Points [0].Y, 5);
- evt.UpdateCoordinates (FieldPositionType.Goal, new List<Point> {new Point (4, 5)});
- Assert.AreEqual (evt.GoalPosition.Points[0].X, 4);
- Assert.AreEqual (evt.GoalPosition.Points[0].Y, 5);
+ evt.UpdateCoordinates (FieldPositionType.Goal, new List<Point> { new Point (4, 5) });
+ Assert.AreEqual (evt.GoalPosition.Points [0].X, 4);
+ Assert.AreEqual (evt.GoalPosition.Points [0].Y, 5);
}
}
}
diff --git a/Tests/Makefile.am b/Tests/Makefile.am
index f6dca31..e2c350d 100644
--- a/Tests/Makefile.am
+++ b/Tests/Makefile.am
@@ -16,6 +16,7 @@ SOURCES = Core/Common/TestColor.cs \
Core/Store/Drawables/TestQuadrilateral.cs \
Core/Store/Drawables/TestRectangle.cs \
Core/Store/Drawables/TestText.cs \
+ Core/Store/Playlists/TestPlaylistPlayElement.cs \
Core/Store/Templates/TestTeamTemplate.cs \
Core/Store/TestCoordinates.cs \
Core/Store/TestDashboardButton.cs \
diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj
index ef288e7..8103c49 100644
--- a/Tests/Tests.csproj
+++ b/Tests/Tests.csproj
@@ -81,6 +81,7 @@
<Compile Include="DB\TestStorage.cs" />
<Compile Include="Services\TestTemplatesService.cs" />
<Compile Include="Services\TestRenderingJobsManager.cs" />
+ <Compile Include="Core\Store\Playlists\TestPlaylistPlayElement.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LongoMatch.Core\LongoMatch.Core.csproj">
@@ -107,5 +108,6 @@
<Folder Include="Core\Store\Templates\" />
<Folder Include="Services\" />
<Folder Include="DB\" />
+ <Folder Include="Core\Store\Playlists\" />
</ItemGroup>
</Project>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]