status_t SampleTable::setSampleAuxiliaryInformationSizeParams( off64_t data_offset, size_t data_size, uint32_t drm_scheme) { off64_t data_end = data_offset + data_size; uint8_t version; uint32_t aux_type; status_t err = validateCencBoxHeader( mDataSource, data_offset, &version, &aux_type); if (err != OK) { return err; } if (aux_type && aux_type != kAuxTypeCenc && drm_scheme != kAuxTypeCenc) { // Quietly skip aux types we don't care about. return OK; } if (!mCencSizes.IsEmpty() || mCencDefaultSize) { ALOGE("duplicate cenc saiz box"); return ERROR_MALFORMED; } if (version) { ALOGV("unsupported cenc saiz version"); return ERROR_UNSUPPORTED; } if (mDataSource->readAt( data_offset++, &mCencDefaultSize, sizeof(mCencDefaultSize)) < sizeof(mCencDefaultSize)) { return ERROR_IO; } if (!mDataSource->getUInt32(data_offset, &mCencInfoCount)) { return ERROR_IO; } data_offset += 4; if (!mCencDefaultSize) { if (!mCencSizes.InsertElementsAt(0, mCencInfoCount, mozilla::fallible)) { return ERROR_IO; } if (mDataSource->readAt( data_offset, mCencSizes.Elements(), mCencInfoCount) < mCencInfoCount) { return ERROR_IO; } data_offset += mCencInfoCount; } if (data_offset != data_end) { ALOGW("wrong saiz data size, expected %lu, actual %lu", data_size, data_offset - (data_end - data_size)); // Continue, assume extra data is not important. // Parser will skip past the box end. } return parseSampleCencInfo(); }
status_t SampleTable::setSampleAuxiliaryInformationOffsetParams( off64_t data_offset, size_t data_size, uint32_t drm_scheme) { off64_t data_end = data_offset + data_size; uint8_t version; uint32_t aux_type; status_t err = validateCencBoxHeader(mDataSource, data_offset, &version, &aux_type); if (err != OK) { return err; } if (aux_type && aux_type != kAuxTypeCenc && drm_scheme != kAuxTypeCenc) { // Quietly skip aux types we don't care about. return OK; } if (!mCencOffsets.isEmpty()) { ALOGE("duplicate cenc saio box"); return ERROR_MALFORMED; } uint32_t cencOffsetCount; if (!mDataSource->getUInt32(data_offset, &cencOffsetCount)) { ALOGE("error reading cenc aux info offset count"); return ERROR_IO; } data_offset += 4; mCencOffsets.setCapacity(cencOffsetCount); if (!version) { for (uint32_t i = 0; i < cencOffsetCount; i++) { uint32_t tmp; if (!mDataSource->getUInt32(data_offset, &tmp)) { ALOGE("error reading cenc aux info offsets"); return ERROR_IO; } mCencOffsets.push(tmp); data_offset += 4; } } else { for (uint32_t i = 0; i < cencOffsetCount; i++) { if (!mDataSource->getUInt64(data_offset, &mCencOffsets.editItemAt(i))) { ALOGE("error reading cenc aux info offsets"); return ERROR_IO; } data_offset += 8; } } CHECK(data_offset == data_end); return parseSampleCencInfo(); }
status_t SampleTable::setSampleAuxiliaryInformationSizeParams( off64_t data_offset, size_t data_size, uint32_t drm_scheme) { off64_t data_end = data_offset + data_size; uint8_t version; uint32_t aux_type; status_t err = validateCencBoxHeader( mDataSource, data_offset, &version, &aux_type); if (err != OK) { return err; } if (aux_type && aux_type != kAuxTypeCenc && drm_scheme != kAuxTypeCenc) { // Quietly skip aux types we don't care about. return OK; } if (!mCencSizes.isEmpty() || mCencDefaultSize) { ALOGE("duplicate cenc saiz box"); return ERROR_MALFORMED; } if (version) { ALOGV("unsupported cenc saiz version"); return ERROR_UNSUPPORTED; } if (mDataSource->readAt( data_offset++, &mCencDefaultSize, sizeof(mCencDefaultSize)) < sizeof(mCencDefaultSize)) { return ERROR_IO; } if (!mDataSource->getUInt32(data_offset, &mCencInfoCount)) { return ERROR_IO; } data_offset += 4; if (!mCencDefaultSize) { mCencSizes.insertAt(0, 0, mCencInfoCount); if (mDataSource->readAt( data_offset, mCencSizes.editArray(), mCencInfoCount) < mCencInfoCount) { return ERROR_IO; } data_offset += mCencInfoCount; } CHECK(data_offset == data_end); return parseSampleCencInfo(); }
status_t SampleTable::setSampleAuxiliaryInformationOffsetParams( off64_t data_offset, size_t data_size, uint32_t drm_scheme) { off64_t data_end = data_offset + data_size; uint8_t version; uint32_t aux_type; status_t err = validateCencBoxHeader(mDataSource, data_offset, &version, &aux_type); if (err != OK) { return err; } if (aux_type && aux_type != kAuxTypeCenc && drm_scheme != kAuxTypeCenc) { // Quietly skip aux types we don't care about. return OK; } if (!mCencOffsets.IsEmpty()) { ALOGE("duplicate cenc saio box"); return ERROR_MALFORMED; } uint32_t cencOffsetCount; if (!mDataSource->getUInt32(data_offset, &cencOffsetCount)) { ALOGE("error reading cenc aux info offset count"); return ERROR_IO; } data_offset += 4; if (cencOffsetCount >= kMAX_ALLOCATION) { return ERROR_MALFORMED; } if (!version) { if (!mCencOffsets.SetCapacity(cencOffsetCount, mozilla::fallible)) { return ERROR_MALFORMED; } for (uint32_t i = 0; i < cencOffsetCount; i++) { uint32_t tmp; if (!mDataSource->getUInt32(data_offset, &tmp)) { ALOGE("error reading cenc aux info offsets"); return ERROR_IO; } // FIXME: Make this infallible after bug 968520 is done. MOZ_ALWAYS_TRUE(mCencOffsets.AppendElement(tmp, mozilla::fallible)); data_offset += 4; } } else { if (!mCencOffsets.SetLength(cencOffsetCount, mozilla::fallible)) { return ERROR_MALFORMED; } for (uint32_t i = 0; i < cencOffsetCount; i++) { if (!mDataSource->getUInt64(data_offset, &mCencOffsets[i])) { ALOGE("error reading cenc aux info offsets"); return ERROR_IO; } data_offset += 8; } } if (data_offset != data_end) { ALOGW("wrong saio data size, expected %lu, actual %lu", data_size, data_offset - (data_end - data_size)); // Continue, assume extra data is not important. // Parser will skip past the box end. } return parseSampleCencInfo(); }