gst_v4l2_object_clear_format_list (v4l2object);
}
+ if (v4l2object->probed_caps) {
+ gst_caps_unref (v4l2object->probed_caps);
+ }
+
g_free (v4l2object);
}
* Get the list of supported capture formats, a list of
* <code>struct v4l2_fmtdesc</code>.
*/
-GSList *
+static GSList *
gst_v4l2_object_get_format_list (GstV4l2Object * v4l2object)
{
if (!v4l2object->formats)
}
#endif
-GstCaps *
+static GstCaps *
gst_v4l2_object_probe_caps_for_format (GstV4l2Object * v4l2object,
guint32 pixelformat, const GstStructure * template)
{
return FALSE;
}
}
+
+GstCaps *
+gst_v4l2_object_get_caps (GstV4l2Object * v4l2object, GstCaps * filter)
+{
+ GstCaps *ret;
+ GSList *walk;
+ GSList *formats;
+
+ if (v4l2object->probed_caps == NULL) {
+ formats = gst_v4l2_object_get_format_list (v4l2object);
+
+ ret = gst_caps_new_empty ();
+
+ for (walk = formats; walk; walk = walk->next) {
+ struct v4l2_fmtdesc *format;
+ GstStructure *template;
+
+ format = (struct v4l2_fmtdesc *) walk->data;
+
+ template = gst_v4l2_object_v4l2fourcc_to_structure (format->pixelformat);
+
+ if (template) {
+ GstCaps *tmp;
+
+ tmp = gst_v4l2_object_probe_caps_for_format (v4l2object,
+ format->pixelformat, template);
+ if (tmp)
+ gst_caps_append (ret, tmp);
+
+ gst_structure_free (template);
+ } else {
+ GST_DEBUG_OBJECT (v4l2object->element, "unknown format %u",
+ format->pixelformat);
+ }
+ }
+ v4l2object->probed_caps = ret;
+ }
+
+ if (filter) {
+ ret = gst_caps_intersect_full (filter, v4l2object->probed_caps,
+ GST_CAPS_INTERSECT_FIRST);
+ } else {
+ ret = gst_caps_ref (v4l2object->probed_caps);
+ }
+
+ GST_INFO_OBJECT (v4l2object->element, "probed caps: %p", ret);
+ LOG_CAPS (v4l2object->element, ret);
+
+ return ret;
+}
/* lists... */
GSList *formats; /* list of available capture formats */
+ GstCaps *probed_caps;
GList *colors;
GList *norms;
GList ** klass_devices);
#endif
-GstCaps* gst_v4l2_object_probe_caps_for_format (GstV4l2Object *v4l2object, guint32 pixelformat,
- const GstStructure * template);
-
-GSList* gst_v4l2_object_get_format_list (GstV4l2Object *v4l2object);
-
GstCaps* gst_v4l2_object_get_all_caps (void);
GstStructure* gst_v4l2_object_v4l2fourcc_to_structure (guint32 fourcc);
gboolean gst_v4l2_object_copy (GstV4l2Object * v4l2object,
GstBuffer * dest, GstBuffer *src);
+GstCaps * gst_v4l2_object_get_caps (GstV4l2Object * v4l2object,
+ GstCaps * filter);
+
#define GST_IMPLEMENT_V4L2_PROBE_METHODS(Type_Class, interface_as_function) \
\
gst_v4l2sink_video_orientation_interface_init));
-static void gst_v4l2sink_dispose (GObject * object);
static void gst_v4l2sink_finalize (GstV4l2Sink * v4l2sink);
/* GObject methods: */
element_class = GST_ELEMENT_CLASS (klass);
basesink_class = GST_BASE_SINK_CLASS (klass);
- gobject_class->dispose = gst_v4l2sink_dispose;
gobject_class->finalize = (GObjectFinalizeFunc) gst_v4l2sink_finalize;
gobject_class->set_property = gst_v4l2sink_set_property;
gobject_class->get_property = gst_v4l2sink_get_property;
*/
g_object_set (v4l2sink, "device", "/dev/video1", NULL);
- v4l2sink->probed_caps = NULL;
-
v4l2sink->overlay_fields_set = 0;
v4l2sink->crop_fields_set = 0;
}
static void
-gst_v4l2sink_dispose (GObject * object)
-{
- GstV4l2Sink *v4l2sink = GST_V4L2SINK (object);
-
- if (v4l2sink->probed_caps) {
- gst_caps_unref (v4l2sink->probed_caps);
- }
-
- G_OBJECT_CLASS (parent_class)->dispose (object);
-}
-
-
-static void
gst_v4l2sink_finalize (GstV4l2Sink * v4l2sink)
{
gst_v4l2_object_destroy (v4l2sink->v4l2object);
gst_v4l2sink_get_caps (GstBaseSink * bsink, GstCaps * filter)
{
GstV4l2Sink *v4l2sink = GST_V4L2SINK (bsink);
- GstCaps *ret;
- GSList *walk;
- GSList *formats;
if (!GST_V4L2_IS_OPEN (v4l2sink->v4l2object)) {
/* FIXME: copy? */
return gst_pad_get_pad_template_caps (GST_BASE_SINK_PAD (v4l2sink));
}
- if (v4l2sink->probed_caps == NULL) {
- formats = gst_v4l2_object_get_format_list (v4l2sink->v4l2object);
-
- ret = gst_caps_new_empty ();
-
- for (walk = formats; walk; walk = walk->next) {
- struct v4l2_fmtdesc *format;
-
- GstStructure *template;
-
- format = (struct v4l2_fmtdesc *) walk->data;
-
- template = gst_v4l2_object_v4l2fourcc_to_structure (format->pixelformat);
-
- if (template) {
- GstCaps *tmp;
-
- tmp =
- gst_v4l2_object_probe_caps_for_format (v4l2sink->v4l2object,
- format->pixelformat, template);
- if (tmp)
- gst_caps_append (ret, tmp);
-
- gst_structure_free (template);
- } else {
- GST_DEBUG_OBJECT (v4l2sink, "unknown format %u", format->pixelformat);
- }
- }
- v4l2sink->probed_caps = ret;
- }
-
- if (filter) {
- ret =
- gst_caps_intersect_full (filter, v4l2sink->probed_caps,
- GST_CAPS_INTERSECT_FIRST);
- } else {
- ret = gst_caps_ref (v4l2sink->probed_caps);
- }
-
- GST_INFO_OBJECT (v4l2sink, "probed caps: %p", ret);
- LOG_CAPS (v4l2sink, ret);
- return ret;
+ return gst_v4l2_object_get_caps (v4l2sink->v4l2object, filter);
}
static gboolean
/*< private >*/
GstV4l2Object * v4l2object;
- GstCaps *probed_caps; /* all supported caps of underlying v4l2 device */
gint video_width, video_height; /* original (unscaled) video w/h */
G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_ORIENTATION,
gst_v4l2src_video_orientation_interface_init));
-static void gst_v4l2src_dispose (GObject * object);
static void gst_v4l2src_finalize (GstV4l2Src * v4l2src);
/* element methods */
basesrc_class = GST_BASE_SRC_CLASS (klass);
pushsrc_class = GST_PUSH_SRC_CLASS (klass);
- gobject_class->dispose = gst_v4l2src_dispose;
gobject_class->finalize = (GObjectFinalizeFunc) gst_v4l2src_finalize;
gobject_class->set_property = gst_v4l2src_set_property;
gobject_class->get_property = gst_v4l2src_get_property;
gst_base_src_set_live (GST_BASE_SRC (v4l2src), TRUE);
}
-static void
-gst_v4l2src_dispose (GObject * object)
-{
- GstV4l2Src *v4l2src = GST_V4L2SRC (object);
-
- if (v4l2src->probed_caps) {
- gst_caps_unref (v4l2src->probed_caps);
- }
-
- G_OBJECT_CLASS (parent_class)->dispose (object);
-}
-
static void
gst_v4l2src_finalize (GstV4l2Src * v4l2src)
{
GstV4l2Src *v4l2src;
GstV4l2Object *obj;
- GstCaps *ret;
- GSList *walk;
- GSList *formats;
v4l2src = GST_V4L2SRC (src);
obj = v4l2src->v4l2object;
return gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD (v4l2src));
}
- if (v4l2src->probed_caps)
- return gst_caps_ref (v4l2src->probed_caps);
-
- formats = gst_v4l2_object_get_format_list (obj);
-
- ret = gst_caps_new_empty ();
-
- for (walk = formats; walk; walk = walk->next) {
- struct v4l2_fmtdesc *format;
- GstStructure *template;
-
- format = (struct v4l2_fmtdesc *) walk->data;
-
- template = gst_v4l2_object_v4l2fourcc_to_structure (format->pixelformat);
-
- if (template) {
- GstCaps *tmp;
-
- tmp =
- gst_v4l2_object_probe_caps_for_format (obj,
- format->pixelformat, template);
- if (tmp)
- gst_caps_append (ret, tmp);
-
- gst_structure_free (template);
- } else {
- GST_DEBUG_OBJECT (v4l2src, "unknown format %u", format->pixelformat);
- }
- }
-
- v4l2src->probed_caps = gst_caps_ref (ret);
-
- GST_INFO_OBJECT (v4l2src, "probed caps: %" GST_PTR_FORMAT, ret);
-
- return ret;
+ return gst_v4l2_object_get_caps (obj, filter);
}
static gboolean
if (!gst_v4l2_object_close (obj))
return GST_STATE_CHANGE_FAILURE;
- if (v4l2src->probed_caps) {
- gst_caps_unref (v4l2src->probed_caps);
- v4l2src->probed_caps = NULL;
- }
break;
default:
break;
/*< private >*/
GstV4l2Object * v4l2object;
- /* pads */
- GstCaps *probed_caps;
-
guint64 offset;
GstClockTime ctrl_time;