gstreamer/sys/decklink/gstdecklinkvideosink.h
Matthew Waters bf849e9a69 decklink: start scheduled playback in paused
This is part of a much larger goal to always keep the frames we schedule to
decklink be always increasing.  This also allows us to avoid using both the
sync and async frame display functions which aren't recomended to be used
together.

If the output timestatmsp is not always increasing decklink seems to hold
onto the latest frame and may cause a flash in the output if the played
sequence has a framerate less than the video output.

Scenario is play for N seconds, pause, flushing seek to some other position,
play again.  Each of the play sequences would normally start at 0 with
the decklink time.  As a result, the latest frame from the previous sequence
is kept alive waiting for it's timestamp to pass before either dropping
(if a subsequent frame in the new sequence overrides it) or displayed
causing the out of place frame to be displayed.

This is also supported by the debug logs from the decklink video sink
element where a ScheduledFrameCompleted() callback would not occur for
the frame until the above had happened.

It was timing related as to whether the frame was displayed based
on the decklink refresh cycle (which seems to be 16ms here),
when the frame was scheduled by the sink and the difference between
the 'time since vblank' of the two play requests (and thus start times
of scheduled playback).

https://bugzilla.gnome.org/show_bug.cgi?id=797130
2018-09-12 21:16:27 +10:00

85 lines
2.8 KiB
C

/* GStreamer
*
* Copyright (C) 2011 David Schleef <ds@schleef.org>
* Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_DECKLINK_VIDEO_SINK_H__
#define __GST_DECKLINK_VIDEO_SINK_H__
#include <gst/gst.h>
#include <gst/base/base.h>
#include <gst/video/video.h>
#include "gstdecklink.h"
G_BEGIN_DECLS
#define GST_TYPE_DECKLINK_VIDEO_SINK \
(gst_decklink_video_sink_get_type())
#define GST_DECKLINK_VIDEO_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_DECKLINK_VIDEO_SINK, GstDecklinkVideoSink))
#define GST_DECKLINK_VIDEO_SINK_CAST(obj) \
((GstDecklinkVideoSink*)obj)
#define GST_DECKLINK_VIDEO_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_DECKLINK_VIDEO_SINK, GstDecklinkVideoSinkClass))
#define GST_IS_DECKLINK_VIDEO_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_DECKLINK_VIDEO_SINK))
#define GST_IS_DECKLINK_VIDEO_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_DECKLINK_VIDEO_SINK))
typedef struct _GstDecklinkVideoSink GstDecklinkVideoSink;
typedef struct _GstDecklinkVideoSinkClass GstDecklinkVideoSinkClass;
struct _GstDecklinkVideoSink
{
GstBaseSink parent;
GstDecklinkModeEnum mode;
gint device_number;
GstDecklinkVideoFormat video_format;
BMDTimecodeFormat timecode_format;
BMDKeyerMode keyer_mode;
gint keyer_level;
GstVideoInfo info;
GstClockTime internal_base_time;
GstClockTime external_base_time;
/* all in internal time of the decklink clock */
/* really an internal base time */
GstClockTime playing_start_time; /* time that we entered playing */
/* really an internal start time */
GstClockTime paused_start_time; /* time we entered paused, used to track how long we are in paused while the clock is running */
GstDecklinkOutput *output;
};
struct _GstDecklinkVideoSinkClass
{
GstBaseSinkClass parent_class;
};
GType gst_decklink_video_sink_get_type (void);
void gst_decklink_video_sink_convert_to_internal_clock (GstDecklinkVideoSink * self,
GstClockTime * timestamp, GstClockTime * duration);
G_END_DECLS
#endif /* __GST_DECKLINK_VIDEO_SINK_H__ */