videosink: Add new GstVideoSink::set_info() virtual method

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/986>
This commit is contained in:
Sebastian Dröge 2021-01-11 12:25:33 +02:00 committed by GStreamer Merge Bot
parent 198434e71a
commit 7e16eed522
2 changed files with 19 additions and 3 deletions

View file

@ -36,7 +36,6 @@
#endif #endif
#include "gstvideosink.h" #include "gstvideosink.h"
#include "video-info.h"
enum enum
{ {
@ -199,7 +198,7 @@ gst_video_sink_change_state (GstElement * element, GstStateChange transition)
switch (transition) { switch (transition) {
case GST_STATE_CHANGE_READY_TO_PAUSED: case GST_STATE_CHANGE_READY_TO_PAUSED:
memset (&vsink->priv->info, 0, sizeof (vsink->priv->info)); gst_video_info_init (&vsink->priv->info);
break; break;
default: default:
break; break;
@ -212,9 +211,11 @@ static gboolean
gst_video_sink_set_caps (GstBaseSink * bsink, GstCaps * caps) gst_video_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
{ {
GstVideoSink *vsink; GstVideoSink *vsink;
GstVideoSinkClass *klass;
GstVideoInfo info; GstVideoInfo info;
vsink = GST_VIDEO_SINK_CAST (bsink); vsink = GST_VIDEO_SINK_CAST (bsink);
klass = GST_VIDEO_SINK_GET_CLASS (vsink);
if (!gst_video_info_from_caps (&info, caps)) { if (!gst_video_info_from_caps (&info, caps)) {
GST_ERROR_OBJECT (bsink, "Failed to parse caps %" GST_PTR_FORMAT, caps); GST_ERROR_OBJECT (bsink, "Failed to parse caps %" GST_PTR_FORMAT, caps);
@ -224,6 +225,9 @@ gst_video_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
GST_DEBUG_OBJECT (bsink, "Setting caps %" GST_PTR_FORMAT, caps); GST_DEBUG_OBJECT (bsink, "Setting caps %" GST_PTR_FORMAT, caps);
vsink->priv->info = info; vsink->priv->info = info;
if (klass->set_info)
return klass->set_info (vsink, caps, &vsink->priv->info);
return TRUE; return TRUE;
} }

View file

@ -26,6 +26,7 @@
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/base/gstbasesink.h> #include <gst/base/gstbasesink.h>
#include <gst/video/video-prelude.h> #include <gst/video/video-prelude.h>
#include <gst/video/video-info.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@ -117,8 +118,19 @@ struct _GstVideoSinkClass {
GstFlowReturn (*show_frame) (GstVideoSink *video_sink, GstBuffer *buf); GstFlowReturn (*show_frame) (GstVideoSink *video_sink, GstBuffer *buf);
/**
* GstVideoSinkClass::set_info:
* @caps: A #GstCaps.
* @info: A #GstVideoInfo corresponding to @caps.
*
* Notifies the subclass of changed #GstVideoInfo.
*
* Since: 1.20
*/
gboolean (*set_info) (GstVideoSink *video_sink, GstCaps *caps, const GstVideoInfo *info);
/*< private >*/ /*< private >*/
gpointer _gst_reserved[GST_PADDING]; gpointer _gst_reserved[GST_PADDING-1];
}; };
GST_VIDEO_API GST_VIDEO_API