mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 15:51:11 +00:00
omxvideodec: Make sink/src pad template caps configurable
This commit is contained in:
parent
2023754bcf
commit
a24cdd41bc
4 changed files with 72 additions and 48 deletions
|
@ -50,32 +50,11 @@ enum
|
|||
GST_BOILERPLATE_FULL (GstOMXH264Dec, gst_omx_h264_dec,
|
||||
GstOMXVideoDec, GST_TYPE_OMX_VIDEO_DEC, DEBUG_INIT);
|
||||
|
||||
static GstStaticPadTemplate gst_omx_h264_dec_sink_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("video/x-h264, "
|
||||
"parsed=(boolean) true, "
|
||||
"alignment=(string)au, " "stream-format=(string) {avc, byte-stream}")
|
||||
);
|
||||
|
||||
static GstStaticPadTemplate gst_omx_h264_dec_src_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
|
||||
);
|
||||
|
||||
static void
|
||||
gst_omx_h264_dec_base_init (gpointer g_class)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_omx_h264_dec_src_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_omx_h264_dec_sink_template));
|
||||
|
||||
gst_element_class_set_details_simple (element_class,
|
||||
"OpenMAX H264 Video Decoder",
|
||||
"Codec/Decoder/Video",
|
||||
|
@ -94,6 +73,11 @@ gst_omx_h264_dec_class_init (GstOMXH264DecClass * klass)
|
|||
videodec_class->is_format_change =
|
||||
GST_DEBUG_FUNCPTR (gst_omx_h264_dec_is_format_change);
|
||||
videodec_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_h264_dec_set_format);
|
||||
|
||||
videodec_class->default_sink_template_caps = "video/x-h264, "
|
||||
"parsed=(boolean) true, "
|
||||
"alignment=(string)au, " "stream-format=(string) avc";
|
||||
videodec_class->default_src_template_caps = GST_VIDEO_CAPS_YUV ("I420");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -50,34 +50,11 @@ enum
|
|||
GST_BOILERPLATE_FULL (GstOMXMPEG4VideoDec, gst_omx_mpeg4_video_dec,
|
||||
GstOMXVideoDec, GST_TYPE_OMX_VIDEO_DEC, DEBUG_INIT);
|
||||
|
||||
static GstStaticPadTemplate gst_omx_mpeg4_video_dec_sink_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("video/mpeg, "
|
||||
"mpegversion=(int) 4, "
|
||||
"systemstream=(boolean) false, "
|
||||
"parsed=(boolean) true, "
|
||||
"width=(int) [ 16, 4096 ], " "height=(int) [ 16, 4096 ]")
|
||||
);
|
||||
|
||||
static GstStaticPadTemplate gst_omx_mpeg4_video_dec_src_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
|
||||
);
|
||||
|
||||
static void
|
||||
gst_omx_mpeg4_video_dec_base_init (gpointer g_class)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_omx_mpeg4_video_dec_src_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_omx_mpeg4_video_dec_sink_template));
|
||||
|
||||
gst_element_class_set_details_simple (element_class,
|
||||
"OpenMAX MPEG4 Video Decoder",
|
||||
"Codec/Decoder/Video",
|
||||
|
@ -97,6 +74,13 @@ gst_omx_mpeg4_video_dec_class_init (GstOMXMPEG4VideoDecClass * klass)
|
|||
GST_DEBUG_FUNCPTR (gst_omx_mpeg4_video_dec_is_format_change);
|
||||
videodec_class->set_format =
|
||||
GST_DEBUG_FUNCPTR (gst_omx_mpeg4_video_dec_set_format);
|
||||
|
||||
videodec_class->default_sink_template_caps = "video/mpeg, "
|
||||
"mpegversion=(int) 4, "
|
||||
"systemstream=(boolean) false, "
|
||||
"parsed=(boolean) true, "
|
||||
"width=(int) [ 16, 4096 ], " "height=(int) [ 16, 4096 ]";
|
||||
videodec_class->default_src_template_caps = GST_VIDEO_CAPS_YUV ("I420");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -77,12 +77,16 @@ GST_BOILERPLATE_FULL (GstOMXVideoDec, gst_omx_video_dec, GstBaseVideoDecoder,
|
|||
static void
|
||||
gst_omx_video_dec_base_init (gpointer g_class)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
||||
GstOMXVideoDecClass *videodec_class = GST_OMX_VIDEO_DEC_CLASS (g_class);
|
||||
GKeyFile *config;
|
||||
const gchar *element_name;
|
||||
GError *err;
|
||||
gchar *core_name, *component_name;
|
||||
gint in_port_index, out_port_index;
|
||||
gchar *template_caps;
|
||||
GstPadTemplate *templ;
|
||||
GstCaps *caps;
|
||||
|
||||
element_name =
|
||||
g_type_get_qdata (G_TYPE_FROM_CLASS (g_class),
|
||||
|
@ -124,6 +128,59 @@ gst_omx_video_dec_base_init (gpointer g_class)
|
|||
g_error_free (err);
|
||||
}
|
||||
videodec_class->out_port_index = out_port_index;
|
||||
|
||||
/* Add pad templates */
|
||||
err = NULL;
|
||||
if (!(template_caps =
|
||||
g_key_file_get_string (config, element_name, "sink-template-caps",
|
||||
&err))) {
|
||||
GST_DEBUG
|
||||
("No sink template caps specified for element '%s', using default '%s'",
|
||||
element_name, videodec_class->default_sink_template_caps);
|
||||
caps = gst_caps_from_string (videodec_class->default_sink_template_caps);
|
||||
g_assert (caps != NULL);
|
||||
g_error_free (err);
|
||||
} else {
|
||||
caps = gst_caps_from_string (template_caps);
|
||||
if (!caps) {
|
||||
GST_DEBUG
|
||||
("Could not parse sink template caps '%s' for element '%s', using default '%s'",
|
||||
template_caps, element_name,
|
||||
videodec_class->default_sink_template_caps);
|
||||
caps = gst_caps_from_string (videodec_class->default_sink_template_caps);
|
||||
g_assert (caps != NULL);
|
||||
}
|
||||
}
|
||||
templ = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, caps);
|
||||
g_free (template_caps);
|
||||
gst_element_class_add_pad_template (element_class, templ);
|
||||
gst_object_unref (templ);
|
||||
|
||||
err = NULL;
|
||||
if (!(template_caps =
|
||||
g_key_file_get_string (config, element_name, "src-template-caps",
|
||||
&err))) {
|
||||
GST_DEBUG
|
||||
("No src template caps specified for element '%s', using default '%s'",
|
||||
element_name, videodec_class->default_src_template_caps);
|
||||
caps = gst_caps_from_string (videodec_class->default_src_template_caps);
|
||||
g_assert (caps != NULL);
|
||||
g_error_free (err);
|
||||
} else {
|
||||
caps = gst_caps_from_string (template_caps);
|
||||
if (!caps) {
|
||||
GST_DEBUG
|
||||
("Could not parse src template caps '%s' for element '%s', using default '%s'",
|
||||
template_caps, element_name,
|
||||
videodec_class->default_src_template_caps);
|
||||
caps = gst_caps_from_string (videodec_class->default_src_template_caps);
|
||||
g_assert (caps != NULL);
|
||||
}
|
||||
}
|
||||
templ = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
|
||||
g_free (template_caps);
|
||||
gst_element_class_add_pad_template (element_class, templ);
|
||||
gst_object_unref (templ);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -150,9 +207,6 @@ gst_omx_video_dec_class_init (GstOMXVideoDecClass * klass)
|
|||
GST_DEBUG_FUNCPTR (gst_omx_video_dec_handle_frame);
|
||||
base_video_decoder_class->finish =
|
||||
GST_DEBUG_FUNCPTR (gst_omx_video_dec_finish);
|
||||
|
||||
klass->in_port_index = 0;
|
||||
klass->out_port_index = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -177,7 +231,6 @@ gst_omx_video_dec_open (GstOMXVideoDec * self)
|
|||
GST_CLOCK_TIME_NONE) != OMX_StateLoaded)
|
||||
return FALSE;
|
||||
|
||||
/* FIXME: Always 0 == input, 1 == output? Make configurable? Let subclass decide? */
|
||||
self->in_port =
|
||||
gst_omx_component_add_port (self->component, klass->in_port_index);
|
||||
self->out_port =
|
||||
|
|
|
@ -64,6 +64,9 @@ struct _GstOMXVideoDecClass
|
|||
const gchar *core_name;
|
||||
const gchar *component_name;
|
||||
|
||||
const gchar *default_src_template_caps;
|
||||
const gchar *default_sink_template_caps;
|
||||
|
||||
guint32 in_port_index, out_port_index;
|
||||
|
||||
gboolean (*is_format_change) (GstOMXVideoDec * self, GstOMXPort * port, GstVideoState * state);
|
||||
|
|
Loading…
Reference in a new issue