blob: 87eb4bcff324b77cf8bd05ed2d59e26fc4d17dd4 [file] [log] [blame]
Songyue Han130053e2024-04-25 22:04:38 +00001/*
2 * Copyright 2024, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//#define LOG_NDEBUG 0
18#define LOG_TAG "CodecCapabilities"
19
20#include <utils/Log.h>
21#include <media/CodecCapabilities.h>
22#include <media/CodecCapabilitiesUtils.h>
23#include <media/stagefright/foundation/ADebug.h>
24#include <media/stagefright/foundation/AMessage.h>
25
26namespace android {
27
Songyue Hanad936af2024-10-14 23:53:58 +000028bool CodecCapabilities::SupportsBitrate(Range<int32_t> bitrateRange,
Songyue Han73d6d112024-06-05 17:39:06 +000029 const sp<AMessage> &format) {
30 // consider max bitrate over average bitrate for support
31 int32_t maxBitrate = 0;
32 format->findInt32(KEY_MAX_BIT_RATE, &maxBitrate);
33 int32_t bitrate = 0;
34 format->findInt32(KEY_BIT_RATE, &bitrate);
35
36 if (bitrate == 0) {
37 bitrate = maxBitrate;
38 } else if (maxBitrate != 0) {
39 bitrate = std::max(bitrate, maxBitrate);
40 }
41
42 if (bitrate > 0) {
43 return bitrateRange.contains(bitrate);
44 }
45
46 return true;
47}
48
49const std::string& CodecCapabilities::getMediaType() {
50 return mMediaType;
51}
52
53const std::vector<ProfileLevel>& CodecCapabilities::getProfileLevels() {
54 return mProfileLevels;
55}
56
Songyue Han130053e2024-04-25 22:04:38 +000057} // namespace android