summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/NuMediaExtractor.cpp
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2012-05-03 11:33:01 -0700
committerAndreas Huber <andih@google.com>2012-05-03 11:47:08 -0700
commit9806555d3930be43e11106281dee354820ac1c88 (patch)
treeb5aa448cc0bfede361540f45b97c81ad398a9df4 /media/libstagefright/NuMediaExtractor.cpp
parent6a3969cc3bcbfc84dbcc27aa726eb96bc03a830b (diff)
downloadframeworks_av-9806555d3930be43e11106281dee354820ac1c88.zip
frameworks_av-9806555d3930be43e11106281dee354820ac1c88.tar.gz
frameworks_av-9806555d3930be43e11106281dee354820ac1c88.tar.bz2
Respect channel mask in ACodec and NuPlayer.
Refactor conversion from MetaData into AMessage while we're at it. Change-Id: I5479129836ea4316e8de28cf1b472bf19e3ac4ab related-to-bug: 6439076
Diffstat (limited to 'media/libstagefright/NuMediaExtractor.cpp')
-rw-r--r--media/libstagefright/NuMediaExtractor.cpp169
1 files changed, 1 insertions, 168 deletions
diff --git a/media/libstagefright/NuMediaExtractor.cpp b/media/libstagefright/NuMediaExtractor.cpp
index d6075cd..cfe4773 100644
--- a/media/libstagefright/NuMediaExtractor.cpp
+++ b/media/libstagefright/NuMediaExtractor.cpp
@@ -193,174 +193,7 @@ status_t NuMediaExtractor::getTrackFormat(
}
sp<MetaData> meta = mImpl->getTrackMetaData(index);
-
- const char *mime;
- CHECK(meta->findCString(kKeyMIMEType, &mime));
-
- sp<AMessage> msg = new AMessage;
- msg->setString("mime", mime);
-
- int64_t durationUs;
- if (meta->findInt64(kKeyDuration, &durationUs)) {
- msg->setInt64("durationUs", durationUs);
- }
-
- if (!strncasecmp("video/", mime, 6)) {
- int32_t width, height;
- CHECK(meta->findInt32(kKeyWidth, &width));
- CHECK(meta->findInt32(kKeyHeight, &height));
-
- msg->setInt32("width", width);
- msg->setInt32("height", height);
- } else if (!strncasecmp("audio/", mime, 6)) {
- int32_t numChannels, sampleRate;
- CHECK(meta->findInt32(kKeyChannelCount, &numChannels));
- CHECK(meta->findInt32(kKeySampleRate, &sampleRate));
-
- msg->setInt32("channel-count", numChannels);
- msg->setInt32("sample-rate", sampleRate);
-
- int32_t delay = 0;
- if (meta->findInt32(kKeyEncoderDelay, &delay)) {
- msg->setInt32("encoder-delay", delay);
- }
- int32_t padding = 0;
- if (meta->findInt32(kKeyEncoderPadding, &padding)) {
- msg->setInt32("encoder-padding", padding);
- }
-
- int32_t isADTS;
- if (meta->findInt32(kKeyIsADTS, &isADTS)) {
- msg->setInt32("is-adts", true);
- }
- }
-
- int32_t maxInputSize;
- if (meta->findInt32(kKeyMaxInputSize, &maxInputSize)) {
- msg->setInt32("max-input-size", maxInputSize);
- }
-
- uint32_t type;
- const void *data;
- size_t size;
- if (meta->findData(kKeyAVCC, &type, &data, &size)) {
- // Parse the AVCDecoderConfigurationRecord
-
- const uint8_t *ptr = (const uint8_t *)data;
-
- CHECK(size >= 7);
- CHECK_EQ((unsigned)ptr[0], 1u); // configurationVersion == 1
- uint8_t profile = ptr[1];
- uint8_t level = ptr[3];
-
- // There is decodable content out there that fails the following
- // assertion, let's be lenient for now...
- // CHECK((ptr[4] >> 2) == 0x3f); // reserved
-
- size_t lengthSize = 1 + (ptr[4] & 3);
-
- // commented out check below as H264_QVGA_500_NO_AUDIO.3gp
- // violates it...
- // CHECK((ptr[5] >> 5) == 7); // reserved
-
- size_t numSeqParameterSets = ptr[5] & 31;
-
- ptr += 6;
- size -= 6;
-
- sp<ABuffer> buffer = new ABuffer(1024);
- buffer->setRange(0, 0);
-
- for (size_t i = 0; i < numSeqParameterSets; ++i) {
- CHECK(size >= 2);
- size_t length = U16_AT(ptr);
-
- ptr += 2;
- size -= 2;
-
- CHECK(size >= length);
-
- memcpy(buffer->data() + buffer->size(), "\x00\x00\x00\x01", 4);
- memcpy(buffer->data() + buffer->size() + 4, ptr, length);
- buffer->setRange(0, buffer->size() + 4 + length);
-
- ptr += length;
- size -= length;
- }
-
- buffer->meta()->setInt32("csd", true);
- buffer->meta()->setInt64("timeUs", 0);
-
- msg->setBuffer("csd-0", buffer);
-
- buffer = new ABuffer(1024);
- buffer->setRange(0, 0);
-
- CHECK(size >= 1);
- size_t numPictureParameterSets = *ptr;
- ++ptr;
- --size;
-
- for (size_t i = 0; i < numPictureParameterSets; ++i) {
- CHECK(size >= 2);
- size_t length = U16_AT(ptr);
-
- ptr += 2;
- size -= 2;
-
- CHECK(size >= length);
-
- memcpy(buffer->data() + buffer->size(), "\x00\x00\x00\x01", 4);
- memcpy(buffer->data() + buffer->size() + 4, ptr, length);
- buffer->setRange(0, buffer->size() + 4 + length);
-
- ptr += length;
- size -= length;
- }
-
- buffer->meta()->setInt32("csd", true);
- buffer->meta()->setInt64("timeUs", 0);
- msg->setBuffer("csd-1", buffer);
- } else if (meta->findData(kKeyESDS, &type, &data, &size)) {
- ESDS esds((const char *)data, size);
- CHECK_EQ(esds.InitCheck(), (status_t)OK);
-
- const void *codec_specific_data;
- size_t codec_specific_data_size;
- esds.getCodecSpecificInfo(
- &codec_specific_data, &codec_specific_data_size);
-
- sp<ABuffer> buffer = new ABuffer(codec_specific_data_size);
-
- memcpy(buffer->data(), codec_specific_data,
- codec_specific_data_size);
-
- buffer->meta()->setInt32("csd", true);
- buffer->meta()->setInt64("timeUs", 0);
- msg->setBuffer("csd-0", buffer);
- } else if (meta->findData(kKeyVorbisInfo, &type, &data, &size)) {
- sp<ABuffer> buffer = new ABuffer(size);
- memcpy(buffer->data(), data, size);
-
- buffer->meta()->setInt32("csd", true);
- buffer->meta()->setInt64("timeUs", 0);
- msg->setBuffer("csd-0", buffer);
-
- if (!meta->findData(kKeyVorbisBooks, &type, &data, &size)) {
- return -EINVAL;
- }
-
- buffer = new ABuffer(size);
- memcpy(buffer->data(), data, size);
-
- buffer->meta()->setInt32("csd", true);
- buffer->meta()->setInt64("timeUs", 0);
- msg->setBuffer("csd-1", buffer);
- }
-
- *format = msg;
-
- return OK;
+ return convertMetaDataToMessage(meta, format);
}
status_t NuMediaExtractor::selectTrack(size_t index) {