cheese r710 - in branches/cheese-vala: . src
- From: jhaitsma svn gnome org
- To: svn-commits-list gnome org
- Subject: cheese r710 - in branches/cheese-vala: . src
- Date: Sat, 3 May 2008 22:19:45 +0100 (BST)
Author: jhaitsma
Date: Sat May 3 21:19:45 2008
New Revision: 710
URL: http://svn.gnome.org/viewvc/cheese?rev=710&view=rev
Log:
Woohoo, we can now obtain all webcams from HAL correctly
Modified:
branches/cheese-vala/ (props changed)
branches/cheese-vala/src/Makefile.am
branches/cheese-vala/src/cheese-webcam.vala
Modified: branches/cheese-vala/src/Makefile.am
==============================================================================
--- branches/cheese-vala/src/Makefile.am (original)
+++ branches/cheese-vala/src/Makefile.am Sat May 3 21:19:45 2008
@@ -42,7 +42,7 @@
$(cheese_VALASOURCES:.vala=.h)
cheese.vala.stamp: $(cheese_VALASOURCES)
- $(VALAC) -C $(VALA_CFLAGS) $^
+ $(VALAC) -C -g $(VALA_CFLAGS) $^
touch $@
cheese_LDADD = \
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 21:19:45 2008
@@ -158,8 +158,33 @@
public void setup () {
detect_webcam_devices ();
+ print_devices ();
}
+
+
+ void print_devices () {
+ int i = 0;
+ print ("Following devices have been detected\n");
+ foreach (Device d in devices) {
+ print ("Device %d\n", i);
+ i++;
+ print ("==============================\n");
+ print ("udi: %s\n", d.udi);
+ print ("device: %s\n", d.device);
+ print ("gstreamer_element_name: %s\n", d.gstreamer_element_name);
+ print ("product_name: %s\n", d.product_name);
+ foreach (VideoFormat format in d.video_format) {
+ print ("Resolution: %d x %d (%s)\n", format.width, format.height, format.mime_type);
+ print ("Frame rates: ");
+ foreach (FrameRate f in format.frame_rate) {
+ print ("%d/%d ", f.numerator, f.denominator);
+ }
+ print ("\n");
+ }
+ }
+ }
+
public void play () {
}
@@ -237,9 +262,48 @@
void get_supported_framerates (VideoFormat format, Structure structure) {
+ Value* frame_rates;
+ frame_rates = structure.get_value ("framerate");
+
+ if ((*frame_rates).holds (fraction_get_type ())) {
+ var frame_rate = new FrameRate ();
+ frame_rate.numerator = value_get_fraction_numerator (*frame_rates);
+ frame_rate.denominator = value_get_fraction_denominator (*frame_rates);
+ format.frame_rate.add (frame_rate);
+ } else if ((*frame_rates).holds (value_list_get_type ())) {
+ for (int i = 0; i < value_list_get_size (*frame_rates); i++) {
+ Value *f;
+ f = value_list_get_value (*frame_rates, i);
+ var frame_rate = new FrameRate ();
+ frame_rate.numerator = value_get_fraction_numerator (*f);
+ frame_rate.denominator = value_get_fraction_denominator (*f);
+ format.frame_rate.add (frame_rate);
+ }
+
+ } else if ((*frame_rates).holds (fraction_range_get_type ())) {
+ Value* fraction_range_min = value_get_fraction_range_min (*frame_rates);
+ int numerator_min = value_get_fraction_numerator (*fraction_range_min);
+ int denominator_min = value_get_fraction_denominator (*fraction_range_min);
+
+ Value* fraction_range_max = value_get_fraction_range_max (*frame_rates);
+ int numerator_max = value_get_fraction_numerator (*fraction_range_max);
+ int denominator_max = value_get_fraction_denominator (*fraction_range_max);
+ print ("FractionRange: %d/%d - %d/%d\n", numerator_min, denominator_min, numerator_max, denominator_max);
+
+ for (int i = numerator_min; i <= numerator_max; i++) {
+ for (int j = denominator_min; j <= denominator_max; j++) {
+ var frame_rate = new FrameRate ();
+ frame_rate.numerator = i;
+ frame_rate.denominator = j;
+ format.frame_rate.add (frame_rate);
+ }
+ }
+ } else {
+ critical ("GValue type %s, cannot be handled for framerates", (*frame_rates).type_name ());
+ }
}
-
+
void get_supported_video_formats (Device device, Caps caps) {
for (int i = 0; i < caps.get_size (); i++) {
@@ -253,19 +317,19 @@
if (!(structure.has_name ("video/x-raw-yuv") || structure.has_name ("video/x-raw-rgb"))) {
continue;
}
- Value* width;
- width = structure.get_value ("width");
+
+ Value* width = structure.get_value ("width");
Value* height = structure.get_value ("height");
if ((*width).holds (typeof (int))) {
- VideoFormat format = new VideoFormat ();
+ var format = new VideoFormat ();
format.mime_type = structure.get_name ();
structure.get_int ("width", out format.width);
- structure.get_int ("heigth", out format.height);
+ structure.get_int ("height", out format.height);
get_supported_framerates (format, structure);
- device.video_format.add (&format);
+ device.video_format.add (format);
} else if ((*width).holds (int_range_get_type ())) {
// FIXME: vala bug. int_range_get_type should have class
@@ -279,7 +343,7 @@
int cur_height = min_height;
while (cur_width < max_width && cur_height < max_height) {
- VideoFormat format = new VideoFormat ();
+ var format = new VideoFormat ();
format.mime_type = structure.get_name ();
format.width = cur_width;
@@ -294,7 +358,7 @@
cur_width = max_width;
cur_height = max_height;
while (cur_width > min_width && cur_height > min_height) {
- VideoFormat format;
+ var format = new VideoFormat ();
format.mime_type = structure.get_name ();
format.width = cur_width;
@@ -306,7 +370,7 @@
cur_height /= 2;
}
} else {
- critical ("GValue type %s, cannot be handled for resolution width".printf ((*width).type_name ()));
+ critical ("GValue type %s, cannot be handled for resolution width", ((*width).type_name ()));
}
}
}
@@ -359,15 +423,14 @@
warning ("parse_launch error: " + e.message);
}
i++;
- }
+ }
}
- void detect_webcam_devices () {
-/*
+ 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]