Fixed splitmuxsink 32-bit overflow bug

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
This commit is contained in:
Jie Jiang 2016-08-20 16:59:30 +08:00 committed by Jan Schmidt
parent 64fd099a3a
commit 655856deee
2 changed files with 12 additions and 9 deletions

View file

@ -748,7 +748,7 @@ handle_mq_output (GstPad * pad, GstPadProbeInfo * info, MqStreamCtx * ctx)
GST_LOG_OBJECT (splitmux, GST_LOG_OBJECT (splitmux,
"Pad %" GST_PTR_FORMAT " buffer with run TS %" GST_STIME_FORMAT "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); pad, GST_STIME_ARGS (ctx->out_running_time), buf_info->buf_size);
if (splitmux->opening_first_fragment) { if (splitmux->opening_first_fragment) {
@ -920,7 +920,7 @@ static void
handle_gathered_gop (GstSplitMuxSink * splitmux) handle_gathered_gop (GstSplitMuxSink * splitmux)
{ {
GList *cur; GList *cur;
gsize queued_bytes = 0; guint64 queued_bytes = 0;
GstClockTimeDiff queued_time = 0; GstClockTimeDiff queued_time = 0;
/* Assess if the multiqueue contents overflowed the current file */ /* Assess if the multiqueue contents overflowed the current file */
@ -932,6 +932,9 @@ handle_gathered_gop (GstSplitMuxSink * splitmux)
queued_bytes += tmpctx->in_bytes; 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_bytes >= splitmux->mux_start_bytes);
g_assert (queued_time >= splitmux->mux_start_time); g_assert (queued_time >= splitmux->mux_start_time);
@ -942,7 +945,7 @@ handle_gathered_gop (GstSplitMuxSink * splitmux)
queued_bytes += (queued_bytes * splitmux->mux_overhead); queued_bytes += (queued_bytes * splitmux->mux_overhead);
GST_LOG_OBJECT (splitmux, "mq at TS %" GST_STIME_FORMAT 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 /* Check for overrun - have we output at least one byte and overrun
* either threshold? */ * either threshold? */
@ -961,7 +964,7 @@ handle_gathered_gop (GstSplitMuxSink * splitmux)
} else { } else {
/* No overflow */ /* No overflow */
GST_LOG_OBJECT (splitmux, 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.", " queued %" G_GSIZE_FORMAT " time %" GST_STIME_FORMAT " Continuing.",
splitmux->muxed_out_bytes - splitmux->mux_start_bytes, splitmux->muxed_out_bytes - splitmux->mux_start_bytes,
queued_bytes, GST_STIME_ARGS (queued_time)); 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 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); GST_STIME_ARGS (buf_info->run_ts), ctx->in_bytes);
loop_again = TRUE; loop_again = TRUE;

View file

@ -49,7 +49,7 @@ typedef struct _MqStreamBuf
{ {
gboolean keyframe; gboolean keyframe;
GstClockTimeDiff run_ts; GstClockTimeDiff run_ts;
gsize buf_size; guint64 buf_size;
GstClockTime duration; GstClockTime duration;
} MqStreamBuf; } MqStreamBuf;
@ -74,7 +74,7 @@ typedef struct _MqStreamCtx
GstClockTimeDiff in_running_time; GstClockTimeDiff in_running_time;
GstClockTimeDiff out_running_time; GstClockTimeDiff out_running_time;
gsize in_bytes; guint64 in_bytes;
GQueue queued_bufs; GQueue queued_bufs;
@ -120,11 +120,11 @@ struct _GstSplitMuxSink {
GstClockTimeDiff max_out_running_time; GstClockTimeDiff max_out_running_time;
GstClockTimeDiff muxed_out_time; GstClockTimeDiff muxed_out_time;
gsize muxed_out_bytes; guint64 muxed_out_bytes;
gboolean have_muxed_something; gboolean have_muxed_something;
GstClockTimeDiff mux_start_time; GstClockTimeDiff mux_start_time;
gsize mux_start_bytes; guint64 mux_start_bytes;
GstClockTime last_frame_duration; GstClockTime last_frame_duration;
gboolean opening_first_fragment; gboolean opening_first_fragment;