18253f44c3d0d8a7003dd2e6f728f9e3d63927727Steven Moreland/*
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
26class MediaResource {
27public:
28    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
41    MediaResource();
42    MediaResource(Type type, uint64_t value);
43    MediaResource(Type type, SubType subType, uint64_t value);
44
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
53    Type mType;
54    SubType mSubType;
55    uint64_t mValue;
56};
57
58inline 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
77}; // namespace android
78
79#endif  // ANDROID_MEDIA_RESOURCE_H
80