Loading media/libstagefright/MPEG4Extractor.cpp +56 −0 Original line number Original line Diff line number Diff line Loading @@ -878,6 +878,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { } } } } if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->sampleTable = new SampleTable(mDataSource); mLastTrack->sampleTable = new SampleTable(mDataSource); } } Loading Loading @@ -1032,6 +1035,10 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { } } original_fourcc = ntohl(original_fourcc); original_fourcc = ntohl(original_fourcc); ALOGV("read original format: %d", original_fourcc); ALOGV("read original format: %d", original_fourcc); if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(original_fourcc)); mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(original_fourcc)); uint32_t num_channels = 0; uint32_t num_channels = 0; uint32_t sample_rate = 0; uint32_t sample_rate = 0; Loading Loading @@ -1087,6 +1094,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { return ERROR_IO; return ERROR_IO; } } if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->meta->setInt32(kKeyCryptoMode, defaultAlgorithmId); mLastTrack->meta->setInt32(kKeyCryptoMode, defaultAlgorithmId); mLastTrack->meta->setInt32(kKeyCryptoDefaultIVSize, defaultIVSize); mLastTrack->meta->setInt32(kKeyCryptoDefaultIVSize, defaultIVSize); mLastTrack->meta->setData(kKeyCryptoKey, 'tenc', defaultKeyId, 16); mLastTrack->meta->setData(kKeyCryptoKey, 'tenc', defaultKeyId, 16); Loading Loading @@ -1266,6 +1276,10 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { // display the timed text. // display the timed text. // For encrypted files, there may also be more than one entry. // For encrypted files, there may also be more than one entry. const char *mime; const char *mime; if (mLastTrack == NULL) return ERROR_MALFORMED; CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); if (strcasecmp(mime, MEDIA_MIMETYPE_TEXT_3GPP) && if (strcasecmp(mime, MEDIA_MIMETYPE_TEXT_3GPP) && strcasecmp(mime, "application/octet-stream")) { strcasecmp(mime, "application/octet-stream")) { Loading Loading @@ -1312,6 +1326,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { uint16_t sample_size = U16_AT(&buffer[18]); uint16_t sample_size = U16_AT(&buffer[18]); uint32_t sample_rate = U32_AT(&buffer[24]) >> 16; uint32_t sample_rate = U32_AT(&buffer[24]) >> 16; if (mLastTrack == NULL) return ERROR_MALFORMED; if (chunk_type != FOURCC('e', 'n', 'c', 'a')) { if (chunk_type != FOURCC('e', 'n', 'c', 'a')) { // if the chunk type is enca, we'll get the type from the sinf/frma box later // if the chunk type is enca, we'll get the type from the sinf/frma box later mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(chunk_type)); mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(chunk_type)); Loading Loading @@ -1373,6 +1390,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { // printf("*** coding='%s' width=%d height=%d\n", // printf("*** coding='%s' width=%d height=%d\n", // chunk, width, height); // chunk, width, height); if (mLastTrack == NULL) return ERROR_MALFORMED; if (chunk_type != FOURCC('e', 'n', 'c', 'v')) { if (chunk_type != FOURCC('e', 'n', 'c', 'v')) { // if the chunk type is encv, we'll get the type from the sinf/frma box later // if the chunk type is encv, we'll get the type from the sinf/frma box later mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(chunk_type)); mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(chunk_type)); Loading Loading @@ -1618,6 +1638,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { return ERROR_MALFORMED; return ERROR_MALFORMED; } } if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->meta->setData( mLastTrack->meta->setData( kKeyESDS, kTypeESDS, &buffer[4], chunk_data_size - 4); kKeyESDS, kTypeESDS, &buffer[4], chunk_data_size - 4); Loading Loading @@ -1650,6 +1673,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { return ERROR_IO; return ERROR_IO; } } if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->meta->setData( mLastTrack->meta->setData( kKeyAVCC, kTypeAVCC, buffer->data(), chunk_data_size); kKeyAVCC, kTypeAVCC, buffer->data(), chunk_data_size); Loading @@ -1664,6 +1690,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { return ERROR_IO; return ERROR_IO; } } if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->meta->setData( mLastTrack->meta->setData( kKeyHVCC, kTypeHVCC, buffer->data(), chunk_data_size); kKeyHVCC, kTypeHVCC, buffer->data(), chunk_data_size); Loading Loading @@ -1697,6 +1726,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { return ERROR_IO; return ERROR_IO; } } if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->meta->setData(kKeyD263, kTypeD263, buffer, chunk_data_size); mLastTrack->meta->setData(kKeyD263, kTypeD263, buffer, chunk_data_size); break; break; Loading Loading @@ -1875,6 +1907,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { return ERROR_IO; return ERROR_IO; } } if (mLastTrack == NULL) return ERROR_MALFORMED; uint32_t type = ntohl(buffer); uint32_t type = ntohl(buffer); // For the 3GPP file format, the handler-type within the 'hdlr' box // For the 3GPP file format, the handler-type within the 'hdlr' box // shall be 'text'. We also want to support 'sbtl' handler type // shall be 'text'. We also want to support 'sbtl' handler type Loading Loading @@ -1907,6 +1942,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { case FOURCC('t', 'x', '3', 'g'): case FOURCC('t', 'x', '3', 'g'): { { if (mLastTrack == NULL) return ERROR_MALFORMED; uint32_t type; uint32_t type; const void *data; const void *data; size_t size = 0; size_t size = 0; Loading Loading @@ -2145,6 +2183,9 @@ status_t MPEG4Extractor::parseSegmentIndex(off64_t offset, size_t size) { uint64_t sidxDuration = total_duration * 1000000 / timeScale; uint64_t sidxDuration = total_duration * 1000000 / timeScale; if (mLastTrack == NULL) return ERROR_MALFORMED; int64_t metaDuration; int64_t metaDuration; if (!mLastTrack->meta->findInt64(kKeyDuration, &metaDuration) || metaDuration == 0) { if (!mLastTrack->meta->findInt64(kKeyDuration, &metaDuration) || metaDuration == 0) { mLastTrack->meta->setInt64(kKeyDuration, sidxDuration); mLastTrack->meta->setInt64(kKeyDuration, sidxDuration); Loading Loading @@ -2195,6 +2236,9 @@ status_t MPEG4Extractor::parseTrackHeader( return ERROR_UNSUPPORTED; return ERROR_UNSUPPORTED; } } if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->meta->setInt32(kKeyTrackID, id); mLastTrack->meta->setInt32(kKeyTrackID, id); size_t matrixOffset = dynSize + 16; size_t matrixOffset = dynSize + 16; Loading Loading @@ -2377,6 +2421,9 @@ status_t MPEG4Extractor::parseITunesMetaData(off64_t offset, size_t size) { int32_t delay, padding; int32_t delay, padding; if (sscanf(mLastCommentData, if (sscanf(mLastCommentData, " %*x %x %x %*x", &delay, &padding) == 2) { " %*x %x %x %*x", &delay, &padding) == 2) { if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->meta->setInt32(kKeyEncoderDelay, delay); mLastTrack->meta->setInt32(kKeyEncoderDelay, delay); mLastTrack->meta->setInt32(kKeyEncoderPadding, padding); mLastTrack->meta->setInt32(kKeyEncoderPadding, padding); } } Loading Loading @@ -2749,6 +2796,9 @@ status_t MPEG4Extractor::updateAudioTrackInfoFromESDS_MPEG4Audio( if (objectTypeIndication == 0xe1) { if (objectTypeIndication == 0xe1) { // This isn't MPEG4 audio at all, it's QCELP 14k... // This isn't MPEG4 audio at all, it's QCELP 14k... if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_QCELP); mLastTrack->meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_QCELP); return OK; return OK; } } Loading Loading @@ -2797,6 +2847,9 @@ status_t MPEG4Extractor::updateAudioTrackInfoFromESDS_MPEG4Audio( objectType = 32 + br.getBits(6); objectType = 32 + br.getBits(6); } } if (mLastTrack == NULL) return ERROR_MALFORMED; //keep AOT type //keep AOT type mLastTrack->meta->setInt32(kKeyAACAOT, objectType); mLastTrack->meta->setInt32(kKeyAACAOT, objectType); Loading Loading @@ -2967,6 +3020,9 @@ status_t MPEG4Extractor::updateAudioTrackInfoFromESDS_MPEG4Audio( return ERROR_UNSUPPORTED; return ERROR_UNSUPPORTED; } } if (mLastTrack == NULL) return ERROR_MALFORMED; int32_t prevSampleRate; int32_t prevSampleRate; CHECK(mLastTrack->meta->findInt32(kKeySampleRate, &prevSampleRate)); CHECK(mLastTrack->meta->findInt32(kKeySampleRate, &prevSampleRate)); Loading Loading
media/libstagefright/MPEG4Extractor.cpp +56 −0 Original line number Original line Diff line number Diff line Loading @@ -878,6 +878,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { } } } } if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->sampleTable = new SampleTable(mDataSource); mLastTrack->sampleTable = new SampleTable(mDataSource); } } Loading Loading @@ -1032,6 +1035,10 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { } } original_fourcc = ntohl(original_fourcc); original_fourcc = ntohl(original_fourcc); ALOGV("read original format: %d", original_fourcc); ALOGV("read original format: %d", original_fourcc); if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(original_fourcc)); mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(original_fourcc)); uint32_t num_channels = 0; uint32_t num_channels = 0; uint32_t sample_rate = 0; uint32_t sample_rate = 0; Loading Loading @@ -1087,6 +1094,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { return ERROR_IO; return ERROR_IO; } } if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->meta->setInt32(kKeyCryptoMode, defaultAlgorithmId); mLastTrack->meta->setInt32(kKeyCryptoMode, defaultAlgorithmId); mLastTrack->meta->setInt32(kKeyCryptoDefaultIVSize, defaultIVSize); mLastTrack->meta->setInt32(kKeyCryptoDefaultIVSize, defaultIVSize); mLastTrack->meta->setData(kKeyCryptoKey, 'tenc', defaultKeyId, 16); mLastTrack->meta->setData(kKeyCryptoKey, 'tenc', defaultKeyId, 16); Loading Loading @@ -1266,6 +1276,10 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { // display the timed text. // display the timed text. // For encrypted files, there may also be more than one entry. // For encrypted files, there may also be more than one entry. const char *mime; const char *mime; if (mLastTrack == NULL) return ERROR_MALFORMED; CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); if (strcasecmp(mime, MEDIA_MIMETYPE_TEXT_3GPP) && if (strcasecmp(mime, MEDIA_MIMETYPE_TEXT_3GPP) && strcasecmp(mime, "application/octet-stream")) { strcasecmp(mime, "application/octet-stream")) { Loading Loading @@ -1312,6 +1326,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { uint16_t sample_size = U16_AT(&buffer[18]); uint16_t sample_size = U16_AT(&buffer[18]); uint32_t sample_rate = U32_AT(&buffer[24]) >> 16; uint32_t sample_rate = U32_AT(&buffer[24]) >> 16; if (mLastTrack == NULL) return ERROR_MALFORMED; if (chunk_type != FOURCC('e', 'n', 'c', 'a')) { if (chunk_type != FOURCC('e', 'n', 'c', 'a')) { // if the chunk type is enca, we'll get the type from the sinf/frma box later // if the chunk type is enca, we'll get the type from the sinf/frma box later mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(chunk_type)); mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(chunk_type)); Loading Loading @@ -1373,6 +1390,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { // printf("*** coding='%s' width=%d height=%d\n", // printf("*** coding='%s' width=%d height=%d\n", // chunk, width, height); // chunk, width, height); if (mLastTrack == NULL) return ERROR_MALFORMED; if (chunk_type != FOURCC('e', 'n', 'c', 'v')) { if (chunk_type != FOURCC('e', 'n', 'c', 'v')) { // if the chunk type is encv, we'll get the type from the sinf/frma box later // if the chunk type is encv, we'll get the type from the sinf/frma box later mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(chunk_type)); mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(chunk_type)); Loading Loading @@ -1618,6 +1638,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { return ERROR_MALFORMED; return ERROR_MALFORMED; } } if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->meta->setData( mLastTrack->meta->setData( kKeyESDS, kTypeESDS, &buffer[4], chunk_data_size - 4); kKeyESDS, kTypeESDS, &buffer[4], chunk_data_size - 4); Loading Loading @@ -1650,6 +1673,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { return ERROR_IO; return ERROR_IO; } } if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->meta->setData( mLastTrack->meta->setData( kKeyAVCC, kTypeAVCC, buffer->data(), chunk_data_size); kKeyAVCC, kTypeAVCC, buffer->data(), chunk_data_size); Loading @@ -1664,6 +1690,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { return ERROR_IO; return ERROR_IO; } } if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->meta->setData( mLastTrack->meta->setData( kKeyHVCC, kTypeHVCC, buffer->data(), chunk_data_size); kKeyHVCC, kTypeHVCC, buffer->data(), chunk_data_size); Loading Loading @@ -1697,6 +1726,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { return ERROR_IO; return ERROR_IO; } } if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->meta->setData(kKeyD263, kTypeD263, buffer, chunk_data_size); mLastTrack->meta->setData(kKeyD263, kTypeD263, buffer, chunk_data_size); break; break; Loading Loading @@ -1875,6 +1907,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { return ERROR_IO; return ERROR_IO; } } if (mLastTrack == NULL) return ERROR_MALFORMED; uint32_t type = ntohl(buffer); uint32_t type = ntohl(buffer); // For the 3GPP file format, the handler-type within the 'hdlr' box // For the 3GPP file format, the handler-type within the 'hdlr' box // shall be 'text'. We also want to support 'sbtl' handler type // shall be 'text'. We also want to support 'sbtl' handler type Loading Loading @@ -1907,6 +1942,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { case FOURCC('t', 'x', '3', 'g'): case FOURCC('t', 'x', '3', 'g'): { { if (mLastTrack == NULL) return ERROR_MALFORMED; uint32_t type; uint32_t type; const void *data; const void *data; size_t size = 0; size_t size = 0; Loading Loading @@ -2145,6 +2183,9 @@ status_t MPEG4Extractor::parseSegmentIndex(off64_t offset, size_t size) { uint64_t sidxDuration = total_duration * 1000000 / timeScale; uint64_t sidxDuration = total_duration * 1000000 / timeScale; if (mLastTrack == NULL) return ERROR_MALFORMED; int64_t metaDuration; int64_t metaDuration; if (!mLastTrack->meta->findInt64(kKeyDuration, &metaDuration) || metaDuration == 0) { if (!mLastTrack->meta->findInt64(kKeyDuration, &metaDuration) || metaDuration == 0) { mLastTrack->meta->setInt64(kKeyDuration, sidxDuration); mLastTrack->meta->setInt64(kKeyDuration, sidxDuration); Loading Loading @@ -2195,6 +2236,9 @@ status_t MPEG4Extractor::parseTrackHeader( return ERROR_UNSUPPORTED; return ERROR_UNSUPPORTED; } } if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->meta->setInt32(kKeyTrackID, id); mLastTrack->meta->setInt32(kKeyTrackID, id); size_t matrixOffset = dynSize + 16; size_t matrixOffset = dynSize + 16; Loading Loading @@ -2377,6 +2421,9 @@ status_t MPEG4Extractor::parseITunesMetaData(off64_t offset, size_t size) { int32_t delay, padding; int32_t delay, padding; if (sscanf(mLastCommentData, if (sscanf(mLastCommentData, " %*x %x %x %*x", &delay, &padding) == 2) { " %*x %x %x %*x", &delay, &padding) == 2) { if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->meta->setInt32(kKeyEncoderDelay, delay); mLastTrack->meta->setInt32(kKeyEncoderDelay, delay); mLastTrack->meta->setInt32(kKeyEncoderPadding, padding); mLastTrack->meta->setInt32(kKeyEncoderPadding, padding); } } Loading Loading @@ -2749,6 +2796,9 @@ status_t MPEG4Extractor::updateAudioTrackInfoFromESDS_MPEG4Audio( if (objectTypeIndication == 0xe1) { if (objectTypeIndication == 0xe1) { // This isn't MPEG4 audio at all, it's QCELP 14k... // This isn't MPEG4 audio at all, it's QCELP 14k... if (mLastTrack == NULL) return ERROR_MALFORMED; mLastTrack->meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_QCELP); mLastTrack->meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_QCELP); return OK; return OK; } } Loading Loading @@ -2797,6 +2847,9 @@ status_t MPEG4Extractor::updateAudioTrackInfoFromESDS_MPEG4Audio( objectType = 32 + br.getBits(6); objectType = 32 + br.getBits(6); } } if (mLastTrack == NULL) return ERROR_MALFORMED; //keep AOT type //keep AOT type mLastTrack->meta->setInt32(kKeyAACAOT, objectType); mLastTrack->meta->setInt32(kKeyAACAOT, objectType); Loading Loading @@ -2967,6 +3020,9 @@ status_t MPEG4Extractor::updateAudioTrackInfoFromESDS_MPEG4Audio( return ERROR_UNSUPPORTED; return ERROR_UNSUPPORTED; } } if (mLastTrack == NULL) return ERROR_MALFORMED; int32_t prevSampleRate; int32_t prevSampleRate; CHECK(mLastTrack->meta->findInt32(kKeySampleRate, &prevSampleRate)); CHECK(mLastTrack->meta->findInt32(kKeySampleRate, &prevSampleRate)); Loading