diff options
author | Ronghua Wu <ronghuawu@google.com> | 2015-04-21 14:23:06 -0700 |
---|---|---|
committer | Ronghua Wu <ronghuawu@google.com> | 2015-05-08 09:51:26 -0700 |
commit | 9ba21b9418d10ddcc39f08901e24fbf43d82b2bc (patch) | |
tree | 363f0598085516cf16ddd4ee5df2d1043e2955da | |
parent | ba21a9ac7b6b76f85681cfb5e756e947c0ae3b53 (diff) | |
download | frameworks_av-9ba21b9418d10ddcc39f08901e24fbf43d82b2bc.zip frameworks_av-9ba21b9418d10ddcc39f08901e24fbf43d82b2bc.tar.gz frameworks_av-9ba21b9418d10ddcc39f08901e24fbf43d82b2bc.tar.bz2 |
libstagefright: config resource manager with secure codec co-existing policy.
Bug: 19620911
Change-Id: I0d729782c1622f23e9c37b7a9231e58e3f807470
-rw-r--r-- | include/media/MediaResourcePolicy.h | 4 | ||||
-rw-r--r-- | media/libmedia/MediaResourcePolicy.cpp | 10 | ||||
-rw-r--r-- | media/libstagefright/MediaCodecList.cpp | 21 | ||||
-rw-r--r-- | media/libstagefright/MediaCodecListOverrides.cpp | 15 | ||||
-rw-r--r-- | media/libstagefright/MediaCodecListOverrides.h | 3 | ||||
-rw-r--r-- | media/libstagefright/tests/MediaCodecListOverrides_test.cpp | 4 | ||||
-rw-r--r-- | services/mediaresourcemanager/ResourceManagerService.cpp | 6 | ||||
-rw-r--r-- | services/mediaresourcemanager/test/ResourceManagerService_test.cpp | 18 |
8 files changed, 62 insertions, 19 deletions
diff --git a/include/media/MediaResourcePolicy.h b/include/media/MediaResourcePolicy.h index 1e1c341..9bc2eec 100644 --- a/include/media/MediaResourcePolicy.h +++ b/include/media/MediaResourcePolicy.h @@ -29,7 +29,7 @@ extern const char kPolicySupportsSecureWithNonSecureCodec[]; class MediaResourcePolicy { public: MediaResourcePolicy(); - MediaResourcePolicy(String8 type, uint64_t value); + MediaResourcePolicy(String8 type, String8 value); void readFromParcel(const Parcel &parcel); void writeToParcel(Parcel *parcel) const; @@ -37,7 +37,7 @@ public: String8 toString() const; String8 mType; - uint64_t mValue; + String8 mValue; }; }; // namespace android diff --git a/media/libmedia/MediaResourcePolicy.cpp b/media/libmedia/MediaResourcePolicy.cpp index 139a38c..5210825 100644 --- a/media/libmedia/MediaResourcePolicy.cpp +++ b/media/libmedia/MediaResourcePolicy.cpp @@ -24,25 +24,25 @@ namespace android { const char kPolicySupportsMultipleSecureCodecs[] = "supports-multiple-secure-codecs"; const char kPolicySupportsSecureWithNonSecureCodec[] = "supports-secure-with-non-secure-codec"; -MediaResourcePolicy::MediaResourcePolicy() : mValue(0) {} +MediaResourcePolicy::MediaResourcePolicy() {} -MediaResourcePolicy::MediaResourcePolicy(String8 type, uint64_t value) +MediaResourcePolicy::MediaResourcePolicy(String8 type, String8 value) : mType(type), mValue(value) {} void MediaResourcePolicy::readFromParcel(const Parcel &parcel) { mType = parcel.readString8(); - mValue = parcel.readUint64(); + mValue = parcel.readString8(); } void MediaResourcePolicy::writeToParcel(Parcel *parcel) const { parcel->writeString8(mType); - parcel->writeUint64(mValue); + parcel->writeString8(mValue); } String8 MediaResourcePolicy::toString() const { String8 str; - str.appendFormat("%s:%llu", mType.string(), (unsigned long long)mValue); + str.appendFormat("%s:%s", mType.string(), mValue.string()); return str; } diff --git a/media/libstagefright/MediaCodecList.cpp b/media/libstagefright/MediaCodecList.cpp index e212fb8..d2352bc 100644 --- a/media/libstagefright/MediaCodecList.cpp +++ b/media/libstagefright/MediaCodecList.cpp @@ -24,7 +24,9 @@ #include <media/IMediaCodecList.h> #include <media/IMediaPlayerService.h> +#include <media/IResourceManagerService.h> #include <media/MediaCodecInfo.h> +#include <media/MediaResourcePolicy.h> #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/foundation/AMessage.h> @@ -171,6 +173,25 @@ void MediaCodecList::parseTopLevelXMLFile(const char *codecs_xml, bool ignore_er return; } + Vector<MediaResourcePolicy> policies; + AString value; + if (mGlobalSettings->findString(kPolicySupportsMultipleSecureCodecs, &value)) { + policies.push_back( + MediaResourcePolicy( + String8(kPolicySupportsMultipleSecureCodecs), + String8(value.c_str()))); + } + if (policies.size() > 0) { + sp<IServiceManager> sm = defaultServiceManager(); + sp<IBinder> binder = sm->getService(String16("media.resource_manager")); + sp<IResourceManagerService> service = interface_cast<IResourceManagerService>(binder); + if (service == NULL) { + ALOGE("MediaCodecList: failed to get ResourceManagerService"); + } else { + service->config(policies); + } + } + for (size_t i = mCodecInfos.size(); i-- > 0;) { const MediaCodecInfo &info = *mCodecInfos.itemAt(i).get(); if (info.mCaps.size() == 0) { diff --git a/media/libstagefright/MediaCodecListOverrides.cpp b/media/libstagefright/MediaCodecListOverrides.cpp index 535db09..0d95676 100644 --- a/media/libstagefright/MediaCodecListOverrides.cpp +++ b/media/libstagefright/MediaCodecListOverrides.cpp @@ -24,7 +24,7 @@ #include <media/ICrypto.h> #include <media/IMediaCodecList.h> #include <media/MediaCodecInfo.h> - +#include <media/MediaResourcePolicy.h> #include <media/stagefright/foundation/AMessage.h> #include <media/stagefright/MediaCodec.h> @@ -196,19 +196,21 @@ bool splitString( } void profileCodecs(const Vector<sp<MediaCodecInfo>> &infos) { - CodecSettings global_results; // TODO: add global results. + CodecSettings global_results; KeyedVector<AString, CodecSettings> encoder_results; KeyedVector<AString, CodecSettings> decoder_results; - profileCodecs(infos, &encoder_results, &decoder_results); + profileCodecs(infos, &global_results, &encoder_results, &decoder_results); exportResultsToXML(kProfilingResults, global_results, encoder_results, decoder_results); } void profileCodecs( const Vector<sp<MediaCodecInfo>> &infos, + CodecSettings *global_results, KeyedVector<AString, CodecSettings> *encoder_results, KeyedVector<AString, CodecSettings> *decoder_results, bool forceToMeasure) { KeyedVector<AString, sp<MediaCodecInfo::Capabilities>> codecsNeedMeasure; + AString supportMultipleSecureCodecs = "true"; for (size_t i = 0; i < infos.size(); ++i) { const sp<MediaCodecInfo> info = infos[i]; AString name = info->getCodecName(); @@ -243,9 +245,16 @@ void profileCodecs( } else { decoder_results->add(key, settings); } + + if (name.endsWith(".secure")) { + if (max <= 1) { + supportMultipleSecureCodecs = "false"; + } + } } } } + global_results->add(kPolicySupportsMultipleSecureCodecs, supportMultipleSecureCodecs); } static AString globalResultsToXml(const CodecSettings& results) { diff --git a/media/libstagefright/MediaCodecListOverrides.h b/media/libstagefright/MediaCodecListOverrides.h index c4758fa..e350d2a 100644 --- a/media/libstagefright/MediaCodecListOverrides.h +++ b/media/libstagefright/MediaCodecListOverrides.h @@ -35,9 +35,10 @@ bool splitString(const AString &s, const AString &delimiter, AString *s1, AStrin // profile codecs and save the result to xml file named kProfilingResults. void profileCodecs(const Vector<sp<MediaCodecInfo>> &infos); -// profile codecs and save the result to encoder_results and decoder_results. +// profile codecs and save the result to global_results, encoder_results and decoder_results. void profileCodecs( const Vector<sp<MediaCodecInfo>> &infos, + CodecSettings *global_results, KeyedVector<AString, CodecSettings> *encoder_results, KeyedVector<AString, CodecSettings> *decoder_results, bool forceToMeasure = false); diff --git a/media/libstagefright/tests/MediaCodecListOverrides_test.cpp b/media/libstagefright/tests/MediaCodecListOverrides_test.cpp index 146a244..cee62a3 100644 --- a/media/libstagefright/tests/MediaCodecListOverrides_test.cpp +++ b/media/libstagefright/tests/MediaCodecListOverrides_test.cpp @@ -121,9 +121,11 @@ TEST_F(MediaCodecListOverridesTest, DISABLED_profileCodecs) { for (size_t i = 0; i < list->countCodecs(); ++i) { infos.push_back(list->getCodecInfo(i)); } + CodecSettings global_results; KeyedVector<AString, CodecSettings> encoder_results; KeyedVector<AString, CodecSettings> decoder_results; - profileCodecs(infos, &encoder_results, &decoder_results, true /* forceToMeasure */); + profileCodecs( + infos, &global_results, &encoder_results, &decoder_results, true /* forceToMeasure */); verifyProfileResults(encoder_results); verifyProfileResults(decoder_results); } diff --git a/services/mediaresourcemanager/ResourceManagerService.cpp b/services/mediaresourcemanager/ResourceManagerService.cpp index e3f70ff..3c093f9 100644 --- a/services/mediaresourcemanager/ResourceManagerService.cpp +++ b/services/mediaresourcemanager/ResourceManagerService.cpp @@ -154,11 +154,11 @@ void ResourceManagerService::config(const Vector<MediaResourcePolicy> &policies) Mutex::Autolock lock(mLock); for (size_t i = 0; i < policies.size(); ++i) { String8 type = policies[i].mType; - uint64_t value = policies[i].mValue; + String8 value = policies[i].mValue; if (type == kPolicySupportsMultipleSecureCodecs) { - mSupportsMultipleSecureCodecs = (value != 0); + mSupportsMultipleSecureCodecs = (value == "true"); } else if (type == kPolicySupportsSecureWithNonSecureCodec) { - mSupportsSecureWithNonSecureCodec = (value != 0); + mSupportsSecureWithNonSecureCodec = (value == "true"); } } } diff --git a/services/mediaresourcemanager/test/ResourceManagerService_test.cpp b/services/mediaresourcemanager/test/ResourceManagerService_test.cpp index bccc7fa..3d53f1f 100644 --- a/services/mediaresourcemanager/test/ResourceManagerService_test.cpp +++ b/services/mediaresourcemanager/test/ResourceManagerService_test.cpp @@ -180,17 +180,27 @@ protected: EXPECT_TRUE(mService->mSupportsSecureWithNonSecureCodec); Vector<MediaResourcePolicy> policies1; - policies1.push_back(MediaResourcePolicy(String8(kPolicySupportsMultipleSecureCodecs), 1)); policies1.push_back( - MediaResourcePolicy(String8(kPolicySupportsSecureWithNonSecureCodec), 0)); + MediaResourcePolicy( + String8(kPolicySupportsMultipleSecureCodecs), + String8("true"))); + policies1.push_back( + MediaResourcePolicy( + String8(kPolicySupportsSecureWithNonSecureCodec), + String8("false"))); mService->config(policies1); EXPECT_TRUE(mService->mSupportsMultipleSecureCodecs); EXPECT_FALSE(mService->mSupportsSecureWithNonSecureCodec); Vector<MediaResourcePolicy> policies2; - policies2.push_back(MediaResourcePolicy(String8(kPolicySupportsMultipleSecureCodecs), 0)); policies2.push_back( - MediaResourcePolicy(String8(kPolicySupportsSecureWithNonSecureCodec), 1)); + MediaResourcePolicy( + String8(kPolicySupportsMultipleSecureCodecs), + String8("false"))); + policies2.push_back( + MediaResourcePolicy( + String8(kPolicySupportsSecureWithNonSecureCodec), + String8("true"))); mService->config(policies2); EXPECT_FALSE(mService->mSupportsMultipleSecureCodecs); EXPECT_TRUE(mService->mSupportsSecureWithNonSecureCodec); |