[longomatch] Handle video editor errors correctly



commit e419a35085de398913f5fc0dc745d60918d32271
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sun Dec 29 18:20:44 2013 +0100

    Handle video editor errors correctly

 .../Interfaces/Multimedia/IVideoEditor.cs          |    1 +
 LongoMatch.Multimedia/Editor/GstVideoSplitter.cs   |    7 ++++-
 .../Services/RenderingJobsManager.cs               |   28 +++++++++++--------
 3 files changed, 23 insertions(+), 13 deletions(-)
---
diff --git a/LongoMatch.Core/Interfaces/Multimedia/IVideoEditor.cs 
b/LongoMatch.Core/Interfaces/Multimedia/IVideoEditor.cs
index 6765e96..d830aae 100644
--- a/LongoMatch.Core/Interfaces/Multimedia/IVideoEditor.cs
+++ b/LongoMatch.Core/Interfaces/Multimedia/IVideoEditor.cs
@@ -29,6 +29,7 @@ namespace LongoMatch.Interfaces.Multimedia
        public interface IVideoEditor
        {
                event ProgressHandler Progress;
+               event ErrorHandler Error;
 
                EncodingSettings EncodingSettings{
                        set;
diff --git a/LongoMatch.Multimedia/Editor/GstVideoSplitter.cs 
b/LongoMatch.Multimedia/Editor/GstVideoSplitter.cs
index f15c297..d1fbaa8 100644
--- a/LongoMatch.Multimedia/Editor/GstVideoSplitter.cs
+++ b/LongoMatch.Multimedia/Editor/GstVideoSplitter.cs
@@ -36,6 +36,7 @@ namespace LongoMatch.Video.Editor {
                static extern unsafe IntPtr gst_video_editor_new(out IntPtr err);
 
                public event LongoMatch.Handlers.ProgressHandler Progress;
+               public event LongoMatch.Handlers.ErrorHandler Error;
 
                public unsafe GstVideoSplitter() : base(IntPtr.Zero)
                {
@@ -49,6 +50,10 @@ namespace LongoMatch.Video.Editor {
                                if(Progress!= null)
                                        Progress(args.Percent);
                        };
+                       InternalError += delegate(object o, ErrorArgs args) {
+                               if (Error != null)
+                                       Error (o, args.Message);
+                       };
                }
 
                #region GSignals
@@ -91,7 +96,7 @@ namespace LongoMatch.Video.Editor {
                }
 
                [GLib.Signal("error")]
-               public event ErrorHandler Error {
+               public event ErrorHandler InternalError {
                        add {
                                GLib.Signal sig = GLib.Signal.Lookup(this, "error", typeof(ErrorArgs));
                                sig.AddDelegate(value);
diff --git a/LongoMatch.Services/Services/RenderingJobsManager.cs 
b/LongoMatch.Services/Services/RenderingJobsManager.cs
index b8f3bac..d520637 100644
--- a/LongoMatch.Services/Services/RenderingJobsManager.cs
+++ b/LongoMatch.Services/Services/RenderingJobsManager.cs
@@ -114,6 +114,7 @@ namespace LongoMatch.Services
                        
                        if (job is EditionJob) {
                                videoEditor.Progress -= OnProgress;
+                               videoEditor.Error -= OnError;
                                videoEditor.Cancel();
                        } else {
                                videoConverter.Progress -= OnProgress;
@@ -158,17 +159,11 @@ namespace LongoMatch.Services
                        }
                }
 
-               void OnError (object o, string message)
-               {
-                       Log.Error("Error rendering job: ", currentJob.Name);
-                       guiToolkit.ErrorMessage(Catalog.GetString("An error has occurred in the video 
renderer.")
-                                               + " " + Catalog.GetString("Please, try again."));
-               }
-               
                private void LoadEditionJob(EditionJob job) {
                        videoEditor = multimediaToolkit.GetVideoEditor();
                        videoEditor.EncodingSettings = job.EncodingSettings;
                        videoEditor.Progress += OnProgress;
+                       videoEditor.Error += OnError;
                        
                        foreach(PlayListPlay segment in job.Playlist) {
                                if (!ProcessSegment(segment))
@@ -277,6 +272,14 @@ namespace LongoMatch.Services
                        } catch {}
                }
                
+               void HandleError () {
+                       Log.Debug ("Job finished with errors");
+                       guiToolkit.ErrorMessage(Catalog.GetString("An error has occurred in the video 
editor.")
+                                               +Catalog.GetString("Please, try again."));
+                       currentJob.State = JobState.Error;
+                       CloseAndNext();
+               }
+               
                private void MainLoopOnProgress (float progress) {
                        if(progress > (float)EditorState.START && progress <= (float)EditorState.FINISHED
                           && progress > stateBar.Fraction) {
@@ -309,14 +312,15 @@ namespace LongoMatch.Services
                        }
 
                        else if(progress == (float)EditorState.ERROR) {
-                               Log.Debug ("Job finished with errors");
-                               guiToolkit.ErrorMessage(Catalog.GetString("An error has occurred in the video 
editor.")
-                                                         +Catalog.GetString("Please, try again."));
-                               currentJob.State = JobState.Error;
-                               CloseAndNext();
+                               HandleError ();
                        }
                }
                
+               protected void OnError (object o, string message)
+               {
+                       HandleError ();
+               }
+               
                protected void OnProgress(float progress)
                {
                        MainLoopOnProgress (progress);


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