Clean up CHECK macros in mp4 muxer code.
Change-Id: I887344c8f79bb3b45a17abe23bc0b2614c0dcd48
This commit is contained in:
parent
fe2214b9a0
commit
a8fb39fb27
|
@ -19,7 +19,8 @@ const uint64 kInvalidTime = kuint64max;
|
||||||
// otherwise it is a NOP. Return true if the table is optimized.
|
// otherwise it is a NOP. Return true if the table is optimized.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool OptimizeSampleEntries(std::vector<T>* entries, T* default_value) {
|
bool OptimizeSampleEntries(std::vector<T>* entries, T* default_value) {
|
||||||
DCHECK(entries != NULL && default_value != NULL);
|
DCHECK(entries);
|
||||||
|
DCHECK(default_value);
|
||||||
DCHECK(!entries->empty());
|
DCHECK(!entries->empty());
|
||||||
|
|
||||||
typename std::vector<T>::const_iterator it = entries->begin();
|
typename std::vector<T>::const_iterator it = entries->begin();
|
||||||
|
@ -54,8 +55,7 @@ MP4Fragmenter::MP4Fragmenter(TrackFragment* traf,
|
||||||
MP4Fragmenter::~MP4Fragmenter() {}
|
MP4Fragmenter::~MP4Fragmenter() {}
|
||||||
|
|
||||||
Status MP4Fragmenter::AddSample(scoped_refptr<MediaSample> sample) {
|
Status MP4Fragmenter::AddSample(scoped_refptr<MediaSample> sample) {
|
||||||
CHECK(sample->pts() >= sample->dts());
|
CHECK_GT(sample->duration(), 0);
|
||||||
CHECK(sample->duration() > 0);
|
|
||||||
|
|
||||||
if (ShouldEncryptFragment()) {
|
if (ShouldEncryptFragment()) {
|
||||||
Status status = EncryptSample(sample);
|
Status status = EncryptSample(sample);
|
||||||
|
|
|
@ -37,7 +37,8 @@ Status MP4GeneralSegmenter::Initialize(
|
||||||
if (!status.ok())
|
if (!status.ok())
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
DCHECK(ftyp() != NULL && moov() != NULL);
|
DCHECK(ftyp());
|
||||||
|
DCHECK(moov());
|
||||||
// Generate the output file with init segment.
|
// Generate the output file with init segment.
|
||||||
File* file = File::Open(options().output_file_name.c_str(), "w");
|
File* file = File::Open(options().output_file_name.c_str(), "w");
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
|
@ -73,7 +74,7 @@ Status MP4GeneralSegmenter::FinalizeSegment() {
|
||||||
if (!status.ok())
|
if (!status.ok())
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
DCHECK(sidx() != NULL);
|
DCHECK(sidx());
|
||||||
// earliest_presentation_time is the earliest presentation time of any
|
// earliest_presentation_time is the earliest presentation time of any
|
||||||
// access unit in the reference stream in the first subsegment.
|
// access unit in the reference stream in the first subsegment.
|
||||||
// It will be re-calculated later when subsegments are finalized.
|
// It will be re-calculated later when subsegments are finalized.
|
||||||
|
@ -134,7 +135,9 @@ Status MP4GeneralSegmenter::FinalizeSegment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Status MP4GeneralSegmenter::WriteSegment() {
|
Status MP4GeneralSegmenter::WriteSegment() {
|
||||||
DCHECK(sidx() != NULL && fragment_buffer() != NULL && styp_ != NULL);
|
DCHECK(sidx());
|
||||||
|
DCHECK(fragment_buffer());
|
||||||
|
DCHECK(styp_);
|
||||||
|
|
||||||
scoped_ptr<BufferWriter> buffer(new BufferWriter());
|
scoped_ptr<BufferWriter> buffer(new BufferWriter());
|
||||||
File* file;
|
File* file;
|
||||||
|
|
|
@ -119,7 +119,7 @@ Status MP4Muxer::Initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Status MP4Muxer::Finalize() {
|
Status MP4Muxer::Finalize() {
|
||||||
DCHECK(segmenter_ != NULL);
|
DCHECK(segmenter_);
|
||||||
Status segmenter_finalized = segmenter_->Finalize();
|
Status segmenter_finalized = segmenter_->Finalize();
|
||||||
|
|
||||||
if (!segmenter_finalized.ok())
|
if (!segmenter_finalized.ok())
|
||||||
|
@ -131,7 +131,7 @@ Status MP4Muxer::Finalize() {
|
||||||
|
|
||||||
Status MP4Muxer::AddSample(const MediaStream* stream,
|
Status MP4Muxer::AddSample(const MediaStream* stream,
|
||||||
scoped_refptr<MediaSample> sample) {
|
scoped_refptr<MediaSample> sample) {
|
||||||
DCHECK(segmenter_ != NULL);
|
DCHECK(segmenter_);
|
||||||
return segmenter_->AddSample(stream, sample);
|
return segmenter_->AddSample(stream, sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ void MP4Muxer::GenerateVideoTrak(const VideoStreamInfo* video_info,
|
||||||
sample_description.video_entries.push_back(video);
|
sample_description.video_entries.push_back(video);
|
||||||
|
|
||||||
if (IsEncryptionRequired()) {
|
if (IsEncryptionRequired()) {
|
||||||
DCHECK(encryptor_source() != NULL);
|
DCHECK(encryptor_source());
|
||||||
// Add a second entry for clear content if needed.
|
// Add a second entry for clear content if needed.
|
||||||
if (clear_lead_in_seconds() > 0)
|
if (clear_lead_in_seconds() > 0)
|
||||||
sample_description.video_entries.push_back(video);
|
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);
|
sample_description.audio_entries.push_back(audio);
|
||||||
|
|
||||||
if (IsEncryptionRequired()) {
|
if (IsEncryptionRequired()) {
|
||||||
DCHECK(encryptor_source() != NULL);
|
DCHECK(encryptor_source());
|
||||||
// Add a second entry for clear content if needed.
|
// Add a second entry for clear content if needed.
|
||||||
if (clear_lead_in_seconds() > 0)
|
if (clear_lead_in_seconds() > 0)
|
||||||
sample_description.audio_entries.push_back(audio);
|
sample_description.audio_entries.push_back(audio);
|
||||||
|
@ -225,13 +225,13 @@ void MP4Muxer::GenerateAudioTrak(const AudioStreamInfo* audio_info,
|
||||||
}
|
}
|
||||||
|
|
||||||
void MP4Muxer::GeneratePssh(ProtectionSystemSpecificHeader* pssh) {
|
void MP4Muxer::GeneratePssh(ProtectionSystemSpecificHeader* pssh) {
|
||||||
DCHECK(encryptor_source() != NULL);
|
DCHECK(encryptor_source());
|
||||||
pssh->system_id = encryptor_source()->key_system_id();
|
pssh->system_id = encryptor_source()->key_system_id();
|
||||||
pssh->data = encryptor_source()->pssh();
|
pssh->data = encryptor_source()->pssh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MP4Muxer::GenerateSinf(ProtectionSchemeInfo* sinf, FourCC old_type) {
|
void MP4Muxer::GenerateSinf(ProtectionSchemeInfo* sinf, FourCC old_type) {
|
||||||
DCHECK(encryptor_source() != NULL);
|
DCHECK(encryptor_source());
|
||||||
sinf->format.format = old_type;
|
sinf->format.format = old_type;
|
||||||
sinf->type.type = FOURCC_CENC;
|
sinf->type.type = FOURCC_CENC;
|
||||||
sinf->type.version = kCencSchemeVersion;
|
sinf->type.version = kCencSchemeVersion;
|
||||||
|
|
|
@ -113,7 +113,8 @@ Status MP4Segmenter::Finalize() {
|
||||||
Status MP4Segmenter::AddSample(const MediaStream* stream,
|
Status MP4Segmenter::AddSample(const MediaStream* stream,
|
||||||
scoped_refptr<MediaSample> sample) {
|
scoped_refptr<MediaSample> sample) {
|
||||||
// Find the fragmenter for this stream.
|
// 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];
|
uint32 stream_id = stream_map_[stream];
|
||||||
MP4Fragmenter* fragmenter = fragmenters_[stream_id];
|
MP4Fragmenter* fragmenter = fragmenters_[stream_id];
|
||||||
|
|
||||||
|
@ -191,7 +192,7 @@ Status MP4Segmenter::FinalizeSegment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 MP4Segmenter::GetReferenceStreamId() {
|
uint32 MP4Segmenter::GetReferenceStreamId() {
|
||||||
DCHECK(sidx_ != NULL);
|
DCHECK(sidx_);
|
||||||
return sidx_->reference_id - 1;
|
return sidx_->reference_id - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,8 @@ Status MP4VODSegmenter::FinalizeSegment() {
|
||||||
if (!status.ok())
|
if (!status.ok())
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
DCHECK(sidx() != NULL && fragment_buffer() != NULL);
|
DCHECK(sidx());
|
||||||
|
DCHECK(fragment_buffer());
|
||||||
// sidx() contains pre-generated segment references with one reference per
|
// sidx() contains pre-generated segment references with one reference per
|
||||||
// fragment. In VOD, this segment is converted into a subsegment, i.e. one
|
// fragment. In VOD, this segment is converted into a subsegment, i.e. one
|
||||||
// reference, which contains all the fragments in sidx().
|
// reference, which contains all the fragments in sidx().
|
||||||
|
|
Loading…
Reference in New Issue