cheese r709 - in branches/cheese-vala: . src
- From: jhaitsma svn gnome org
- To: svn-commits-list gnome org
- Subject: cheese r709 - in branches/cheese-vala: . src
- Date: Sat, 3 May 2008 15:17:03 +0100 (BST)
Author: jhaitsma
Date: Sat May 3 14:17:02 2008
New Revision: 709
URL: http://svn.gnome.org/viewvc/cheese?rev=709&view=rev
Log:
more webcam stuff
Modified:
branches/cheese-vala/ (props changed)
branches/cheese-vala/src/cheese-webcam.vala
Modified: branches/cheese-vala/src/cheese-webcam.vala
==============================================================================
--- branches/cheese-vala/src/cheese-webcam.vala (original)
+++ branches/cheese-vala/src/cheese-webcam.vala Sat May 3 14:17:02 2008
@@ -42,24 +42,32 @@
}
- public struct FrameRate {
+ public class FrameRate : GLib.Object {
public int numerator;
public int denominator;
}
- public struct VideoFormat {
- public string mimetype;
+ public class VideoFormat : GLib.Object {
+ public string mime_type;
public int width;
public int height;
- public FrameRate[] framerates;
+ public ArrayList<FrameRate> frame_rate;
+
+ construct {
+ frame_rate = new ArrayList<FrameRate> ();
+ }
}
- public struct Device {
+ public class Device : GLib.Object {
public string udi;
public string device;
public string gstreamer_element_name;
public string product_name;
- public VideoFormat[] video_format;
+ public ArrayList<VideoFormat> video_format;
+
+ construct {
+ video_format = new ArrayList<VideoFormat> ();
+ }
}
enum ColorSpace {
@@ -99,7 +107,7 @@
}
}
- Device[] devices;
+ ArrayList<Device> devices = new ArrayList<Device> ();
Pipeline pipeline;
Gst.Bus bus;
/* We build the active pipeline by linking the appropriate pipelines
@@ -167,8 +175,8 @@
public void take_photo (string filename) {
}
- public Device[] get_devices () {
- return null;
+ public ArrayList<Device> get_devices () {
+ return devices;
}
public void set_effect (Effect effect) {
@@ -216,34 +224,102 @@
if (dbus_error.is_set ())
throw new WebcamError.FAILED ("Error finding video4linux devices: %s: %s".printf (dbus_error.name, dbus_error.message));
- devices = new Device [udis.length];
-
for (int i = 0; i < udis.length; i++) {
- devices[i].udi=udis[i];
- devices[i].device = hal.device_get_property_string (udis[i], "video4linux.device", ref dbus_error);
+ var device = new Device ();
+ device.udi=udis[i];
+ device.device = hal.device_get_property_string (udis[i], "video4linux.device", ref dbus_error);
if (dbus_error.is_set ())
- throw new WebcamError.FAILED ("Error getting property string: %s: %s".printf (dbus_error.name, dbus_error.message));
+ throw new WebcamError.FAILED ("Error getting property string: %s: %s".printf (dbus_error.name, dbus_error.message));
+ devices.add (device);
}
}
- void get_supported_framerates () {
+ void get_supported_framerates (VideoFormat format, Structure structure) {
}
void get_supported_video_formats (Device device, Caps caps) {
-
+
+ for (int i = 0; i < caps.get_size (); i++) {
+ weak Structure structure;
+ structure = caps.get_structure (i);
+
+ /* only interested in raw formats; we don't want to end up using image/jpeg
+ * (or whatever else the cam may produce) since we won't be able to link
+ * that to ffmpegcolorspace or the effect plugins, which makes it rather
+ * useless (although we could plug a decoder of course) */
+ if (!(structure.has_name ("video/x-raw-yuv") || structure.has_name ("video/x-raw-rgb"))) {
+ continue;
+ }
+ Value* width;
+ width = structure.get_value ("width");
+ Value* height = structure.get_value ("height");
+
+ if ((*width).holds (typeof (int))) {
+ VideoFormat format = new VideoFormat ();
+
+ format.mime_type = structure.get_name ();
+ structure.get_int ("width", out format.width);
+ structure.get_int ("heigth", out format.height);
+ get_supported_framerates (format, structure);
+
+ device.video_format.add (&format);
+ } else if ((*width).holds (int_range_get_type ())) {
+ // FIXME: vala bug. int_range_get_type should have class
+
+ print ("width hold int_range type\n");
+ int min_width = value_get_int_range_min (*width);
+ int max_width = value_get_int_range_max (*width);
+ int min_height = value_get_int_range_min (*height);
+ int max_height = value_get_int_range_max (*height);
+
+ int cur_width = min_width;
+ int cur_height = min_height;
+
+ while (cur_width < max_width && cur_height < max_height) {
+ VideoFormat format = new VideoFormat ();
+
+ format.mime_type = structure.get_name ();
+ format.width = cur_width;
+ format.height = cur_height;
+ get_supported_framerates (format, structure);
+ device.video_format.add (format);
+
+ cur_width *= 2;
+ cur_height *= 2;
+ }
+
+ cur_width = max_width;
+ cur_height = max_height;
+ while (cur_width > min_width && cur_height > min_height) {
+ VideoFormat format;
+
+ format.mime_type = structure.get_name ();
+ format.width = cur_width;
+ format.height = cur_height;
+ get_supported_framerates (format, structure);
+ device.video_format.add (format);
+
+ cur_width /= 2;
+ cur_height /= 2;
+ }
+ } else {
+ critical ("GValue type %s, cannot be handled for resolution width".printf ((*width).type_name ()));
+ }
+ }
}
+
+ // FIXME: Move into get_webcam_device_data when local const are supported by vala
const string[] GSTREAMER_VIDEO_SOURCES = {
"v4l2src",
"v4lsrc"
};
void get_webcam_device_data (Device device) {
-
-
+
bool pipeline_works = false;
int i = 0;
while (!pipeline_works && (i < GSTREAMER_VIDEO_SOURCES.length)) {
@@ -278,22 +354,20 @@
get_supported_video_formats (device, caps);
}
pipeline.set_state (State.NULL);
- }
-
+ }
} catch (GLib.Error e) {
warning ("parse_launch error: " + e.message);
}
i++;
- }
-
+ }
}
void detect_webcam_devices () {
-
+/*
get_video_devices_from_hal ();
foreach (Device d in devices) {
get_webcam_device_data (d);
- }
+ } */
}
bool create_webcam_source_bin () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]