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 //#define LOG_NDEBUG 0
18 #define LOG_TAG "MediaResource"
19 #include <utils/Log.h>
20 #include <media/MediaResource.h>
21
22 namespace android {
23
24 const char kResourceSecureCodec[] = "secure-codec";
25 const char kResourceNonSecureCodec[] = "non-secure-codec";
26 const char kResourceAudioCodec[] = "audio-codec";
27 const char kResourceVideoCodec[] = "video-codec";
28 const char kResourceGraphicMemory[] = "graphic-memory";
29
MediaResource()30 MediaResource::MediaResource() : mValue(0) {}
31
MediaResource(String8 type,uint64_t value)32 MediaResource::MediaResource(String8 type, uint64_t value)
33 : mType(type),
34 mValue(value) {}
35
MediaResource(String8 type,String8 subType,uint64_t value)36 MediaResource::MediaResource(String8 type, String8 subType, uint64_t value)
37 : mType(type),
38 mSubType(subType),
39 mValue(value) {}
40
readFromParcel(const Parcel & parcel)41 void MediaResource::readFromParcel(const Parcel &parcel) {
42 mType = parcel.readString8();
43 mSubType = parcel.readString8();
44 mValue = parcel.readUint64();
45 }
46
writeToParcel(Parcel * parcel) const47 void MediaResource::writeToParcel(Parcel *parcel) const {
48 parcel->writeString8(mType);
49 parcel->writeString8(mSubType);
50 parcel->writeUint64(mValue);
51 }
52
toString() const53 String8 MediaResource::toString() const {
54 String8 str;
55 str.appendFormat("%s/%s:%llu", mType.string(), mSubType.string(), (unsigned long long)mValue);
56 return str;
57 }
58
operator ==(const MediaResource & other) const59 bool MediaResource::operator==(const MediaResource &other) const {
60 return (other.mType == mType) && (other.mSubType == mSubType) && (other.mValue == mValue);
61 }
62
operator !=(const MediaResource & other) const63 bool MediaResource::operator!=(const MediaResource &other) const {
64 return !(*this == other);
65 }
66
67 }; // namespace android
68