[chronojump] camera record and snapshot working



commit 662584719835459050bd141ba01b44d2a4c4dd56
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Feb 1 01:29:11 2011 +0100

    camera record and snapshot working

 CesarPlayer/Gui/CapturerBin.cs                    |   29 +++++++++++++--------
 CesarPlayer/MultimediaFactory.cs                  |    3 +-
 CesarPlayer/gtk-gui/LongoMatch.Gui.CapturerBin.cs |    2 +-
 src/gui/chronojump.cs                             |   26 ++++++++++++------
 4 files changed, 38 insertions(+), 22 deletions(-)
---
diff --git a/CesarPlayer/Gui/CapturerBin.cs b/CesarPlayer/Gui/CapturerBin.cs
index b858ec9..1b4f014 100644
--- a/CesarPlayer/Gui/CapturerBin.cs
+++ b/CesarPlayer/Gui/CapturerBin.cs
@@ -67,7 +67,6 @@ namespace LongoMatch.Gui
 		
 		public CapturerType Type {
 			set {
-				bool snapshot = value == CapturerType.Snapshot;
 				/* Close any previous instance of the capturer */
 				Close();
 
@@ -81,17 +80,11 @@ namespace LongoMatch.Gui
 					(capturer as Widget).Visible = true;
 					capturerhbox.Visible = true;
 					logodrawingarea.Visible = false;
-				} else if (value == CapturerType.Snapshot) {
-				}
-				else{
+                                } else{
 					logodrawingarea.Visible = true;
 					capturerhbox.Visible = false;
 				}
 				
-				recbutton.Visible = !snapshot;
-				pausebutton.Visible = !snapshot;
-				stopbutton.Visible = !snapshot;
-				snapshotbutton.Visible = snapshot;
 				
 				SetProperties();
 				capturerType = value;
@@ -135,9 +128,11 @@ namespace LongoMatch.Gui
 			
 			capturing = true;
 			captureStarted = true;
+				
 			recbutton.Visible = false;
 			pausebutton.Visible = true;
 			stopbutton.Visible = true;
+			
 			capturer.Start();
 		}
 		
@@ -159,8 +154,10 @@ namespace LongoMatch.Gui
 		}
 		
 		public void Run(){
-			if (capturer != null)
+			if (capturer != null) {
 				capturer.Run();
+				SetButtonsVisibility();
+			}
 		}
 
 		public void Close(){
@@ -238,6 +235,16 @@ namespace LongoMatch.Gui
 			capturer.VideoBitrate = captureProps.VideoBitrate;
 			capturer.AudioBitrate = captureProps.AudioBitrate;
 		}
+
+		private void SetButtonsVisibility() {
+			bool snapshot = capturerType == CapturerType.Snapshot;
+			recbutton.Visible = !snapshot;
+			pausebutton.Visible = !snapshot;
+			stopbutton.Visible = !snapshot;
+			snapshotbutton.Visible = snapshot;
+			timelabel.Visible = !snapshot;
+		}
+
 
 		protected virtual void OnRecbuttonClicked (object sender, System.EventArgs e)
 		{
@@ -310,7 +317,7 @@ namespace LongoMatch.Gui
 				                                     MessageType.Question, ButtonsType.Ok,
 				                                     Catalog.GetString("Device disconnected. " +
 				                                     	"The capture will be paused"));
-				md.Icon=Stetic.IconLoader.LoadIcon(md, "longomatch", Gtk.IconSize.Dialog, 48);
+				md.Icon=Stetic.IconLoader.LoadIcon(md, "longomatch", Gtk.IconSize.Dialog);
 				md.Run();
 				md.Destroy();			
 			} else {
@@ -319,7 +326,7 @@ namespace LongoMatch.Gui
 				                                     MessageType.Question, ButtonsType.YesNo,
 				                                     Catalog.GetString("Device reconnected." +
 				                                     	"Do you want to restart the capture?"));
-				md.Icon=Stetic.IconLoader.LoadIcon(md, "longomatch", Gtk.IconSize.Dialog, 48);
+				md.Icon=Stetic.IconLoader.LoadIcon(md, "longomatch", Gtk.IconSize.Dialog);
 				if (md.Run() == (int)ResponseType.Yes){
 					Console.WriteLine ("Accepted to toggle pause");
 					TogglePause();
diff --git a/CesarPlayer/MultimediaFactory.cs b/CesarPlayer/MultimediaFactory.cs
index a9712c1..9c15be5 100644
--- a/CesarPlayer/MultimediaFactory.cs
+++ b/CesarPlayer/MultimediaFactory.cs
@@ -98,6 +98,7 @@ namespace LongoMatch.Video
 					return new FakeCapturer();
 					
 				case CapturerType.Live:
+				case CapturerType.Snapshot:
 					return new GstCameraCapturer("test.avi");
 									
 				default:
@@ -105,4 +106,4 @@ namespace LongoMatch.Video
 			}			
 		}
 	}
-}
\ No newline at end of file
+}
diff --git a/CesarPlayer/gtk-gui/LongoMatch.Gui.CapturerBin.cs b/CesarPlayer/gtk-gui/LongoMatch.Gui.CapturerBin.cs
index f791c6c..e8b11f2 100644
--- a/CesarPlayer/gtk-gui/LongoMatch.Gui.CapturerBin.cs
+++ b/CesarPlayer/gtk-gui/LongoMatch.Gui.CapturerBin.cs
@@ -140,7 +140,7 @@ namespace LongoMatch.Gui
 			// Container child GtkHBox.Gtk.Container+ContainerChild
 			global::Gtk.Image w32 = new global::Gtk.Image ();
 			w32.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "stock_about", global::Gtk.IconSize.Button);
-			w31.Add (w32);
+			//w31.Add (w32);
 			// Container child GtkHBox.Gtk.Container+ContainerChild
 			global::Gtk.Label w34 = new global::Gtk.Label ();
 			w34.LabelProp = global::Mono.Unix.Catalog.GetString ("Take _snaphot");
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 3a3ce56..b224de3 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2167,23 +2167,31 @@ public class ChronoJumpWindow
 		Gtk.Window d = new Gtk.Window("Capturer");
 		d.Add(capturer);
 		d.ShowAll();
+		d.DeleteEvent += delegate(object sender, DeleteEventArgs e) {capturer.Close(); capturer.Dispose();};
 		capturer.Run();
 	}
 	
 	private void on_menuitem_camera_photo(object o, EventArgs args) {
-		string file = "/tmp/test_photo_chronojump_is_cooler.jpg";
-		GstCameraCapturer gst = new GstCameraCapturer(file);
-		gst.OutputWidth = 360;
-		gst.OutputHeight = 288;
-
-		gst.Run();
+		CapturerBin capturer = new CapturerBin();
+		CapturePropertiesStruct s = new CapturePropertiesStruct();
 
-		Pixbuf pixbuf;
-		pixbuf = gst.CurrentFrame;
+		s.CaptureSourceType = CaptureSourceType.Raw;
 
-		pixbuf.Save(file, "jpeg");
+		capturer.CaptureProperties = s;
+		capturer.Type = CapturerType.Snapshot;
+		capturer.Visible=true;
+		capturer.NewSnapshot += on_snapshot_done;
+		
+		Gtk.Window d = new Gtk.Window("Capturer");
+		d.Add(capturer);
+		d.ShowAll();
+		d.DeleteEvent += delegate(object sender, DeleteEventArgs e) {capturer.Close(); capturer.Dispose();};
+		capturer.Run();
 	}
 
+	private void on_snapshot_done(Pixbuf pixbuf) {
+		pixbuf.Save("/tmp/test-foto.jpg","jpeg");
+	}
 
 
 	/* ---------------------------------------------------------



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