Linux video (v4l2) output drivers can support multiple TV norms, add a
parameter to the v4l2sink plugin to select one. Signed-off-by: Guennadi Liakhovetski <[hidden email]> --- Ok, I have no idea what's the patch submission procudure here, for now I just followed the one I'm familiar with - from the Linux kernel. Feel free to point me out to some doc. diff -u a/sys/v4l2/gstv4l2sink.c b/sys/v4l2/gstv4l2sink.c --- a/sys/v4l2/gstv4l2sink.c 2010-03-08 16:41:32.000000000 +0100 +++ b/sys/v4l2/gstv4l2sink.c 2010-03-10 19:44:29.000000000 +0100 @@ -75,6 +75,7 @@ PROP_OVERLAY_LEFT, PROP_OVERLAY_WIDTH, PROP_OVERLAY_HEIGHT, + PROP_TV_NORM, }; @@ -251,6 +252,11 @@ "The height of the video overlay; default is equal to negotiated image height", 0, 0xffffffff, 0, G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, PROP_TV_NORM, + g_param_spec_string ("tv-norm", "TV norm", + "One of NTSC-M, NTSC-J, NTSC-443, PAL-B, PAL-M, PAL-N", + "NTSC-M", G_PARAM_READWRITE)); + basesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_v4l2sink_get_caps); basesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_v4l2sink_set_caps); basesink_class->buffer_alloc = GST_DEBUG_FUNCPTR (gst_v4l2sink_buffer_alloc); @@ -280,6 +286,7 @@ v4l2sink->overlay_fields_set = 0; v4l2sink->state = 0; + v4l2sink->tv_norm = V4L2_STD_NTSC_M; } @@ -367,6 +374,7 @@ gst_v4l2sink_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { + const gchar *norm; GstV4l2Sink *v4l2sink = GST_V4L2SINK (object); if (!gst_v4l2_object_set_property_helper (v4l2sink->v4l2object, @@ -395,6 +403,23 @@ v4l2sink->overlay_fields_set |= OVERLAY_HEIGHT_SET; gst_v4l2sink_sync_overlay_fields (v4l2sink); break; + case PROP_TV_NORM: + norm = g_value_get_string (value); + if (strcmp (norm, "NTSC-M") == 0) + v4l2sink->tv_norm = V4L2_STD_NTSC_M; + else if (strcmp (norm, "NTSC-J") == 0) + v4l2sink->tv_norm = V4L2_STD_NTSC_M_JP; + else if (strcmp (norm, "NTSC-443") == 0) + v4l2sink->tv_norm = V4L2_STD_NTSC_443; + else if (strcmp (norm, "PAL-B") == 0) + v4l2sink->tv_norm = V4L2_STD_PAL_B; + else if (strcmp (norm, "PAL-M") == 0) + v4l2sink->tv_norm = V4L2_STD_PAL_M; + else if (strcmp (norm, "PAL-N") == 0) + v4l2sink->tv_norm = V4L2_STD_PAL_N; + else + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -427,6 +452,28 @@ case PROP_OVERLAY_HEIGHT: g_value_set_uint (value, v4l2sink->overlay.height); break; + case PROP_TV_NORM: + switch (v4l2sink->tv_norm) { + case V4L2_STD_NTSC_M: + g_value_set_string (value, "NTSC-M"); + break; + case V4L2_STD_NTSC_M_JP: + g_value_set_string (value, "NTSC-J"); + break; + case V4L2_STD_NTSC_443: + g_value_set_string (value, "NTSC-443"); + break; + case V4L2_STD_PAL_B: + g_value_set_string (value, "PAL-B"); + break; + case V4L2_STD_PAL_M: + g_value_set_string (value, "PAL-M"); + break; + case V4L2_STD_PAL_N: + g_value_set_string (value, "PAL-N"); + break; + } + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -591,6 +638,11 @@ return FALSE; } + if (!gst_v4l2_set_norm (v4l2sink->v4l2object, v4l2sink->tv_norm)) { + GST_DEBUG_OBJECT (v4l2sink, "unsupported TV norm %llx", v4l2sink->tv_norm); + return FALSE; + } + gst_v4l2sink_sync_overlay_fields (v4l2sink); v4l2sink->current_caps = gst_caps_ref (caps); diff -u a/sys/v4l2/gstv4l2sink.h b/sys/v4l2/gstv4l2sink.h --- a/sys/v4l2/gstv4l2sink.h 2009-11-20 10:59:46.000000000 +0100 +++ b/sys/v4l2/gstv4l2sink.h 2010-03-10 19:34:54.000000000 +0100 @@ -28,6 +28,7 @@ #include <gst/video/gstvideosink.h> #include <gstv4l2object.h> #include <gstv4l2bufferpool.h> +#include <linux/videodev2.h> GST_DEBUG_CATEGORY_EXTERN (v4l2sink_debug); @@ -72,6 +73,7 @@ guint8 overlay_fields_set; guint8 state; + v4l2_std_id tv_norm; }; struct _GstV4l2SinkClass { ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
Is there a reason why you didn't make that an enum?
Benjamin On Wed, 2010-03-10 at 20:04 +0100, Guennadi Liakhovetski wrote: > Linux video (v4l2) output drivers can support multiple TV norms, add a > parameter to the v4l2sink plugin to select one. > > Signed-off-by: Guennadi Liakhovetski <[hidden email]> > --- > Ok, I have no idea what's the patch submission procudure here, for now I > just followed the one I'm familiar with - from the Linux kernel. Feel free > to point me out to some doc. > > diff -u a/sys/v4l2/gstv4l2sink.c b/sys/v4l2/gstv4l2sink.c > --- a/sys/v4l2/gstv4l2sink.c 2010-03-08 16:41:32.000000000 +0100 > +++ b/sys/v4l2/gstv4l2sink.c 2010-03-10 19:44:29.000000000 +0100 > @@ -75,6 +75,7 @@ > PROP_OVERLAY_LEFT, > PROP_OVERLAY_WIDTH, > PROP_OVERLAY_HEIGHT, > + PROP_TV_NORM, > }; > > > @@ -251,6 +252,11 @@ > "The height of the video overlay; default is equal to negotiated image height", > 0, 0xffffffff, 0, G_PARAM_READWRITE)); > > + g_object_class_install_property (gobject_class, PROP_TV_NORM, > + g_param_spec_string ("tv-norm", "TV norm", > + "One of NTSC-M, NTSC-J, NTSC-443, PAL-B, PAL-M, PAL-N", > + "NTSC-M", G_PARAM_READWRITE)); > + > basesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_v4l2sink_get_caps); > basesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_v4l2sink_set_caps); > basesink_class->buffer_alloc = GST_DEBUG_FUNCPTR (gst_v4l2sink_buffer_alloc); > @@ -280,6 +286,7 @@ > > v4l2sink->overlay_fields_set = 0; > v4l2sink->state = 0; > + v4l2sink->tv_norm = V4L2_STD_NTSC_M; > } > > > @@ -367,6 +374,7 @@ > gst_v4l2sink_set_property (GObject * object, > guint prop_id, const GValue * value, GParamSpec * pspec) > { > + const gchar *norm; > GstV4l2Sink *v4l2sink = GST_V4L2SINK (object); > > if (!gst_v4l2_object_set_property_helper (v4l2sink->v4l2object, > @@ -395,6 +403,23 @@ > v4l2sink->overlay_fields_set |= OVERLAY_HEIGHT_SET; > gst_v4l2sink_sync_overlay_fields (v4l2sink); > break; > + case PROP_TV_NORM: > + norm = g_value_get_string (value); > + if (strcmp (norm, "NTSC-M") == 0) > + v4l2sink->tv_norm = V4L2_STD_NTSC_M; > + else if (strcmp (norm, "NTSC-J") == 0) > + v4l2sink->tv_norm = V4L2_STD_NTSC_M_JP; > + else if (strcmp (norm, "NTSC-443") == 0) > + v4l2sink->tv_norm = V4L2_STD_NTSC_443; > + else if (strcmp (norm, "PAL-B") == 0) > + v4l2sink->tv_norm = V4L2_STD_PAL_B; > + else if (strcmp (norm, "PAL-M") == 0) > + v4l2sink->tv_norm = V4L2_STD_PAL_M; > + else if (strcmp (norm, "PAL-N") == 0) > + v4l2sink->tv_norm = V4L2_STD_PAL_N; > + else > + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); > + break; > default: > G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); > break; > @@ -427,6 +452,28 @@ > case PROP_OVERLAY_HEIGHT: > g_value_set_uint (value, v4l2sink->overlay.height); > break; > + case PROP_TV_NORM: > + switch (v4l2sink->tv_norm) { > + case V4L2_STD_NTSC_M: > + g_value_set_string (value, "NTSC-M"); > + break; > + case V4L2_STD_NTSC_M_JP: > + g_value_set_string (value, "NTSC-J"); > + break; > + case V4L2_STD_NTSC_443: > + g_value_set_string (value, "NTSC-443"); > + break; > + case V4L2_STD_PAL_B: > + g_value_set_string (value, "PAL-B"); > + break; > + case V4L2_STD_PAL_M: > + g_value_set_string (value, "PAL-M"); > + break; > + case V4L2_STD_PAL_N: > + g_value_set_string (value, "PAL-N"); > + break; > + } > + break; > default: > G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); > break; > @@ -591,6 +638,11 @@ > return FALSE; > } > > + if (!gst_v4l2_set_norm (v4l2sink->v4l2object, v4l2sink->tv_norm)) { > + GST_DEBUG_OBJECT (v4l2sink, "unsupported TV norm %llx", v4l2sink->tv_norm); > + return FALSE; > + } > + > gst_v4l2sink_sync_overlay_fields (v4l2sink); > > v4l2sink->current_caps = gst_caps_ref (caps); > diff -u a/sys/v4l2/gstv4l2sink.h b/sys/v4l2/gstv4l2sink.h > --- a/sys/v4l2/gstv4l2sink.h 2009-11-20 10:59:46.000000000 +0100 > +++ b/sys/v4l2/gstv4l2sink.h 2010-03-10 19:34:54.000000000 +0100 > @@ -28,6 +28,7 @@ > #include <gst/video/gstvideosink.h> > #include <gstv4l2object.h> > #include <gstv4l2bufferpool.h> > +#include <linux/videodev2.h> > > GST_DEBUG_CATEGORY_EXTERN (v4l2sink_debug); > > @@ -72,6 +73,7 @@ > guint8 overlay_fields_set; > > guint8 state; > + v4l2_std_id tv_norm; > }; > > struct _GstV4l2SinkClass { > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > gstreamer-devel mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/gstreamer-devel ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
In reply to this post by Guennadi Liakhovetski
I agree that an enum would be a good idea (have a look at "flags" property.. search for GST_TYPE_V4L2_DEVICE_FLAGS in gstv4l2object.c for an example)
also.. I think it might be a good idea to put this property in gstv4l2object.c (see the install/get/set_property_helper functions).. so that both v4l2sink and v4l2src get the property. BR, -R On Mar 10, 2010, at 1:04 PM, Guennadi Liakhovetski wrote: > Linux video (v4l2) output drivers can support multiple TV norms, add a > parameter to the v4l2sink plugin to select one. > > Signed-off-by: Guennadi Liakhovetski <[hidden email]> > --- > Ok, I have no idea what's the patch submission procudure here, for now I > just followed the one I'm familiar with - from the Linux kernel. Feel free > to point me out to some doc. > > diff -u a/sys/v4l2/gstv4l2sink.c b/sys/v4l2/gstv4l2sink.c > --- a/sys/v4l2/gstv4l2sink.c 2010-03-08 16:41:32.000000000 +0100 > +++ b/sys/v4l2/gstv4l2sink.c 2010-03-10 19:44:29.000000000 +0100 > @@ -75,6 +75,7 @@ > PROP_OVERLAY_LEFT, > PROP_OVERLAY_WIDTH, > PROP_OVERLAY_HEIGHT, > + PROP_TV_NORM, > }; > > > @@ -251,6 +252,11 @@ > "The height of the video overlay; default is equal to negotiated image height", > 0, 0xffffffff, 0, G_PARAM_READWRITE)); > > + g_object_class_install_property (gobject_class, PROP_TV_NORM, > + g_param_spec_string ("tv-norm", "TV norm", > + "One of NTSC-M, NTSC-J, NTSC-443, PAL-B, PAL-M, PAL-N", > + "NTSC-M", G_PARAM_READWRITE)); > + > basesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_v4l2sink_get_caps); > basesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_v4l2sink_set_caps); > basesink_class->buffer_alloc = GST_DEBUG_FUNCPTR (gst_v4l2sink_buffer_alloc); > @@ -280,6 +286,7 @@ > > v4l2sink->overlay_fields_set = 0; > v4l2sink->state = 0; > + v4l2sink->tv_norm = V4L2_STD_NTSC_M; > } > > > @@ -367,6 +374,7 @@ > gst_v4l2sink_set_property (GObject * object, > guint prop_id, const GValue * value, GParamSpec * pspec) > { > + const gchar *norm; > GstV4l2Sink *v4l2sink = GST_V4L2SINK (object); > > if (!gst_v4l2_object_set_property_helper (v4l2sink->v4l2object, > @@ -395,6 +403,23 @@ > v4l2sink->overlay_fields_set |= OVERLAY_HEIGHT_SET; > gst_v4l2sink_sync_overlay_fields (v4l2sink); > break; > + case PROP_TV_NORM: > + norm = g_value_get_string (value); > + if (strcmp (norm, "NTSC-M") == 0) > + v4l2sink->tv_norm = V4L2_STD_NTSC_M; > + else if (strcmp (norm, "NTSC-J") == 0) > + v4l2sink->tv_norm = V4L2_STD_NTSC_M_JP; > + else if (strcmp (norm, "NTSC-443") == 0) > + v4l2sink->tv_norm = V4L2_STD_NTSC_443; > + else if (strcmp (norm, "PAL-B") == 0) > + v4l2sink->tv_norm = V4L2_STD_PAL_B; > + else if (strcmp (norm, "PAL-M") == 0) > + v4l2sink->tv_norm = V4L2_STD_PAL_M; > + else if (strcmp (norm, "PAL-N") == 0) > + v4l2sink->tv_norm = V4L2_STD_PAL_N; > + else > + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); > + break; > default: > G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); > break; > @@ -427,6 +452,28 @@ > case PROP_OVERLAY_HEIGHT: > g_value_set_uint (value, v4l2sink->overlay.height); > break; > + case PROP_TV_NORM: > + switch (v4l2sink->tv_norm) { > + case V4L2_STD_NTSC_M: > + g_value_set_string (value, "NTSC-M"); > + break; > + case V4L2_STD_NTSC_M_JP: > + g_value_set_string (value, "NTSC-J"); > + break; > + case V4L2_STD_NTSC_443: > + g_value_set_string (value, "NTSC-443"); > + break; > + case V4L2_STD_PAL_B: > + g_value_set_string (value, "PAL-B"); > + break; > + case V4L2_STD_PAL_M: > + g_value_set_string (value, "PAL-M"); > + break; > + case V4L2_STD_PAL_N: > + g_value_set_string (value, "PAL-N"); > + break; > + } > + break; > default: > G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); > break; > @@ -591,6 +638,11 @@ > return FALSE; > } > > + if (!gst_v4l2_set_norm (v4l2sink->v4l2object, v4l2sink->tv_norm)) { > + GST_DEBUG_OBJECT (v4l2sink, "unsupported TV norm %llx", v4l2sink->tv_norm); > + return FALSE; > + } > + > gst_v4l2sink_sync_overlay_fields (v4l2sink); > > v4l2sink->current_caps = gst_caps_ref (caps); > diff -u a/sys/v4l2/gstv4l2sink.h b/sys/v4l2/gstv4l2sink.h > --- a/sys/v4l2/gstv4l2sink.h 2009-11-20 10:59:46.000000000 +0100 > +++ b/sys/v4l2/gstv4l2sink.h 2010-03-10 19:34:54.000000000 +0100 > @@ -28,6 +28,7 @@ > #include <gst/video/gstvideosink.h> > #include <gstv4l2object.h> > #include <gstv4l2bufferpool.h> > +#include <linux/videodev2.h> > > GST_DEBUG_CATEGORY_EXTERN (v4l2sink_debug); > > @@ -72,6 +73,7 @@ > guint8 overlay_fields_set; > > guint8 state; > + v4l2_std_id tv_norm; > }; > > struct _GstV4l2SinkClass { ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
In reply to this post by Guennadi Liakhovetski
On Wed, 2010-03-10 at 20:04 +0100, Guennadi Liakhovetski wrote:
Hi, > Ok, I have no idea what's the patch submission procudure here, for now I > just followed the one I'm familiar with - from the Linux kernel. Feel free > to point me out to some doc. http://gstreamer.freedesktop.org/wiki/SubmittingPatches has some pointers. It would be great if you could put your patch into bugzilla so it's not forgotten about. Thanks! Cheers -Tim ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
In reply to this post by Clark, Rob
On Wed, 10 Mar 2010, Clark, Rob wrote:
> I agree that an enum would be a good idea (have a look at "flags" > property.. search for GST_TYPE_V4L2_DEVICE_FLAGS in gstv4l2object.c for > an example) ok, done that, but > also.. I think it might be a good idea to put this property in > gstv4l2object.c (see the install/get/set_property_helper functions).. > so that both v4l2sink and v4l2src get the property. there we get a conflict with the norm API for the tuner (see gst-plugins-base/gst-libs/gst/interfaces/tuner.c, etc.) gstv4l2object.c already contains some references to the tuner API, e.g., struct _GstV4l2Object already containse a gchar *norm; pointer under "properties", and indeed there is a PROP_NORM property in gst_v4l2_object_set_property_helper(), but it is commented out... I tried to find out who committed that code, but it goes back to sys/v4l2/gstv4l2element.c from the original CVS... So, what do we do? Delete dead code and start anew?... Thanks Guennadi --- Guennadi Liakhovetski, Ph.D. Freelance Open-Source Software Developer http://www.open-technology.de/ ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
In reply to this post by Guennadi Liakhovetski
Based on a patch by Guennadi Liakhovetski.
Note: I don't actually have a device supporting tuner, so I can't really test this myself. I'd appreciate if someone with a tuner device could give this a try. --- sys/v4l2/gstv4l2object.c | 70 +++++++++++++++++++++++++++++----------------- sys/v4l2/gstv4l2object.h | 5 ++- sys/v4l2/gstv4l2tuner.c | 23 ++++++++++++++- sys/v4l2/gstv4l2tuner.h | 5 +++ 4 files changed, 74 insertions(+), 29 deletions(-) diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c index 601cc51..f205cb6 100644 --- a/sys/v4l2/gstv4l2object.c +++ b/sys/v4l2/gstv4l2object.c @@ -49,7 +49,7 @@ GST_DEBUG_CATEGORY_EXTERN (v4l2_debug); #define DEFAULT_PROP_DEVICE_NAME NULL #define DEFAULT_PROP_DEVICE_FD -1 #define DEFAULT_PROP_FLAGS 0 -#define DEFAULT_PROP_NORM NULL +#define DEFAULT_PROP_TV_NORM 0 #define DEFAULT_PROP_CHANNEL NULL #define DEFAULT_PROP_FREQUENCY 0 @@ -309,6 +309,30 @@ gst_v4l2_device_get_type (void) return v4l2_device_type; } +#define GST_TYPE_V4L2_TV_NORM (gst_v4l2_tv_norm_get_type ()) +static GType +gst_v4l2_tv_norm_get_type (void) +{ + static GType v4l2_tv_norm = 0; + + if (!v4l2_tv_norm) { + static const GEnumValue tv_norms[] = { + {0, "none", "none"}, + {V4L2_STD_NTSC_M, "NTSC-M", "NTSC-M"}, + {V4L2_STD_NTSC_M_JP, "NTSC-J", "NTSC-J"}, + {V4L2_STD_NTSC_443, "NTSC-443", "NTSC-443"}, + {V4L2_STD_PAL_B, "PAL-B", "PAL-B"}, + {V4L2_STD_PAL_M, "PAL-M", "PAL-M"}, + {V4L2_STD_PAL_N, "PAL-N", "PAL-N"}, + {0, NULL, NULL}, + }; + + v4l2_tv_norm = g_enum_register_static ("V4L2_TV_norms", tv_norms); + } + + return v4l2_tv_norm; +} + void gst_v4l2_object_install_properties_helper (GObjectClass * gobject_class, const char *default_device) @@ -326,6 +350,11 @@ gst_v4l2_object_install_properties_helper (GObjectClass * gobject_class, g_object_class_install_property (gobject_class, PROP_FLAGS, g_param_spec_flags ("flags", "Flags", "Device type flags", GST_TYPE_V4L2_DEVICE_FLAGS, DEFAULT_PROP_FLAGS, G_PARAM_READABLE)); + g_object_class_install_property (gobject_class, PROP_TV_NORM, + g_param_spec_enum ("norm", "TV norm", + "video standard", + GST_TYPE_V4L2_TV_NORM, DEFAULT_PROP_TV_NORM, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); } GstV4l2Object * @@ -382,9 +411,6 @@ gst_v4l2_object_destroy (GstV4l2Object * v4l2object) if (v4l2object->channel) g_free (v4l2object->channel); - if (v4l2object->norm) - g_free (v4l2object->norm); - if (v4l2object->formats) { gst_v4l2_object_clear_format_list (v4l2object); } @@ -413,23 +439,10 @@ gst_v4l2_object_set_property_helper (GstV4l2Object * v4l2object, g_free (v4l2object->videodev); v4l2object->videodev = g_value_dup_string (value); break; -#if 0 - case PROP_NORM: - if (GST_V4L2_IS_OPEN (v4l2object)) { - GstTuner *tuner = GST_TUNER (v4l2object->element); - GstTunerNorm *norm = gst_tuner_find_norm_by_name (tuner, - (gchar *) g_value_get_string (value)); - - if (norm) { - /* like gst_tuner_set_norm (tuner, norm) - without g_object_notify */ - gst_v4l2_tuner_set_norm (v4l2object, norm); - } - } else { - g_free (v4l2object->norm); - v4l2object->norm = g_value_dup_string (value); - } + case PROP_TV_NORM: + v4l2object->tv_norm = g_value_get_enum (value); break; +#if 0 case PROP_CHANNEL: if (GST_V4L2_IS_OPEN (v4l2object)) { GstTuner *tuner = GST_TUNER (v4l2object->element); @@ -516,6 +529,9 @@ gst_v4l2_object_get_property_helper (GstV4l2Object * v4l2object, g_value_set_flags (value, flags); break; } + case PROP_TV_NORM: + g_value_set_enum (value, v4l2object->tv_norm); + break; default: return FALSE; break; @@ -535,16 +551,16 @@ gst_v4l2_set_defaults (GstV4l2Object * v4l2object) tuner = GST_TUNER (v4l2object->element); - if (v4l2object->norm) - norm = gst_tuner_find_norm_by_name (tuner, v4l2object->norm); + if (v4l2object->tv_norm) + norm = gst_v4l2_tuner_get_norm_by_std_id (v4l2object, v4l2object->tv_norm); if (norm) { gst_tuner_set_norm (tuner, norm); } else { norm = GST_TUNER_NORM (gst_tuner_get_norm (GST_TUNER (v4l2object->element))); if (norm) { - g_free (v4l2object->norm); - v4l2object->norm = g_strdup (norm->label); + v4l2object->tv_norm = + gst_v4l2_tuner_get_std_id_by_norm (v4l2object, norm); gst_tuner_norm_changed (tuner, norm); } } @@ -1729,13 +1745,15 @@ default_frame_sizes: } /* Since we can't get framerate directly, try to use the current norm */ - if (v4l2object->norm && v4l2object->norms) { + if (v4l2object->tv_norm && v4l2object->norms) { GList *norms; GstTunerNorm *norm; + GstTunerNorm *current = + gst_v4l2_tuner_get_norm_by_std_id (v4l2object, v4l2object->tv_norm); for (norms = v4l2object->norms; norms != NULL; norms = norms->next) { norm = (GstTunerNorm *) norms->data; - if (!strcmp (norm->label, v4l2object->norm)) + if (!strcmp (norm->label, current->label)) break; } /* If it's possible, set framerate to that (discrete) value */ diff --git a/sys/v4l2/gstv4l2object.h b/sys/v4l2/gstv4l2object.h index ba0799f..2b7761e 100644 --- a/sys/v4l2/gstv4l2object.h +++ b/sys/v4l2/gstv4l2object.h @@ -107,7 +107,7 @@ struct _GstV4l2Object { GList *channels; /* properties */ - gchar *norm; + v4l2_std_id tv_norm; gchar *channel; gulong frequency; @@ -132,7 +132,8 @@ GType gst_v4l2_object_get_type (void); PROP_DEVICE, \ PROP_DEVICE_NAME, \ PROP_DEVICE_FD, \ - PROP_FLAGS + PROP_FLAGS, \ + PROP_TV_NORM /* create/destroy */ GstV4l2Object * gst_v4l2_object_new (GstElement * element, diff --git a/sys/v4l2/gstv4l2tuner.c b/sys/v4l2/gstv4l2tuner.c index c5f8442..a805396 100644 --- a/sys/v4l2/gstv4l2tuner.c +++ b/sys/v4l2/gstv4l2tuner.c @@ -237,7 +237,6 @@ gst_v4l2_tuner_set_norm (GstV4l2Object * v4l2object, GstTunerNorm * norm) GstTunerNorm * gst_v4l2_tuner_get_norm (GstV4l2Object * v4l2object) { - GList *item; v4l2_std_id norm; /* assert that we're opened and that we're using a known item */ @@ -245,6 +244,14 @@ gst_v4l2_tuner_get_norm (GstV4l2Object * v4l2object) gst_v4l2_get_norm (v4l2object, &norm); + return gst_v4l2_tuner_get_norm_by_std_id (v4l2object, norm); +} + +GstTunerNorm * +gst_v4l2_tuner_get_norm_by_std_id (GstV4l2Object * v4l2object, v4l2_std_id norm) +{ + GList *item; + for (item = v4l2object->norms; item != NULL; item = item->next) { if (norm & GST_V4L2_TUNER_NORM (item->data)->index) return (GstTunerNorm *) item->data; @@ -253,6 +260,20 @@ gst_v4l2_tuner_get_norm (GstV4l2Object * v4l2object) return NULL; } +v4l2_std_id +gst_v4l2_tuner_get_std_id_by_norm (GstV4l2Object * v4l2object, + GstTunerNorm * norm) +{ + GList *item; + + for (item = v4l2object->norms; item != NULL; item = item->next) { + if (norm == GST_TUNER_NORM (item->data)) + return GST_V4L2_TUNER_NORM (item->data)->index; + } + + return 0; +} + void gst_v4l2_tuner_set_frequency_and_notify (GstV4l2Object * v4l2object, GstTunerChannel * channel, gulong frequency) diff --git a/sys/v4l2/gstv4l2tuner.h b/sys/v4l2/gstv4l2tuner.h index 5ec2b67..4c16ac4 100644 --- a/sys/v4l2/gstv4l2tuner.h +++ b/sys/v4l2/gstv4l2tuner.h @@ -94,6 +94,11 @@ void gst_v4l2_tuner_set_norm_and_notify (GstV4l2Object * v4l2o GstTunerNorm* gst_v4l2_tuner_get_norm (GstV4l2Object * v4l2object); gboolean gst_v4l2_tuner_set_norm (GstV4l2Object * v4l2object, GstTunerNorm * norm); +GstTunerNorm* gst_v4l2_tuner_get_norm_by_std_id (GstV4l2Object * v4l2object, + v4l2_std_id norm); +v4l2_std_id gst_v4l2_tuner_get_std_id_by_norm (GstV4l2Object * v4l2object, + GstTunerNorm * norm); + /* frequency */ void gst_v4l2_tuner_set_frequency_and_notify (GstV4l2Object * v4l2object, GstTunerChannel * channel, -- 1.6.6 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
On Sun, 21 Mar 2010, Rob Clark wrote:
> Based on a patch by Guennadi Liakhovetski. > > Note: I don't actually have a device supporting tuner, so I can't really > test this myself. I'd appreciate if someone with a tuner device could give > this a try. I'm afraid, this didn't work out of the box. I think, the actual call to gst_v4l2_set_norm() is missing. Attached my enum-based version of the patch for your reference. Thanks Guennadi --- Guennadi Liakhovetski, Ph.D. Freelance Open-Source Software Developer http://www.open-technology.de/ ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel gst-tvnorm-2.patch (6K) Download Attachment |
On Mar 23, 2010, at 1:20 PM, Guennadi Liakhovetski wrote: > (did you drop the list from CC on purpose?) > oh, opps.. my bad > On Tue, 23 Mar 2010, Clark, Rob wrote: > >> >> On Mar 23, 2010, at 12:17 PM, Guennadi Liakhovetski wrote: >> >>> On Sun, 21 Mar 2010, Rob Clark wrote: >>> >>>> Based on a patch by Guennadi Liakhovetski. >>>> >>>> Note: I don't actually have a device supporting tuner, so I can't really >>>> test this myself. I'd appreciate if someone with a tuner device could give >>>> this a try. >>> >>> I'm afraid, this didn't work out of the box. I think, the actual call to >>> gst_v4l2_set_norm() is missing. Attached my enum-based version of the >>> patch for your reference. >>> >> >> what I wonder, is if querying the supported formats of the driver is >> working.. if it doesn't end up in the list of supported GstTunerNorm's, >> then it won't be picked.. >> >> Since I can't really replicate, could you run w/ GST_DEBUG="*v4l2*:5" >> and send me the log? Thx > > Attached, but a question in the meantime - you're repeatedly referring to > "tuner," whereas G_STD and S_STD V4L2 ioctls are applicable not only to > tuners. Can it be, that gstreamer only wants to apply norm ioctl()s to > tners? I.e., to v4l2 devices, advertising tuner capability > (V4L2_CAP_TUNER)? Actually, as far as I can tell, it doesn't care about V4L2_CAP_TUNER... but it does care that that the element implements GstTuner interface, which I omitted to add to v4l2sink. I'll send an updated patch in a bit. BR, -R > >> >> >> BR, >> -R >> > Thanks > Guennadi > --- > Guennadi Liakhovetski, Ph.D. > Freelance Open-Source Software Developer > http://www.open-technology.de/<gst-norm.log.bz2> ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |