summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/media/stagefright/OMXCodec.h8
-rw-r--r--media/libstagefright/ACodec.cpp20
-rwxr-xr-xmedia/libstagefright/OMXCodec.cpp44
3 files changed, 37 insertions, 35 deletions
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h
index c57e2a58..bb9e595f 100644
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -102,13 +102,17 @@ struct OMXCodec : public MediaSource,
kOutputBuffersAreUnreadable = 4096,
};
+ struct CodecNameAndQuirks {
+ String8 mName;
+ uint32_t mQuirks;
+ };
+
// for use by ACodec
static void findMatchingCodecs(
const char *mime,
bool createEncoder, const char *matchComponentName,
uint32_t flags,
- Vector<String8> *matchingCodecs,
- Vector<uint32_t> *matchingCodecQuirks = NULL);
+ Vector<CodecNameAndQuirks> *matchingCodecNamesAndQuirks);
static uint32_t getComponentQuirks(
const MediaCodecList *list, size_t index);
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index f96a429f..c37d2cae 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -2886,20 +2886,21 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) {
sp<IOMX> omx = client.interface();
- Vector<String8> matchingCodecs;
- Vector<uint32_t> matchingCodecQuirks;
+ Vector<OMXCodec::CodecNameAndQuirks> matchingCodecs;
AString mime;
AString componentName;
uint32_t quirks;
if (msg->findString("componentName", &componentName)) {
- matchingCodecs.push_back(String8(componentName.c_str()));
+ ssize_t index = matchingCodecs.add();
+ OMXCodec::CodecNameAndQuirks *entry = &matchingCodecs.editItemAt(index);
+ entry->mName = String8(componentName.c_str());
- if (!OMXCodec::findCodecQuirks(componentName.c_str(), &quirks)) {
- quirks = 0;
+ if (!OMXCodec::findCodecQuirks(
+ componentName.c_str(), &entry->mQuirks)) {
+ entry->mQuirks = 0;
}
- matchingCodecQuirks.push_back(quirks);
} else {
CHECK(msg->findString("mime", &mime));
@@ -2913,8 +2914,7 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) {
encoder, // createEncoder
NULL, // matchComponentName
0, // flags
- &matchingCodecs,
- &matchingCodecQuirks);
+ &matchingCodecs);
}
sp<CodecObserver> observer = new CodecObserver;
@@ -2922,8 +2922,8 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) {
for (size_t matchIndex = 0; matchIndex < matchingCodecs.size();
++matchIndex) {
- componentName = matchingCodecs.itemAt(matchIndex).string();
- quirks = matchingCodecQuirks.itemAt(matchIndex);
+ componentName = matchingCodecs.itemAt(matchIndex).mName.string();
+ quirks = matchingCodecs.itemAt(matchIndex).mQuirks;
pid_t tid = androidGetTid();
int prevPriority = androidGetThreadPriority(tid);
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index e8cb9d55..5615d0f5 100755
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -147,12 +147,13 @@ static bool IsSoftwareCodec(const char *componentName) {
// A sort order in which OMX software codecs are first, followed
// by other (non-OMX) software codecs, followed by everything else.
static int CompareSoftwareCodecsFirst(
- const String8 *elem1, const String8 *elem2) {
- bool isOMX1 = !strncmp(elem1->string(), "OMX.", 4);
- bool isOMX2 = !strncmp(elem2->string(), "OMX.", 4);
+ const OMXCodec::CodecNameAndQuirks *elem1,
+ const OMXCodec::CodecNameAndQuirks *elem2) {
+ bool isOMX1 = !strncmp(elem1->mName.string(), "OMX.", 4);
+ bool isOMX2 = !strncmp(elem2->mName.string(), "OMX.", 4);
- bool isSoftwareCodec1 = IsSoftwareCodec(elem1->string());
- bool isSoftwareCodec2 = IsSoftwareCodec(elem2->string());
+ bool isSoftwareCodec1 = IsSoftwareCodec(elem1->mName.string());
+ bool isSoftwareCodec2 = IsSoftwareCodec(elem2->mName.string());
if (isSoftwareCodec1) {
if (!isSoftwareCodec2) { return -1; }
@@ -182,14 +183,9 @@ void OMXCodec::findMatchingCodecs(
const char *mime,
bool createEncoder, const char *matchComponentName,
uint32_t flags,
- Vector<String8> *matchingCodecs,
- Vector<uint32_t> *matchingCodecQuirks) {
+ Vector<CodecNameAndQuirks> *matchingCodecs) {
matchingCodecs->clear();
- if (matchingCodecQuirks) {
- matchingCodecQuirks->clear();
- }
-
const MediaCodecList *list = MediaCodecList::getInstance();
if (list == NULL) {
return;
@@ -221,11 +217,13 @@ void OMXCodec::findMatchingCodecs(
((flags & kHardwareCodecsOnly) && !IsSoftwareCodec(componentName)) ||
(!(flags & (kSoftwareCodecsOnly | kHardwareCodecsOnly)))) {
- matchingCodecs->push(String8(componentName));
+ ssize_t index = matchingCodecs->add();
+ CodecNameAndQuirks *entry = &matchingCodecs->editItemAt(index);
+ entry->mName = String8(componentName);
+ entry->mQuirks = getComponentQuirks(list, matchIndex);
- if (matchingCodecQuirks) {
- matchingCodecQuirks->push(getComponentQuirks(list, matchIndex));
- }
+ ALOGV("matching '%s' quirks 0x%08x",
+ entry->mName.string(), entry->mQuirks);
}
}
@@ -294,11 +292,9 @@ sp<MediaSource> OMXCodec::Create(
bool success = meta->findCString(kKeyMIMEType, &mime);
CHECK(success);
- Vector<String8> matchingCodecs;
- Vector<uint32_t> matchingCodecQuirks;
+ Vector<CodecNameAndQuirks> matchingCodecs;
findMatchingCodecs(
- mime, createEncoder, matchComponentName, flags,
- &matchingCodecs, &matchingCodecQuirks);
+ mime, createEncoder, matchComponentName, flags, &matchingCodecs);
if (matchingCodecs.isEmpty()) {
ALOGV("No matching codecs! (mime: %s, createEncoder: %s, "
@@ -311,8 +307,8 @@ sp<MediaSource> OMXCodec::Create(
IOMX::node_id node = 0;
for (size_t i = 0; i < matchingCodecs.size(); ++i) {
- const char *componentNameBase = matchingCodecs[i].string();
- uint32_t quirks = matchingCodecQuirks[i];
+ const char *componentNameBase = matchingCodecs[i].mName.string();
+ uint32_t quirks = matchingCodecs[i].mQuirks;
const char *componentName = componentNameBase;
AString tmp;
@@ -572,6 +568,8 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
if ((mFlags & kClientNeedsFramebuffer)
&& !strncmp(mComponentName, "OMX.SEC.", 8)) {
+ // This appears to no longer be needed???
+
OMX_INDEXTYPE index;
status_t err =
@@ -4489,7 +4487,7 @@ status_t QueryCodecs(
const sp<IOMX> &omx,
const char *mime, bool queryDecoders, bool hwCodecOnly,
Vector<CodecCapabilities> *results) {
- Vector<String8> matchingCodecs;
+ Vector<OMXCodec::CodecNameAndQuirks> matchingCodecs;
results->clear();
OMXCodec::findMatchingCodecs(mime,
@@ -4499,7 +4497,7 @@ status_t QueryCodecs(
&matchingCodecs);
for (size_t c = 0; c < matchingCodecs.size(); c++) {
- const char *componentName = matchingCodecs.itemAt(c).string();
+ const char *componentName = matchingCodecs.itemAt(c).mName.string();
results->push();
CodecCapabilities *caps = &results->editItemAt(results->size() - 1);