videoflip: check that stream actually changed when resetting

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4377>
This commit is contained in:
Guillaume Desmottes 2023-04-20 16:31:04 +02:00
parent 7c4e36acfd
commit d4a9106499
2 changed files with 47 additions and 4 deletions

View file

@ -1825,10 +1825,20 @@ gst_video_flip_sink_event (GstBaseTransform * trans, GstEvent * event)
break;
case GST_EVENT_STREAM_START:
GST_DEBUG_OBJECT (vf, "new stream, reset orientation from tags");
vf->got_orientation_stream_tag = FALSE;
vf->global_tag_method = GST_VIDEO_ORIENTATION_IDENTITY;
gst_video_flip_set_method (vf, GST_VIDEO_ORIENTATION_IDENTITY, TRUE);
{
const gchar *stream_id;
gst_event_parse_stream_start (event, &stream_id);
if (g_strcmp0 (stream_id, vf->stream_id) != 0) {
GST_DEBUG_OBJECT (vf, "new stream, reset orientation from tags");
vf->got_orientation_stream_tag = FALSE;
vf->global_tag_method = GST_VIDEO_ORIENTATION_IDENTITY;
gst_video_flip_set_method (vf, GST_VIDEO_ORIENTATION_IDENTITY, TRUE);
g_clear_pointer (&vf->stream_id, g_free);
vf->stream_id = g_strdup (stream_id);
}
}
break;
default:
break;
@ -1873,6 +1883,35 @@ gst_video_flip_get_property (GObject * object, guint prop_id, GValue * value,
}
}
static void
gst_video_flip_finalize (GObject * object)
{
GstVideoFlip *videoflip = GST_VIDEO_FLIP (object);
g_clear_pointer (&videoflip->stream_id, g_free);
G_OBJECT_CLASS (gst_video_flip_parent_class)->finalize (object);
}
static GstStateChangeReturn
gst_video_flip_change_state (GstElement * element, GstStateChange transition)
{
GstVideoFlip *videoflip = GST_VIDEO_FLIP (element);
GstStateChangeReturn result;
result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
switch (transition) {
case GST_STATE_CHANGE_PAUSED_TO_READY:
g_clear_pointer (&videoflip->stream_id, g_free);
break;
default:
break;
}
return result;
}
static void
gst_video_flip_class_init (GstVideoFlipClass * klass)
{
@ -1886,6 +1925,7 @@ gst_video_flip_class_init (GstVideoFlipClass * klass)
gobject_class->set_property = gst_video_flip_set_property;
gobject_class->get_property = gst_video_flip_get_property;
gobject_class->finalize = gst_video_flip_finalize;
g_object_class_install_property (gobject_class, PROP_METHOD,
g_param_spec_enum ("method", "method",
@ -1900,6 +1940,8 @@ gst_video_flip_class_init (GstVideoFlipClass * klass)
pspec = g_object_class_find_property (gobject_class, "video-direction");
pspec->flags |= GST_PARAM_MUTABLE_PLAYING;
gstelement_class->change_state = gst_video_flip_change_state;
gst_element_class_set_static_metadata (gstelement_class, "Video flipper",
"Filter/Effect/Video",
"Flips and rotates video", "David Schleef <ds@schleef.org>");

View file

@ -76,6 +76,7 @@ struct _GstVideoFlip {
/* < private > */
GstVideoFormat v_format;
gchar *stream_id;
GstVideoOrientationMethod method;
GstVideoOrientationMethod tag_method;