decklinksrc: Add property to drop frames that are marked as having no input signal
https://bugzilla.gnome.org/show_bug.cgi?id=774850
diff --git a/sys/decklink/gstdecklinkaudiosrc.cpp b/sys/decklink/gstdecklinkaudiosrc.cpp
index 63c75d2..04dc2f7 100644
--- a/sys/decklink/gstdecklinkaudiosrc.cpp
+++ b/sys/decklink/gstdecklinkaudiosrc.cpp
@@ -428,14 +428,20 @@
GstClockTime timestamp;
GST_LOG_OBJECT (self,
- "Got audio packet at %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT,
- GST_TIME_ARGS (capture_time), GST_TIME_ARGS (packet_time));
+ "Got audio packet at %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT
+ ", no signal %d", GST_TIME_ARGS (capture_time),
+ GST_TIME_ARGS (packet_time), no_signal);
g_mutex_lock (&self->input->lock);
if (self->input->videosrc) {
GstDecklinkVideoSrc *videosrc =
GST_DECKLINK_VIDEO_SRC_CAST (gst_object_ref (self->input->videosrc));
+ if (videosrc->drop_no_signal_frames && no_signal) {
+ g_mutex_unlock (&self->input->lock);
+ return;
+ }
+
if (videosrc->first_time == GST_CLOCK_TIME_NONE)
videosrc->first_time = packet_time;
diff --git a/sys/decklink/gstdecklinkvideosrc.cpp b/sys/decklink/gstdecklinkvideosrc.cpp
index b259211..d6c0561 100644
--- a/sys/decklink/gstdecklinkvideosrc.cpp
+++ b/sys/decklink/gstdecklinkvideosrc.cpp
@@ -34,6 +34,7 @@
#define DEFAULT_BUFFER_SIZE (5)
#define DEFAULT_OUTPUT_STREAM_TIME (FALSE)
#define DEFAULT_SKIP_FIRST_TIME (0)
+#define DEFAULT_DROP_NO_SIGNAL_FRAMES (FALSE)
enum
{
@@ -45,7 +46,8 @@
PROP_VIDEO_FORMAT,
PROP_TIMECODE_FORMAT,
PROP_OUTPUT_STREAM_TIME,
- PROP_SKIP_FIRST_TIME
+ PROP_SKIP_FIRST_TIME,
+ PROP_DROP_NO_SIGNAL_FRAMES
};
typedef struct
@@ -195,6 +197,12 @@
G_MAXUINT64, DEFAULT_SKIP_FIRST_TIME,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+ g_object_class_install_property (gobject_class, PROP_DROP_NO_SIGNAL_FRAMES,
+ g_param_spec_boolean ("drop-no-signal-frames", "Drop No Signal Frames",
+ "Drop frames that are marked as having no input signal",
+ DEFAULT_DROP_NO_SIGNAL_FRAMES,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
templ_caps = gst_decklink_mode_get_template_caps ();
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, templ_caps));
@@ -222,6 +230,7 @@
self->no_signal = FALSE;
self->output_stream_time = DEFAULT_OUTPUT_STREAM_TIME;
self->skip_first_time = DEFAULT_SKIP_FIRST_TIME;
+ self->drop_no_signal_frames = DEFAULT_DROP_NO_SIGNAL_FRAMES;
self->window_size = 64;
self->times = g_new (GstClockTime, 4 * self->window_size);
@@ -293,6 +302,9 @@
case PROP_SKIP_FIRST_TIME:
self->skip_first_time = g_value_get_uint64 (value);
break;
+ case PROP_DROP_NO_SIGNAL_FRAMES:
+ self->drop_no_signal_frames = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -331,6 +343,9 @@
case PROP_SKIP_FIRST_TIME:
g_value_set_uint64 (value, self->skip_first_time);
break;
+ case PROP_DROP_NO_SIGNAL_FRAMES:
+ g_value_set_boolean (value, self->drop_no_signal_frames);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -594,8 +609,11 @@
GST_LOG_OBJECT (self,
"Got video frame at %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT " (%"
- GST_TIME_FORMAT ")", GST_TIME_ARGS (capture_time),
- GST_TIME_ARGS (stream_time), GST_TIME_ARGS (stream_duration));
+ GST_TIME_FORMAT "), no signal: %d", GST_TIME_ARGS (capture_time),
+ GST_TIME_ARGS (stream_time), GST_TIME_ARGS (stream_duration), no_signal);
+
+ if (self->drop_no_signal_frames && no_signal)
+ return;
g_mutex_lock (&self->lock);
if (self->first_time == GST_CLOCK_TIME_NONE)
diff --git a/sys/decklink/gstdecklinkvideosrc.h b/sys/decklink/gstdecklinkvideosrc.h
index 3292796..77db2b0 100644
--- a/sys/decklink/gstdecklinkvideosrc.h
+++ b/sys/decklink/gstdecklinkvideosrc.h
@@ -57,6 +57,7 @@
gint device_number;
gboolean output_stream_time;
GstClockTime skip_first_time;
+ gboolean drop_no_signal_frames;
GstVideoInfo info;
GstDecklinkVideoFormat video_format;