summaryrefslogtreecommitdiffstats
path: root/sys/v4l2
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2003-12-22 01:47:09 +0000
committerDavid Schleef <ds@schleef.org>2003-12-22 01:47:09 +0000
commitb144bc6c58979f49a6e8e04a04a65f771247297a (patch)
tree648bc437ca5562bc7c67224ad71ef90dfacc12d1 /sys/v4l2
parent2309d726b7b0c37dbd9c57c653e2053ec6258ac8 (diff)
downloadgst-plugins-bad-b144bc6c58979f49a6e8e04a04a65f771247297a.tar.gz
gst-plugins-bad-b144bc6c58979f49a6e8e04a04a65f771247297a.tar.bz2
gst-plugins-bad-b144bc6c58979f49a6e8e04a04a65f771247297a.zip
Merge CAPS branch
Original commit message from CVS: Merge CAPS branch
Diffstat (limited to 'sys/v4l2')
-rw-r--r--sys/v4l2/gstv4l2src.c228
-rw-r--r--sys/v4l2/gstv4l2src.h3
2 files changed, 86 insertions, 145 deletions
diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c
index cd98162f..b6e86b0a 100644
--- a/sys/v4l2/gstv4l2src.c
+++ b/sys/v4l2/gstv4l2src.c
@@ -62,29 +62,25 @@ static void gst_v4l2src_base_init (GstV4l2SrcClass *klass);
static void gst_v4l2src_init (GstV4l2Src *v4l2src);
/* signal functions */
-static void gst_v4l2src_open (GstElement *element,
- const gchar *device);
-static void gst_v4l2src_close (GstElement *element,
- const gchar *device);
-
-/* pad/info functions */
-static gboolean gst_v4l2src_src_convert (GstPad *pad,
- GstFormat src_format,
- gint64 src_value,
- GstFormat *dest_format,
- gint64 *dest_value);
-static gboolean gst_v4l2src_src_query (GstPad *pad,
- GstQueryType type,
- GstFormat *format,
- gint64 *value);
-
-/* buffer functions */
-static GstPadLinkReturn
- gst_v4l2src_srcconnect (GstPad *pad,
- GstCaps *caps);
-static GstCaps *gst_v4l2src_getcaps (GstPad *pad,
- GstCaps *caps);
-static GstData *gst_v4l2src_get (GstPad *pad);
+static void gst_v4l2src_open (GstElement *element,
+ const gchar *device);
+static void gst_v4l2src_close (GstElement *element,
+ const gchar *device);
+
+/* pad/buffer functions */
+static GstPadLinkReturn gst_v4l2src_srcconnect (GstPad *pad,
+ const GstCaps *caps);
+static GstCaps * gst_v4l2src_getcaps (GstPad *pad);
+static GstData * gst_v4l2src_get (GstPad *pad);
+static gboolean gst_v4l2src_src_convert (GstPad *pad,
+ GstFormat src_format,
+ gint64 src_value,
+ GstFormat *dest_format,
+ gint64 *dest_value);
+static gboolean gst_v4l2src_src_query (GstPad *pad,
+ GstQueryType type,
+ GstFormat *format,
+ gint64 *value);
/* get/set params */
static void gst_v4l2src_set_property (GObject *object,
@@ -104,16 +100,6 @@ static GstElementStateReturn
static void gst_v4l2src_set_clock (GstElement *element,
GstClock *clock);
-/* bufferpool functions */
-static GstBuffer *gst_v4l2src_buffer_new (GstBufferPool *pool,
- guint64 offset,
- guint size,
- gpointer user_data);
-static void gst_v4l2src_buffer_free (GstBufferPool *pool,
- GstBuffer *buf,
- gpointer user_data);
-
-
static GstPadTemplate *src_template;
static GstElementClass *parent_class = NULL;
@@ -240,12 +226,6 @@ gst_v4l2src_init (GstV4l2Src *v4l2src)
gst_pad_set_query_type_function (v4l2src->srcpad,
gst_v4l2src_get_query_types);
- v4l2src->bufferpool = gst_buffer_pool_new(NULL, NULL,
- gst_v4l2src_buffer_new,
- NULL,
- gst_v4l2src_buffer_free,
- v4l2src);
-
v4l2src->breq.count = 0;
v4l2src->formats = NULL;
@@ -386,21 +366,16 @@ gst_v4l2src_src_query (GstPad *pad,
}
-static GstCaps *
+static GstStructure *
gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc,
- GstPropsEntry *width,
- GstPropsEntry *height,
- GstPropsEntry *fps,
gboolean compressed)
{
- GstCaps *caps = NULL;
+ GstStructure *structure;
switch (fourcc) {
case V4L2_PIX_FMT_MJPEG: /* Motion-JPEG */
case V4L2_PIX_FMT_JPEG: /* JFIF JPEG */
- caps = GST_CAPS_NEW("v4l2src_caps",
- "video/x-jpeg",
- NULL);
+ structure = gst_structure_new ("video/x-jpeg", NULL);
break;
case V4L2_PIX_FMT_RGB332:
case V4L2_PIX_FMT_RGB555:
@@ -488,15 +463,14 @@ gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc,
break;
}
- caps = GST_CAPS_NEW("v4l2src_caps",
- "video/x-raw-rgb",
- "bpp", GST_PROPS_INT(bpp),
- "depth", GST_PROPS_INT(depth),
- "red_mask", GST_PROPS_INT(r_mask),
- "green_mask", GST_PROPS_INT(g_mask),
- "blue_mask", GST_PROPS_INT(b_mask),
- "endianness", GST_PROPS_INT(endianness),
- NULL);
+ structure = gst_structure_new ("video/x-raw-rgb",
+ "bpp", G_TYPE_INT, bpp,
+ "depth", G_TYPE_INT, depth,
+ "red_mask", G_TYPE_INT, r_mask,
+ "green_mask", G_TYPE_INT, g_mask,
+ "blue_mask", G_TYPE_INT, b_mask,
+ "endianness", G_TYPE_INT, endianness,
+ NULL);
break;
}
case V4L2_PIX_FMT_YUV420: /* I420/IYUV */
@@ -527,10 +501,9 @@ gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc,
break;
}
- caps = GST_CAPS_NEW("v4l2src_caps",
- "video/x-raw-yuv",
- "format", GST_PROPS_FOURCC(fcc),
- NULL);
+ structure = gst_structure_new ("video/x-raw-yuv",
+ "format", GST_TYPE_FOURCC, fcc,
+ NULL);
break;
}
default:
@@ -550,26 +523,24 @@ gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc,
}
string_format = g_strdup_printf("video/%4.4s",
print_format_str);
- caps = GST_CAPS_NEW("v4l2src_caps",
- string_format,
- NULL);
+ structure = gst_structure_new (string_format, NULL);
g_free(string_format);
} else {
- caps = GST_CAPS_NEW("v4l2src_caps",
- "video/x-raw-yuv",
- "format",GST_PROPS_FOURCC(fourcc),
- NULL);
+ structure = gst_structure_new ("video/x-raw-yuv",
+ "format", GST_TYPE_FOURCC, fourcc, NULL);
}
break;
}
- if (!caps->properties)
- caps->properties = gst_props_empty_new();
- gst_props_add_entry(caps->properties, width);
- gst_props_add_entry(caps->properties, height);
- gst_props_add_entry(caps->properties, fps);
+#if 0
+ gst_caps_set_simple (caps,
+ "width", G_TYPE_INT, width,
+ "height", G_TYPE_INT, height,
+ "framerate", G_TYPE_DOUBLE, fps,
+ NULL);
+#endif
- return caps;
+ return structure;
}
#define gst_v4l2src_v4l2fourcc_to_caps_fixed(f, width, height, fps, c) \
@@ -594,19 +565,19 @@ gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc,
static struct v4l2_fmtdesc *
gst_v4l2_caps_to_v4l2fourcc (GstV4l2Src *v4l2src,
- GstCaps *caps)
+ GstStructure *structure)
{
gint i;
guint32 fourcc = 0;
struct v4l2_fmtdesc *end_fmt = NULL;
- const gchar *format = gst_caps_get_mime(caps);
+ const gchar *format = gst_structure_get_name (structure);
if (!strcmp(format, "video/x-raw-yuv") ||
!strcmp(format, "video/x-raw-rgb")) {
if (!strcmp(format, "video/x-raw-rgb"))
fourcc = GST_MAKE_FOURCC('R','G','B',' ');
else
- gst_caps_get_fourcc_int(caps, "format", &fourcc);
+ gst_structure_get_fourcc (structure, "format", &fourcc);
switch (fourcc) {
case GST_MAKE_FOURCC('I','4','2','0'):
@@ -628,8 +599,8 @@ gst_v4l2_caps_to_v4l2fourcc (GstV4l2Src *v4l2src,
case GST_MAKE_FOURCC('R','G','B',' '): {
gint depth, endianness;
- gst_caps_get_int(caps, "depth", &depth);
- gst_caps_get_int(caps, "endianness", &endianness);
+ gst_structure_get_int (structure, "depth", &depth);
+ gst_structure_get_int (structure, "endianness", &endianness);
switch (depth) {
case 8:
@@ -721,17 +692,19 @@ gst_v4l2_caps_to_v4l2fourcc (GstV4l2Src *v4l2src,
static GstPadLinkReturn
gst_v4l2src_srcconnect (GstPad *pad,
- GstCaps *vscapslist)
+ const GstCaps *vscapslist)
{
GstV4l2Src *v4l2src;
GstV4l2Element *v4l2element;
- GstCaps *caps;
struct v4l2_fmtdesc *format;
int w, h;
+ GstStructure *structure;
v4l2src = GST_V4L2SRC(gst_pad_get_parent (pad));
v4l2element = GST_V4L2ELEMENT(v4l2src);
+ structure = gst_caps_get_structure (vscapslist, 0);
+
/* clean up if we still haven't cleaned up our previous
* capture session */
if (GST_V4L2_IS_ACTIVE(v4l2element)) {
@@ -741,52 +714,18 @@ gst_v4l2src_srcconnect (GstPad *pad,
return GST_PAD_LINK_DELAYED;
}
- for (caps = vscapslist; caps != NULL; caps = caps->next) {
- /* we want our own v4l2 type of fourcc codes */
- if (!(format = gst_v4l2_caps_to_v4l2fourcc(v4l2src, caps))) {
- continue;
- }
- if (gst_caps_has_property(caps, "width")) {
- if (gst_caps_has_fixed_property(caps, "width")) {
- gst_caps_get_int(caps, "width", &w);
- } else {
- int max;
- gst_caps_get_int_range(caps, "width", &max, &w);
- }
- }
- if (gst_caps_has_property(caps, "height")) {
- if (gst_caps_has_fixed_property(caps, "height")) {
- gst_caps_get_int(caps, "height", &h);
- } else {
- int max;
- gst_caps_get_int_range(caps, "height", &max, &h);
- }
- }
+ /* we want our own v4l2 type of fourcc codes */
+ if (!(format = gst_v4l2_caps_to_v4l2fourcc(v4l2src, structure))) {
+ return GST_PAD_LINK_REFUSED;
+ }
- /* we found the pixelformat! - try it out */
- if (gst_v4l2src_set_capture(v4l2src, format, w, h)) {
- /* it fits! Now, get the proper counterpart and retry
- * it on the other side (again...) - if it works, we're
- * done -> GST_PAD_LINK_OK */
- GstCaps *lastcaps;
- GstPadLinkReturn ret_val;
-
- lastcaps = gst_v4l2src_v4l2fourcc_to_caps_fixed(format->pixelformat,
- v4l2src->format.fmt.pix.width,
- v4l2src->format.fmt.pix.height,
- gst_v4l2src_get_fps(v4l2src),
- format->flags & V4L2_FMT_FLAG_COMPRESSED);
-
- ret_val = gst_pad_try_set_caps(v4l2src->srcpad,
- lastcaps);
-
- if (ret_val > 0) {
- if (gst_v4l2src_capture_init(v4l2src)) {
- return GST_PAD_LINK_DONE;
- }
- } else if (ret_val == GST_PAD_LINK_DELAYED) {
- return GST_PAD_LINK_DELAYED;
- }
+ gst_structure_get_int (structure, "width", &w);
+ gst_structure_get_int (structure, "height", &h);
+
+ /* we found the pixelformat! - try it out */
+ if (gst_v4l2src_set_capture(v4l2src, format, w, h)) {
+ if (gst_v4l2src_capture_init(v4l2src)) {
+ return GST_PAD_LINK_OK;
}
}
@@ -795,11 +734,10 @@ gst_v4l2src_srcconnect (GstPad *pad,
static GstCaps *
-gst_v4l2src_getcaps (GstPad *pad,
- GstCaps *caps)
+gst_v4l2src_getcaps (GstPad *pad)
{
GstV4l2Src *v4l2src = GST_V4L2SRC(gst_pad_get_parent (pad));
- GstCaps *list = NULL;
+ GstCaps *caps;
gint i;
struct v4l2_fmtdesc *format;
int min_w, max_w, min_h, max_h;
@@ -809,7 +747,10 @@ gst_v4l2src_getcaps (GstPad *pad,
}
/* build our own capslist */
+ caps = gst_caps_new_empty();
for (i=0;i<g_list_length(v4l2src->formats);i++) {
+ GstStructure *structure;
+
format = g_list_nth_data(v4l2src->formats, i);
/* get size delimiters */
@@ -820,15 +761,19 @@ gst_v4l2src_getcaps (GstPad *pad,
}
/* add to list */
- caps = gst_v4l2src_v4l2fourcc_to_caps_range(format->pixelformat,
- min_w, max_w,
- min_h, max_h,
- format->flags & V4L2_FMT_FLAG_COMPRESSED);
+ structure = gst_v4l2src_v4l2fourcc_to_caps (format->pixelformat,
+ format->flags & V4L2_FMT_FLAG_COMPRESSED);
- list = gst_caps_append(list, caps);
+ gst_structure_set (structure,
+ "width", GST_TYPE_INT_RANGE, min_w, max_w,
+ "height", GST_TYPE_INT_RANGE, min_h, max_h,
+ "framerate", GST_TYPE_DOUBLE_RANGE, 0, G_MAXDOUBLE,
+ NULL);
+
+ gst_caps_append_structure (caps, structure);
}
- return list;
+ return caps;
}
@@ -848,13 +793,6 @@ gst_v4l2src_get (GstPad *pad)
(fps = gst_v4l2src_get_fps(v4l2src)) == 0)
return NULL;
- buf = gst_buffer_new_from_pool(v4l2src->bufferpool, 0, 0);
- if (!buf) {
- gst_element_error(GST_ELEMENT(v4l2src),
- "Failed to create a new GstBuffer");
- return NULL;
- }
-
if (v4l2src->need_writes > 0) {
/* use last frame */
num = v4l2src->last_frame;
@@ -929,8 +867,10 @@ gst_v4l2src_get (GstPad *pad)
v4l2src->use_num_times[num] = 1;
}
+ buf = gst_buffer_new ();
GST_BUFFER_DATA(buf) = gst_v4l2src_get_buffer(v4l2src, num);
GST_BUFFER_SIZE(buf) = v4l2src->bufsettings.bytesused;
+ GST_BUFFER_FLAG_SET(buf, GST_BUFFER_READONLY);
if (v4l2src->use_fixed_fps)
GST_BUFFER_TIMESTAMP(buf) = v4l2src->handled * GST_SECOND / fps;
else /* calculate time based on our own clock */
@@ -1074,6 +1014,7 @@ gst_v4l2src_set_clock (GstElement *element,
}
+#if 0
static GstBuffer*
gst_v4l2src_buffer_new (GstBufferPool *pool,
guint64 offset,
@@ -1097,8 +1038,9 @@ gst_v4l2src_buffer_new (GstBufferPool *pool,
return buffer;
}
+#endif
-
+#if 0
static void
gst_v4l2src_buffer_free (GstBufferPool *pool,
GstBuffer *buf,
@@ -1126,3 +1068,5 @@ gst_v4l2src_buffer_free (GstBufferPool *pool,
/* free the buffer itself */
gst_buffer_default_free(buf);
}
+#endif
+
diff --git a/sys/v4l2/gstv4l2src.h b/sys/v4l2/gstv4l2src.h
index 1b4ab095..bae60900 100644
--- a/sys/v4l2/gstv4l2src.h
+++ b/sys/v4l2/gstv4l2src.h
@@ -80,9 +80,6 @@ struct _GstV4l2Src {
/* how are we going to push buffers? */
gboolean use_fixed_fps;
-
- /* bufferpool for the buffers we're gonna use */
- GstBufferPool *bufferpool;
};
struct _GstV4l2SrcClass {