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