plugin: encode: Add static caps for template documentation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/354>
This commit is contained in:
He Junyan 2020-07-09 13:49:29 +08:00 committed by Víctor Manuel Jáquez Leal
parent f7e0303b9c
commit e911c1ff02
7 changed files with 90 additions and 24 deletions

View file

@ -51,6 +51,18 @@ struct _GstVaapiEncodeInitData
GstCaps *src_caps;
};
/* *INDENT-OFF* */
#define GST_VAAPI_ENCODE_STATIC_SINK_CAPS \
GST_VAAPI_MAKE_SURFACE_CAPS ", " \
GST_CAPS_INTERLACED_FALSE "; " \
GST_VIDEO_CAPS_MAKE (GST_VAAPI_FORMATS_ALL) ", " \
GST_CAPS_INTERLACED_FALSE ";" \
GST_VIDEO_CAPS_MAKE_WITH_FEATURES( \
GST_CAPS_FEATURE_MEMORY_DMABUF, \
GST_VAAPI_FORMATS_ALL) "," \
GST_CAPS_INTERLACED_FALSE
/* *INDENT-ON* */
#define GST_VAAPI_ENCODE_REGISTER_TYPE(NAME, CODEC, CLASS, _EXT_FMT_, FUN) \
static GstVaapiEncodeInitData encode_init_data = { NULL, NULL }; \
static GType encode_type = G_TYPE_INVALID; \

View file

@ -546,6 +546,8 @@ gst_vaapiencode_h264_class_init (GstVaapiEncodeH264Class * klass, gpointer data)
GstVaapiEncodeClass *const encode_class = GST_VAAPIENCODE_CLASS (klass);
GstCaps *sink_caps = ((GstVaapiEncodeInitData *) data)->sink_caps;
GstCaps *src_caps = ((GstVaapiEncodeInitData *) data)->src_caps;
GstPadTemplate *templ;
GstCaps *static_caps;
gpointer encoder_class;
object_class->finalize = gst_vaapiencode_h264_finalize;
@ -566,14 +568,21 @@ gst_vaapiencode_h264_class_init (GstVaapiEncodeH264Class * klass, gpointer data)
/* sink pad */
g_assert (sink_caps);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sink_caps));
static_caps = gst_caps_from_string (GST_VAAPI_ENCODE_STATIC_SINK_CAPS);
templ =
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sink_caps);
gst_pad_template_set_documentation_caps (templ, static_caps);
gst_element_class_add_pad_template (element_class, templ);
gst_caps_unref (static_caps);
gst_caps_unref (sink_caps);
/* src pad */
g_assert (src_caps);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, src_caps));
static_caps = gst_caps_from_string (GST_CODEC_CAPS);
templ = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, src_caps);
gst_pad_template_set_documentation_caps (templ, static_caps);
gst_element_class_add_pad_template (element_class, templ);
gst_caps_unref (static_caps);
gst_caps_unref (src_caps);
encoder_class = g_type_class_ref (GST_TYPE_VAAPI_ENCODER_H264);

View file

@ -359,6 +359,8 @@ gst_vaapiencode_h265_class_init (GstVaapiEncodeH265Class * klass, gpointer data)
GstVaapiEncodeClass *const encode_class = GST_VAAPIENCODE_CLASS (klass);
GstCaps *sink_caps = ((GstVaapiEncodeInitData *) data)->sink_caps;
GstCaps *src_caps = ((GstVaapiEncodeInitData *) data)->src_caps;
GstPadTemplate *templ;
GstCaps *static_caps;
gpointer encoder_class;
object_class->finalize = gst_vaapiencode_h265_finalize;
@ -380,14 +382,21 @@ gst_vaapiencode_h265_class_init (GstVaapiEncodeH265Class * klass, gpointer data)
/* sink pad */
g_assert (sink_caps);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sink_caps));
static_caps = gst_caps_from_string (GST_VAAPI_ENCODE_STATIC_SINK_CAPS);
templ =
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sink_caps);
gst_pad_template_set_documentation_caps (templ, static_caps);
gst_element_class_add_pad_template (element_class, templ);
gst_caps_unref (static_caps);
gst_caps_unref (sink_caps);
/* src pad */
g_assert (src_caps);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, src_caps));
static_caps = gst_caps_from_string (GST_CODEC_CAPS);
templ = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, src_caps);
gst_pad_template_set_documentation_caps (templ, static_caps);
gst_element_class_add_pad_template (element_class, templ);
gst_caps_unref (static_caps);
gst_caps_unref (src_caps);
encoder_class = g_type_class_ref (GST_TYPE_VAAPI_ENCODER_H265);

View file

@ -91,6 +91,8 @@ gst_vaapiencode_jpeg_class_init (GstVaapiEncodeJpegClass * klass, gpointer data)
GstVaapiEncodeClass *const encode_class = GST_VAAPIENCODE_CLASS (klass);
GstCaps *sink_caps = ((GstVaapiEncodeInitData *) data)->sink_caps;
GstCaps *src_caps = ((GstVaapiEncodeInitData *) data)->src_caps;
GstPadTemplate *templ;
GstCaps *static_caps;
gpointer encoder_class;
object_class->finalize = gst_vaapiencode_jpeg_finalize;
@ -108,14 +110,21 @@ gst_vaapiencode_jpeg_class_init (GstVaapiEncodeJpegClass * klass, gpointer data)
/* sink pad */
g_assert (sink_caps);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sink_caps));
static_caps = gst_caps_from_string (GST_VAAPI_ENCODE_STATIC_SINK_CAPS);
templ =
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sink_caps);
gst_pad_template_set_documentation_caps (templ, static_caps);
gst_element_class_add_pad_template (element_class, templ);
gst_caps_unref (static_caps);
gst_caps_unref (sink_caps);
/* src pad */
g_assert (src_caps);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, src_caps));
static_caps = gst_caps_from_string (GST_CODEC_CAPS);
templ = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, src_caps);
gst_pad_template_set_documentation_caps (templ, static_caps);
gst_element_class_add_pad_template (element_class, templ);
gst_caps_unref (static_caps);
gst_caps_unref (src_caps);
encoder_class = g_type_class_ref (GST_TYPE_VAAPI_ENCODER_JPEG);

View file

@ -97,6 +97,8 @@ gst_vaapiencode_mpeg2_class_init (GstVaapiEncodeMpeg2Class * klass,
GstVaapiEncodeClass *const encode_class = GST_VAAPIENCODE_CLASS (klass);
GstCaps *sink_caps = ((GstVaapiEncodeInitData *) data)->sink_caps;
GstCaps *src_caps = ((GstVaapiEncodeInitData *) data)->src_caps;
GstPadTemplate *templ;
GstCaps *static_caps;
gpointer encoder_class;
object_class->finalize = gst_vaapiencode_mpeg2_finalize;
@ -113,14 +115,21 @@ gst_vaapiencode_mpeg2_class_init (GstVaapiEncodeMpeg2Class * klass,
/* sink pad */
g_assert (sink_caps);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sink_caps));
static_caps = gst_caps_from_string (GST_VAAPI_ENCODE_STATIC_SINK_CAPS);
templ =
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sink_caps);
gst_pad_template_set_documentation_caps (templ, static_caps);
gst_element_class_add_pad_template (element_class, templ);
gst_caps_unref (static_caps);
gst_caps_unref (sink_caps);
/* src pad */
g_assert (src_caps);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, src_caps));
static_caps = gst_caps_from_string (GST_CODEC_CAPS);
templ = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, src_caps);
gst_pad_template_set_documentation_caps (templ, static_caps);
gst_element_class_add_pad_template (element_class, templ);
gst_caps_unref (static_caps);
gst_caps_unref (src_caps);
encoder_class = g_type_class_ref (GST_TYPE_VAAPI_ENCODER_MPEG2);

View file

@ -91,6 +91,8 @@ gst_vaapiencode_vp8_class_init (GstVaapiEncodeVP8Class * klass, gpointer data)
GstVaapiEncodeClass *const encode_class = GST_VAAPIENCODE_CLASS (klass);
GstCaps *sink_caps = ((GstVaapiEncodeInitData *) data)->sink_caps;
GstCaps *src_caps = ((GstVaapiEncodeInitData *) data)->src_caps;
GstPadTemplate *templ;
GstCaps *static_caps;
gpointer encoder_class;
object_class->finalize = gst_vaapiencode_vp8_finalize;
@ -108,14 +110,21 @@ gst_vaapiencode_vp8_class_init (GstVaapiEncodeVP8Class * klass, gpointer data)
/* sink pad */
g_assert (sink_caps);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sink_caps));
static_caps = gst_caps_from_string (GST_VAAPI_ENCODE_STATIC_SINK_CAPS);
templ =
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sink_caps);
gst_pad_template_set_documentation_caps (templ, static_caps);
gst_element_class_add_pad_template (element_class, templ);
gst_caps_unref (static_caps);
gst_caps_unref (sink_caps);
/* src pad */
g_assert (src_caps);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, src_caps));
static_caps = gst_caps_from_string (GST_CODEC_CAPS);
templ = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, src_caps);
gst_pad_template_set_documentation_caps (templ, static_caps);
gst_element_class_add_pad_template (element_class, templ);
gst_caps_unref (static_caps);
gst_caps_unref (src_caps);
encoder_class = g_type_class_ref (GST_TYPE_VAAPI_ENCODER_VP8);

View file

@ -91,6 +91,8 @@ gst_vaapiencode_vp9_class_init (GstVaapiEncodeVP9Class * klass, gpointer data)
GstVaapiEncodeClass *const encode_class = GST_VAAPIENCODE_CLASS (klass);
GstCaps *sink_caps = ((GstVaapiEncodeInitData *) data)->sink_caps;
GstCaps *src_caps = ((GstVaapiEncodeInitData *) data)->src_caps;
GstPadTemplate *templ;
GstCaps *static_caps;
gpointer encoder_class;
object_class->finalize = gst_vaapiencode_vp9_finalize;
@ -108,14 +110,21 @@ gst_vaapiencode_vp9_class_init (GstVaapiEncodeVP9Class * klass, gpointer data)
/* sink pad */
g_assert (sink_caps);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sink_caps));
static_caps = gst_caps_from_string (GST_VAAPI_ENCODE_STATIC_SINK_CAPS);
templ =
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sink_caps);
gst_pad_template_set_documentation_caps (templ, static_caps);
gst_element_class_add_pad_template (element_class, templ);
gst_caps_unref (static_caps);
gst_caps_unref (sink_caps);
/* src pad */
g_assert (src_caps);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, src_caps));
static_caps = gst_caps_from_string (GST_CODEC_CAPS);
templ = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, src_caps);
gst_pad_template_set_documentation_caps (templ, static_caps);
gst_element_class_add_pad_template (element_class, templ);
gst_caps_unref (static_caps);
gst_caps_unref (src_caps);
encoder_class = g_type_class_ref (GST_TYPE_VAAPI_ENCODER_VP9);