[longomatch/livecapture2: 14/31] Use the new timer for live sources in the capturers
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch/livecapture2: 14/31] Use the new timer for live sources in the capturers
- Date: Mon, 3 May 2010 22:39:59 +0000 (UTC)
commit 089735a17a7dfcd5c68c24094917bf57d9301f1e
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Wed Mar 31 15:38:32 2010 +0200
Use the new timer for live sources in the capturers
CesarPlayer/Capturer/FakeCapturer.cs | 61 ++++++---------------
CesarPlayer/Capturer/GstCameraCapturer.cs | 30 +++++++----
CesarPlayer/CesarPlayer.mdp | 1 +
CesarPlayer/gtk-gui/LongoMatch.Gui.CapturerBin.cs | 12 ++--
4 files changed, 43 insertions(+), 61 deletions(-)
---
diff --git a/CesarPlayer/Capturer/FakeCapturer.cs b/CesarPlayer/Capturer/FakeCapturer.cs
index 93f4ea6..91e456f 100644
--- a/CesarPlayer/Capturer/FakeCapturer.cs
+++ b/CesarPlayer/Capturer/FakeCapturer.cs
@@ -29,42 +29,20 @@ namespace LongoMatch.Video.Capturer
{
public event EllpasedTimeHandler EllapsedTime;
- private DateTime lastStart;
- private TimeSpan ellapsed;
- private bool playing;
- private bool started;
- private uint timerID;
+ private LiveSourceTimer timer;
- public FakeCapturer()
+ public FakeCapturer(): base ()
{
- lastStart = DateTime.Now;
- ellapsed = new TimeSpan(0,0,0);
- playing = false;
- started = false;
+ timer = new LiveSourceTimer();
+ timer.EllapsedTime += delegate(int ellapsedTime) {
+ if (EllapsedTime!= null)
+ EllapsedTime(ellapsedTime);
+ };
}
public int CurrentTime{
get{
- if (!started)
- return 0;
- else if (playing)
- return (int)(ellapsed + (DateTime.Now - lastStart)).TotalMilliseconds;
- else
- return (int)ellapsed.TotalMilliseconds;
- }
- }
-
- public void TogglePause(){
- if (!started)
- return;
-
- if (playing){
- playing = false;
- ellapsed += DateTime.Now - lastStart;
- }
- else{
- playing = true;
- lastStart = DateTime.Now;
+ return timer.CurrentTime;
}
}
@@ -72,12 +50,17 @@ namespace LongoMatch.Video.Capturer
}
public void Start(){
- timerID = GLib.Timeout.Add(100, OnTick);
- lastStart = DateTime.Now;
- playing = true;
- started = true;
+ timer.Start();
}
+ public void Stop(){
+ timer.Stop();
+ }
+
+ public void TogglePause(){
+ timer.TogglePause();
+ }
+
public uint OutputWidth {
get{return 0;}
set{}
@@ -101,10 +84,6 @@ namespace LongoMatch.Video.Capturer
public uint AudioBitrate {
get {return 0;}
set {}
- }
-
- public void Stop(){
- GLib.Source.Remove(timerID);
}
public bool SetVideoEncoder(LongoMatch.Video.Capturer.GccVideoEncoderType type){
@@ -118,11 +97,5 @@ namespace LongoMatch.Video.Capturer
public bool SetVideoMuxer(LongoMatch.Video.Capturer.GccVideoMuxerType type){
return true;
}
-
- protected virtual bool OnTick(){
- if (EllapsedTime != null)
- EllapsedTime(CurrentTime);
- return true;
- }
}
}
diff --git a/CesarPlayer/Capturer/GstCameraCapturer.cs b/CesarPlayer/Capturer/GstCameraCapturer.cs
index 5fa1880..0938a22 100644
--- a/CesarPlayer/Capturer/GstCameraCapturer.cs
+++ b/CesarPlayer/Capturer/GstCameraCapturer.cs
@@ -27,6 +27,8 @@ namespace LongoMatch.Video.Capturer {
public class GstCameraCapturer : Gtk.HBox, LongoMatch.Video.Capturer.ICapturer {
public event EllpasedTimeHandler EllapsedTime;
+
+ private LiveSourceTimer timer;
[Obsolete]
protected GstCameraCapturer(GLib.GType gtype) : base(gtype) {}
@@ -43,6 +45,12 @@ namespace LongoMatch.Video.Capturer {
IntPtr error = IntPtr.Zero;
Raw = gst_camera_capturer_new(GLib.Marshaller.StringToPtrGStrdup(filename), out error);
if (error != IntPtr.Zero) throw new GLib.GException (error);
+
+ timer = new LiveSourceTimer();
+ timer.EllapsedTime += delegate(int ellapsedTime) {
+ if (EllapsedTime!= null)
+ EllapsedTime(ellapsedTime);
+ };
}
[GLib.Property ("output_height")]
@@ -249,6 +257,7 @@ namespace LongoMatch.Video.Capturer {
static extern void gst_camera_capturer_stop(IntPtr raw);
public void Stop() {
+ timer.Stop();
gst_camera_capturer_stop(Handle);
}
@@ -257,13 +266,21 @@ namespace LongoMatch.Video.Capturer {
static extern void gst_camera_capturer_toggle_pause(IntPtr raw);
public void TogglePause() {
+ timer.TogglePause();
gst_camera_capturer_toggle_pause(Handle);
}
-
+
+ public int CurrentTime{
+ get{
+ return timer.CurrentTime;
+ }
+ }
+
[DllImport("libcesarplayer.dll")]
static extern void gst_camera_capturer_start(IntPtr raw);
- public void Start () {
+ public void Start() {
+ timer.Start();
gst_camera_capturer_start(Handle);
}
@@ -310,15 +327,6 @@ namespace LongoMatch.Video.Capturer {
}
[DllImport("libcesarplayer.dll")]
- static extern int gst_camera_capturer_get_current_time(IntPtr raw);
-
- public int CurrentTime{
- get{
- return gst_camera_capturer_get_current_time(Handle);
- }
- }
-
- [DllImport("libcesarplayer.dll")]
static extern IntPtr gst_camera_capturer_get_type();
public static new GLib.GType GType {
diff --git a/CesarPlayer/CesarPlayer.mdp b/CesarPlayer/CesarPlayer.mdp
index 61878a9..94f1183 100644
--- a/CesarPlayer/CesarPlayer.mdp
+++ b/CesarPlayer/CesarPlayer.mdp
@@ -78,6 +78,7 @@
<File name="Capturer/GccType.cs" subtype="Code" buildaction="Compile" />
<File name="gtk-gui/LongoMatch.Gui.CapturerBin.cs" subtype="Code" buildaction="Compile" />
<File name="Capturer/CaptureProperties.cs" subtype="Code" buildaction="Compile" />
+ <File name="Capturer/LiveSourceTimer.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
diff --git a/CesarPlayer/gtk-gui/LongoMatch.Gui.CapturerBin.cs b/CesarPlayer/gtk-gui/LongoMatch.Gui.CapturerBin.cs
index ffc5372..ab24958 100644
--- a/CesarPlayer/gtk-gui/LongoMatch.Gui.CapturerBin.cs
+++ b/CesarPlayer/gtk-gui/LongoMatch.Gui.CapturerBin.cs
@@ -92,14 +92,14 @@ namespace LongoMatch.Gui {
this.pausebutton.UseUnderline = true;
// Container child pausebutton.Gtk.Container+ContainerChild
Gtk.Alignment w12 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
- // Container child GtkAlignment.Gtk.Container+ContainerChild
+ // Container child GtkAlignment1.Gtk.Container+ContainerChild
Gtk.HBox w13 = new Gtk.HBox();
w13.Spacing = 2;
- // Container child GtkHBox.Gtk.Container+ContainerChild
+ // Container child GtkHBox1.Gtk.Container+ContainerChild
Gtk.Image w14 = new Gtk.Image();
w14.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-media-pause", Gtk.IconSize.Dialog, 48);
w13.Add(w14);
- // Container child GtkHBox.Gtk.Container+ContainerChild
+ // Container child GtkHBox1.Gtk.Container+ContainerChild
Gtk.Label w16 = new Gtk.Label();
w13.Add(w16);
w12.Add(w13);
@@ -116,14 +116,14 @@ namespace LongoMatch.Gui {
this.stopbutton.UseUnderline = true;
// Container child stopbutton.Gtk.Container+ContainerChild
Gtk.Alignment w21 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
- // Container child GtkAlignment.Gtk.Container+ContainerChild
+ // Container child GtkAlignment2.Gtk.Container+ContainerChild
Gtk.HBox w22 = new Gtk.HBox();
w22.Spacing = 2;
- // Container child GtkHBox.Gtk.Container+ContainerChild
+ // Container child GtkHBox2.Gtk.Container+ContainerChild
Gtk.Image w23 = new Gtk.Image();
w23.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-media-stop", Gtk.IconSize.Dialog, 48);
w22.Add(w23);
- // Container child GtkHBox.Gtk.Container+ContainerChild
+ // Container child GtkHBox2.Gtk.Container+ContainerChild
Gtk.Label w25 = new Gtk.Label();
w22.Add(w25);
w21.Add(w22);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]