videoencoder: subclass 'set_format' should be optional

Aligns documentation with the code to make the subclass
'set_format' call optional.
This commit is contained in:
Stéphane Cerveau 2020-04-01 17:47:04 +02:00
parent 1dee0f05a7
commit ac6b805827

View file

@ -633,13 +633,10 @@ gst_video_encoder_setcaps (GstVideoEncoder * encoder, GstCaps * caps)
{ {
GstVideoEncoderClass *encoder_class; GstVideoEncoderClass *encoder_class;
GstVideoCodecState *state; GstVideoCodecState *state;
gboolean ret; gboolean ret = TRUE;
encoder_class = GST_VIDEO_ENCODER_GET_CLASS (encoder); encoder_class = GST_VIDEO_ENCODER_GET_CLASS (encoder);
/* subclass should do something here ... */
g_return_val_if_fail (encoder_class->set_format != NULL, FALSE);
GST_DEBUG_OBJECT (encoder, "setcaps %" GST_PTR_FORMAT, caps); GST_DEBUG_OBJECT (encoder, "setcaps %" GST_PTR_FORMAT, caps);
GST_VIDEO_ENCODER_STREAM_LOCK (encoder); GST_VIDEO_ENCODER_STREAM_LOCK (encoder);
@ -669,7 +666,9 @@ gst_video_encoder_setcaps (GstVideoEncoder * encoder, GstCaps * caps)
} }
/* and subclass should be ready to configure format at any time around */ /* and subclass should be ready to configure format at any time around */
ret = encoder_class->set_format (encoder, state); if (encoder_class->set_format != NULL)
ret = encoder_class->set_format (encoder, state);
if (ret) { if (ret) {
if (encoder->priv->input_state) if (encoder->priv->input_state)
gst_video_codec_state_unref (encoder->priv->input_state); gst_video_codec_state_unref (encoder->priv->input_state);