Loading include/media/stagefright/ACodec.h +6 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,12 @@ struct ACodec : public AHierarchicalStateMachine, public CodecBase { int width, int height, int rate, int bitrate, OMX_VIDEO_AVCPROFILETYPE profile = OMX_VIDEO_AVCProfileBaseline); // Quirk still supported, even though deprecated enum Quirks { kRequiresAllocateBufferOnInputPorts = 1, kRequiresAllocateBufferOnOutputPorts = 2, }; static status_t getOMXChannelMapping(size_t numChannels, OMX_AUDIO_CHANNELTYPE map[]); protected: Loading include/media/stagefright/MediaCodecList.h +16 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,22 @@ struct MediaCodecList : public BnMediaCodecList { // only to be used by MediaPlayerService void parseTopLevelXMLFile(const char *path, bool ignore_errors = false); enum Flags { kPreferSoftwareCodecs = 1, kHardwareCodecsOnly = 2, }; static void findMatchingCodecs( const char *mime, bool createEncoder, uint32_t flags, Vector<AString> *matching); static uint32_t getQuirksFor(const char *mComponentName); static bool isSoftwareCodec(const AString &componentName); private: class BinderDeathObserver : public IBinder::DeathRecipient { void binderDied(const wp<IBinder> &the_late_who __unused); Loading include/media/stagefright/OMXCodec.h +0 −2 Original line number Diff line number Diff line Loading @@ -117,8 +117,6 @@ struct OMXCodec : public BnMediaSource, static uint32_t getComponentQuirks( const sp<MediaCodecInfo> &list); static bool findCodecQuirks(const char *componentName, uint32_t *quirks); protected: virtual ~OMXCodec(); Loading media/libstagefright/ACodec.cpp +10 −16 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ #include <media/stagefright/MediaCodecList.h> #include <media/stagefright/MediaDefs.h> #include <media/stagefright/OMXClient.h> #include <media/stagefright/OMXCodec.h> #include <media/stagefright/PersistentSurface.h> #include <media/stagefright/SurfaceUtils.h> #include <media/hardware/HardwareAPI.h> Loading Loading @@ -828,8 +827,8 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) { uint32_t requiresAllocateBufferBit = (portIndex == kPortIndexInput) ? OMXCodec::kRequiresAllocateBufferOnInputPorts : OMXCodec::kRequiresAllocateBufferOnOutputPorts; ? kRequiresAllocateBufferOnInputPorts : kRequiresAllocateBufferOnOutputPorts; if ((portIndex == kPortIndexInput && (mFlags & kFlagIsSecure)) || (portIndex == kPortIndexOutput && usingMetadataOnEncoderOutput())) { Loading Loading @@ -5480,7 +5479,7 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) { mDeathNotifier.clear(); } Vector<OMXCodec::CodecNameAndQuirks> matchingCodecs; Vector<AString> matchingCodecs; AString mime; Loading @@ -5488,13 +5487,9 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) { uint32_t quirks = 0; int32_t encoder = false; if (msg->findString("componentName", &componentName)) { ssize_t index = matchingCodecs.add(); OMXCodec::CodecNameAndQuirks *entry = &matchingCodecs.editItemAt(index); entry->mName = String8(componentName.c_str()); if (!OMXCodec::findCodecQuirks( componentName.c_str(), &entry->mQuirks)) { entry->mQuirks = 0; sp<IMediaCodecList> list = MediaCodecList::getInstance(); if (list != NULL && list->findCodecByName(componentName.c_str()) >= 0) { matchingCodecs.add(componentName); } } else { CHECK(msg->findString("mime", &mime)); Loading @@ -5503,10 +5498,9 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) { encoder = false; } OMXCodec::findMatchingCodecs( MediaCodecList::findMatchingCodecs( mime.c_str(), encoder, // createEncoder NULL, // matchComponentName 0, // flags &matchingCodecs); } Loading @@ -5517,8 +5511,8 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) { status_t err = NAME_NOT_FOUND; for (size_t matchIndex = 0; matchIndex < matchingCodecs.size(); ++matchIndex) { componentName = matchingCodecs.itemAt(matchIndex).mName.string(); quirks = matchingCodecs.itemAt(matchIndex).mQuirks; componentName = matchingCodecs[matchIndex]; quirks = MediaCodecList::getQuirksFor(componentName.c_str()); pid_t tid = gettid(); int prevPriority = androidGetThreadPriority(tid); Loading media/libstagefright/MediaCodecList.cpp +82 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/foundation/AMessage.h> #include <media/stagefright/ACodec.h> #include <media/stagefright/MediaCodecList.h> #include <media/stagefright/MediaErrors.h> #include <media/stagefright/OMXClient.h> Loading Loading @@ -1115,4 +1116,85 @@ const sp<AMessage> MediaCodecList::getGlobalSettings() const { return mGlobalSettings; } //static bool MediaCodecList::isSoftwareCodec(const AString &componentName) { return componentName.startsWithIgnoreCase("OMX.google.") || !componentName.startsWithIgnoreCase("OMX."); } static int compareSoftwareCodecsFirst(const AString *name1, const AString *name2) { // sort order 1: software codecs are first (lower) bool isSoftwareCodec1 = MediaCodecList::isSoftwareCodec(*name1); bool isSoftwareCodec2 = MediaCodecList::isSoftwareCodec(*name2); if (isSoftwareCodec1 != isSoftwareCodec2) { return isSoftwareCodec2 - isSoftwareCodec1; } // sort order 2: OMX codecs are first (lower) bool isOMX1 = name1->startsWithIgnoreCase("OMX."); bool isOMX2 = name2->startsWithIgnoreCase("OMX."); return isOMX2 - isOMX1; } //static void MediaCodecList::findMatchingCodecs( const char *mime, bool encoder, uint32_t flags, Vector<AString> *matches) { matches->clear(); const sp<IMediaCodecList> list = getInstance(); if (list == NULL) { return; } size_t index = 0; for (;;) { ssize_t matchIndex = list->findCodecByType(mime, encoder, index); if (matchIndex < 0) { break; } index = matchIndex + 1; const sp<MediaCodecInfo> info = list->getCodecInfo(matchIndex); CHECK(info != NULL); AString componentName = info->getCodecName(); if (!((flags & kHardwareCodecsOnly) && !isSoftwareCodec(componentName))) { matches->push(componentName); ALOGV("matching '%s'", componentName.c_str()); } } if (flags & kPreferSoftwareCodecs) { matches->sort(compareSoftwareCodecsFirst); } } // static uint32_t MediaCodecList::getQuirksFor(const char *componentName) { const sp<IMediaCodecList> list = getInstance(); if (list == NULL) { return 0; } ssize_t ix = list->findCodecByName(componentName); if (ix < 0) { return 0; } const sp<MediaCodecInfo> info = list->getCodecInfo(ix); uint32_t quirks = 0; if (info->hasQuirk("requires-allocate-on-input-ports")) { quirks |= ACodec::kRequiresAllocateBufferOnInputPorts; } if (info->hasQuirk("requires-allocate-on-output-ports")) { quirks |= ACodec::kRequiresAllocateBufferOnOutputPorts; } return quirks; } } // namespace android Loading
include/media/stagefright/ACodec.h +6 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,12 @@ struct ACodec : public AHierarchicalStateMachine, public CodecBase { int width, int height, int rate, int bitrate, OMX_VIDEO_AVCPROFILETYPE profile = OMX_VIDEO_AVCProfileBaseline); // Quirk still supported, even though deprecated enum Quirks { kRequiresAllocateBufferOnInputPorts = 1, kRequiresAllocateBufferOnOutputPorts = 2, }; static status_t getOMXChannelMapping(size_t numChannels, OMX_AUDIO_CHANNELTYPE map[]); protected: Loading
include/media/stagefright/MediaCodecList.h +16 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,22 @@ struct MediaCodecList : public BnMediaCodecList { // only to be used by MediaPlayerService void parseTopLevelXMLFile(const char *path, bool ignore_errors = false); enum Flags { kPreferSoftwareCodecs = 1, kHardwareCodecsOnly = 2, }; static void findMatchingCodecs( const char *mime, bool createEncoder, uint32_t flags, Vector<AString> *matching); static uint32_t getQuirksFor(const char *mComponentName); static bool isSoftwareCodec(const AString &componentName); private: class BinderDeathObserver : public IBinder::DeathRecipient { void binderDied(const wp<IBinder> &the_late_who __unused); Loading
include/media/stagefright/OMXCodec.h +0 −2 Original line number Diff line number Diff line Loading @@ -117,8 +117,6 @@ struct OMXCodec : public BnMediaSource, static uint32_t getComponentQuirks( const sp<MediaCodecInfo> &list); static bool findCodecQuirks(const char *componentName, uint32_t *quirks); protected: virtual ~OMXCodec(); Loading
media/libstagefright/ACodec.cpp +10 −16 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ #include <media/stagefright/MediaCodecList.h> #include <media/stagefright/MediaDefs.h> #include <media/stagefright/OMXClient.h> #include <media/stagefright/OMXCodec.h> #include <media/stagefright/PersistentSurface.h> #include <media/stagefright/SurfaceUtils.h> #include <media/hardware/HardwareAPI.h> Loading Loading @@ -828,8 +827,8 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) { uint32_t requiresAllocateBufferBit = (portIndex == kPortIndexInput) ? OMXCodec::kRequiresAllocateBufferOnInputPorts : OMXCodec::kRequiresAllocateBufferOnOutputPorts; ? kRequiresAllocateBufferOnInputPorts : kRequiresAllocateBufferOnOutputPorts; if ((portIndex == kPortIndexInput && (mFlags & kFlagIsSecure)) || (portIndex == kPortIndexOutput && usingMetadataOnEncoderOutput())) { Loading Loading @@ -5480,7 +5479,7 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) { mDeathNotifier.clear(); } Vector<OMXCodec::CodecNameAndQuirks> matchingCodecs; Vector<AString> matchingCodecs; AString mime; Loading @@ -5488,13 +5487,9 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) { uint32_t quirks = 0; int32_t encoder = false; if (msg->findString("componentName", &componentName)) { ssize_t index = matchingCodecs.add(); OMXCodec::CodecNameAndQuirks *entry = &matchingCodecs.editItemAt(index); entry->mName = String8(componentName.c_str()); if (!OMXCodec::findCodecQuirks( componentName.c_str(), &entry->mQuirks)) { entry->mQuirks = 0; sp<IMediaCodecList> list = MediaCodecList::getInstance(); if (list != NULL && list->findCodecByName(componentName.c_str()) >= 0) { matchingCodecs.add(componentName); } } else { CHECK(msg->findString("mime", &mime)); Loading @@ -5503,10 +5498,9 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) { encoder = false; } OMXCodec::findMatchingCodecs( MediaCodecList::findMatchingCodecs( mime.c_str(), encoder, // createEncoder NULL, // matchComponentName 0, // flags &matchingCodecs); } Loading @@ -5517,8 +5511,8 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) { status_t err = NAME_NOT_FOUND; for (size_t matchIndex = 0; matchIndex < matchingCodecs.size(); ++matchIndex) { componentName = matchingCodecs.itemAt(matchIndex).mName.string(); quirks = matchingCodecs.itemAt(matchIndex).mQuirks; componentName = matchingCodecs[matchIndex]; quirks = MediaCodecList::getQuirksFor(componentName.c_str()); pid_t tid = gettid(); int prevPriority = androidGetThreadPriority(tid); Loading
media/libstagefright/MediaCodecList.cpp +82 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/foundation/AMessage.h> #include <media/stagefright/ACodec.h> #include <media/stagefright/MediaCodecList.h> #include <media/stagefright/MediaErrors.h> #include <media/stagefright/OMXClient.h> Loading Loading @@ -1115,4 +1116,85 @@ const sp<AMessage> MediaCodecList::getGlobalSettings() const { return mGlobalSettings; } //static bool MediaCodecList::isSoftwareCodec(const AString &componentName) { return componentName.startsWithIgnoreCase("OMX.google.") || !componentName.startsWithIgnoreCase("OMX."); } static int compareSoftwareCodecsFirst(const AString *name1, const AString *name2) { // sort order 1: software codecs are first (lower) bool isSoftwareCodec1 = MediaCodecList::isSoftwareCodec(*name1); bool isSoftwareCodec2 = MediaCodecList::isSoftwareCodec(*name2); if (isSoftwareCodec1 != isSoftwareCodec2) { return isSoftwareCodec2 - isSoftwareCodec1; } // sort order 2: OMX codecs are first (lower) bool isOMX1 = name1->startsWithIgnoreCase("OMX."); bool isOMX2 = name2->startsWithIgnoreCase("OMX."); return isOMX2 - isOMX1; } //static void MediaCodecList::findMatchingCodecs( const char *mime, bool encoder, uint32_t flags, Vector<AString> *matches) { matches->clear(); const sp<IMediaCodecList> list = getInstance(); if (list == NULL) { return; } size_t index = 0; for (;;) { ssize_t matchIndex = list->findCodecByType(mime, encoder, index); if (matchIndex < 0) { break; } index = matchIndex + 1; const sp<MediaCodecInfo> info = list->getCodecInfo(matchIndex); CHECK(info != NULL); AString componentName = info->getCodecName(); if (!((flags & kHardwareCodecsOnly) && !isSoftwareCodec(componentName))) { matches->push(componentName); ALOGV("matching '%s'", componentName.c_str()); } } if (flags & kPreferSoftwareCodecs) { matches->sort(compareSoftwareCodecsFirst); } } // static uint32_t MediaCodecList::getQuirksFor(const char *componentName) { const sp<IMediaCodecList> list = getInstance(); if (list == NULL) { return 0; } ssize_t ix = list->findCodecByName(componentName); if (ix < 0) { return 0; } const sp<MediaCodecInfo> info = list->getCodecInfo(ix); uint32_t quirks = 0; if (info->hasQuirk("requires-allocate-on-input-ports")) { quirks |= ACodec::kRequiresAllocateBufferOnInputPorts; } if (info->hasQuirk("requires-allocate-on-output-ports")) { quirks |= ACodec::kRequiresAllocateBufferOnOutputPorts; } return quirks; } } // namespace android