blob: e7362c13b47aac4abcd3bcc5ec9057519effd894 [file] [log] [blame]
Ronghua Wu231c3d12015-03-11 15:10:32 -07001/*
2 * Copyright 2015 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
18#ifndef ANDROID_MEDIA_RESOURCE_H
19#define ANDROID_MEDIA_RESOURCE_H
20
Chong Zhangfdd512a2019-11-22 11:03:14 -080021#include <aidl/android/media/MediaResourceParcel.h>
22#include <utils/String8.h>
Ronghua Wu231c3d12015-03-11 15:10:32 -070023
24namespace android {
25
Chong Zhangfdd512a2019-11-22 11:03:14 -080026using aidl::android::media::MediaResourceParcel;
27using aidl::android::media::MediaResourceSubType;
28using aidl::android::media::MediaResourceType;
Chong Zhang181e6952019-10-09 13:23:39 -070029
30class MediaResource : public MediaResourceParcel {
Ronghua Wu231c3d12015-03-11 15:10:32 -070031public:
Chong Zhang181e6952019-10-09 13:23:39 -070032 using Type = MediaResourceType;
33 using SubType = MediaResourceSubType;
Ronghua Wuea15fd22016-03-03 13:35:05 -080034
Chong Zhang181e6952019-10-09 13:23:39 -070035 MediaResource() = delete;
36 MediaResource(Type type, int64_t value);
37 MediaResource(Type type, SubType subType, int64_t value);
Chong Zhangfdd512a2019-11-22 11:03:14 -080038 MediaResource(Type type, const std::vector<int8_t> &id, int64_t value);
Ronghua Wuea15fd22016-03-03 13:35:05 -080039
Chong Zhang181e6952019-10-09 13:23:39 -070040 static MediaResource CodecResource(bool secure, bool video);
41 static MediaResource GraphicMemoryResource(int64_t value);
42 static MediaResource CpuBoostResource();
43 static MediaResource VideoBatteryResource();
Chong Zhangfdd512a2019-11-22 11:03:14 -080044 static MediaResource DrmSessionResource(const std::vector<int8_t> &id, int64_t value);
Ronghua Wu231c3d12015-03-11 15:10:32 -070045};
46
Ronghua Wuea15fd22016-03-03 13:35:05 -080047inline static const char *asString(MediaResource::Type i, const char *def = "??") {
48 switch (i) {
Chong Zhang181e6952019-10-09 13:23:39 -070049 case MediaResource::Type::kUnspecified: return "unspecified";
50 case MediaResource::Type::kSecureCodec: return "secure-codec";
51 case MediaResource::Type::kNonSecureCodec: return "non-secure-codec";
52 case MediaResource::Type::kGraphicMemory: return "graphic-memory";
53 case MediaResource::Type::kCpuBoost: return "cpu-boost";
54 case MediaResource::Type::kBattery: return "battery";
55 case MediaResource::Type::kDrmSession: return "drm-session";
56 default: return def;
Ronghua Wuea15fd22016-03-03 13:35:05 -080057 }
58}
59
60inline static const char *asString(MediaResource::SubType i, const char *def = "??") {
61 switch (i) {
Chong Zhang181e6952019-10-09 13:23:39 -070062 case MediaResource::SubType::kUnspecifiedSubType: return "unspecified";
63 case MediaResource::SubType::kAudioCodec: return "audio-codec";
64 case MediaResource::SubType::kVideoCodec: return "video-codec";
Ronghua Wuea15fd22016-03-03 13:35:05 -080065 default: return def;
66 }
67}
68
Chong Zhang181e6952019-10-09 13:23:39 -070069String8 toString(const MediaResourceParcel& resource);
70
Ronghua Wu231c3d12015-03-11 15:10:32 -070071}; // namespace android
72
73#endif // ANDROID_MEDIA_RESOURCE_H