Clean up CHECK macros in mp4 muxer code.

Change-Id: I887344c8f79bb3b45a17abe23bc0b2614c0dcd48
This commit is contained in:
Kongqun Yang 2014-01-22 16:13:41 -08:00 committed by KongQun Yang
parent fe2214b9a0
commit a8fb39fb27
5 changed files with 20 additions and 15 deletions

View File

@ -19,7 +19,8 @@ const uint64 kInvalidTime = kuint64max;
// otherwise it is a NOP. Return true if the table is optimized.
template <typename T>
bool OptimizeSampleEntries(std::vector<T>* entries, T* default_value) {
DCHECK(entries != NULL && default_value != NULL);
DCHECK(entries);
DCHECK(default_value);
DCHECK(!entries->empty());
typename std::vector<T>::const_iterator it = entries->begin();
@ -54,8 +55,7 @@ MP4Fragmenter::MP4Fragmenter(TrackFragment* traf,
MP4Fragmenter::~MP4Fragmenter() {}
Status MP4Fragmenter::AddSample(scoped_refptr<MediaSample> sample) {
CHECK(sample->pts() >= sample->dts());
CHECK(sample->duration() > 0);
CHECK_GT(sample->duration(), 0);
if (ShouldEncryptFragment()) {
Status status = EncryptSample(sample);

View File

@ -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<BufferWriter> buffer(new BufferWriter());
File* file;

View File

@ -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<MediaSample> 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;

View File

@ -113,7 +113,8 @@ Status MP4Segmenter::Finalize() {
Status MP4Segmenter::AddSample(const MediaStream* stream,
scoped_refptr<MediaSample> 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;
}

View File

@ -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().