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 26 class MediaResource { 27 public: 28 enum Type { 29 kUnspecified = 0, 30 kSecureCodec, 31 kNonSecureCodec, 32 kGraphicMemory, 33 kCpuBoost, 34 }; 35 36 enum SubType { 37 kUnspecifiedSubType = 0, 38 kAudioCodec, 39 kVideoCodec 40 }; 41 42 MediaResource(); 43 MediaResource(Type type, uint64_t value); 44 MediaResource(Type type, SubType subType, uint64_t value); 45 46 void readFromParcel(const Parcel &parcel); 47 void writeToParcel(Parcel *parcel) const; 48 49 String8 toString() const; 50 51 bool operator==(const MediaResource &other) const; 52 bool operator!=(const MediaResource &other) const; 53 54 Type mType; 55 SubType mSubType; 56 uint64_t mValue; 57 }; 58 59 inline static const char *asString(MediaResource::Type i, const char *def = "??") { 60 switch (i) { 61 case MediaResource::kUnspecified: return "unspecified"; 62 case MediaResource::kSecureCodec: return "secure-codec"; 63 case MediaResource::kNonSecureCodec: return "non-secure-codec"; 64 case MediaResource::kGraphicMemory: return "graphic-memory"; 65 default: return def; 66 } 67 } 68 69 inline static const char *asString(MediaResource::SubType i, const char *def = "??") { 70 switch (i) { 71 case MediaResource::kUnspecifiedSubType: return "unspecified"; 72 case MediaResource::kAudioCodec: return "audio-codec"; 73 case MediaResource::kVideoCodec: return "video-codec"; 74 default: return def; 75 } 76 } 77 78 }; // namespace android 79 80 #endif // ANDROID_MEDIA_RESOURCE_H 81