Add error messages for when a WebM Cluster is too large.

Issue #90

Change-Id: I7fe8393df931a12e999724e3604648b97de24da7
This commit is contained in:
Jacob Trimble 2016-02-24 15:48:11 -08:00
parent a01b07fbfd
commit e0e0925b31
1 changed files with 12 additions and 0 deletions

View File

@ -392,6 +392,18 @@ Status Segmenter::WriteFrame(bool write_duration) {
frame.set_reference_block_timestamp(timestamp_ns); 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<double>(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)) { if (!cluster_->AddFrame(&frame)) {
return Status(error::MUXER_FAILURE, return Status(error::MUXER_FAILURE,
"Error adding sample to segment: Cluster::AddFrame failed"); "Error adding sample to segment: Cluster::AddFrame failed");