From e0e0925b315adc0a8c9a1e720b7df3a52242cb1b Mon Sep 17 00:00:00 2001 From: Jacob Trimble Date: Wed, 24 Feb 2016 15:48:11 -0800 Subject: [PATCH] Add error messages for when a WebM Cluster is too large. Issue #90 Change-Id: I7fe8393df931a12e999724e3604648b97de24da7 --- packager/media/formats/webm/segmenter.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packager/media/formats/webm/segmenter.cc b/packager/media/formats/webm/segmenter.cc index 34e0cafbde..5db1d3f96b 100644 --- a/packager/media/formats/webm/segmenter.cc +++ b/packager/media/formats/webm/segmenter.cc @@ -392,6 +392,18 @@ Status Segmenter::WriteFrame(bool write_duration) { frame.set_reference_block_timestamp(timestamp_ns); } + // GetRelativeTimecode will return -1 if the relative timecode is too large + // to fit in the frame. + if (cluster_->GetRelativeTimecode(frame.timestamp() / + cluster_->timecode_scale()) < 0) { + const double segment_duration = + static_cast(frame.timestamp()) / kSecondsToNs; + LOG(ERROR) << "Error adding sample to segment: segment too large, " + << segment_duration << " seconds."; + return Status(error::MUXER_FAILURE, + "Error adding sample to segment: segment too large"); + } + if (!cluster_->AddFrame(&frame)) { return Status(error::MUXER_FAILURE, "Error adding sample to segment: Cluster::AddFrame failed");