[longomatch/livecapture2: 31/31] Add an event listener for capturer errors



commit e56ba6d869aeb30cba4c441123af3edceb957079
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sun May 2 14:50:09 2010 +0200

    Add an event listener for capturer errors

 CesarPlayer/Capturer/FakeCapturer.cs            |    1 +
 CesarPlayer/Capturer/ICapturer.cs               |    1 +
 CesarPlayer/Gui/CapturerBin.cs                  |   13 +++++++++++--
 CesarPlayer/gtk-gui/objects.xml                 |    1 +
 LongoMatch/Gui/MainWindow.cs                    |    7 +++++++
 LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs |    3 ++-
 LongoMatch/gtk-gui/gui.stetic                   |    1 +
 7 files changed, 24 insertions(+), 3 deletions(-)
---
diff --git a/CesarPlayer/Capturer/FakeCapturer.cs b/CesarPlayer/Capturer/FakeCapturer.cs
index f074bb2..e340dde 100644
--- a/CesarPlayer/Capturer/FakeCapturer.cs
+++ b/CesarPlayer/Capturer/FakeCapturer.cs
@@ -29,6 +29,7 @@ namespace LongoMatch.Video.Capturer
 	public class FakeCapturer : Gtk.Bin, ICapturer
 	{
 		public event EllpasedTimeHandler EllapsedTime;
+		public event ErrorHandler Error;
 		
 		private LiveSourceTimer timer;
 		
diff --git a/CesarPlayer/Capturer/ICapturer.cs b/CesarPlayer/Capturer/ICapturer.cs
index 298d7a7..024aede 100644
--- a/CesarPlayer/Capturer/ICapturer.cs
+++ b/CesarPlayer/Capturer/ICapturer.cs
@@ -29,6 +29,7 @@ namespace LongoMatch.Video.Capturer
 	public interface ICapturer
 	{	
 		event EllpasedTimeHandler EllapsedTime;
+		event ErrorHandler Error;
 			
 		uint OutputWidth {
 			get ;
diff --git a/CesarPlayer/Gui/CapturerBin.cs b/CesarPlayer/Gui/CapturerBin.cs
index f47307b..dd85449 100644
--- a/CesarPlayer/Gui/CapturerBin.cs
+++ b/CesarPlayer/Gui/CapturerBin.cs
@@ -36,6 +36,7 @@ namespace LongoMatch.Gui
 	public partial class CapturerBin : Gtk.Bin
 	{
 		public event EventHandler CaptureFinished;
+		public event ErrorHandler Error;
 		
 		private Pixbuf logopix;
 		private uint outputWidth;
@@ -66,14 +67,16 @@ namespace LongoMatch.Gui
 		}		
 		
 		public CapturerType Type {
-			set{
-				if (capturer != null){
+			set {
+				if (capturer != null) {
+					capturer.Error -= OnError;
 					capturer.Stop();
 					capturerhbox.Remove(capturer as Gtk.Widget);
 				}
 				MultimediaFactory factory = new MultimediaFactory();
 				capturer = factory.getCapturer(value);	
 				capturer.EllapsedTime += OnTick;
+				capturer.Error += OnError;
 				if (value != CapturerType.FAKE){
 					capturerhbox.Add((Widget)capturer);
 					(capturer as Widget).Visible = true;
@@ -260,6 +263,12 @@ namespace LongoMatch.Gui
 			timelabel.Text = "Time: " + TimeString.MSecondsToSecondsString(CurrentTime);
 		}
 		
+		protected virtual void OnError (object o, ErrorArgs args)
+		{
+			if (Error != null)
+				Error (o, args);
+		}
+		
 		protected virtual void OnLogodrawingareaExposeEvent (object o, Gtk.ExposeEventArgs args)
 		{	
 			Gdk.Window win;
diff --git a/CesarPlayer/gtk-gui/objects.xml b/CesarPlayer/gtk-gui/objects.xml
index 603a329..935f280 100644
--- a/CesarPlayer/gtk-gui/objects.xml
+++ b/CesarPlayer/gtk-gui/objects.xml
@@ -4,6 +4,7 @@
     <signals>
       <itemgroup label="CapturerBin Signals">
         <signal name="CaptureFinished" />
+        <signal name="Error" />
       </itemgroup>
     </signals>
   </object>
diff --git a/LongoMatch/Gui/MainWindow.cs b/LongoMatch/Gui/MainWindow.cs
index b445778..8457714 100644
--- a/LongoMatch/Gui/MainWindow.cs
+++ b/LongoMatch/Gui/MainWindow.cs
@@ -546,6 +546,13 @@ namespace LongoMatch.Gui
 		{
 			CloseAndQuit();
 		}
+		
+		protected virtual void OnCapturerBinError (object o, LongoMatch.Video.Capturer.ErrorArgs args)
+		{
+			MessagePopup.PopupMessage(this, MessageType.Info,
+			                          Catalog.GetString("An error occured in the video capturer and the current project will be closed:")+"\n" +args.Message);
+			CloseOpenedProject(true);
+		}
 		#endregion	
 	}
 }
\ No newline at end of file
diff --git a/LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs b/LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs
index ed5048d..c968012 100644
--- a/LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs
+++ b/LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs
@@ -195,7 +195,7 @@ namespace LongoMatch.Gui {
             this.ImportProjectAction.ShortLabel = Mono.Unix.Catalog.GetString("_Import Project");
             w1.Add(this.ImportProjectAction, "<Control>i");
             this.FreeCaptureModeAction = new Gtk.RadioAction("FreeCaptureModeAction", Mono.Unix.Catalog.GetString("Free Capture Mode"), null, null, 0);
-            this.FreeCaptureModeAction.Group = this.AnalyzeModeAction.Group;
+            this.FreeCaptureModeAction.Group = this.CaptureModeAction.Group;
             this.FreeCaptureModeAction.Sensitive = false;
             this.FreeCaptureModeAction.ShortLabel = Mono.Unix.Catalog.GetString("Free Capture Mode");
             w1.Add(this.FreeCaptureModeAction, null);
@@ -448,6 +448,7 @@ namespace LongoMatch.Gui {
             this.treewidget1.TimeNodeSelected += new LongoMatch.Handlers.TimeNodeSelectedHandler(this.OnTimeNodeSelected);
             this.playerbin1.Error += new LongoMatch.Video.Handlers.ErrorHandler(this.OnPlayerbin1Error);
             this.playerbin1.SegmentClosedEvent += new LongoMatch.Video.Handlers.SegmentClosedHandler(this.OnSegmentClosedEvent);
+            this.capturerBin.Error += new LongoMatch.Video.Capturer.ErrorHandler(this.OnCapturerBinError);
             this.timelinewidget1.TimeNodeSelected += new LongoMatch.Handlers.TimeNodeSelectedHandler(this.OnTimeNodeSelected);
         }
     }
diff --git a/LongoMatch/gtk-gui/gui.stetic b/LongoMatch/gtk-gui/gui.stetic
index 58f5ab5..6b8f711 100644
--- a/LongoMatch/gtk-gui/gui.stetic
+++ b/LongoMatch/gtk-gui/gui.stetic
@@ -2145,6 +2145,7 @@
                           <widget class="LongoMatch.Gui.CapturerBin" id="capturerBin">
                             <property name="MemberName" />
                             <property name="Events">ButtonPressMask</property>
+                            <signal name="Error" handler="OnCapturerBinError" />
                           </widget>
                           <packing>
                             <property name="Position">2</property>



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