[longomatch] Move the seeker to Core and remove GLib dep



commit 2fcb6839ff8df671af308378ba94d5e27fb15bb8
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Mon Mar 23 10:54:40 2015 +0100

    Move the seeker to Core and remove GLib dep

 LongoMatch.Core/Common/Enums.cs                    |    9 +++
 LongoMatch.Core/Common/Seeker.cs                   |   59 +++++++++++++++++
 LongoMatch.Core/Handlers/Multimedia.cs             |   14 ++---
 LongoMatch.Core/LongoMatch.Core.csproj             |    1 +
 LongoMatch.Multimedia/Common/Enum.cs               |    8 ---
 LongoMatch.Multimedia/Common/Handlers.cs           |    1 -
 LongoMatch.Multimedia/LongoMatch.Multimedia.csproj |    1 -
 LongoMatch.Multimedia/Utils/Seeker.cs              |   66 --------------------
 8 files changed, 74 insertions(+), 85 deletions(-)
---
diff --git a/LongoMatch.Core/Common/Enums.cs b/LongoMatch.Core/Common/Enums.cs
index b1f3208..4287e9c 100644
--- a/LongoMatch.Core/Common/Enums.cs
+++ b/LongoMatch.Core/Common/Enums.cs
@@ -403,6 +403,15 @@ namespace LongoMatch.Core.Common
                FitTimeline,
        }
 
+       public enum SeekType
+       {
+               Keyframe,
+               Accurate,
+               StepUp,
+               StepDown,
+               None
+       }
+
        public enum ProjectSortMethod
        {
                Name,
diff --git a/LongoMatch.Core/Common/Seeker.cs b/LongoMatch.Core/Common/Seeker.cs
new file mode 100644
index 0000000..ddbe91a
--- /dev/null
+++ b/LongoMatch.Core/Common/Seeker.cs
@@ -0,0 +1,59 @@
+using LongoMatch.Core.Store;
+using LongoMatch.Core.Handlers;
+using Timer = System.Threading.Timer;
+using System.Threading;
+
+namespace LongoMatch.Core.Common
+{
+       public class Seeker
+       {
+               public event SeekHandler SeekEvent;
+
+               uint timeout;
+               bool pendingSeek;
+               bool waiting;
+               Time start;
+               float rate;
+               SeekType seekType;
+               Timer timer;
+
+               public Seeker (uint timeoutMS = 80)
+               {
+                       timeout = timeoutMS;
+                       pendingSeek = false;
+                       seekType = SeekType.None;
+                       timer = new Timer (HandleSeekTimeout);
+               }
+
+               public void Seek (SeekType seekType, Time start = null, float rate = 1)
+               {
+                       this.seekType = seekType;
+                       this.start = start;
+                       this.rate = rate;
+
+                       pendingSeek = true;
+                       if (waiting) {
+                               return;
+                       }
+
+                       HandleSeekTimeout (this);
+                       waiting = true;
+                       timer.Change (timeout, Timeout.Infinite);
+               }
+
+               void HandleSeekTimeout (object state)
+               {
+                       waiting = false;
+                       if (pendingSeek) {
+                               if (seekType != SeekType.None) {
+                                       if (SeekEvent != null) {
+                                               SeekEvent (seekType, start, rate);
+                                       }
+                                       seekType = SeekType.None;
+                               }
+                       }
+                       timer.Change (Timeout.Infinite, Timeout.Infinite);
+               }
+       }
+}
+
diff --git a/LongoMatch.Core/Handlers/Multimedia.cs b/LongoMatch.Core/Handlers/Multimedia.cs
index fc31a4d..143f7a3 100644
--- a/LongoMatch.Core/Handlers/Multimedia.cs
+++ b/LongoMatch.Core/Handlers/Multimedia.cs
@@ -37,7 +37,8 @@ namespace LongoMatch.Core.Handlers
        public delegate void EllpasedTimeHandler (Time ellapsedTime);
        public delegate void PlaybackRateChangedHandler (float rate);
        public delegate void PrepareLoadEventHandler (MediaFileSet fileset);
-       
+       public delegate void SeekHandler (SeekType type,Time start,float rate);
+
        public delegate void DeviceChangeHandler (int deviceID);
        public delegate void CaptureFinishedHandler (bool close);
        public delegate void ErrorHandler (string message);
@@ -48,12 +49,7 @@ namespace LongoMatch.Core.Handlers
        public delegate void MediaInfoHandler (int width,int height,int parN,int parD);
        public delegate void EosHandler ();
        public delegate void ReadyToSeekHandler ();
-
-       public delegate void LoadImageHander (Image image,FrameDrawing frameDrawing);
-
-       public delegate void ElementLoadedHandler (bool hasNext);
-
-       public delegate void ElementUnloadedHandler ();
-
-       public delegate void PARChangedHandler (float par);
+       public delegate void LoadDrawingsHandler (FrameDrawing frameDrawing);
+       public delegate void ElementLoadedHandler (object element,bool hasNext);
+       public delegate void PARChangedHandler (IntPtr windowHandle,float par);
 }
diff --git a/LongoMatch.Core/LongoMatch.Core.csproj b/LongoMatch.Core/LongoMatch.Core.csproj
index b7f56ae..f8b72a1 100644
--- a/LongoMatch.Core/LongoMatch.Core.csproj
+++ b/LongoMatch.Core/LongoMatch.Core.csproj
@@ -139,6 +139,7 @@
     <Compile Include="Store\Templates\Team.cs" />
     <Compile Include="Interfaces\IPlayerController.cs" />
     <Compile Include="Common\Registry.cs" />
+    <Compile Include="Common\Seeker.cs" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Common\" />
diff --git a/LongoMatch.Multimedia/Common/Enum.cs b/LongoMatch.Multimedia/Common/Enum.cs
index ce3a7ad..a581450 100644
--- a/LongoMatch.Multimedia/Common/Enum.cs
+++ b/LongoMatch.Multimedia/Common/Enum.cs
@@ -118,12 +118,4 @@ namespace LongoMatch.Video.Common
                Par,
        }
 
-       public enum SeekType
-       {
-               Keyframe,
-               Accurate,
-               StepUp,
-               StepDown,
-               None
-       }
 }
diff --git a/LongoMatch.Multimedia/Common/Handlers.cs b/LongoMatch.Multimedia/Common/Handlers.cs
index 82f790e..91e31fc 100644
--- a/LongoMatch.Multimedia/Common/Handlers.cs
+++ b/LongoMatch.Multimedia/Common/Handlers.cs
@@ -23,7 +23,6 @@ namespace LongoMatch.Video.Common
        public delegate void ProgressHandler (float progress);
        public delegate void FramesProgressHandler (int actual,int total,Image frame);
        public delegate void DrawFrameHandler (int time);
-       public delegate void SeekHandler (SeekType type,Time start,float rate);
        public delegate void GlibErrorHandler (object o,ErrorArgs args);
        public delegate void GlibPercentCompletedHandler (object o,PercentCompletedArgs args);
        public delegate void GlibStateChangeHandler (object o,StateChangeArgs args);
diff --git a/LongoMatch.Multimedia/LongoMatch.Multimedia.csproj 
b/LongoMatch.Multimedia/LongoMatch.Multimedia.csproj
index e549cfc..8dff6a0 100644
--- a/LongoMatch.Multimedia/LongoMatch.Multimedia.csproj
+++ b/LongoMatch.Multimedia/LongoMatch.Multimedia.csproj
@@ -44,7 +44,6 @@
     <Compile Include="Remuxer\ObjectManager.cs" />
     <Compile Include="Converter\GstVideoConverter.cs" />
     <Compile Include="Converter\ObjectManager.cs" />
-    <Compile Include="Utils\Seeker.cs" />
     <Compile Include="Utils\MultimediaFactory.cs" />
     <Compile Include="Player\GstPlayer.cs" />
     <Compile Include="Player\ObjectManager.cs" />


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