v4l2dec: get framerate from sink caps and then set to src caps [1/2]
PD#SWPL-154612
Problem:
Need set sink caps framerate to videosink
Solution:
get framerate from sink caps and then set to src caps
Verify:
AH212
Change-Id: Ie7277e5ed0ed5dae8d899c7ff349504935f60b66
Signed-off-by: sheng.liu <sheng.liu@amlogic.com>
diff --git a/src/gstamlv4l2object.c b/src/gstamlv4l2object.c
index 3836a90..f9c3e52 100644
--- a/src/gstamlv4l2object.c
+++ b/src/gstamlv4l2object.c
@@ -880,6 +880,13 @@
v4l2object->par = NULL;
}
+ if (v4l2object->fps)
+ {
+ g_value_unset(v4l2object->fps);
+ g_free(v4l2object->fps);
+ v4l2object->fps = NULL;
+ }
+
if (v4l2object->channel)
{
g_free(v4l2object->channel);
@@ -4768,6 +4775,12 @@
GST_VIDEO_INFO_PAR_N(info) = width;
GST_VIDEO_INFO_PAR_D(info) = height;
}
+
+ if (v4l2object->fps)
+ {
+ GST_VIDEO_INFO_FPS_N(info) = gst_value_get_fraction_numerator(v4l2object->fps);
+ GST_VIDEO_INFO_FPS_D(info) = gst_value_get_fraction_denominator(v4l2object->fps);
+ }
/* Shall we setup the pool ? */
return TRUE;
diff --git a/src/gstamlv4l2object.h b/src/gstamlv4l2object.h
index 5daf7b6..8fe08d7 100644
--- a/src/gstamlv4l2object.h
+++ b/src/gstamlv4l2object.h
@@ -201,6 +201,7 @@
gboolean stream_mode;
GValue *par;
gboolean have_set_par;
+ GValue *fps;
/* funcs */
GstAmlV4l2GetInOutFunction get_in_out_func;
diff --git a/src/gstamlv4l2videodec.c b/src/gstamlv4l2videodec.c
index 9598a0a..bd85206 100644
--- a/src/gstamlv4l2videodec.c
+++ b/src/gstamlv4l2videodec.c
@@ -1576,6 +1576,23 @@
}
}
+ if ( gst_structure_get_fraction( structure, "framerate", &num, &denom ) )
+ {
+ if ( denom == 0 ) denom= 1;
+
+ if (self->v4l2capture->fps)
+ {
+ g_value_unset(self->v4l2capture->fps);
+ g_free(self->v4l2capture->fps);
+ }
+
+ self->v4l2capture->fps = g_new0(GValue, 1);
+ g_value_init(self->v4l2capture->fps, GST_TYPE_FRACTION);
+ gst_value_set_fraction(self->v4l2capture->fps, num, denom);
+
+ GST_DEBUG_OBJECT(self, "get framerate ratio %d:%d", num, denom);
+ }
+
if (( gst_structure_get_fraction( structure, "pixel-aspect-ratio", &num, &denom ) ) &&
( !self->v4l2capture->have_set_par ) )
{