Fixed splitmuxsink 32-bit overflow bug
authorJie Jiang <jiangjie@nudt.edu.cn>
Sat, 20 Aug 2016 08:59:30 +0000 (16:59 +0800)
committerJan Schmidt <jan@centricular.com>
Sat, 20 Aug 2016 09:53:11 +0000 (19:53 +1000)
Extend the byte tracking counters to 64-bit on
all platforms, instead of using gsize, which overflows
after 4GB.

https://bugzilla.gnome.org/show_bug.cgi?id=770019

gst/multifile/gstsplitmuxsink.c
gst/multifile/gstsplitmuxsink.h

index 8d352ff..1e0c91e 100644 (file)
@@ -748,7 +748,7 @@ handle_mq_output (GstPad * pad, GstPadProbeInfo * info, MqStreamCtx * ctx)
 
   GST_LOG_OBJECT (splitmux,
       "Pad %" GST_PTR_FORMAT " buffer with run TS %" GST_STIME_FORMAT
-      " size %" G_GSIZE_FORMAT,
+      " size %" G_GUINT64_FORMAT,
       pad, GST_STIME_ARGS (ctx->out_running_time), buf_info->buf_size);
 
   if (splitmux->opening_first_fragment) {
@@ -920,7 +920,7 @@ static void
 handle_gathered_gop (GstSplitMuxSink * splitmux)
 {
   GList *cur;
-  gsize queued_bytes = 0;
+  guint64 queued_bytes = 0;
   GstClockTimeDiff queued_time = 0;
 
   /* Assess if the multiqueue contents overflowed the current file */
@@ -932,6 +932,9 @@ handle_gathered_gop (GstSplitMuxSink * splitmux)
     queued_bytes += tmpctx->in_bytes;
   }
 
+  GST_LOG_OBJECT (splitmux, " queued_bytes %" G_GUINT64_FORMAT
+      " splitmuxsink->mux_start_bytes %" G_GUINT64_FORMAT, queued_bytes,
+      splitmux->mux_start_bytes);
   g_assert (queued_bytes >= splitmux->mux_start_bytes);
   g_assert (queued_time >= splitmux->mux_start_time);
 
@@ -942,7 +945,7 @@ handle_gathered_gop (GstSplitMuxSink * splitmux)
   queued_bytes += (queued_bytes * splitmux->mux_overhead);
 
   GST_LOG_OBJECT (splitmux, "mq at TS %" GST_STIME_FORMAT
-      " bytes %" G_GSIZE_FORMAT, GST_STIME_ARGS (queued_time), queued_bytes);
+      " bytes %" G_GUINT64_FORMAT, GST_STIME_ARGS (queued_time), queued_bytes);
 
   /* Check for overrun - have we output at least one byte and overrun
    * either threshold? */
@@ -961,7 +964,7 @@ handle_gathered_gop (GstSplitMuxSink * splitmux)
   } else {
     /* No overflow */
     GST_LOG_OBJECT (splitmux,
-        "This GOP didn't overflow the fragment. Bytes sent %" G_GSIZE_FORMAT
+        "This GOP didn't overflow the fragment. Bytes sent %" G_GUINT64_FORMAT
         " queued %" G_GSIZE_FORMAT " time %" GST_STIME_FORMAT " Continuing.",
         splitmux->muxed_out_bytes - splitmux->mux_start_bytes,
         queued_bytes, GST_STIME_ARGS (queued_time));
@@ -1222,7 +1225,7 @@ handle_mq_input (GstPad * pad, GstPadProbeInfo * info, MqStreamCtx * ctx)
   }
 
   GST_DEBUG_OBJECT (pad, "Buf TS %" GST_STIME_FORMAT
-      " total in_bytes %" G_GSIZE_FORMAT,
+      " total in_bytes %" G_GUINT64_FORMAT,
       GST_STIME_ARGS (buf_info->run_ts), ctx->in_bytes);
 
   loop_again = TRUE;
index f966bb7..aeda8a5 100644 (file)
@@ -49,7 +49,7 @@ typedef struct _MqStreamBuf
 {
   gboolean keyframe;
   GstClockTimeDiff run_ts;
-  gsize buf_size;
+  guint64 buf_size;
   GstClockTime duration;
 } MqStreamBuf;
 
@@ -74,7 +74,7 @@ typedef struct _MqStreamCtx
   GstClockTimeDiff in_running_time;
   GstClockTimeDiff out_running_time;
 
-  gsize in_bytes;
+  guint64 in_bytes;
 
   GQueue queued_bufs;
 
@@ -120,11 +120,11 @@ struct _GstSplitMuxSink {
   GstClockTimeDiff max_out_running_time;
 
   GstClockTimeDiff muxed_out_time;
-  gsize muxed_out_bytes;
+  guint64 muxed_out_bytes;
   gboolean have_muxed_something;
 
   GstClockTimeDiff mux_start_time;
-  gsize mux_start_bytes;
+  guint64 mux_start_bytes;
   GstClockTime last_frame_duration;
 
   gboolean opening_first_fragment;