Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 24 | namespace android { |
| 25 | |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 26 | class MediaResource { |
| 27 | public: |
Ronghua Wu | ea15fd2 | 2016-03-03 13:35:05 -0800 | [diff] [blame] | 28 | enum Type { |
| 29 | kUnspecified = 0, |
| 30 | kSecureCodec, |
| 31 | kNonSecureCodec, |
Chong Zhang | 79d2b28 | 2018-04-17 14:14:31 -0700 | [diff] [blame] | 32 | kGraphicMemory, |
| 33 | kCpuBoost, |
Chong Zhang | ee33d64 | 2019-08-08 14:26:43 -0700 | [diff] [blame] | 34 | kBattery, |
Ronghua Wu | ea15fd2 | 2016-03-03 13:35:05 -0800 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | enum SubType { |
| 38 | kUnspecifiedSubType = 0, |
| 39 | kAudioCodec, |
Chong Zhang | ee33d64 | 2019-08-08 14:26:43 -0700 | [diff] [blame] | 40 | kVideoCodec, |
Ronghua Wu | ea15fd2 | 2016-03-03 13:35:05 -0800 | [diff] [blame] | 41 | }; |
| 42 | |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 43 | MediaResource(); |
Ronghua Wu | ea15fd2 | 2016-03-03 13:35:05 -0800 | [diff] [blame] | 44 | MediaResource(Type type, uint64_t value); |
| 45 | MediaResource(Type type, SubType subType, uint64_t value); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 46 | |
| 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 Wu | ea15fd2 | 2016-03-03 13:35:05 -0800 | [diff] [blame] | 55 | Type mType; |
| 56 | SubType mSubType; |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 57 | uint64_t mValue; |
| 58 | }; |
| 59 | |
Ronghua Wu | ea15fd2 | 2016-03-03 13:35:05 -0800 | [diff] [blame] | 60 | inline 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 Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 66 | case MediaResource::kCpuBoost: return "cpu-boost"; |
| 67 | case MediaResource::kBattery: return "battery"; |
Ronghua Wu | ea15fd2 | 2016-03-03 13:35:05 -0800 | [diff] [blame] | 68 | default: return def; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | inline 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 Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 81 | }; // namespace android |
| 82 | |
| 83 | #endif // ANDROID_MEDIA_RESOURCE_H |