blob: 10a07bb639c6f573ebda72524a854ff323ccab5f [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
21#include <binder/Parcel.h>
22#include <utils/String8.h>
23
24namespace android {
25
Ronghua Wu231c3d12015-03-11 15:10:32 -070026class MediaResource {
27public:
Ronghua Wuea15fd22016-03-03 13:35:05 -080028 enum Type {
29 kUnspecified = 0,
30 kSecureCodec,
31 kNonSecureCodec,
Chong Zhang79d2b282018-04-17 14:14:31 -070032 kGraphicMemory,
33 kCpuBoost,
Chong Zhangee33d642019-08-08 14:26:43 -070034 kBattery,
Ronghua Wuea15fd22016-03-03 13:35:05 -080035 };
36
37 enum SubType {
38 kUnspecifiedSubType = 0,
39 kAudioCodec,
Chong Zhangee33d642019-08-08 14:26:43 -070040 kVideoCodec,
Ronghua Wuea15fd22016-03-03 13:35:05 -080041 };
42
Ronghua Wu231c3d12015-03-11 15:10:32 -070043 MediaResource();
Ronghua Wuea15fd22016-03-03 13:35:05 -080044 MediaResource(Type type, uint64_t value);
45 MediaResource(Type type, SubType subType, uint64_t value);
Ronghua Wu231c3d12015-03-11 15:10:32 -070046
47 void readFromParcel(const Parcel &parcel);
48 void writeToParcel(Parcel *parcel) const;
49
50 String8 toString() const;
51
52 bool operator==(const MediaResource &other) const;
53 bool operator!=(const MediaResource &other) const;
54
Ronghua Wuea15fd22016-03-03 13:35:05 -080055 Type mType;
56 SubType mSubType;
Ronghua Wu231c3d12015-03-11 15:10:32 -070057 uint64_t mValue;
58};
59
Ronghua Wuea15fd22016-03-03 13:35:05 -080060inline static const char *asString(MediaResource::Type i, const char *def = "??") {
61 switch (i) {
62 case MediaResource::kUnspecified: return "unspecified";
63 case MediaResource::kSecureCodec: return "secure-codec";
64 case MediaResource::kNonSecureCodec: return "non-secure-codec";
65 case MediaResource::kGraphicMemory: return "graphic-memory";
Chong Zhangfb092d32019-08-12 09:45:44 -070066 case MediaResource::kCpuBoost: return "cpu-boost";
67 case MediaResource::kBattery: return "battery";
Ronghua Wuea15fd22016-03-03 13:35:05 -080068 default: return def;
69 }
70}
71
72inline static const char *asString(MediaResource::SubType i, const char *def = "??") {
73 switch (i) {
74 case MediaResource::kUnspecifiedSubType: return "unspecified";
75 case MediaResource::kAudioCodec: return "audio-codec";
76 case MediaResource::kVideoCodec: return "video-codec";
77 default: return def;
78 }
79}
80
Ronghua Wu231c3d12015-03-11 15:10:32 -070081}; // namespace android
82
83#endif // ANDROID_MEDIA_RESOURCE_H