зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1044714 - Add MP4 parser 'trex' atom support; r=edwin
This commit is contained in:
Родитель
d3ef0039ef
Коммит
02c96aa201
|
@ -48,7 +48,8 @@ public:
|
|||
int32_t timeScale,
|
||||
const sp<SampleTable> &sampleTable,
|
||||
Vector<SidxEntry> &sidx,
|
||||
off64_t firstMoofOffset);
|
||||
off64_t firstMoofOffset,
|
||||
MPEG4Extractor::TrackExtends &trackExtends);
|
||||
|
||||
virtual status_t start(MetaData *params = NULL);
|
||||
virtual status_t stop();
|
||||
|
@ -142,6 +143,7 @@ private:
|
|||
Vector<uint32_t> encryptedsizes;
|
||||
};
|
||||
Vector<Sample> mCurrentSamples;
|
||||
MPEG4Extractor::TrackExtends mTrackExtends;
|
||||
|
||||
MPEG4Source(const MPEG4Source &);
|
||||
MPEG4Source &operator=(const MPEG4Source &);
|
||||
|
@ -1046,6 +1048,17 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
|
|||
break;
|
||||
}
|
||||
|
||||
case FOURCC('t', 'r', 'e', 'x'):
|
||||
{
|
||||
status_t err;
|
||||
if ((err = parseTrackExtends(data_offset, chunk_data_size)) != OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
*offset += chunk_size;
|
||||
break;
|
||||
}
|
||||
|
||||
case FOURCC('t', 'k', 'h', 'd'):
|
||||
{
|
||||
status_t err;
|
||||
|
@ -1908,7 +1921,26 @@ status_t MPEG4Extractor::parseSegmentIndex(off64_t offset, size_t size) {
|
|||
return OK;
|
||||
}
|
||||
|
||||
|
||||
status_t MPEG4Extractor::parseTrackExtends(
|
||||
off64_t data_offset, off64_t data_size) {
|
||||
if (data_size != 24) {
|
||||
return ERROR_MALFORMED;
|
||||
}
|
||||
uint8_t buffer[24];
|
||||
if (mDataSource->readAt(data_offset, buffer, 24) < 24) {
|
||||
return ERROR_IO;
|
||||
}
|
||||
mTrackExtends.mVersion = buffer[0];
|
||||
mTrackExtends.mFlags[0] = buffer[1];
|
||||
mTrackExtends.mFlags[1] = buffer[2];
|
||||
mTrackExtends.mFlags[2] = buffer[3];
|
||||
mTrackExtends.mTrackId = U32_AT(&buffer[4]);
|
||||
mTrackExtends.mDefaultSampleDescriptionIndex = U32_AT(&buffer[8]);
|
||||
mTrackExtends.mDefaultSampleDuration = U32_AT(&buffer[12]);
|
||||
mTrackExtends.mDefaultSampleSize = U32_AT(&buffer[16]);
|
||||
mTrackExtends.mDefaultSampleFlags = U32_AT(&buffer[20]);
|
||||
return OK;
|
||||
}
|
||||
|
||||
status_t MPEG4Extractor::parseTrackHeader(
|
||||
off64_t data_offset, off64_t data_size) {
|
||||
|
@ -2210,7 +2242,7 @@ sp<MediaSource> MPEG4Extractor::getTrack(size_t index) {
|
|||
|
||||
return new MPEG4Source(
|
||||
track->meta, mDataSource, track->timescale, track->sampleTable,
|
||||
mSidxEntries, mMoofOffset);
|
||||
mSidxEntries, mMoofOffset, mTrackExtends);
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -2372,7 +2404,8 @@ MPEG4Source::MPEG4Source(
|
|||
int32_t timeScale,
|
||||
const sp<SampleTable> &sampleTable,
|
||||
Vector<SidxEntry> &sidx,
|
||||
off64_t firstMoofOffset)
|
||||
off64_t firstMoofOffset,
|
||||
MPEG4Extractor::TrackExtends &trackExtends)
|
||||
: mFormat(format),
|
||||
mDataSource(dataSource),
|
||||
mTimescale(timeScale),
|
||||
|
@ -2392,7 +2425,8 @@ MPEG4Source::MPEG4Source(
|
|||
mStarted(false),
|
||||
mBuffer(NULL),
|
||||
mWantsNALFragments(false),
|
||||
mSrcBuffer(NULL) {
|
||||
mSrcBuffer(NULL),
|
||||
mTrackExtends(trackExtends) {
|
||||
|
||||
mFormat->findInt32(kKeyCryptoMode, &mCryptoMode);
|
||||
mDefaultIVSize = 0;
|
||||
|
@ -2937,7 +2971,7 @@ status_t MPEG4Source::parseTrackFragmentRun(off64_t offset, off64_t size) {
|
|||
& TrackFragmentHeaderInfo::kDefaultSampleDurationPresent) {
|
||||
sampleDuration = mTrackFragmentHeaderInfo.mDefaultSampleDuration;
|
||||
} else {
|
||||
sampleDuration = mTrackFragmentHeaderInfo.mDefaultSampleDuration;
|
||||
sampleDuration = mTrackExtends.mDefaultSampleDuration;
|
||||
}
|
||||
|
||||
if (flags & kSampleSizePresent) {
|
||||
|
@ -2946,7 +2980,7 @@ status_t MPEG4Source::parseTrackFragmentRun(off64_t offset, off64_t size) {
|
|||
& TrackFragmentHeaderInfo::kDefaultSampleSizePresent) {
|
||||
sampleSize = mTrackFragmentHeaderInfo.mDefaultSampleSize;
|
||||
} else {
|
||||
sampleSize = mTrackFragmentHeaderInfo.mDefaultSampleSize;
|
||||
sampleSize = mTrackExtends.mDefaultSampleSize;
|
||||
}
|
||||
|
||||
if (flags & kSampleFlagsPresent) {
|
||||
|
@ -2955,7 +2989,7 @@ status_t MPEG4Source::parseTrackFragmentRun(off64_t offset, off64_t size) {
|
|||
& TrackFragmentHeaderInfo::kDefaultSampleFlagsPresent) {
|
||||
sampleFlags = mTrackFragmentHeaderInfo.mDefaultSampleFlags;
|
||||
} else {
|
||||
sampleFlags = mTrackFragmentHeaderInfo.mDefaultSampleFlags;
|
||||
sampleFlags = mTrackExtends.mDefaultSampleFlags;
|
||||
}
|
||||
|
||||
if (flags & kSampleCompositionTimeOffsetPresent) {
|
||||
|
|
|
@ -54,6 +54,24 @@ public:
|
|||
// for DRM
|
||||
virtual char* getDrmTrackInfo(size_t trackID, int *len);
|
||||
|
||||
struct TrackExtends {
|
||||
TrackExtends(): mVersion(0), mTrackId(0),
|
||||
mDefaultSampleDescriptionIndex(0), mDefaultSampleDuration(0),
|
||||
mDefaultSampleSize(0), mDefaultSampleFlags(0)
|
||||
{
|
||||
mFlags[0] = 0;
|
||||
mFlags[1] = 0;
|
||||
mFlags[2] = 0;
|
||||
}
|
||||
uint8_t mVersion;
|
||||
uint8_t mFlags[3];
|
||||
uint32_t mTrackId;
|
||||
uint32_t mDefaultSampleDescriptionIndex;
|
||||
uint32_t mDefaultSampleDuration;
|
||||
uint32_t mDefaultSampleSize;
|
||||
uint32_t mDefaultSampleFlags;
|
||||
};
|
||||
|
||||
protected:
|
||||
virtual ~MPEG4Extractor();
|
||||
|
||||
|
@ -113,8 +131,12 @@ private:
|
|||
SINF *mFirstSINF;
|
||||
|
||||
bool mIsDrm;
|
||||
TrackExtends mTrackExtends;
|
||||
|
||||
status_t parseDrmSINF(off64_t *offset, off64_t data_offset);
|
||||
|
||||
status_t parseTrackExtends(off64_t data_offset, off64_t data_size);
|
||||
|
||||
status_t parseTrackHeader(off64_t data_offset, off64_t data_size);
|
||||
|
||||
status_t parseSegmentIndex(off64_t data_offset, size_t data_size);
|
||||
|
|
Загрузка…
Ссылка в новой задаче