videotimecode: Fix handling of timecodes without daily jam in gst_video_time_code_to_...
authorSebastian Dröge <sebastian@centricular.com>
Fri, 14 Dec 2018 18:59:11 +0000 (20:59 +0200)
committerMathieu Duponchelle <mduponchelle1@gmail.com>
Wed, 19 Dec 2018 23:11:24 +0000 (23:11 +0000)
So that it behaves according to documentation.

gst-libs/gst/video/gstvideotimecode.c

index 748b7bf..d99f2b2 100644 (file)
@@ -177,17 +177,13 @@ gst_video_time_code_to_date_time (const GstVideoTimeCode * tc)
   gdouble add_us;
 
   g_return_val_if_fail (gst_video_time_code_is_valid (tc), NULL);
-  g_return_val_if_fail (tc->config.latest_daily_jam != NULL, NULL);
 
-  ret = g_date_time_ref (tc->config.latest_daily_jam);
-
-  if (ret == NULL) {
+  if (tc->config.latest_daily_jam == NULL) {
     gchar *tc_str = gst_video_time_code_to_string (tc);
     GST_WARNING
         ("Asked to convert time code %s to GDateTime, but its latest daily jam is NULL",
         tc_str);
     g_free (tc_str);
-    g_date_time_unref (ret);
     return NULL;
   }
 
@@ -197,10 +193,11 @@ gst_video_time_code_to_date_time (const GstVideoTimeCode * tc)
         ("Asked to convert time code %s to GDateTime, but its framerate is unknown",
         tc_str);
     g_free (tc_str);
-    g_date_time_unref (ret);
     return NULL;
   }
 
+  ret = g_date_time_ref (tc->config.latest_daily_jam);
+
   gst_util_fraction_to_double (tc->frames * tc->config.fps_d, tc->config.fps_n,
       &add_us);
   if ((tc->config.flags & GST_VIDEO_TIME_CODE_FLAGS_INTERLACED)