blob: caf03b155a4557b658c9ce8cd7589a29553420b6 [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 Zhang181e6952019-10-09 13:23:39 -070021#include <android/media/MediaResourceParcel.h>
Ronghua Wu231c3d12015-03-11 15:10:32 -070022
23namespace android {
24
Chong Zhang181e6952019-10-09 13:23:39 -070025using android::media::MediaResourceParcel;
26using android::media::MediaResourceSubType;
27using android::media::MediaResourceType;
28
29class MediaResource : public MediaResourceParcel {
Ronghua Wu231c3d12015-03-11 15:10:32 -070030public:
Chong Zhang181e6952019-10-09 13:23:39 -070031 using Type = MediaResourceType;
32 using SubType = MediaResourceSubType;
Ronghua Wuea15fd22016-03-03 13:35:05 -080033
Chong Zhang181e6952019-10-09 13:23:39 -070034 MediaResource() = delete;
35 MediaResource(Type type, int64_t value);
36 MediaResource(Type type, SubType subType, int64_t value);
37 MediaResource(Type type, const std::vector<uint8_t> &id, int64_t value);
Ronghua Wuea15fd22016-03-03 13:35:05 -080038
Chong Zhang181e6952019-10-09 13:23:39 -070039 static MediaResource CodecResource(bool secure, bool video);
40 static MediaResource GraphicMemoryResource(int64_t value);
41 static MediaResource CpuBoostResource();
42 static MediaResource VideoBatteryResource();
43 static MediaResource DrmSessionResource(const std::vector<uint8_t> &id, int64_t value);
Ronghua Wu231c3d12015-03-11 15:10:32 -070044};
45
Ronghua Wuea15fd22016-03-03 13:35:05 -080046inline static const char *asString(MediaResource::Type i, const char *def = "??") {
47 switch (i) {
Chong Zhang181e6952019-10-09 13:23:39 -070048 case MediaResource::Type::kUnspecified: return "unspecified";
49 case MediaResource::Type::kSecureCodec: return "secure-codec";
50 case MediaResource::Type::kNonSecureCodec: return "non-secure-codec";
51 case MediaResource::Type::kGraphicMemory: return "graphic-memory";
52 case MediaResource::Type::kCpuBoost: return "cpu-boost";
53 case MediaResource::Type::kBattery: return "battery";
54 case MediaResource::Type::kDrmSession: return "drm-session";
55 default: return def;
Ronghua Wuea15fd22016-03-03 13:35:05 -080056 }
57}
58
59inline static const char *asString(MediaResource::SubType i, const char *def = "??") {
60 switch (i) {
Chong Zhang181e6952019-10-09 13:23:39 -070061 case MediaResource::SubType::kUnspecifiedSubType: return "unspecified";
62 case MediaResource::SubType::kAudioCodec: return "audio-codec";
63 case MediaResource::SubType::kVideoCodec: return "video-codec";
Ronghua Wuea15fd22016-03-03 13:35:05 -080064 default: return def;
65 }
66}
67
Chong Zhang181e6952019-10-09 13:23:39 -070068String8 toString(const MediaResourceParcel& resource);
69
Ronghua Wu231c3d12015-03-11 15:10:32 -070070}; // namespace android
71
72#endif // ANDROID_MEDIA_RESOURCE_H