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 | |
Chong Zhang | fdd512a | 2019-11-22 11:03:14 -0800 | [diff] [blame] | 21 | #include <aidl/android/media/MediaResourceParcel.h> |
| 22 | #include <utils/String8.h> |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 23 | |
| 24 | namespace android { |
| 25 | |
Chong Zhang | fdd512a | 2019-11-22 11:03:14 -0800 | [diff] [blame] | 26 | using aidl::android::media::MediaResourceParcel; |
| 27 | using aidl::android::media::MediaResourceSubType; |
| 28 | using aidl::android::media::MediaResourceType; |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame] | 29 | |
| 30 | class MediaResource : public MediaResourceParcel { |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 31 | public: |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame] | 32 | using Type = MediaResourceType; |
| 33 | using SubType = MediaResourceSubType; |
Ronghua Wu | ea15fd2 | 2016-03-03 13:35:05 -0800 | [diff] [blame] | 34 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame] | 35 | MediaResource() = delete; |
| 36 | MediaResource(Type type, int64_t value); |
| 37 | MediaResource(Type type, SubType subType, int64_t value); |
Chong Zhang | fdd512a | 2019-11-22 11:03:14 -0800 | [diff] [blame] | 38 | MediaResource(Type type, const std::vector<int8_t> &id, int64_t value); |
Ronghua Wu | ea15fd2 | 2016-03-03 13:35:05 -0800 | [diff] [blame] | 39 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame] | 40 | static MediaResource CodecResource(bool secure, bool video); |
| 41 | static MediaResource GraphicMemoryResource(int64_t value); |
| 42 | static MediaResource CpuBoostResource(); |
| 43 | static MediaResource VideoBatteryResource(); |
Chong Zhang | fdd512a | 2019-11-22 11:03:14 -0800 | [diff] [blame] | 44 | static MediaResource DrmSessionResource(const std::vector<int8_t> &id, int64_t value); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
Ronghua Wu | ea15fd2 | 2016-03-03 13:35:05 -0800 | [diff] [blame] | 47 | inline static const char *asString(MediaResource::Type i, const char *def = "??") { |
| 48 | switch (i) { |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame] | 49 | 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 Wu | ea15fd2 | 2016-03-03 13:35:05 -0800 | [diff] [blame] | 57 | } |
| 58 | } |
| 59 | |
| 60 | inline static const char *asString(MediaResource::SubType i, const char *def = "??") { |
| 61 | switch (i) { |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame] | 62 | case MediaResource::SubType::kUnspecifiedSubType: return "unspecified"; |
| 63 | case MediaResource::SubType::kAudioCodec: return "audio-codec"; |
| 64 | case MediaResource::SubType::kVideoCodec: return "video-codec"; |
Ronghua Wu | ea15fd2 | 2016-03-03 13:35:05 -0800 | [diff] [blame] | 65 | default: return def; |
| 66 | } |
| 67 | } |
| 68 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame] | 69 | String8 toString(const MediaResourceParcel& resource); |
| 70 | |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 71 | }; // namespace android |
| 72 | |
| 73 | #endif // ANDROID_MEDIA_RESOURCE_H |