From 71b8a1f3929d973594996142d3548ab5d8e8da18 Mon Sep 17 00:00:00 2001 From: Young-Ho Cha Date: Sun, 7 Jan 2007 21:53:38 +0000 Subject: [PATCH] sys/xvimage/xvimagesink.c: Fixes : #390076. Original commit message from CVS: 2007-01-07 Julien MOUTTE * sys/xvimage/xvimagesink.c: (gst_xvimage_buffer_destroy), (gst_xvimage_buffer_finalize), (gst_xvimagesink_xvimage_new), (gst_xvimagesink_xvimage_put), (gst_lookup_xv_port_from_adaptor), (gst_xvimagesink_get_xv_support), (gst_xvimagesink_setcaps), (gst_xvimagesink_set_xwindow_id), (gst_xvimagesink_set_event_handling), (gst_xvimagesink_set_property), (gst_xvimagesink_get_property), (gst_xvimagesink_init), (gst_xvimagesink_class_init): Patch by : Young-Ho Cha Fixes : #390076. Add an adaptor property to select a specific XV adaptor. * sys/xvimage/xvimagesink.h: --- ChangeLog | 15 +++++++++ sys/xvimage/xvimagesink.c | 66 ++++++++++++++++++++++++++++----------- sys/xvimage/xvimagesink.h | 1 + 3 files changed, 64 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index b13b059844..8b5899f9e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2007-01-07 Julien MOUTTE + + * sys/xvimage/xvimagesink.c: (gst_xvimage_buffer_destroy), + (gst_xvimage_buffer_finalize), (gst_xvimagesink_xvimage_new), + (gst_xvimagesink_xvimage_put), (gst_lookup_xv_port_from_adaptor), + (gst_xvimagesink_get_xv_support), (gst_xvimagesink_setcaps), + (gst_xvimagesink_set_xwindow_id), + (gst_xvimagesink_set_event_handling), + (gst_xvimagesink_set_property), (gst_xvimagesink_get_property), + (gst_xvimagesink_init), (gst_xvimagesink_class_init): + Patch by : Young-Ho Cha + Fixes : #390076. + Add an adaptor property to select a specific XV adaptor. + * sys/xvimage/xvimagesink.h: + 2007-01-07 Julien MOUTTE * sys/ximage/ximagesink.c: (gst_ximage_buffer_finalize), diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c index 0fbfb57931..fe20e0db4b 100644 --- a/sys/xvimage/xvimagesink.c +++ b/sys/xvimage/xvimagesink.c @@ -189,7 +189,8 @@ enum ARG_SYNCHRONOUS, ARG_PIXEL_ASPECT_RATIO, ARG_FORCE_ASPECT_RATIO, - ARG_HANDLE_EVENTS + ARG_HANDLE_EVENTS, + ARG_ADAPTOR /* FILL ME */ }; @@ -1139,6 +1140,28 @@ gst_xvimagesink_handle_xevents (GstXvImageSink * xvimagesink) } } +static void +gst_lookup_xv_port_from_adaptor (GstXContext * xcontext, + XvAdaptorInfo * adaptors, int adaptor_no) +{ + gint j; + + /* Do we support XvImageMask ? */ + if (!(adaptors[adaptor_no].type & XvImageMask)) + return; + + /* We found such an adaptor, looking for an available port */ + for (j = 0; j < adaptors[adaptor_no].num_ports && !xcontext->xv_port_id; j++) { + /* We try to grab the port */ + if (Success == XvGrabPort (xcontext->disp, adaptors[adaptor_no].base_id + j, + 0)) { + xcontext->xv_port_id = adaptors[adaptor_no].base_id + j; + GST_DEBUG ("XV Adaptor %s with %ld ports", adaptors[adaptor_no].name, + adaptors[adaptor_no].num_ports); + } + } +} + /* This function generates a caps with all supported format by the first Xv grabable port we find. We store each one of the supported formats in a format list and append the format to a newly created caps that we return @@ -1182,27 +1205,24 @@ gst_xvimagesink_get_xv_support (GstXvImageSink * xvimagesink, GST_DEBUG ("Found %u XV adaptor(s)", nb_adaptors); - /* Now search for an adaptor that supports XvImageMask */ - for (i = 0; i < nb_adaptors && !xcontext->xv_port_id; i++) { - if (adaptors[i].type & XvImageMask) { - gint j; - - /* We found such an adaptor, looking for an available port */ - for (j = 0; j < adaptors[i].num_ports && !xcontext->xv_port_id; j++) { - /* We try to grab the port */ - if (Success == XvGrabPort (xcontext->disp, adaptors[i].base_id + j, 0)) { - xcontext->xv_port_id = adaptors[i].base_id + j; - } - } - } - - GST_DEBUG ("XV Adaptor %s with %ld ports", adaptors[i].name, - adaptors[i].num_ports); - + if (xvimagesink->adaptor_no >= 0 && xvimagesink->adaptor_no < nb_adaptors) { + /* Find xv port from user defined adaptor */ + gst_lookup_xv_port_from_adaptor (xcontext, adaptors, + xvimagesink->adaptor_no); } + + if (!xcontext->xv_port_id) { + /* Now search for an adaptor that supports XvImageMask */ + for (i = 0; i < nb_adaptors && !xcontext->xv_port_id; i++) { + gst_lookup_xv_port_from_adaptor (xcontext, adaptors, i); + xvimagesink->adaptor_no = i; + } + } + XvFreeAdaptorInfo (adaptors); if (!xcontext->xv_port_id) { + xvimagesink->adaptor_no = -1; GST_ELEMENT_ERROR (xvimagesink, RESOURCE, BUSY, ("Could not initialise Xv output"), ("No port available")); return NULL; @@ -2642,6 +2662,9 @@ gst_xvimagesink_set_property (GObject * object, guint prop_id, gst_xvimagesink_set_event_handling (GST_X_OVERLAY (xvimagesink), g_value_get_boolean (value)); break; + case ARG_ADAPTOR: + xvimagesink->adaptor_no = g_value_get_int (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -2687,6 +2710,9 @@ gst_xvimagesink_get_property (GObject * object, guint prop_id, case ARG_HANDLE_EVENTS: g_value_set_boolean (value, xvimagesink->handle_events); break; + case ARG_ADAPTOR: + g_value_set_int (value, xvimagesink->adaptor_no); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -2732,6 +2758,7 @@ static void gst_xvimagesink_init (GstXvImageSink * xvimagesink) { xvimagesink->display_name = NULL; + xvimagesink->adaptor_no = -1; xvimagesink->xcontext = NULL; xvimagesink->xwindow = NULL; xvimagesink->xvimage = NULL; @@ -2817,6 +2844,9 @@ gst_xvimagesink_class_init (GstXvImageSinkClass * klass) g_param_spec_boolean ("handle-events", "Handle XEvents", "When enabled, XEvents will be selected and handled", TRUE, G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, ARG_ADAPTOR, + g_param_spec_int ("adaptor", "Adaptor number", + "The number of the video adaptor", -1, 1000, 0, G_PARAM_READWRITE)); gobject_class->finalize = gst_xvimagesink_finalize; diff --git a/sys/xvimage/xvimagesink.h b/sys/xvimage/xvimagesink.h index 6872dc5ba6..88ad0a116a 100644 --- a/sys/xvimage/xvimagesink.h +++ b/sys/xvimage/xvimagesink.h @@ -225,6 +225,7 @@ struct _GstXvImageSink { GstVideoSink videosink; char *display_name; + gint adaptor_no; GstXContext *xcontext; GstXWindow *xwindow;