decklink*src: Aggregate dropped frame/packet logging

decklink*src currently prints a log entry for every dropped frame and
audio packet. That completely spams the logs.

This change aggregates information about dropped packets and only prints
a message once when dropping starts, and a summary when dropping ends.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/705

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/378>
This commit is contained in:
Georg Lippitsch 2017-11-28 13:44:18 +01:00 committed by Sebastian Dröge
parent 9d810bbd81
commit a45b0c8f1a
4 changed files with 44 additions and 16 deletions

View file

@ -237,6 +237,10 @@ gst_decklink_audio_src_init (GstDecklinkAudioSrc * self)
self->current_packets =
gst_queue_array_new_for_struct (sizeof (CapturePacket),
DEFAULT_BUFFER_SIZE);
self->skipped_last = 0;
self->skip_from_timestamp = GST_CLOCK_TIME_NONE;
self->skip_to_timestamp = GST_CLOCK_TIME_NONE;
}
void
@ -526,25 +530,31 @@ gst_decklink_audio_src_got_packet (GstElement * element,
if (!self->flushing) {
CapturePacket p;
guint skipped_packets = 0;
GstClockTime from_timestamp = GST_CLOCK_TIME_NONE;
GstClockTime to_timestamp = GST_CLOCK_TIME_NONE;
while (gst_queue_array_get_length (self->current_packets) >=
self->buffer_size) {
CapturePacket *tmp = (CapturePacket *)
gst_queue_array_pop_head_struct (self->current_packets);
if (skipped_packets == 0)
from_timestamp = tmp->timestamp;
if (skipped_packets == 0 && self->skipped_last == 0)
self->skip_from_timestamp = tmp->timestamp;
skipped_packets++;
to_timestamp = tmp->timestamp;
self->skip_to_timestamp = tmp->timestamp;
capture_packet_clear (tmp);
}
if (skipped_packets > 0)
if (self->skipped_last == 0 && skipped_packets > 0) {
GST_WARNING_OBJECT (self, "Starting to drop audio packets");
}
if (skipped_packets == 0 && self->skipped_last > 0) {
GST_WARNING_OBJECT (self,
"Dropped %u old packets from %" GST_TIME_FORMAT " to %"
GST_TIME_FORMAT, skipped_packets, GST_TIME_ARGS (from_timestamp),
GST_TIME_ARGS (to_timestamp));
GST_TIME_FORMAT, self->skipped_last,
GST_TIME_ARGS (self->skip_from_timestamp),
GST_TIME_ARGS (self->skip_to_timestamp));
self->skipped_last = 0;
}
self->skipped_last += skipped_packets;
memset (&p, 0, sizeof (p));
p.packet = packet;

View file

@ -81,6 +81,10 @@ struct _GstDecklinkAudioSrc
GstClockTime discont_time;
guint buffer_size;
guint skipped_last;
GstClockTime skip_from_timestamp;
GstClockTime skip_to_timestamp;
};
struct _GstDecklinkAudioSrcClass

View file

@ -408,6 +408,9 @@ gst_decklink_video_src_init (GstDecklinkVideoSrc * self)
self->window_fill = 0;
self->window_skip = 1;
self->window_skip_count = 0;
self->skipped_last = 0;
self->skip_from_timestamp = GST_CLOCK_TIME_NONE;
self->skip_to_timestamp = GST_CLOCK_TIME_NONE;
gst_base_src_set_live (GST_BASE_SRC (self), TRUE);
gst_base_src_set_format (GST_BASE_SRC (self), GST_FORMAT_TIME);
@ -837,27 +840,34 @@ gst_decklink_video_src_got_frame (GstElement * element,
GstVideoTimeCodeFlags flags = GST_VIDEO_TIME_CODE_FLAGS_NONE;
guint field_count = 0;
guint skipped_frames = 0;
GstClockTime from_timestamp = GST_CLOCK_TIME_NONE;
GstClockTime to_timestamp = GST_CLOCK_TIME_NONE;
while (gst_queue_array_get_length (self->current_frames) >=
self->buffer_size) {
CaptureFrame *tmp = (CaptureFrame *)
gst_queue_array_pop_head_struct (self->current_frames);
if (tmp->frame) {
if (skipped_frames == 0)
from_timestamp = tmp->timestamp;
if (skipped_frames == 0 && self->skipped_last == 0)
self->skip_from_timestamp = tmp->timestamp;
skipped_frames++;
to_timestamp = tmp->timestamp;
self->skip_to_timestamp = tmp->timestamp;
}
capture_frame_clear (tmp);
}
if (skipped_frames > 0)
if (self->skipped_last == 0 && skipped_frames > 0) {
GST_WARNING_OBJECT (self, "Starting to drop frames");
}
if (skipped_frames == 0 && self->skipped_last > 0) {
GST_WARNING_OBJECT (self,
"Dropped %u old frames from %" GST_TIME_FORMAT " to %"
GST_TIME_FORMAT, skipped_frames, GST_TIME_ARGS (from_timestamp),
GST_TIME_ARGS (to_timestamp));
GST_TIME_FORMAT, self->skipped_last,
GST_TIME_ARGS (self->skip_from_timestamp),
GST_TIME_ARGS (self->skip_to_timestamp));
self->skipped_last = 0;
}
self->skipped_last += skipped_frames;
memset (&f, 0, sizeof (f));
f.frame = frame;

View file

@ -111,6 +111,10 @@ struct _GstDecklinkVideoSrc
gboolean output_afd_bar;
gint last_afd_bar_vbi_line;
gint last_afd_bar_vbi_line_field2;
guint skipped_last;
GstClockTime skip_from_timestamp;
GstClockTime skip_to_timestamp;
};
struct _GstDecklinkVideoSrcClass