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 <aidl/android/media/MediaResourceParcel.h> 22 #include <utils/String8.h> 23 24 namespace android { 25 26 using aidl::android::media::MediaResourceParcel; 27 using aidl::android::media::MediaResourceSubType; 28 using aidl::android::media::MediaResourceType; 29 30 class MediaResource : public MediaResourceParcel { 31 public: 32 using Type = MediaResourceType; 33 using SubType = MediaResourceSubType; 34 35 MediaResource() = delete; 36 MediaResource(Type type, int64_t value); 37 MediaResource(Type type, SubType subType, int64_t value); 38 MediaResource(Type type, const std::vector<uint8_t> &id, int64_t value); 39 40 static MediaResource CodecResource(bool secure, MediaResourceSubType subType, 41 int64_t instanceCount = 1); 42 static MediaResource GraphicMemoryResource(int64_t value); 43 static MediaResource CpuBoostResource(); 44 static MediaResource VideoBatteryResource(bool isHardware = true); 45 static MediaResource DrmSessionResource(const std::vector<uint8_t> &id, int64_t value); 46 }; 47 48 inline static const char *asString(MediaResource::Type i, const char *def = "??") { 49 switch (i) { 50 case MediaResource::Type::kUnspecified: return "unspecified"; 51 case MediaResource::Type::kSecureCodec: return "secure-codec"; 52 case MediaResource::Type::kNonSecureCodec: return "non-secure-codec"; 53 case MediaResource::Type::kGraphicMemory: return "graphic-memory"; 54 case MediaResource::Type::kCpuBoost: return "cpu-boost"; 55 case MediaResource::Type::kBattery: return "battery"; 56 case MediaResource::Type::kDrmSession: return "drm-session"; 57 default: return def; 58 } 59 } 60 61 inline static const char *asString(MediaResource::SubType i, const char *def = "??") { 62 switch (i) { 63 case MediaResource::SubType::kUnspecifiedSubType: return "unspecified"; 64 case MediaResource::SubType::kHwAudioCodec: return "hw-audio-codec"; 65 case MediaResource::SubType::kSwAudioCodec: return "sw-audio-codec"; 66 case MediaResource::SubType::kHwVideoCodec: return "hw-video-codec"; 67 case MediaResource::SubType::kSwVideoCodec: return "sw-video-codec"; 68 case MediaResource::SubType::kHwImageCodec: return "hw-image-codec"; 69 case MediaResource::SubType::kSwImageCodec: return "sw-image-codec"; 70 default: return def; 71 } 72 } 73 74 String8 toString(const MediaResourceParcel& resource); 75 76 }; // namespace android 77 78 #endif // ANDROID_MEDIA_RESOURCE_H 79