flvmux: don't put timestamps larger than G_MAXINT32 in the FLV tags
authorJan Urbański <wulczer@wulczer.org>
Tue, 16 Mar 2010 22:32:45 +0000 (23:32 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 17 Mar 2010 08:24:49 +0000 (09:24 +0100)
For non-live input respond by pushing EOS, for live wrap the
timestamps every G_MAXINT32 miliseconds.

Fixes #613003.

gst/flv/gstflvmux.c

index efaca19..4b12715 100644 (file)
@@ -896,6 +896,8 @@ gst_flv_mux_buffer_to_tag_internal (GstFlvMux * mux, GstBuffer * buffer,
   data[2] = ((size - 11 - 4) >> 8) & 0xff;
   data[3] = ((size - 11 - 4) >> 0) & 0xff;
 
+  /* wrap the timestamp every G_MAXINT32 miliseconds */
+  timestamp &= 0x7fffffff;
   data[4] = (timestamp >> 16) & 0xff;
   data[5] = (timestamp >> 8) & 0xff;
   data[6] = (timestamp >> 0) & 0xff;
@@ -1345,8 +1347,11 @@ gst_flv_mux_collected (GstCollectPads * pads, gpointer user_data)
     }
   }
 
-  if (GST_CLOCK_TIME_IS_VALID (best_time)
-      && best_time / GST_MSECOND > G_MAXUINT32) {
+  /* The FLV timestamp is an int32 field. For non-live streams error out if a
+     bigger timestamp is seen, for live the timestamp will get wrapped in
+     gst_flv_mux_buffer_to_tag */
+  if (!mux->is_live && GST_CLOCK_TIME_IS_VALID (best_time)
+      && best_time / GST_MSECOND > G_MAXINT32) {
     GST_WARNING_OBJECT (mux, "Timestamp larger than FLV supports - EOS");
     eos = TRUE;
   }