[longomatch] Add new plugin interface for file discovery



commit c9a7063c041cb478e811269029520192e1c48892
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Thu Jul 17 19:35:24 2014 +0200

    Add new plugin interface for file discovery

 .../Interfaces/Multimedia/IDiscoverer.cs           |   28 +++++++++++++++
 .../Interfaces/Multimedia/IMultimediaToolkit.cs    |    2 +-
 LongoMatch.Core/LongoMatch.Core.mdp                |    3 +-
 LongoMatch.Core/Makefile.am                        |    1 +
 LongoMatch.GUI/Gui/Dialog/VideoConversionTool.cs   |    4 +-
 LongoMatch.GUI/Gui/GUIToolkit.cs                   |    2 +-
 LongoMatch.Multimedia/LongoMatch.Multimedia.mdp    |    5 +--
 LongoMatch.Multimedia/Makefile.am                  |    3 +-
 .../{PreviewMediaFile.cs => GstDiscoverer.cs}      |    6 +--
 LongoMatch.Multimedia/Utils/IMetadataReader.cs     |   37 --------------------
 LongoMatch.Multimedia/Utils/MultimediaFactory.cs   |    9 ++++-
 LongoMatch.Services/Services/ProjectsManager.cs    |    2 +-
 12 files changed, 48 insertions(+), 54 deletions(-)
---
diff --git a/LongoMatch.Core/Interfaces/Multimedia/IDiscoverer.cs 
b/LongoMatch.Core/Interfaces/Multimedia/IDiscoverer.cs
new file mode 100644
index 0000000..5ca2ac1
--- /dev/null
+++ b/LongoMatch.Core/Interfaces/Multimedia/IDiscoverer.cs
@@ -0,0 +1,28 @@
+//
+//  Copyright (C) 2014 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 System;
+using LongoMatch.Store;
+
+namespace LongoMatch.Interfaces.Multimedia
+{
+       public interface IDiscoverer
+       {
+               MediaFile DiscoverFile (string filePath, bool takeScreenshot = true);
+       }
+}
+
diff --git a/LongoMatch.Core/Interfaces/Multimedia/IMultimediaToolkit.cs 
b/LongoMatch.Core/Interfaces/Multimedia/IMultimediaToolkit.cs
index 039ca2b..01da02b 100644
--- a/LongoMatch.Core/Interfaces/Multimedia/IMultimediaToolkit.cs
+++ b/LongoMatch.Core/Interfaces/Multimedia/IMultimediaToolkit.cs
@@ -39,7 +39,7 @@ namespace LongoMatch.Interfaces.Multimedia
                
                ICapturer GetCapturer(CapturerType type);
                
-               MediaFile DiscoverFile(string path);
+               MediaFile DiscoverFile(string path, bool takeScreenshot=true);
                
                List<Device> VideoDevices {get;}
                
diff --git a/LongoMatch.Core/LongoMatch.Core.mdp b/LongoMatch.Core/LongoMatch.Core.mdp
index a31d448..50f4144 100644
--- a/LongoMatch.Core/LongoMatch.Core.mdp
+++ b/LongoMatch.Core/LongoMatch.Core.mdp
@@ -140,6 +140,7 @@
     <File subtype="Code" buildaction="Compile" name="Store/PenaltyCardEvent.cs" />
     <File subtype="Code" buildaction="Compile" name="Store/Tag.cs" />
     <File subtype="Code" buildaction="Compile" name="Stats/SubCategoryStat.cs" />
+    <File subtype="Code" buildaction="Compile" name="Interfaces/Multimedia/IDiscoverer.cs" />
   </Contents>
   <References>
     <ProjectReference type="Package" localcopy="True" refto="System, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089" />
@@ -151,4 +152,4 @@
     <ProjectReference type="Package" localcopy="True" refto="System.Drawing, Version=4.0.0.0, 
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     <ProjectReference type="Package" localcopy="False" refto="Newtonsoft.Json, Version=5.0.0.0, 
Culture=neutral, PublicKeyToken=b9a188c8922137c6" />
   </References>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/LongoMatch.Core/Makefile.am b/LongoMatch.Core/Makefile.am
index d55fdf4..3f93ff2 100644
--- a/LongoMatch.Core/Makefile.am
+++ b/LongoMatch.Core/Makefile.am
@@ -53,6 +53,7 @@ SOURCES = Common/Area.cs \
        Interfaces/ITemplatesService.cs \
        Interfaces/ITimelineNode.cs \
        Interfaces/Multimedia/ICapturer.cs \
+       Interfaces/Multimedia/IDiscoverer.cs \
        Interfaces/Multimedia/IFramesCapturer.cs \
        Interfaces/Multimedia/IMultimediaToolkit.cs \
        Interfaces/Multimedia/IPlayer.cs \
diff --git a/LongoMatch.GUI/Gui/Dialog/VideoConversionTool.cs 
b/LongoMatch.GUI/Gui/Dialog/VideoConversionTool.cs
index f075b6b..b9ec6cc 100644
--- a/LongoMatch.GUI/Gui/Dialog/VideoConversionTool.cs
+++ b/LongoMatch.GUI/Gui/Dialog/VideoConversionTool.cs
@@ -66,7 +66,7 @@ namespace LongoMatch.Gui.Dialog
                        mediaFileCol.SetCellDataFunc(mediaFileCell, new TreeCellDataFunc(RenderMediaFile));
                        treeview1.AppendColumn(mediaFileCol);
                        
-                       store = new ListStore(typeof(PreviewMediaFile));
+                       store = new ListStore(typeof(MediaFile));
                        treeview1.Model = store;
                }
                
@@ -86,7 +86,7 @@ namespace LongoMatch.Gui.Dialog
                        List<string> errors = new List<string>();
                        foreach (string path in paths) {
                                try {
-                                       MediaFile file = PreviewMediaFile.DiscoverFile(path, false);
+                                       MediaFile file = Config.MultimediaToolkit.DiscoverFile(path, false);
                                        store.AppendValues (file);
                                        Files.Add (file);
                                } catch (Exception) {
diff --git a/LongoMatch.GUI/Gui/GUIToolkit.cs b/LongoMatch.GUI/Gui/GUIToolkit.cs
index 6d17248..e08d91a 100644
--- a/LongoMatch.GUI/Gui/GUIToolkit.cs
+++ b/LongoMatch.GUI/Gui/GUIToolkit.cs
@@ -309,7 +309,7 @@ namespace LongoMatch.Gui
                
                public string RemuxFile (string inputFile, string outputFile, VideoMuxerType muxer) {
                        Log.Information ("Remux file");
-                       Remuxer remuxer = new Remuxer (PreviewMediaFile.DiscoverFile(inputFile),
+                       Remuxer remuxer = new Remuxer (Config.MultimediaToolkit.DiscoverFile (inputFile),
                                                       outputFile, muxer);
                        return remuxer.Remux (mainWindow as Gtk.Window);
                }
diff --git a/LongoMatch.Multimedia/LongoMatch.Multimedia.mdp b/LongoMatch.Multimedia/LongoMatch.Multimedia.mdp
index af237a0..edf8883 100644
--- a/LongoMatch.Multimedia/LongoMatch.Multimedia.mdp
+++ b/LongoMatch.Multimedia/LongoMatch.Multimedia.mdp
@@ -25,8 +25,7 @@
     <File subtype="Code" buildaction="Compile" name="Capturer/LiveSourceTimer.cs" />
     <File subtype="Directory" buildaction="Compile" name="Utils" />
     <File subtype="Code" buildaction="Compile" name="Utils/TimeString.cs" />
-    <File subtype="Code" buildaction="Compile" name="Utils/IMetadataReader.cs" />
-    <File subtype="Code" buildaction="Compile" name="Utils/PreviewMediaFile.cs" />
+    <File subtype="Code" buildaction="Compile" name="Utils/GstDiscoverer.cs" />
     <File subtype="Directory" buildaction="Compile" name="Utils" />
     <File subtype="Directory" buildaction="Compile" name="Common" />
     <File subtype="Directory" buildaction="Compile" name="Common" />
@@ -67,4 +66,4 @@
     <ProjectReference type="Package" localcopy="True" refto="gtk-sharp, Version=2.12.0.0, Culture=neutral, 
PublicKeyToken=35e10195dab3c99f" />
     <ProjectReference type="Package" specificVersion="False" localcopy="False" refto="System.Core, 
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
   </References>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/LongoMatch.Multimedia/Makefile.am b/LongoMatch.Multimedia/Makefile.am
index 260786f..fc766e1 100644
--- a/LongoMatch.Multimedia/Makefile.am
+++ b/LongoMatch.Multimedia/Makefile.am
@@ -21,9 +21,8 @@ SOURCES = Capturer/FakeCapturer.cs \
        Remuxer/ObjectManager.cs \
        Utils/GStreamer.cs \
        Utils/GtkHelpers.cs \
-       Utils/IMetadataReader.cs \
+       Utils/GstDiscoverer.cs \
        Utils/MultimediaFactory.cs \
-       Utils/PreviewMediaFile.cs \
        Utils/Seeker.cs \
        Utils/TimeString.cs \
        Utils/VideoDevice.cs
diff --git a/LongoMatch.Multimedia/Utils/PreviewMediaFile.cs b/LongoMatch.Multimedia/Utils/GstDiscoverer.cs
similarity index 96%
rename from LongoMatch.Multimedia/Utils/PreviewMediaFile.cs
rename to LongoMatch.Multimedia/Utils/GstDiscoverer.cs
index 4f17229..7175ab3 100644
--- a/LongoMatch.Multimedia/Utils/PreviewMediaFile.cs
+++ b/LongoMatch.Multimedia/Utils/GstDiscoverer.cs
@@ -29,9 +29,7 @@ using GLib;
 
 namespace LongoMatch.Video.Utils
 {
-
-       [Serializable]
-       public class PreviewMediaFile
+       public class GstDiscoverer: IDiscoverer
        {
                const int THUMBNAIL_MAX_HEIGHT=72;
                const int THUMBNAIL_MAX_WIDTH=96;
@@ -46,7 +44,7 @@ namespace LongoMatch.Video.Utils
                                                           out IntPtr audio_codec,
                                                           out IntPtr err);
                
-               public static MediaFile DiscoverFile(string filePath, bool takeScreenshot = true) {
+               public MediaFile DiscoverFile (string filePath, bool takeScreenshot = true) {
                        long duration = 0;
                        uint width, height, fps_n, fps_d, par_n, par_d, ret, fps = 0;
                        string container, audio_codec, video_codec;
diff --git a/LongoMatch.Multimedia/Utils/MultimediaFactory.cs 
b/LongoMatch.Multimedia/Utils/MultimediaFactory.cs
index ebeae1d..e865daf 100644
--- a/LongoMatch.Multimedia/Utils/MultimediaFactory.cs
+++ b/LongoMatch.Multimedia/Utils/MultimediaFactory.cs
@@ -52,6 +52,7 @@ namespace LongoMatch.Video
                        Register (0, typeof (IVideoEditor), typeof (GstVideoSplitter));
                        Register (0, typeof (IRemuxer), typeof (GstRemuxer));
                        Register (0, typeof (ICapturer), typeof (GstCameraCapturer));
+                       Register (0, typeof (IDiscoverer), typeof (GstDiscoverer));
                }
                
                public void Register (int priority, Type interfac, Type elementType) {
@@ -77,6 +78,10 @@ namespace LongoMatch.Video
                        return GetDefaultElement<IVideoConverter> (typeof (IVideoConverter));
                }
 
+               public IDiscoverer GetDiscoverer () {
+                       return GetDefaultElement<IDiscoverer> (typeof (IDiscoverer));
+               }
+               
                public ICapturer GetCapturer(CapturerType type) {
                        switch(type) {
                        case CapturerType.Live:
@@ -98,8 +103,8 @@ namespace LongoMatch.Video
                        }
                }
                
-               public MediaFile DiscoverFile (string file) {
-                       return PreviewMediaFile.DiscoverFile(file);
+               public MediaFile DiscoverFile (string file, bool takeScreenshot = true) {
+                       return GetDiscoverer().DiscoverFile (file, takeScreenshot);
                }       
                
                public List<Device> VideoDevices {
diff --git a/LongoMatch.Services/Services/ProjectsManager.cs b/LongoMatch.Services/Services/ProjectsManager.cs
index dbca7c1..68e577d 100644
--- a/LongoMatch.Services/Services/ProjectsManager.cs
+++ b/LongoMatch.Services/Services/ProjectsManager.cs
@@ -145,7 +145,7 @@ namespace LongoMatch.Services
                                RemuxOutputFile (Capturer.CaptureSettings.EncodingSettings);
                        
                                Log.Debug("Reloading saved file: " + filePath);
-                               project.Description.File = multimediaToolkit.DiscoverFile(filePath);
+                               project.Description.File = multimediaToolkit.DiscoverFile (filePath);
                                DB.AddProject(project);
                        } catch(Exception ex) {
                                Log.Exception(ex);


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