diff options
-rw-r--r-- | cmds/stagefright/codec.cpp | 134 | ||||
-rw-r--r-- | include/media/stagefright/MetaData.h | 5 | ||||
-rw-r--r-- | include/media/stagefright/NuMediaExtractor.h | 4 | ||||
-rw-r--r-- | media/libstagefright/NuMediaExtractor.cpp | 37 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/AnotherPacketSource.cpp | 6 |
5 files changed, 19 insertions, 167 deletions
diff --git a/cmds/stagefright/codec.cpp b/cmds/stagefright/codec.cpp index ece3c09..ebb5d58 100644 --- a/cmds/stagefright/codec.cpp +++ b/cmds/stagefright/codec.cpp @@ -39,8 +39,7 @@ static void usage(const char *me) { fprintf(stderr, "usage: %s [-a] use audio\n" "\t\t[-v] use video\n" "\t\t[-p] playback\n" - "\t\t[-S] allocate buffers from a surface\n" - "\t\t[-D] decrypt input buffers\n", + "\t\t[-S] allocate buffers from a surface\n", me); exit(1); @@ -61,33 +60,6 @@ struct CodecState { bool mIsAudio; }; -static sp<ICrypto> makeCrypto( - const uint8_t uuid[16], const void *data, size_t size) { - sp<IServiceManager> sm = defaultServiceManager(); - - sp<IBinder> binder = - sm->getService(String16("media.player")); - - sp<IMediaPlayerService> service = - interface_cast<IMediaPlayerService>(binder); - - CHECK(service != NULL); - - sp<ICrypto> crypto = service->makeCrypto(); - - if (crypto == NULL || crypto->initCheck() != OK) { - return NULL; - } - - status_t err = crypto->createPlugin(uuid, data, size); - - if (err != OK) { - return NULL; - } - - return crypto; -} - } // namespace android static int decode( @@ -95,8 +67,7 @@ static int decode( const char *path, bool useAudio, bool useVideo, - const android::sp<android::Surface> &surface, - bool decryptInputBuffers) { + const android::sp<android::Surface> &surface) { using namespace android; static int64_t kTimeout = 500ll; @@ -107,8 +78,6 @@ static int decode( return 1; } - sp<ICrypto> crypto; - KeyedVector<size_t, CodecState> stateByTrack; bool haveAudio = false; @@ -144,62 +113,14 @@ static int decode( state->mNumBuffersDecoded = 0; state->mIsAudio = isAudio; - if (decryptInputBuffers && crypto == NULL) { - sp<ABuffer> emm; - CHECK(format->findBuffer("emm", &emm)); - - sp<ABuffer> ecm; - CHECK(format->findBuffer("ecm", &ecm)); - - struct WVOpaqueInitData { - uint8_t mEMM[16]; - uint8_t mECM[32]; - - } opaque; - - CHECK_EQ(emm->size(), sizeof(opaque.mEMM)); - memcpy(opaque.mEMM, emm->data(), emm->size()); - - CHECK_EQ(ecm->size(), 80u); - // bytes 16..47 of the original ecm stream data. - memcpy(opaque.mECM, ecm->data() + 16, 32); - - static const uint8_t kUUIDWidevine[16] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 - }; - - crypto = makeCrypto(kUUIDWidevine, &opaque, sizeof(opaque)); - CHECK(crypto != NULL); - CHECK_EQ(crypto->initCheck(), (status_t)OK); - } - - if (decryptInputBuffers - && crypto->requiresSecureDecoderComponent(mime.c_str())) { - static const MediaCodecList *list = MediaCodecList::getInstance(); - - ssize_t index = - list->findCodecByType(mime.c_str(), false /* encoder */); - - CHECK_GE(index, 0); - - const char *componentName = list->getCodecName(index); - - AString fullName = componentName; - fullName.append(".secure"); - - state->mCodec = MediaCodec::CreateByComponentName( - looper, fullName.c_str()); - } else { - state->mCodec = MediaCodec::CreateByType( - looper, mime.c_str(), false /* encoder */); - } + state->mCodec = MediaCodec::CreateByType( + looper, mime.c_str(), false /* encoder */); CHECK(state->mCodec != NULL); err = state->mCodec->configure( format, isVideo ? surface : NULL, - crypto, + NULL /* crypto */, 0 /* flags */); CHECK_EQ(err, (status_t)OK); @@ -289,35 +210,12 @@ static int decode( uint32_t bufferFlags = 0; - uint32_t sampleFlags; - err = extractor->getSampleFlags(&sampleFlags); - CHECK_EQ(err, (status_t)OK); - - if (sampleFlags & NuMediaExtractor::SAMPLE_FLAG_ENCRYPTED) { - CHECK(decryptInputBuffers); - - CryptoPlugin::SubSample ss; - ss.mNumBytesOfClearData = 0; - ss.mNumBytesOfEncryptedData = buffer->size(); - - err = state->mCodec->queueSecureInputBuffer( - index, - 0 /* offset */, - &ss, - 1 /* numSubSamples */, - NULL /* key */, - NULL /* iv */, - CryptoPlugin::kMode_AES_WV, - timeUs, - bufferFlags); - } else { - err = state->mCodec->queueInputBuffer( - index, - 0 /* offset */, - buffer->size(), - timeUs, - bufferFlags); - } + err = state->mCodec->queueInputBuffer( + index, + 0 /* offset */, + buffer->size(), + timeUs, + bufferFlags); CHECK_EQ(err, (status_t)OK); @@ -451,7 +349,6 @@ int main(int argc, char **argv) { bool useVideo = false; bool playback = false; bool useSurface = false; - bool decryptInputBuffers = false; int res; while ((res = getopt(argc, argv, "havpSD")) >= 0) { @@ -480,12 +377,6 @@ int main(int argc, char **argv) { break; } - case 'D': - { - decryptInputBuffers = true; - break; - } - case '?': case 'h': default: @@ -557,8 +448,7 @@ int main(int argc, char **argv) { player->stop(); player->reset(); } else { - decode(looper, argv[0], - useAudio, useVideo, surface, decryptInputBuffers); + decode(looper, argv[0], useAudio, useVideo, surface); } if (playback || (useSurface && useVideo)) { diff --git a/include/media/stagefright/MetaData.h b/include/media/stagefright/MetaData.h index d0db98e..8a87d83 100644 --- a/include/media/stagefright/MetaData.h +++ b/include/media/stagefright/MetaData.h @@ -129,10 +129,6 @@ enum { kKeyRequiresSecureBuffers = 'secu', // bool (int32_t) - kKeyScrambling = 'scrm', // int32_t - kKeyEMM = 'emm ', // raw data - kKeyECM = 'ecm ', // raw data - kKeyIsADTS = 'adts', // bool (int32_t) // If a MediaBuffer's data represents (at least partially) encrypted @@ -156,6 +152,7 @@ enum { kKeyPlainSizes = 'plai', // size_t[] kKeyCryptoKey = 'cryK', // uint8_t[16] kKeyCryptoIV = 'cryI', // uint8_t[16] + kKeyCryptoMode = 'cryM', // int32_t }; enum { diff --git a/include/media/stagefright/NuMediaExtractor.h b/include/media/stagefright/NuMediaExtractor.h index a09f971..9c61113 100644 --- a/include/media/stagefright/NuMediaExtractor.h +++ b/include/media/stagefright/NuMediaExtractor.h @@ -31,6 +31,7 @@ struct AMessage; struct MediaBuffer; struct MediaExtractor; struct MediaSource; +struct MetaData; struct NuMediaExtractor : public RefBase { enum SampleFlags { @@ -57,7 +58,7 @@ struct NuMediaExtractor : public RefBase { status_t readSampleData(const sp<ABuffer> &buffer); status_t getSampleTrackIndex(size_t *trackIndex); status_t getSampleTime(int64_t *sampleTimeUs); - status_t getSampleFlags(uint32_t *sampleFlags); + status_t getSampleMeta(sp<MetaData> *sampleMeta); protected: virtual ~NuMediaExtractor(); @@ -73,7 +74,6 @@ private: status_t mFinalResult; MediaBuffer *mSample; int64_t mSampleTimeUs; - uint32_t mSampleFlags; uint32_t mTrackFlags; // bitmask of "TrackFlags" }; diff --git a/media/libstagefright/NuMediaExtractor.cpp b/media/libstagefright/NuMediaExtractor.cpp index 166a99f..00bb74f 100644 --- a/media/libstagefright/NuMediaExtractor.cpp +++ b/media/libstagefright/NuMediaExtractor.cpp @@ -289,20 +289,6 @@ status_t NuMediaExtractor::getTrackFormat( msg->setBuffer("csd-1", buffer); } - if (meta->findData(kKeyEMM, &type, &data, &size)) { - sp<ABuffer> emm = new ABuffer(size); - memcpy(emm->data(), data, size); - - msg->setBuffer("emm", emm); - } - - if (meta->findData(kKeyECM, &type, &data, &size)) { - sp<ABuffer> ecm = new ABuffer(size); - memcpy(ecm->data(), data, size); - - msg->setBuffer("ecm", ecm); - } - *format = msg; return OK; @@ -338,7 +324,6 @@ status_t NuMediaExtractor::selectTrack(size_t index) { info->mFinalResult = OK; info->mSample = NULL; info->mSampleTimeUs = -1ll; - info->mSampleFlags = 0; info->mTrackFlags = 0; const char *mime; @@ -360,7 +345,6 @@ void NuMediaExtractor::releaseTrackSamples() { info->mSample = NULL; info->mSampleTimeUs = -1ll; - info->mSampleFlags = 0; } } } @@ -379,7 +363,6 @@ ssize_t NuMediaExtractor::fetchTrackSamples(int64_t seekTimeUs) { info->mSample->release(); info->mSample = NULL; info->mSampleTimeUs = -1ll; - info->mSampleFlags = 0; } } else if (info->mFinalResult != OK) { continue; @@ -397,25 +380,11 @@ ssize_t NuMediaExtractor::fetchTrackSamples(int64_t seekTimeUs) { info->mFinalResult = err; info->mSampleTimeUs = -1ll; - info->mSampleFlags = 0; continue; } else { CHECK(info->mSample != NULL); CHECK(info->mSample->meta_data()->findInt64( kKeyTime, &info->mSampleTimeUs)); - - info->mSampleFlags = 0; - - int32_t val; - if (info->mSample->meta_data()->findInt32( - kKeyIsSyncFrame, &val) && val != 0) { - info->mSampleFlags |= SAMPLE_FLAG_SYNC; - } - - if (info->mSample->meta_data()->findInt32( - kKeyScrambling, &val) && val != 0) { - info->mSampleFlags |= SAMPLE_FLAG_ENCRYPTED; - } } } @@ -524,7 +493,9 @@ status_t NuMediaExtractor::getSampleTime(int64_t *sampleTimeUs) { return OK; } -status_t NuMediaExtractor::getSampleFlags(uint32_t *sampleFlags) { +status_t NuMediaExtractor::getSampleMeta(sp<MetaData> *sampleMeta) { + *sampleMeta = NULL; + ssize_t minIndex = fetchTrackSamples(); if (minIndex < 0) { @@ -532,7 +503,7 @@ status_t NuMediaExtractor::getSampleFlags(uint32_t *sampleFlags) { } TrackInfo *info = &mSelectedTracks.editItemAt(minIndex); - *sampleFlags = info->mSampleFlags; + *sampleMeta = info->mSample->meta_data(); return OK; } diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp index e1ac53c..d708ba6 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp @@ -117,12 +117,6 @@ status_t AnotherPacketSource::read( mediaBuffer->meta_data()->setInt64(kKeyTime, timeUs); - int32_t scrambling; - if (buffer->meta()->findInt32("scrambling", &scrambling) - && scrambling != 0) { - mediaBuffer->meta_data()->setInt32(kKeyScrambling, scrambling); - } - *out = mediaBuffer; return OK; } |