/* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _NDK_MEDIA_CODEC_INFO_PRIV_H #define _NDK_MEDIA_CODEC_INFO_PRIV_H #include #include struct ACodecAudioCapabilities { std::shared_ptr mAudioCaps; std::vector mSampleRates; std::vector mSampleRateRanges; std::vector mInputChannelCountRanges; void initSampleRates() { mSampleRates = mAudioCaps->getSupportedSampleRates(); } void initSampleRateRanges() { const std::vector>& sampleRateRanges = mAudioCaps->getSupportedSampleRateRanges(); for (auto it = sampleRateRanges.begin(); it != sampleRateRanges.end(); it++) { mSampleRateRanges.emplace_back(it->lower(), it->upper()); } } void initInputChannelCountRanges() { const std::vector>& inputChannels = mAudioCaps->getInputChannelCountRanges(); for (auto it = inputChannels.begin(); it != inputChannels.end(); it++) { mInputChannelCountRanges.emplace_back(it->lower(), it->upper()); } } ACodecAudioCapabilities(std::shared_ptr audioCaps) : mAudioCaps(audioCaps) { initSampleRates(); initSampleRateRanges(); initInputChannelCountRanges(); } }; struct ACodecPerformancePoint { std::shared_ptr mPerformancePoint; ACodecPerformancePoint(std::shared_ptr performancePoint) : mPerformancePoint(performancePoint) {} }; struct ACodecVideoCapabilities { std::shared_ptr mVideoCaps; std::vector mPerformancePoints; void initPerformancePoints() { const std::vector& performancePoints = mVideoCaps->getSupportedPerformancePoints(); for (auto it = performancePoints.begin(); it != performancePoints.end(); it++) { mPerformancePoints.emplace_back( std::shared_ptr(&(*it))); } } ACodecVideoCapabilities(std::shared_ptr videoCaps) : mVideoCaps(videoCaps) { initPerformancePoints(); } }; struct ACodecEncoderCapabilities { std::shared_ptr mEncoderCaps; ACodecEncoderCapabilities(std::shared_ptr encoderCaps) : mEncoderCaps(encoderCaps) {} }; struct AMediaCodecInfo { std::string mName; android::sp mInfo; std::string mMediaType; std::shared_ptr mCodecCaps; std::shared_ptr mAAudioCaps; std::shared_ptr mAVideoCaps; std::shared_ptr mAEncoderCaps; AMediaCodecInfo(const std::string &name, android::sp info, std::shared_ptr 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) { mAAudioCaps = std::make_shared( mCodecCaps->getAudioCapabilities()); } if (mCodecCaps->getVideoCapabilities() != nullptr) { mAVideoCaps = std::make_shared( mCodecCaps->getVideoCapabilities()); } if (mCodecCaps->getEncoderCapabilities() != nullptr) { mAEncoderCaps = std::make_shared( mCodecCaps->getEncoderCapabilities()); } } } }; #endif //_NDK_MEDIA_CODEC_INFO_PRIV_H