[longomatch] Add properties change the source type and the device id



commit 1d8e2243f07be5f84e3b93ded97a6a86b2f47b46
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sun May 30 16:00:19 2010 +0200

    Add properties change the source type and the device id

 CesarPlayer/Capturer/CaptureProperties.cs |    4 ++--
 CesarPlayer/Capturer/FakeCapturer.cs      |    9 +++++++++
 CesarPlayer/Capturer/GstCameraCapturer.cs |   15 +++++++++++++++
 CesarPlayer/Capturer/ICapturer.cs         |    7 +++++++
 CesarPlayer/Gui/CapturerBin.cs            |    6 ++++++
 libcesarplayer/src/gst-camera-capturer.c  |   29 +++++++++++++++++++++++++++++
 6 files changed, 68 insertions(+), 2 deletions(-)
---
diff --git a/CesarPlayer/Capturer/CaptureProperties.cs b/CesarPlayer/Capturer/CaptureProperties.cs
index 53e2b72..3030915 100644
--- a/CesarPlayer/Capturer/CaptureProperties.cs
+++ b/CesarPlayer/Capturer/CaptureProperties.cs
@@ -25,8 +25,8 @@ namespace LongoMatch.Video.Capturer
 	
 	public struct CapturePropertiesStruct
 	{
-		public string VideoDevice;
-		public string AudioDevice;
+		public CapturerType SourceType;
+		public string DeviceID;
 		public uint VideoBitrate;
 		public uint AudioBitrate;
 		public VideoEncoderType VideoEncoder;
diff --git a/CesarPlayer/Capturer/FakeCapturer.cs b/CesarPlayer/Capturer/FakeCapturer.cs
index fe81cdc..65fc574 100644
--- a/CesarPlayer/Capturer/FakeCapturer.cs
+++ b/CesarPlayer/Capturer/FakeCapturer.cs
@@ -95,6 +95,11 @@ namespace LongoMatch.Video.Capturer
 			get {return null;}
 		}
 		
+		public string DeviceID {
+			get {return "";}
+			set{}
+		}
+		
 		public bool SetVideoEncoder(VideoEncoderType type){
 			return true;
 		}
@@ -106,5 +111,9 @@ namespace LongoMatch.Video.Capturer
 		public bool SetVideoMuxer(VideoMuxerType type){
 			return true;
 		}
+		
+		public bool SetSource(CapturerType type){
+			return true;
+		}
 	}
 }
diff --git a/CesarPlayer/Capturer/GstCameraCapturer.cs b/CesarPlayer/Capturer/GstCameraCapturer.cs
index 62e9ef4..d494cec 100644
--- a/CesarPlayer/Capturer/GstCameraCapturer.cs
+++ b/CesarPlayer/Capturer/GstCameraCapturer.cs
@@ -127,6 +127,21 @@ namespace LongoMatch.Video.Capturer {
 				val.Dispose ();
 			}
 		}
+		
+		[GLib.Property ("device_id")]
+		public string DeviceID {
+			get {
+				GLib.Value val = GetProperty ("device_id");
+				string ret = (string) val;
+				val.Dispose ();
+				return ret;
+			}
+			set {
+				GLib.Value val = new GLib.Value(value);
+				SetProperty("device_id", val);
+				val.Dispose ();
+			}
+		}
 
 		[GLib.CDeclCallback]
 		delegate void ErrorSignalDelegate (IntPtr arg0, IntPtr arg1, IntPtr gch);
diff --git a/CesarPlayer/Capturer/ICapturer.cs b/CesarPlayer/Capturer/ICapturer.cs
index be9deae..6591745 100644
--- a/CesarPlayer/Capturer/ICapturer.cs
+++ b/CesarPlayer/Capturer/ICapturer.cs
@@ -64,12 +64,19 @@ namespace LongoMatch.Video.Capturer
 			get;
 		}
 		
+		string DeviceID {
+			set;
+			get;
+		}
+		
 		bool SetVideoEncoder(VideoEncoderType type);
 		
 		bool SetAudioEncoder(AudioEncoderType type);
 		
 		bool SetVideoMuxer(VideoMuxerType type);
 		
+		bool SetSource(CapturerType type);
+		
 		void TogglePause();
 		
 		void Start();
diff --git a/CesarPlayer/Gui/CapturerBin.cs b/CesarPlayer/Gui/CapturerBin.cs
index 98e9b9d..bd8489d 100644
--- a/CesarPlayer/Gui/CapturerBin.cs
+++ b/CesarPlayer/Gui/CapturerBin.cs
@@ -44,6 +44,8 @@ namespace LongoMatch.Gui
 		private uint outputHeight;
 		private uint videoBitrate;
 		private uint audioBitrate;
+		private CapturerType sourceType;
+		private string deviceID;
 		private VideoEncoderType  videoEncoder;
 		private AudioEncoderType audioEncoder;
 		private VideoMuxerType videoMuxer;
@@ -164,6 +166,8 @@ namespace LongoMatch.Gui
 				audioEncoder = value.AudioEncoder;
 				videoEncoder = value.VideoEncoder;
 				videoMuxer = value.Muxer;
+				sourceType = value.SourceType;
+				deviceID = value.DeviceID;
 			}
 		}
 		
@@ -247,6 +251,8 @@ namespace LongoMatch.Gui
 			capturer.SetVideoEncoder(videoEncoder);
 			capturer.SetAudioEncoder(audioEncoder);
 			capturer.SetVideoMuxer(videoMuxer);	
+			capturer.SetSource(sourceType);
+			capturer.DeviceID = deviceID;
 			capturer.VideoBitrate = videoBitrate;
 			capturer.AudioBitrate = audioBitrate;
 		}
diff --git a/libcesarplayer/src/gst-camera-capturer.c b/libcesarplayer/src/gst-camera-capturer.c
index aa21f71..c4a65b8 100644
--- a/libcesarplayer/src/gst-camera-capturer.c
+++ b/libcesarplayer/src/gst-camera-capturer.c
@@ -72,6 +72,7 @@ enum
   PROP_VIDEO_BITRATE,
   PROP_AUDIO_BITRATE,
   PROP_OUTPUT_FILE,
+  PROP_DEVICE_ID,
   PROP_WITH_AUDIO
 };
 
@@ -80,6 +81,7 @@ struct GstCameraCapturerPrivate
 
   /*Encoding properties */
   gchar *output_file;
+  gchar *device_id;
   guint output_height;
   guint output_width;
   guint output_fps_n;
@@ -262,6 +264,24 @@ gst_camera_capturer_set_output_file (GstCameraCapturer * gcc,
 
 }
 
+static void
+gst_camera_capturer_set_device_id (GstCameraCapturer * gcc,
+    const gchar * device_id)
+{
+  gcc->priv->device_id = g_strdup (device_id);
+#ifdef WIN32
+  /* On windows the source is always dshowvideosrc */
+  g_object_set (gcc->priv->videosrc, "device-name", device_id, NULL);
+#else
+  /* On linux it only makes sense to set the device id
+   * for the dv1394src element because the gconf one can be set 
+   * through gstreamer-properties */
+  if (gcc->priv->source_type == GST_CAMERA_CAPTURE_SOURCE_TYPE_DV)
+    g_object_set (gcc->priv->videosrc, "guid", device_id, NULL);
+#endif 
+  GST_INFO_OBJECT (gcc, "Changed device id/name to :\n%s", device_id);
+}
+
 /***********************************
 *           
 *           GTK Widget
@@ -705,6 +725,9 @@ gst_camera_capturer_set_property (GObject * object, guint property_id,
     case PROP_OUTPUT_FILE:
       gst_camera_capturer_set_output_file (gcc, g_value_get_string (value));
       break;
+    case PROP_DEVICE_ID:
+      gst_camera_capturer_set_device_id (gcc, g_value_get_string (value));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -735,6 +758,9 @@ gst_camera_capturer_get_property (GObject * object, guint property_id,
     case PROP_OUTPUT_FILE:
       g_value_set_string (value, gcc->priv->output_file);
       break;
+    case PROP_DEVICE_ID:
+      g_value_set_string (value, gcc->priv->device_id);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -783,6 +809,9 @@ gst_camera_capturer_class_init (GstCameraCapturerClass * klass)
   g_object_class_install_property (object_class, PROP_OUTPUT_FILE,
       g_param_spec_string ("output_file", NULL,
           NULL, FALSE, G_PARAM_READWRITE));
+  g_object_class_install_property (object_class, PROP_DEVICE_ID,
+      g_param_spec_string ("device_name", NULL,
+          NULL, FALSE, G_PARAM_READWRITE));
 
   /* Signals */
   gcc_signals[SIGNAL_ERROR] =



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