From a8fb39fb27d77b67bc14aab0217a571a2dcd3883 Mon Sep 17 00:00:00 2001 From: Kongqun Yang Date: Wed, 22 Jan 2014 16:13:41 -0800 Subject: [PATCH] Clean up CHECK macros in mp4 muxer code. Change-Id: I887344c8f79bb3b45a17abe23bc0b2614c0dcd48 --- media/mp4/mp4_fragmenter.cc | 6 +++--- media/mp4/mp4_general_segmenter.cc | 9 ++++++--- media/mp4/mp4_muxer.cc | 12 ++++++------ media/mp4/mp4_segmenter.cc | 5 +++-- media/mp4/mp4_vod_segmenter.cc | 3 ++- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/media/mp4/mp4_fragmenter.cc b/media/mp4/mp4_fragmenter.cc index 283162663a..9cd555b338 100644 --- a/media/mp4/mp4_fragmenter.cc +++ b/media/mp4/mp4_fragmenter.cc @@ -19,7 +19,8 @@ const uint64 kInvalidTime = kuint64max; // otherwise it is a NOP. Return true if the table is optimized. template bool OptimizeSampleEntries(std::vector* entries, T* default_value) { - DCHECK(entries != NULL && default_value != NULL); + DCHECK(entries); + DCHECK(default_value); DCHECK(!entries->empty()); typename std::vector::const_iterator it = entries->begin(); @@ -54,8 +55,7 @@ MP4Fragmenter::MP4Fragmenter(TrackFragment* traf, MP4Fragmenter::~MP4Fragmenter() {} Status MP4Fragmenter::AddSample(scoped_refptr sample) { - CHECK(sample->pts() >= sample->dts()); - CHECK(sample->duration() > 0); + CHECK_GT(sample->duration(), 0); if (ShouldEncryptFragment()) { Status status = EncryptSample(sample); diff --git a/media/mp4/mp4_general_segmenter.cc b/media/mp4/mp4_general_segmenter.cc index dcf096943a..9e38f3f911 100644 --- a/media/mp4/mp4_general_segmenter.cc +++ b/media/mp4/mp4_general_segmenter.cc @@ -37,7 +37,8 @@ Status MP4GeneralSegmenter::Initialize( if (!status.ok()) return status; - DCHECK(ftyp() != NULL && moov() != NULL); + DCHECK(ftyp()); + DCHECK(moov()); // Generate the output file with init segment. File* file = File::Open(options().output_file_name.c_str(), "w"); if (file == NULL) { @@ -73,7 +74,7 @@ Status MP4GeneralSegmenter::FinalizeSegment() { if (!status.ok()) return status; - DCHECK(sidx() != NULL); + DCHECK(sidx()); // earliest_presentation_time is the earliest presentation time of any // access unit in the reference stream in the first subsegment. // It will be re-calculated later when subsegments are finalized. @@ -134,7 +135,9 @@ Status MP4GeneralSegmenter::FinalizeSegment() { } Status MP4GeneralSegmenter::WriteSegment() { - DCHECK(sidx() != NULL && fragment_buffer() != NULL && styp_ != NULL); + DCHECK(sidx()); + DCHECK(fragment_buffer()); + DCHECK(styp_); scoped_ptr buffer(new BufferWriter()); File* file; diff --git a/media/mp4/mp4_muxer.cc b/media/mp4/mp4_muxer.cc index ae64f8f17b..93625fb6d7 100644 --- a/media/mp4/mp4_muxer.cc +++ b/media/mp4/mp4_muxer.cc @@ -119,7 +119,7 @@ Status MP4Muxer::Initialize() { } Status MP4Muxer::Finalize() { - DCHECK(segmenter_ != NULL); + DCHECK(segmenter_); Status segmenter_finalized = segmenter_->Finalize(); if (!segmenter_finalized.ok()) @@ -131,7 +131,7 @@ Status MP4Muxer::Finalize() { Status MP4Muxer::AddSample(const MediaStream* stream, scoped_refptr sample) { - DCHECK(segmenter_ != NULL); + DCHECK(segmenter_); return segmenter_->AddSample(stream, sample); } @@ -173,7 +173,7 @@ void MP4Muxer::GenerateVideoTrak(const VideoStreamInfo* video_info, sample_description.video_entries.push_back(video); if (IsEncryptionRequired()) { - DCHECK(encryptor_source() != NULL); + DCHECK(encryptor_source()); // Add a second entry for clear content if needed. if (clear_lead_in_seconds() > 0) sample_description.video_entries.push_back(video); @@ -213,7 +213,7 @@ void MP4Muxer::GenerateAudioTrak(const AudioStreamInfo* audio_info, sample_description.audio_entries.push_back(audio); if (IsEncryptionRequired()) { - DCHECK(encryptor_source() != NULL); + DCHECK(encryptor_source()); // Add a second entry for clear content if needed. if (clear_lead_in_seconds() > 0) sample_description.audio_entries.push_back(audio); @@ -225,13 +225,13 @@ void MP4Muxer::GenerateAudioTrak(const AudioStreamInfo* audio_info, } void MP4Muxer::GeneratePssh(ProtectionSystemSpecificHeader* pssh) { - DCHECK(encryptor_source() != NULL); + DCHECK(encryptor_source()); pssh->system_id = encryptor_source()->key_system_id(); pssh->data = encryptor_source()->pssh(); } void MP4Muxer::GenerateSinf(ProtectionSchemeInfo* sinf, FourCC old_type) { - DCHECK(encryptor_source() != NULL); + DCHECK(encryptor_source()); sinf->format.format = old_type; sinf->type.type = FOURCC_CENC; sinf->type.version = kCencSchemeVersion; diff --git a/media/mp4/mp4_segmenter.cc b/media/mp4/mp4_segmenter.cc index 110f49eaa5..d3c8fcf1aa 100644 --- a/media/mp4/mp4_segmenter.cc +++ b/media/mp4/mp4_segmenter.cc @@ -113,7 +113,8 @@ Status MP4Segmenter::Finalize() { Status MP4Segmenter::AddSample(const MediaStream* stream, scoped_refptr sample) { // Find the fragmenter for this stream. - DCHECK(stream != NULL && stream_map_.find(stream) != stream_map_.end()); + DCHECK(stream); + DCHECK(stream_map_.find(stream) != stream_map_.end()); uint32 stream_id = stream_map_[stream]; MP4Fragmenter* fragmenter = fragmenters_[stream_id]; @@ -191,7 +192,7 @@ Status MP4Segmenter::FinalizeSegment() { } uint32 MP4Segmenter::GetReferenceStreamId() { - DCHECK(sidx_ != NULL); + DCHECK(sidx_); return sidx_->reference_id - 1; } diff --git a/media/mp4/mp4_vod_segmenter.cc b/media/mp4/mp4_vod_segmenter.cc index b09b4d42f6..aa67c0040c 100644 --- a/media/mp4/mp4_vod_segmenter.cc +++ b/media/mp4/mp4_vod_segmenter.cc @@ -111,7 +111,8 @@ Status MP4VODSegmenter::FinalizeSegment() { if (!status.ok()) return status; - DCHECK(sidx() != NULL && fragment_buffer() != NULL); + DCHECK(sidx()); + DCHECK(fragment_buffer()); // sidx() contains pre-generated segment references with one reference per // fragment. In VOD, this segment is converted into a subsegment, i.e. one // reference, which contains all the fragments in sidx().