diff options
author | Andreas Huber <andih@google.com> | 2012-03-30 13:02:09 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2012-04-02 15:18:44 -0700 |
commit | 69829f3bd09ee4e6be49fee8795c5df24c4da70e (patch) | |
tree | ea8e438b08c8bbd6f50bae88a0528280728f643c /media/libstagefright/MediaCodecList.cpp | |
parent | deeb1282621f3177ad667360b40eef8e4fedb298 (diff) | |
download | frameworks_av-69829f3bd09ee4e6be49fee8795c5df24c4da70e.zip frameworks_av-69829f3bd09ee4e6be49fee8795c5df24c4da70e.tar.gz frameworks_av-69829f3bd09ee4e6be49fee8795c5df24c4da70e.tar.bz2 |
Add a few more APIs to MediaCodecList.
Change-Id: I5ac193cd40c82bbcd87c1e55003b78102e8d4674
Diffstat (limited to 'media/libstagefright/MediaCodecList.cpp')
-rw-r--r-- | media/libstagefright/MediaCodecList.cpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/media/libstagefright/MediaCodecList.cpp b/media/libstagefright/MediaCodecList.cpp index a31be0a..c39aa77 100644 --- a/media/libstagefright/MediaCodecList.cpp +++ b/media/libstagefright/MediaCodecList.cpp @@ -22,6 +22,8 @@ #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/MediaErrors.h> +#include <media/stagefright/OMXClient.h> +#include <media/stagefright/OMXCodec.h> #include <utils/threads.h> #include <expat.h> @@ -448,6 +450,10 @@ ssize_t MediaCodecList::findCodecByName(const char *name) const { return -ENOENT; } +size_t MediaCodecList::countCodecs() const { + return mCodecInfos.size(); +} + const char *MediaCodecList::getCodecName(size_t index) const { if (index >= mCodecInfos.size()) { return NULL; @@ -457,6 +463,15 @@ const char *MediaCodecList::getCodecName(size_t index) const { return info.mName.c_str(); } +bool MediaCodecList::isEncoder(size_t index) const { + if (index >= mCodecInfos.size()) { + return NULL; + } + + const CodecInfo &info = mCodecInfos.itemAt(index); + return info.mIsEncoder; +} + bool MediaCodecList::codecHasQuirk( size_t index, const char *quirkName) const { if (index >= mCodecInfos.size()) { @@ -475,4 +490,69 @@ bool MediaCodecList::codecHasQuirk( return false; } +status_t MediaCodecList::getSupportedTypes( + size_t index, Vector<AString> *types) const { + types->clear(); + + if (index >= mCodecInfos.size()) { + return -ERANGE; + } + + const CodecInfo &info = mCodecInfos.itemAt(index); + + for (size_t i = 0; i < mTypes.size(); ++i) { + uint32_t typeMask = 1ul << mTypes.valueAt(i); + + if (info.mTypes & typeMask) { + types->push(mTypes.keyAt(i)); + } + } + + return OK; +} + +status_t MediaCodecList::getCodecCapabilities( + size_t index, const char *type, + Vector<ProfileLevel> *profileLevels, + Vector<uint32_t> *colorFormats) const { + profileLevels->clear(); + colorFormats->clear(); + + if (index >= mCodecInfos.size()) { + return -ERANGE; + } + + const CodecInfo &info = mCodecInfos.itemAt(index); + + OMXClient client; + status_t err = client.connect(); + if (err != OK) { + return err; + } + + CodecCapabilities caps; + err = QueryCodec( + client.interface(), + info.mName.c_str(), type, info.mIsEncoder, &caps); + + if (err != OK) { + return err; + } + + for (size_t i = 0; i < caps.mProfileLevels.size(); ++i) { + const CodecProfileLevel &src = caps.mProfileLevels.itemAt(i); + + ProfileLevel profileLevel; + profileLevel.mProfile = src.mProfile; + profileLevel.mLevel = src.mLevel; + profileLevels->push(profileLevel); + } + + for (size_t i = 0; i < caps.mColorFormats.size(); ++i) { + colorFormats->push(caps.mColorFormats.itemAt(i)); + } + + return OK; +} + } // namespace android |