decklinksrc: Reset timestamp observations on format change
authorSebastian Dröge <sebastian@centricular.com>
Mon, 22 Jul 2019 14:57:01 +0000 (17:57 +0300)
committerSebastian Dröge <sebastian@centricular.com>
Thu, 25 Jul 2019 09:29:22 +0000 (12:29 +0300)
We will usually get timestamps starting from 0 again and due to the
format change the clock of the input might also be different.

sys/decklink/gstdecklink.cpp

index fd42eabf8501cb30dd7624db0c7b9cda6d7fed4b..7ede6aa96eef2b5e04c7d122a8215f48fd917fb9 100644 (file)
@@ -887,6 +887,27 @@ public:
     m_input->input->EnableVideoInput (mode->GetDisplayMode (),
         pixelFormat, bmdVideoInputEnableFormatDetection);
     m_input->input->FlushStreams ();
+
+    /* Reset any timestamp observations we might've made */
+    if (m_input->videosrc) {
+      GstDecklinkVideoSrc *videosrc = GST_DECKLINK_VIDEO_SRC (m_input->videosrc);
+
+      g_mutex_lock (&videosrc->lock);
+      videosrc->window_fill = 0;
+      videosrc->window_filled = FALSE;
+      videosrc->window_skip = 1;
+      videosrc->window_skip_count = 0;
+      videosrc->current_time_mapping.xbase = 0;
+      videosrc->current_time_mapping.b = 0;
+      videosrc->current_time_mapping.num = 1;
+      videosrc->current_time_mapping.den = 1;
+      videosrc->next_time_mapping.xbase = 0;
+      videosrc->next_time_mapping.b = 0;
+      videosrc->next_time_mapping.num = 1;
+      videosrc->next_time_mapping.den = 1;
+      g_mutex_unlock (&videosrc->lock);
+    }
+
     m_input->input->StartStreams ();
     m_input->mode =
         gst_decklink_get_mode (gst_decklink_get_mode_enum_from_bmd