mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
Add the convert functions to the source pads of the video4linux and video4linux2 source plugins
Original commit message from CVS: Add the convert functions to the source pads of the video4linux and video4linux2 source plugins
This commit is contained in:
parent
dd07d61791
commit
899ab22256
1 changed files with 65 additions and 1 deletions
|
@ -56,9 +56,14 @@ static void gst_v4l2src_class_init (GstV4l2SrcClass *klass);
|
|||
static void gst_v4l2src_init (GstV4l2Src *v4l2src);
|
||||
|
||||
/* pad/buffer functions */
|
||||
static gboolean gst_v4l2src_srcconvert (GstPad *pad,
|
||||
GstFormat src_format,
|
||||
gint64 src_value,
|
||||
GstFormat *dest_format,
|
||||
gint64 *dest_value);
|
||||
static GstPadConnectReturn gst_v4l2src_srcconnect (GstPad *pad,
|
||||
GstCaps *caps);
|
||||
static GstBuffer * gst_v4l2src_get (GstPad *pad);
|
||||
static GstBuffer * gst_v4l2src_get (GstPad *pad);
|
||||
|
||||
/* get/set params */
|
||||
static void gst_v4l2src_set_property (GObject *object,
|
||||
|
@ -170,6 +175,7 @@ gst_v4l2src_init (GstV4l2Src *v4l2src)
|
|||
|
||||
gst_pad_set_get_function(v4l2src->srcpad, gst_v4l2src_get);
|
||||
gst_pad_set_connect_function(v4l2src->srcpad, gst_v4l2src_srcconnect);
|
||||
gst_pad_set_convert_function (v4l2src->srcpad, gst_v4l2src_srcconvert);
|
||||
|
||||
v4l2src->bufferpool = gst_buffer_pool_new(NULL, NULL,
|
||||
gst_v4l2src_buffer_new,
|
||||
|
@ -184,6 +190,64 @@ gst_v4l2src_init (GstV4l2Src *v4l2src)
|
|||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
gst_v4l2src_srcconvert (GstPad *pad,
|
||||
GstFormat src_format,
|
||||
gint64 src_value,
|
||||
GstFormat *dest_format,
|
||||
gint64 *dest_value)
|
||||
{
|
||||
GstV4l2Src *v4l2src;
|
||||
gint norm;
|
||||
struct v4l2_standard *std;
|
||||
gdouble fps;
|
||||
|
||||
v4l2src = GST_V4L2SRC (gst_pad_get_parent (pad));
|
||||
|
||||
if (!GST_V4L2_IS_OPEN(v4l2src))
|
||||
return FALSE;
|
||||
|
||||
if (!gst_v4l2_get_norm(v4l2src, &norm))
|
||||
return FALSE;
|
||||
|
||||
std = &((struct v4l2_enumstd *) g_list_nth_data(v4l2src->norms, norm))->std;
|
||||
fps = std->framerate.numerator / std->framerate.denominator;
|
||||
|
||||
switch (src_format) {
|
||||
case GST_FORMAT_TIME:
|
||||
switch (*dest_format) {
|
||||
case GST_FORMAT_DEFAULT:
|
||||
*dest_format = GST_FORMAT_UNITS;
|
||||
/* fall-through */
|
||||
case GST_FORMAT_UNITS:
|
||||
*dest_value = src_value * fps / GST_SECOND;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case GST_FORMAT_UNITS:
|
||||
switch (*dest_format) {
|
||||
case GST_FORMAT_DEFAULT:
|
||||
*dest_format = GST_FORMAT_TIME;
|
||||
/* fall-through */
|
||||
case GST_FORMAT_TIME:
|
||||
*dest_value = src_value * GST_SECOND / fps;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static GstCaps *
|
||||
gst_v4l2src_v4l2fourcc_to_caps (guint32 fourcc,
|
||||
gint width,
|
||||
|
|
Loading…
Reference in a new issue