blob: 1957a45da17f06e2f14bd2fb28f5aaf7f0cf66de [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
21#include <binder/Parcel.h>
22#include <utils/String8.h>
23
24namespace android {
25
Ronghua Wu231c3d12015-03-11 15:10:32 -070026class MediaResource {
27public:
Ronghua Wuea15fd22016-03-03 13:35:05 -080028 enum Type {
29 kUnspecified = 0,
30 kSecureCodec,
31 kNonSecureCodec,
32 kGraphicMemory
33 };
34
35 enum SubType {
36 kUnspecifiedSubType = 0,
37 kAudioCodec,
38 kVideoCodec
39 };
40
Ronghua Wu231c3d12015-03-11 15:10:32 -070041 MediaResource();
Ronghua Wuea15fd22016-03-03 13:35:05 -080042 MediaResource(Type type, uint64_t value);
43 MediaResource(Type type, SubType subType, uint64_t value);
Ronghua Wu231c3d12015-03-11 15:10:32 -070044
45 void readFromParcel(const Parcel &parcel);
46 void writeToParcel(Parcel *parcel) const;
47
48 String8 toString() const;
49
50 bool operator==(const MediaResource &other) const;
51 bool operator!=(const MediaResource &other) const;
52
Ronghua Wuea15fd22016-03-03 13:35:05 -080053 Type mType;
54 SubType mSubType;
Ronghua Wu231c3d12015-03-11 15:10:32 -070055 uint64_t mValue;
56};
57
Ronghua Wuea15fd22016-03-03 13:35:05 -080058inline static const char *asString(MediaResource::Type i, const char *def = "??") {
59 switch (i) {
60 case MediaResource::kUnspecified: return "unspecified";
61 case MediaResource::kSecureCodec: return "secure-codec";
62 case MediaResource::kNonSecureCodec: return "non-secure-codec";
63 case MediaResource::kGraphicMemory: return "graphic-memory";
64 default: return def;
65 }
66}
67
68inline static const char *asString(MediaResource::SubType i, const char *def = "??") {
69 switch (i) {
70 case MediaResource::kUnspecifiedSubType: return "unspecified";
71 case MediaResource::kAudioCodec: return "audio-codec";
72 case MediaResource::kVideoCodec: return "video-codec";
73 default: return def;
74 }
75}
76
Ronghua Wu231c3d12015-03-11 15:10:32 -070077}; // namespace android
78
79#endif // ANDROID_MEDIA_RESOURCE_H