[longomatch] Handle devices returning caps templates
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Handle devices returning caps templates
- Date: Thu, 12 Feb 2015 00:45:59 +0000 (UTC)
commit 64f6edd3e566328e76f957b9ed16472f99ba9830
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Thu Feb 12 01:45:24 2015 +0100
Handle devices returning caps templates
LongoMatch.Core/Common/Device.cs | 3 +++
libcesarplayer/gst-camera-capturer.c | 12 +++++++-----
libcesarplayer/lgm-device.c | 18 ++++++++++++++++--
3 files changed, 26 insertions(+), 7 deletions(-)
---
diff --git a/LongoMatch.Core/Common/Device.cs b/LongoMatch.Core/Common/Device.cs
index 1f8c704..3fb7d98 100644
--- a/LongoMatch.Core/Common/Device.cs
+++ b/LongoMatch.Core/Common/Device.cs
@@ -74,6 +74,9 @@ namespace LongoMatch.Core.Common
public override string ToString ()
{
+ if (width == 0 && height == 0 && fps_n == 0 && fps_d == 0) {
+ return Catalog.GetString ("Default");
+ }
return string.Format ("{0}x{1} {2}fps", width, height,
((double)fps_n/fps_d).ToString ("#.##"));
}
diff --git a/libcesarplayer/gst-camera-capturer.c b/libcesarplayer/gst-camera-capturer.c
index de11fcc..cc216c9 100644
--- a/libcesarplayer/gst-camera-capturer.c
+++ b/libcesarplayer/gst-camera-capturer.c
@@ -848,12 +848,14 @@ gst_camera_capturer_source_caps (GstCameraCapturer *gcc)
caps = gst_caps_from_string ("video/x-raw-yuv;video/x-raw-rgb;"
"video/x-dv, systemstream=true");
- if (gcc->priv->source_width == 0 && gcc->priv->source_height == 0) {
- return caps;
+ if (gcc->priv->source_width != 0 && gcc->priv->source_height != 0) {
+ gst_caps_set_simple (caps, "width", G_TYPE_INT, gcc->priv->source_width,
+ "height", G_TYPE_INT, gcc->priv->source_height, NULL);
+ }
+ if (gcc->priv->source_fps_n != 0 && gcc->priv->source_fps_d != 0) {
+ gst_caps_set_simple (caps, "framerate", GST_TYPE_FRACTION,
+ gcc->priv->source_fps_n, gcc->priv->source_fps_d, NULL);
}
- gst_caps_set_simple (caps, "width", G_TYPE_INT, gcc->priv->source_width,
- "height", G_TYPE_INT, gcc->priv->source_height, "framerate",
- GST_TYPE_FRACTION, gcc->priv->source_fps_n, gcc->priv->source_fps_d, NULL);
caps_str = gst_caps_to_string (caps);
GST_INFO_OBJECT (gcc, "Source caps configured to: %s", caps_str);
g_free (caps_str);
diff --git a/libcesarplayer/lgm-device.c b/libcesarplayer/lgm-device.c
index 0582c26..fab67e7 100644
--- a/libcesarplayer/lgm-device.c
+++ b/libcesarplayer/lgm-device.c
@@ -144,6 +144,11 @@ lgm_device_fixate_int_value (const GValue *val)
} else {
ret = g_value_get_int (val);
}
+
+ /* For sources returning template caps set width and height to 0 */
+ if (ret == 1) {
+ ret = 0;
+ }
return ret;
}
@@ -157,6 +162,9 @@ lgm_device_add_format (GHashTable *table, int width, int height,
fps_n = gst_value_get_fraction_numerator (val);
fps_d = gst_value_get_fraction_denominator (val);
+ if (fps_n == 0) {
+ fps_d = 0;
+ }
format = lgm_device_video_format_new (width, height, fps_n, fps_d);
format_str = lgm_device_video_format_to_string (format);
if (!g_hash_table_contains(table, format_str)) {
@@ -186,10 +194,16 @@ lgm_device_parse_structure (GstStructure *s, GHashTable *table)
if (G_VALUE_TYPE (val) == GST_TYPE_FRACTION) {
lgm_device_add_format (table, width, height, val);
} else if (G_VALUE_TYPE (val) == GST_TYPE_FRACTION_RANGE) {
+ GValue *fr_val;
+
lgm_device_add_format (table, width, height,
gst_value_get_fraction_range_min (val));
- lgm_device_add_format (table, width, height,
- gst_value_get_fraction_range_max (val));
+ /* For sources returning template caps set framerate to 0/0 */
+ fr_val = gst_value_get_fraction_range_min (val);
+ if (!gst_value_get_fraction_numerator (fr_val) == 0) {
+ lgm_device_add_format (table, width, height,
+ gst_value_get_fraction_range_max (val));
+ }
} else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
guint n, len;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]