Loading media/ndk/NdkMediaCodecInfo.cpp +72 −44 Original line number Diff line number Diff line Loading @@ -25,18 +25,6 @@ using namespace android; extern "C" { // Utils EXPORT void AIntRange_delete(AIntRange *range) { free(range); } EXPORT void ADoubleRange_delete(ADoubleRange *range) { free(range); } // AMediaCodecInfo EXPORT Loading @@ -49,12 +37,20 @@ const char* AMediaCodecInfo_getCanonicalName(const AMediaCodecInfo *info) { } EXPORT bool AMediaCodecInfo_isEncoder(const AMediaCodecInfo *info) { return info->mInfo->isEncoder(); AMediaCodecKind AMediaCodecInfo_getKind(const AMediaCodecInfo* info) { if (info == nullptr) { return AMediaCodecKind_INVALID; } return info->mInfo->isEncoder() ? AMediaCodecKind_ENCODER : AMediaCodecKind_DECODER; } EXPORT bool AMediaCodecInfo_isVendor(const AMediaCodecInfo *info) { int32_t AMediaCodecInfo_isVendor(const AMediaCodecInfo *info) { if (info == nullptr) { return -1; } int32_t attributes = info->mInfo->getAttributes(); return (attributes & android::MediaCodecInfo::kFlagIsVendor); } Loading @@ -62,18 +58,18 @@ bool AMediaCodecInfo_isVendor(const AMediaCodecInfo *info) { EXPORT AMediaCodecType AMediaCodecInfo_getMediaCodecInfoType(const AMediaCodecInfo *info) { if (info == nullptr || info->mInfo == nullptr) { return (AMediaCodecType)0; return AMediaCodecType_INVALID_CODEC_INFO; } int32_t attributes = info->mInfo->getAttributes(); if (attributes & android::MediaCodecInfo::kFlagIsSoftwareOnly) { return SOFTWARE_ONLY; return AMediaCodecType_SOFTWARE_ONLY; } if (attributes & android::MediaCodecInfo::kFlagIsHardwareAccelerated) { return HARDWARE_ACCELERATED; return AMediaCodecType_HARDWARE_ACCELERATED; } return SOFTWARE_WITH_DEVICE_ACCESS; return AMediaCodecType_SOFTWARE_WITH_DEVICE_ACCESS; } EXPORT Loading @@ -96,7 +92,7 @@ int32_t AMediaCodecInfo_getMaxSupportedInstances(const AMediaCodecInfo *info) { EXPORT int32_t AMediaCodecInfo_isFeatureSupported(const AMediaCodecInfo *info, const char *featureName) { if (featureName == nullptr) { if (info == nullptr || featureName == nullptr) { return -1; } return info->mCodecCaps->isFeatureSupported(std::string(featureName)); Loading @@ -104,7 +100,7 @@ int32_t AMediaCodecInfo_isFeatureSupported(const AMediaCodecInfo *info, const ch EXPORT int32_t AMediaCodecInfo_isFeatureRequired(const AMediaCodecInfo *info, const char *featureName) { if (featureName == nullptr) { if (info == nullptr || featureName == nullptr) { return -1; } return info->mCodecCaps->isFeatureRequired(std::string(featureName)); Loading @@ -112,7 +108,7 @@ int32_t AMediaCodecInfo_isFeatureRequired(const AMediaCodecInfo *info, const cha EXPORT int32_t AMediaCodecInfo_isFormatSupported(const AMediaCodecInfo *info, const AMediaFormat *format) { if (format == nullptr) { if (info == nullptr || format == nullptr) { return -1; } Loading @@ -125,7 +121,7 @@ int32_t AMediaCodecInfo_isFormatSupported(const AMediaCodecInfo *info, const AMe EXPORT media_status_t AMediaCodecInfo_getAudioCapabilities(const AMediaCodecInfo *info, const ACodecAudioCapabilities **outAudioCaps) { if (info == nullptr || info->mInfo == nullptr) { if (info == nullptr || info->mInfo == nullptr || outAudioCaps == nullptr) { return AMEDIA_ERROR_INVALID_PARAMETER; } Loading @@ -141,7 +137,7 @@ media_status_t AMediaCodecInfo_getAudioCapabilities(const AMediaCodecInfo *info, EXPORT media_status_t AMediaCodecInfo_getVideoCapabilities(const AMediaCodecInfo *info, const ACodecVideoCapabilities **outVideoCaps) { if (info == nullptr || info->mInfo == nullptr) { if (info == nullptr || info->mInfo == nullptr || outVideoCaps == nullptr) { return AMEDIA_ERROR_INVALID_PARAMETER; } Loading @@ -157,7 +153,7 @@ media_status_t AMediaCodecInfo_getVideoCapabilities(const AMediaCodecInfo *info, EXPORT media_status_t AMediaCodecInfo_getEncoderCapabilities(const AMediaCodecInfo *info, const ACodecEncoderCapabilities **outEncoderCaps) { if (info == nullptr || info->mInfo == nullptr) { if (info == nullptr || info->mInfo == nullptr || outEncoderCaps == nullptr) { return AMEDIA_ERROR_INVALID_PARAMETER; } Loading Loading @@ -264,19 +260,17 @@ ACodecPerformancePoint* ACodecPerformancePoint_create(int32_t width, int32_t hei } EXPORT media_status_t ACodecPerformancePoint_delete(ACodecPerformancePoint *performancePoint) { if (performancePoint == nullptr) { return AMEDIA_ERROR_INVALID_PARAMETER; } void ACodecPerformancePoint_destroy(ACodecPerformancePoint *performancePoint) { delete performancePoint; return AMEDIA_OK; } EXPORT bool ACodecPerformancePoint_coversFormat(const ACodecPerformancePoint *performancePoint, int32_t ACodecPerformancePoint_coversFormat(const ACodecPerformancePoint *performancePoint, const AMediaFormat *format) { if (performancePoint == nullptr || format == nullptr) { return -1; } sp<AMessage> nativeFormat; AMediaFormat_getFormat(format, &nativeFormat); Loading @@ -284,14 +278,22 @@ bool ACodecPerformancePoint_coversFormat(const ACodecPerformancePoint *performan } EXPORT bool ACodecPerformancePoint_covers(const ACodecPerformancePoint *one, int32_t ACodecPerformancePoint_covers(const ACodecPerformancePoint *one, const ACodecPerformancePoint *another) { if (one == nullptr || another == nullptr) { return -1; } return one->mPerformancePoint->covers(*(another->mPerformancePoint)); } EXPORT bool ACodecPerformancePoint_equals(const ACodecPerformancePoint *one, int32_t ACodecPerformancePoint_equals(const ACodecPerformancePoint *one, const ACodecPerformancePoint *another) { if (one == nullptr || another == nullptr) { return -1; } return one->mPerformancePoint->equals(*(another->mPerformancePoint)); } Loading Loading @@ -447,18 +449,26 @@ media_status_t ACodecVideoCapabilities_getAchievableFrameRatesFor( } EXPORT media_status_t ACodecVideoCapabilities_getSupportedPerformancePoints( const ACodecVideoCapabilities *videoCaps, const ACodecPerformancePoint **outPerformancePointArray, size_t *outCount) { if (videoCaps == nullptr) { media_status_t ACodecVideoCapabilities_getNextSupportedPerformancePoint( const ACodecVideoCapabilities* _Nonnull videoCaps, const ACodecPerformancePoint* _Nullable * _Nonnull outPerformancePoint) { if (videoCaps == nullptr || outPerformancePoint == nullptr) { return AMEDIA_ERROR_INVALID_PARAMETER; } *outPerformancePointArray = videoCaps->mPerformancePoints.data(); *outCount = videoCaps->mPerformancePoints.size(); bool found = *outPerformancePoint == nullptr; for (const ACodecPerformancePoint& pp : videoCaps->mPerformancePoints) { if (found) { *outPerformancePoint = &pp; return AMEDIA_OK; } if (*outPerformancePoint == &pp) { found = true; } } *outPerformancePoint = nullptr; return AMEDIA_ERROR_UNSUPPORTED; } EXPORT int32_t ACodecVideoCapabilities_areSizeAndRateSupported(const ACodecVideoCapabilities *videoCaps, Loading Loading @@ -509,12 +519,30 @@ media_status_t ACodecEncoderCapabilities_getComplexityRange( } int32_t ACodecEncoderCapabilities_isBitrateModeSupported( const ACodecEncoderCapabilities *encoderCaps, ABiterateMode mode) { const ACodecEncoderCapabilities *encoderCaps, ABitrateMode mode) { if (encoderCaps == nullptr) { return -1; } return encoderCaps->mEncoderCaps->isBitrateModeSupported(mode); } // Feature Names extern const char* AMediaCodecInfo_FEATURE_AdaptivePlayback = "adaptive-playback"; extern const char* AMediaCodecInfo_FEATURE_SecurePlayback = "secure-playback"; extern const char* AMediaCodecInfo_FEATURE_TunneledPlayback = "tunneled-playback"; extern const char* AMediaCodecInfo_FEATURE_DynamicTimestamp = "dynamic-timestamp"; extern const char* AMediaCodecInfo_FEATURE_FrameParsing = "frame-parsing"; extern const char* AMediaCodecInfo_FEATURE_MultipleFrames = "multiple-frames"; extern const char* AMediaCodecInfo_FEATURE_PartialFrame = "partial-frame"; extern const char* AMediaCodecInfo_FEATURE_IntraRefresh = "intra-refresh"; extern const char* AMediaCodecInfo_FEATURE_LowLatency = "low-latency"; extern const char* AMediaCodecInfo_FEATURE_QpBounds = "qp-bounds"; extern const char* AMediaCodecInfo_FEATURE_EncodingStatistics = "encoding-statistics"; extern const char* AMediaCodecInfo_FEATURE_HdrEditing = "hdr-editing"; extern const char* AMediaCodecInfo_FEATURE_HlgEditing = "hlg-editing"; extern const char* AMediaCodecInfo_FEATURE_DynamicColorAspects = "dynamic-color-aspects"; extern const char* AMediaCodecInfo_FEATURE_Roi = "region-of-interest"; extern const char* AMediaCodecInfo_FEATURE_DetachedSurface = "detached-surface"; } No newline at end of file media/ndk/NdkMediaCodecInfoPriv.h +2 −2 Original line number Diff line number Diff line Loading @@ -99,8 +99,8 @@ struct AMediaCodecInfo { std::shared_ptr<const ACodecVideoCapabilities> mAVideoCaps; std::shared_ptr<const ACodecEncoderCapabilities> mAEncoderCaps; AMediaCodecInfo(std::string name, android::sp<android::MediaCodecInfo> info, std::shared_ptr<android::CodecCapabilities> codecCaps, std::string mediaType) AMediaCodecInfo(const std::string &name, android::sp<android::MediaCodecInfo> info, std::shared_ptr<android::CodecCapabilities> codecCaps, const std::string &mediaType) : mName(name), mInfo(info), mMediaType(mediaType), mCodecCaps(codecCaps) { if (!mName.empty() && mInfo != nullptr && !mMediaType.empty() && mCodecCaps != nullptr) { if (mCodecCaps->getAudioCapabilities() != nullptr) { Loading media/ndk/NdkMediaCodecStore.cpp +14 −8 Original line number Diff line number Diff line Loading @@ -66,8 +66,10 @@ static void initMediaTypes() { auto it = typesInfoMap.find(mediaType); if (it == typesInfoMap.end()) { AMediaCodecSupportedMediaType supportedType = { mediaType.c_str(), 0 }; it = typesInfoMap.emplace(mediaType, supportedType).first; char *mediaTypePtr = new char[mediaType.size()+1]; strncpy(mediaTypePtr, mediaType.c_str(), mediaType.size()+1); it = typesInfoMap.emplace(mediaType, (AMediaCodecSupportedMediaType) { mediaTypePtr, 0 }).first; mediaTypes.push_back(mediaType); } uint32_t &mode = it->second.mMode; Loading Loading @@ -152,7 +154,7 @@ static void initCodecInfoMap() { } } static bool codecHandlesFormat(const AMediaCodecInfo codecInfo, static bool codecHandlesFormat(const AMediaCodecInfo &codecInfo, sp<AMessage> format, bool isEncoder) { return codecInfo.mCodecCaps->isEncoder() == isEncoder && codecInfo.mCodecCaps->isFormatSupported(format); Loading @@ -168,10 +170,10 @@ static media_status_t findNextCodecForFormat( initCodecInfoMap(); } std::unique_ptr<std::vector<AMediaCodecInfo>> infos; std::vector<AMediaCodecInfo> *infos; sp<AMessage> nativeFormat; if (format == nullptr) { infos = std::unique_ptr<std::vector<AMediaCodecInfo>>(&sCodecInfos); infos = &sCodecInfos; } else { AMediaFormat_getFormat(format, &nativeFormat); AString mime; Loading @@ -180,11 +182,12 @@ static media_status_t findNextCodecForFormat( } std::string mediaType = std::string(mime.c_str()); auto it = sTypeToInfoList.find(mediaType); std::map<std::string, std::vector<AMediaCodecInfo>>::iterator it = sTypeToInfoList.find(mediaType); if (it == sTypeToInfoList.end()) { return AMEDIA_ERROR_UNSUPPORTED; } infos = std::unique_ptr<std::vector<AMediaCodecInfo>>(&(it->second)); infos = &(it->second); } bool found = *outCodecInfo == nullptr; Loading @@ -197,7 +200,6 @@ static media_status_t findNextCodecForFormat( if (*outCodecInfo == &info) { found = true; } } *outCodecInfo = nullptr; return AMEDIA_ERROR_UNSUPPORTED; Loading Loading @@ -241,6 +243,10 @@ media_status_t AMediaCodecStore_getCodecInfo( return AMEDIA_ERROR_INVALID_PARAMETER; } if (sNameToInfoMap.empty()) { initCodecInfoMap(); } auto it = sNameToInfoMap.find(std::string(name)); if (it == sNameToInfoMap.end()) { *outCodecInfo = nullptr; Loading media/ndk/include/media/NdkMediaCodecInfo.h +429 −169 File changed.Preview size limit exceeded, changes collapsed. Show changes media/ndk/include/media/NdkMediaCodecStore.h +40 −25 Original line number Diff line number Diff line Loading @@ -54,8 +54,8 @@ typedef struct AMediaCodecSupportedMediaType { FLAG_ENCODER = 1 << 1, }; // The media type. const char *mMediaType; // Encoded as ASCII. const char* _Nonnull mMediaType; // bitfields for modes. uint32_t mMode; } AMediaCodecSupportedMediaType; Loading @@ -68,47 +68,59 @@ typedef struct AMediaCodecSupportedMediaType { * * @param outCount size of the out array. * * Return AMEDIA_OK if successfully made the copy. * Return AMEDIA_ERROR_INVALID_PARAMETER if the @param outMediaTypes is invalid. * @return AMEDIA_OK if successfully made the copy. * @return AMEDIA_ERROR_INVALID_PARAMETER if the @param outMediaTypes is invalid. */ media_status_t AMediaCodecStore_getSupportedMediaTypes( const AMediaCodecSupportedMediaType **outMediaTypes, size_t *outCount) __INTRODUCED_IN(36); const AMediaCodecSupportedMediaType* _Nullable * _Nonnull outMediaTypes, size_t* _Nonnull outCount) __INTRODUCED_IN(36); /** * Get the next decoder info that supports the format. * * @param outCodecInfo should be set as NULL to start the iteration. * Keep the last codecInfo you got from a previous call to get the next one. * *outCodecInfo will be set to NULL if reached the end. * It is owned by the framework and has an infinite lifetime. * This API returns the decoder infos supporting the given format in a sequence and stores them * in a pointer at outCodecInfo. Initially, set the pointer pointed to by outCodecInfo to NULL. * On successive calls, keep the last pointer value. When the sequence is over * AMEDIA_ERROR_UNSUPPORTED will be returned and the pointer will be set to NULL. * * @param outCodecInfo a pointer to (the AMediaCodecInfo pointer) where the next codec info * will be stored. The AMediaCodecInfo object is owned by the framework * and has an infinite lifecycle. * * @param format If set as NULL, this API will iterate through all available decoders. * If NOT NULL, it MUST contain key "mime" implying the media type. * * Return AMEDIA_OK if successfully got the info. * Return AMEDIA_ERROR_INVALID_PARAMETER if @param outCodecInfo or @param format is invalid. * Return AMEDIA_ERROR_UNSUPPORTED if no more decoder supporting the format. * @return AMEDIA_OK if successfully got the info. * @return AMEDIA_ERROR_INVALID_PARAMETER if @param outCodecInfo or @param format is invalid. * @return AMEDIA_ERROR_UNSUPPORTED If ther are no more decoder supporting the format. * *outCodecInfo will also be set to NULL in this case. * * It is undefined behavior to call this API with a NON NULL @param outCodecInfo * and a different @param format during an iteration. */ media_status_t AMediaCodecStore_findNextDecoderForFormat( const AMediaFormat *format, const AMediaCodecInfo **outCodecInfo) __INTRODUCED_IN(36); const AMediaFormat* _Nonnull format, const AMediaCodecInfo* _Nullable * _Nonnull outCodecInfo) __INTRODUCED_IN(36); /** * Get the next encoder info that supports the format. * * @param outCodecInfo should be set as NULL to start the iteration. * Keep the last codecInfo you got from a previous call to get the next one. * *outCodecInfo will be set to NULL if reached the end. * It is owned by the framework and has an infinite lifetime. * This API returns the encoder infos supporting the given format in a sequence and stores them * in a pointer at outCodecInfo. Initially, set the pointer pointed to by outCodecInfo to NULL. * On successive calls, keep the last pointer value. When the sequence is over * AMEDIA_ERROR_UNSUPPORTED will be returned and the pointer will be set to NULL. * * @param outCodecInfo a pointer to (the AMediaCodecInfo pointer) where the next codec info * will be stored. The AMediaCodecInfo object is owned by the framework * and has an infinite lifecycle. * * @param format If set as NULL, this API will iterate through all available encoders. * If NOT NULL, it MUST contain key "mime" implying the media type. * * Return AMEDIA_OK if successfully got the info. * Return AMEDIA_ERROR_INVALID_PARAMETER if @param outCodecInfo is invalid. * Return AMEDIA_ERROR_UNSUPPORTED if no more encoder supporting the format. * @return AMEDIA_OK if successfully got the info. * @return AMEDIA_ERROR_INVALID_PARAMETER if @param outCodecInfo is invalid. * @return AMEDIA_ERROR_UNSUPPORTED If ther are no more encoder supporting the format. * *outCodecInfo will also be set to NULL in this case. * * It is undefined behavior to call this API with a NON NULL @param outCodecInfo * and a different @param format during an iteration. Loading @@ -116,12 +128,14 @@ media_status_t AMediaCodecStore_findNextDecoderForFormat( * No secure encoder will show in the output. */ media_status_t AMediaCodecStore_findNextEncoderForFormat( const AMediaFormat* format, const AMediaCodecInfo **outCodecInfo) __INTRODUCED_IN(36); const AMediaFormat* _Nonnull format, const AMediaCodecInfo* _Nullable * _Nonnull outCodecInfo) __INTRODUCED_IN(36); /** * Get the codecInfo corresponding to a given codec name. * * @param name Media codec name. * Encoded as ASCII. * Users can get valid codec names from the AMediaCodecInfo structures * returned from findNextDecoder|EncoderForFormat methods. * Note that this name may not correspond to the name the same codec used Loading @@ -130,12 +144,13 @@ media_status_t AMediaCodecStore_findNextEncoderForFormat( * @param outCodecInfo Output parameter for the corresponding AMeidaCodecInfo structure. * It is owned by the framework and has an infinite lifetime. * * Return AMEDIA_OK if got the codecInfo successfully. * Return AMEDIA_ERROR_UNSUPPORTED if no corresponding codec found. * Return AMEDIA_ERROR_INVALID_PARAMETER if @param outCodecInfo or @param name is invalid. * @return AMEDIA_OK if got the codecInfo successfully. * @return AMEDIA_ERROR_UNSUPPORTED if no corresponding codec found. * @return AMEDIA_ERROR_INVALID_PARAMETER if @param outCodecInfo or @param name is invalid. */ media_status_t AMediaCodecStore_getCodecInfo( const char *name, const AMediaCodecInfo **outCodecInfo) __INTRODUCED_IN(36); const char* _Nonnull name, const AMediaCodecInfo* _Nullable * _Nonnull outCodecInfo) __INTRODUCED_IN(36); __END_DECLS Loading Loading
media/ndk/NdkMediaCodecInfo.cpp +72 −44 Original line number Diff line number Diff line Loading @@ -25,18 +25,6 @@ using namespace android; extern "C" { // Utils EXPORT void AIntRange_delete(AIntRange *range) { free(range); } EXPORT void ADoubleRange_delete(ADoubleRange *range) { free(range); } // AMediaCodecInfo EXPORT Loading @@ -49,12 +37,20 @@ const char* AMediaCodecInfo_getCanonicalName(const AMediaCodecInfo *info) { } EXPORT bool AMediaCodecInfo_isEncoder(const AMediaCodecInfo *info) { return info->mInfo->isEncoder(); AMediaCodecKind AMediaCodecInfo_getKind(const AMediaCodecInfo* info) { if (info == nullptr) { return AMediaCodecKind_INVALID; } return info->mInfo->isEncoder() ? AMediaCodecKind_ENCODER : AMediaCodecKind_DECODER; } EXPORT bool AMediaCodecInfo_isVendor(const AMediaCodecInfo *info) { int32_t AMediaCodecInfo_isVendor(const AMediaCodecInfo *info) { if (info == nullptr) { return -1; } int32_t attributes = info->mInfo->getAttributes(); return (attributes & android::MediaCodecInfo::kFlagIsVendor); } Loading @@ -62,18 +58,18 @@ bool AMediaCodecInfo_isVendor(const AMediaCodecInfo *info) { EXPORT AMediaCodecType AMediaCodecInfo_getMediaCodecInfoType(const AMediaCodecInfo *info) { if (info == nullptr || info->mInfo == nullptr) { return (AMediaCodecType)0; return AMediaCodecType_INVALID_CODEC_INFO; } int32_t attributes = info->mInfo->getAttributes(); if (attributes & android::MediaCodecInfo::kFlagIsSoftwareOnly) { return SOFTWARE_ONLY; return AMediaCodecType_SOFTWARE_ONLY; } if (attributes & android::MediaCodecInfo::kFlagIsHardwareAccelerated) { return HARDWARE_ACCELERATED; return AMediaCodecType_HARDWARE_ACCELERATED; } return SOFTWARE_WITH_DEVICE_ACCESS; return AMediaCodecType_SOFTWARE_WITH_DEVICE_ACCESS; } EXPORT Loading @@ -96,7 +92,7 @@ int32_t AMediaCodecInfo_getMaxSupportedInstances(const AMediaCodecInfo *info) { EXPORT int32_t AMediaCodecInfo_isFeatureSupported(const AMediaCodecInfo *info, const char *featureName) { if (featureName == nullptr) { if (info == nullptr || featureName == nullptr) { return -1; } return info->mCodecCaps->isFeatureSupported(std::string(featureName)); Loading @@ -104,7 +100,7 @@ int32_t AMediaCodecInfo_isFeatureSupported(const AMediaCodecInfo *info, const ch EXPORT int32_t AMediaCodecInfo_isFeatureRequired(const AMediaCodecInfo *info, const char *featureName) { if (featureName == nullptr) { if (info == nullptr || featureName == nullptr) { return -1; } return info->mCodecCaps->isFeatureRequired(std::string(featureName)); Loading @@ -112,7 +108,7 @@ int32_t AMediaCodecInfo_isFeatureRequired(const AMediaCodecInfo *info, const cha EXPORT int32_t AMediaCodecInfo_isFormatSupported(const AMediaCodecInfo *info, const AMediaFormat *format) { if (format == nullptr) { if (info == nullptr || format == nullptr) { return -1; } Loading @@ -125,7 +121,7 @@ int32_t AMediaCodecInfo_isFormatSupported(const AMediaCodecInfo *info, const AMe EXPORT media_status_t AMediaCodecInfo_getAudioCapabilities(const AMediaCodecInfo *info, const ACodecAudioCapabilities **outAudioCaps) { if (info == nullptr || info->mInfo == nullptr) { if (info == nullptr || info->mInfo == nullptr || outAudioCaps == nullptr) { return AMEDIA_ERROR_INVALID_PARAMETER; } Loading @@ -141,7 +137,7 @@ media_status_t AMediaCodecInfo_getAudioCapabilities(const AMediaCodecInfo *info, EXPORT media_status_t AMediaCodecInfo_getVideoCapabilities(const AMediaCodecInfo *info, const ACodecVideoCapabilities **outVideoCaps) { if (info == nullptr || info->mInfo == nullptr) { if (info == nullptr || info->mInfo == nullptr || outVideoCaps == nullptr) { return AMEDIA_ERROR_INVALID_PARAMETER; } Loading @@ -157,7 +153,7 @@ media_status_t AMediaCodecInfo_getVideoCapabilities(const AMediaCodecInfo *info, EXPORT media_status_t AMediaCodecInfo_getEncoderCapabilities(const AMediaCodecInfo *info, const ACodecEncoderCapabilities **outEncoderCaps) { if (info == nullptr || info->mInfo == nullptr) { if (info == nullptr || info->mInfo == nullptr || outEncoderCaps == nullptr) { return AMEDIA_ERROR_INVALID_PARAMETER; } Loading Loading @@ -264,19 +260,17 @@ ACodecPerformancePoint* ACodecPerformancePoint_create(int32_t width, int32_t hei } EXPORT media_status_t ACodecPerformancePoint_delete(ACodecPerformancePoint *performancePoint) { if (performancePoint == nullptr) { return AMEDIA_ERROR_INVALID_PARAMETER; } void ACodecPerformancePoint_destroy(ACodecPerformancePoint *performancePoint) { delete performancePoint; return AMEDIA_OK; } EXPORT bool ACodecPerformancePoint_coversFormat(const ACodecPerformancePoint *performancePoint, int32_t ACodecPerformancePoint_coversFormat(const ACodecPerformancePoint *performancePoint, const AMediaFormat *format) { if (performancePoint == nullptr || format == nullptr) { return -1; } sp<AMessage> nativeFormat; AMediaFormat_getFormat(format, &nativeFormat); Loading @@ -284,14 +278,22 @@ bool ACodecPerformancePoint_coversFormat(const ACodecPerformancePoint *performan } EXPORT bool ACodecPerformancePoint_covers(const ACodecPerformancePoint *one, int32_t ACodecPerformancePoint_covers(const ACodecPerformancePoint *one, const ACodecPerformancePoint *another) { if (one == nullptr || another == nullptr) { return -1; } return one->mPerformancePoint->covers(*(another->mPerformancePoint)); } EXPORT bool ACodecPerformancePoint_equals(const ACodecPerformancePoint *one, int32_t ACodecPerformancePoint_equals(const ACodecPerformancePoint *one, const ACodecPerformancePoint *another) { if (one == nullptr || another == nullptr) { return -1; } return one->mPerformancePoint->equals(*(another->mPerformancePoint)); } Loading Loading @@ -447,18 +449,26 @@ media_status_t ACodecVideoCapabilities_getAchievableFrameRatesFor( } EXPORT media_status_t ACodecVideoCapabilities_getSupportedPerformancePoints( const ACodecVideoCapabilities *videoCaps, const ACodecPerformancePoint **outPerformancePointArray, size_t *outCount) { if (videoCaps == nullptr) { media_status_t ACodecVideoCapabilities_getNextSupportedPerformancePoint( const ACodecVideoCapabilities* _Nonnull videoCaps, const ACodecPerformancePoint* _Nullable * _Nonnull outPerformancePoint) { if (videoCaps == nullptr || outPerformancePoint == nullptr) { return AMEDIA_ERROR_INVALID_PARAMETER; } *outPerformancePointArray = videoCaps->mPerformancePoints.data(); *outCount = videoCaps->mPerformancePoints.size(); bool found = *outPerformancePoint == nullptr; for (const ACodecPerformancePoint& pp : videoCaps->mPerformancePoints) { if (found) { *outPerformancePoint = &pp; return AMEDIA_OK; } if (*outPerformancePoint == &pp) { found = true; } } *outPerformancePoint = nullptr; return AMEDIA_ERROR_UNSUPPORTED; } EXPORT int32_t ACodecVideoCapabilities_areSizeAndRateSupported(const ACodecVideoCapabilities *videoCaps, Loading Loading @@ -509,12 +519,30 @@ media_status_t ACodecEncoderCapabilities_getComplexityRange( } int32_t ACodecEncoderCapabilities_isBitrateModeSupported( const ACodecEncoderCapabilities *encoderCaps, ABiterateMode mode) { const ACodecEncoderCapabilities *encoderCaps, ABitrateMode mode) { if (encoderCaps == nullptr) { return -1; } return encoderCaps->mEncoderCaps->isBitrateModeSupported(mode); } // Feature Names extern const char* AMediaCodecInfo_FEATURE_AdaptivePlayback = "adaptive-playback"; extern const char* AMediaCodecInfo_FEATURE_SecurePlayback = "secure-playback"; extern const char* AMediaCodecInfo_FEATURE_TunneledPlayback = "tunneled-playback"; extern const char* AMediaCodecInfo_FEATURE_DynamicTimestamp = "dynamic-timestamp"; extern const char* AMediaCodecInfo_FEATURE_FrameParsing = "frame-parsing"; extern const char* AMediaCodecInfo_FEATURE_MultipleFrames = "multiple-frames"; extern const char* AMediaCodecInfo_FEATURE_PartialFrame = "partial-frame"; extern const char* AMediaCodecInfo_FEATURE_IntraRefresh = "intra-refresh"; extern const char* AMediaCodecInfo_FEATURE_LowLatency = "low-latency"; extern const char* AMediaCodecInfo_FEATURE_QpBounds = "qp-bounds"; extern const char* AMediaCodecInfo_FEATURE_EncodingStatistics = "encoding-statistics"; extern const char* AMediaCodecInfo_FEATURE_HdrEditing = "hdr-editing"; extern const char* AMediaCodecInfo_FEATURE_HlgEditing = "hlg-editing"; extern const char* AMediaCodecInfo_FEATURE_DynamicColorAspects = "dynamic-color-aspects"; extern const char* AMediaCodecInfo_FEATURE_Roi = "region-of-interest"; extern const char* AMediaCodecInfo_FEATURE_DetachedSurface = "detached-surface"; } No newline at end of file
media/ndk/NdkMediaCodecInfoPriv.h +2 −2 Original line number Diff line number Diff line Loading @@ -99,8 +99,8 @@ struct AMediaCodecInfo { std::shared_ptr<const ACodecVideoCapabilities> mAVideoCaps; std::shared_ptr<const ACodecEncoderCapabilities> mAEncoderCaps; AMediaCodecInfo(std::string name, android::sp<android::MediaCodecInfo> info, std::shared_ptr<android::CodecCapabilities> codecCaps, std::string mediaType) AMediaCodecInfo(const std::string &name, android::sp<android::MediaCodecInfo> info, std::shared_ptr<android::CodecCapabilities> codecCaps, const std::string &mediaType) : mName(name), mInfo(info), mMediaType(mediaType), mCodecCaps(codecCaps) { if (!mName.empty() && mInfo != nullptr && !mMediaType.empty() && mCodecCaps != nullptr) { if (mCodecCaps->getAudioCapabilities() != nullptr) { Loading
media/ndk/NdkMediaCodecStore.cpp +14 −8 Original line number Diff line number Diff line Loading @@ -66,8 +66,10 @@ static void initMediaTypes() { auto it = typesInfoMap.find(mediaType); if (it == typesInfoMap.end()) { AMediaCodecSupportedMediaType supportedType = { mediaType.c_str(), 0 }; it = typesInfoMap.emplace(mediaType, supportedType).first; char *mediaTypePtr = new char[mediaType.size()+1]; strncpy(mediaTypePtr, mediaType.c_str(), mediaType.size()+1); it = typesInfoMap.emplace(mediaType, (AMediaCodecSupportedMediaType) { mediaTypePtr, 0 }).first; mediaTypes.push_back(mediaType); } uint32_t &mode = it->second.mMode; Loading Loading @@ -152,7 +154,7 @@ static void initCodecInfoMap() { } } static bool codecHandlesFormat(const AMediaCodecInfo codecInfo, static bool codecHandlesFormat(const AMediaCodecInfo &codecInfo, sp<AMessage> format, bool isEncoder) { return codecInfo.mCodecCaps->isEncoder() == isEncoder && codecInfo.mCodecCaps->isFormatSupported(format); Loading @@ -168,10 +170,10 @@ static media_status_t findNextCodecForFormat( initCodecInfoMap(); } std::unique_ptr<std::vector<AMediaCodecInfo>> infos; std::vector<AMediaCodecInfo> *infos; sp<AMessage> nativeFormat; if (format == nullptr) { infos = std::unique_ptr<std::vector<AMediaCodecInfo>>(&sCodecInfos); infos = &sCodecInfos; } else { AMediaFormat_getFormat(format, &nativeFormat); AString mime; Loading @@ -180,11 +182,12 @@ static media_status_t findNextCodecForFormat( } std::string mediaType = std::string(mime.c_str()); auto it = sTypeToInfoList.find(mediaType); std::map<std::string, std::vector<AMediaCodecInfo>>::iterator it = sTypeToInfoList.find(mediaType); if (it == sTypeToInfoList.end()) { return AMEDIA_ERROR_UNSUPPORTED; } infos = std::unique_ptr<std::vector<AMediaCodecInfo>>(&(it->second)); infos = &(it->second); } bool found = *outCodecInfo == nullptr; Loading @@ -197,7 +200,6 @@ static media_status_t findNextCodecForFormat( if (*outCodecInfo == &info) { found = true; } } *outCodecInfo = nullptr; return AMEDIA_ERROR_UNSUPPORTED; Loading Loading @@ -241,6 +243,10 @@ media_status_t AMediaCodecStore_getCodecInfo( return AMEDIA_ERROR_INVALID_PARAMETER; } if (sNameToInfoMap.empty()) { initCodecInfoMap(); } auto it = sNameToInfoMap.find(std::string(name)); if (it == sNameToInfoMap.end()) { *outCodecInfo = nullptr; Loading
media/ndk/include/media/NdkMediaCodecInfo.h +429 −169 File changed.Preview size limit exceeded, changes collapsed. Show changes
media/ndk/include/media/NdkMediaCodecStore.h +40 −25 Original line number Diff line number Diff line Loading @@ -54,8 +54,8 @@ typedef struct AMediaCodecSupportedMediaType { FLAG_ENCODER = 1 << 1, }; // The media type. const char *mMediaType; // Encoded as ASCII. const char* _Nonnull mMediaType; // bitfields for modes. uint32_t mMode; } AMediaCodecSupportedMediaType; Loading @@ -68,47 +68,59 @@ typedef struct AMediaCodecSupportedMediaType { * * @param outCount size of the out array. * * Return AMEDIA_OK if successfully made the copy. * Return AMEDIA_ERROR_INVALID_PARAMETER if the @param outMediaTypes is invalid. * @return AMEDIA_OK if successfully made the copy. * @return AMEDIA_ERROR_INVALID_PARAMETER if the @param outMediaTypes is invalid. */ media_status_t AMediaCodecStore_getSupportedMediaTypes( const AMediaCodecSupportedMediaType **outMediaTypes, size_t *outCount) __INTRODUCED_IN(36); const AMediaCodecSupportedMediaType* _Nullable * _Nonnull outMediaTypes, size_t* _Nonnull outCount) __INTRODUCED_IN(36); /** * Get the next decoder info that supports the format. * * @param outCodecInfo should be set as NULL to start the iteration. * Keep the last codecInfo you got from a previous call to get the next one. * *outCodecInfo will be set to NULL if reached the end. * It is owned by the framework and has an infinite lifetime. * This API returns the decoder infos supporting the given format in a sequence and stores them * in a pointer at outCodecInfo. Initially, set the pointer pointed to by outCodecInfo to NULL. * On successive calls, keep the last pointer value. When the sequence is over * AMEDIA_ERROR_UNSUPPORTED will be returned and the pointer will be set to NULL. * * @param outCodecInfo a pointer to (the AMediaCodecInfo pointer) where the next codec info * will be stored. The AMediaCodecInfo object is owned by the framework * and has an infinite lifecycle. * * @param format If set as NULL, this API will iterate through all available decoders. * If NOT NULL, it MUST contain key "mime" implying the media type. * * Return AMEDIA_OK if successfully got the info. * Return AMEDIA_ERROR_INVALID_PARAMETER if @param outCodecInfo or @param format is invalid. * Return AMEDIA_ERROR_UNSUPPORTED if no more decoder supporting the format. * @return AMEDIA_OK if successfully got the info. * @return AMEDIA_ERROR_INVALID_PARAMETER if @param outCodecInfo or @param format is invalid. * @return AMEDIA_ERROR_UNSUPPORTED If ther are no more decoder supporting the format. * *outCodecInfo will also be set to NULL in this case. * * It is undefined behavior to call this API with a NON NULL @param outCodecInfo * and a different @param format during an iteration. */ media_status_t AMediaCodecStore_findNextDecoderForFormat( const AMediaFormat *format, const AMediaCodecInfo **outCodecInfo) __INTRODUCED_IN(36); const AMediaFormat* _Nonnull format, const AMediaCodecInfo* _Nullable * _Nonnull outCodecInfo) __INTRODUCED_IN(36); /** * Get the next encoder info that supports the format. * * @param outCodecInfo should be set as NULL to start the iteration. * Keep the last codecInfo you got from a previous call to get the next one. * *outCodecInfo will be set to NULL if reached the end. * It is owned by the framework and has an infinite lifetime. * This API returns the encoder infos supporting the given format in a sequence and stores them * in a pointer at outCodecInfo. Initially, set the pointer pointed to by outCodecInfo to NULL. * On successive calls, keep the last pointer value. When the sequence is over * AMEDIA_ERROR_UNSUPPORTED will be returned and the pointer will be set to NULL. * * @param outCodecInfo a pointer to (the AMediaCodecInfo pointer) where the next codec info * will be stored. The AMediaCodecInfo object is owned by the framework * and has an infinite lifecycle. * * @param format If set as NULL, this API will iterate through all available encoders. * If NOT NULL, it MUST contain key "mime" implying the media type. * * Return AMEDIA_OK if successfully got the info. * Return AMEDIA_ERROR_INVALID_PARAMETER if @param outCodecInfo is invalid. * Return AMEDIA_ERROR_UNSUPPORTED if no more encoder supporting the format. * @return AMEDIA_OK if successfully got the info. * @return AMEDIA_ERROR_INVALID_PARAMETER if @param outCodecInfo is invalid. * @return AMEDIA_ERROR_UNSUPPORTED If ther are no more encoder supporting the format. * *outCodecInfo will also be set to NULL in this case. * * It is undefined behavior to call this API with a NON NULL @param outCodecInfo * and a different @param format during an iteration. Loading @@ -116,12 +128,14 @@ media_status_t AMediaCodecStore_findNextDecoderForFormat( * No secure encoder will show in the output. */ media_status_t AMediaCodecStore_findNextEncoderForFormat( const AMediaFormat* format, const AMediaCodecInfo **outCodecInfo) __INTRODUCED_IN(36); const AMediaFormat* _Nonnull format, const AMediaCodecInfo* _Nullable * _Nonnull outCodecInfo) __INTRODUCED_IN(36); /** * Get the codecInfo corresponding to a given codec name. * * @param name Media codec name. * Encoded as ASCII. * Users can get valid codec names from the AMediaCodecInfo structures * returned from findNextDecoder|EncoderForFormat methods. * Note that this name may not correspond to the name the same codec used Loading @@ -130,12 +144,13 @@ media_status_t AMediaCodecStore_findNextEncoderForFormat( * @param outCodecInfo Output parameter for the corresponding AMeidaCodecInfo structure. * It is owned by the framework and has an infinite lifetime. * * Return AMEDIA_OK if got the codecInfo successfully. * Return AMEDIA_ERROR_UNSUPPORTED if no corresponding codec found. * Return AMEDIA_ERROR_INVALID_PARAMETER if @param outCodecInfo or @param name is invalid. * @return AMEDIA_OK if got the codecInfo successfully. * @return AMEDIA_ERROR_UNSUPPORTED if no corresponding codec found. * @return AMEDIA_ERROR_INVALID_PARAMETER if @param outCodecInfo or @param name is invalid. */ media_status_t AMediaCodecStore_getCodecInfo( const char *name, const AMediaCodecInfo **outCodecInfo) __INTRODUCED_IN(36); const char* _Nonnull name, const AMediaCodecInfo* _Nullable * _Nonnull outCodecInfo) __INTRODUCED_IN(36); __END_DECLS Loading