blob: fc340c8860107edd721c1e0b6e78bf267c7bb862 [file] [log] [blame]
Lajos Molnar60b1c0e2014-08-06 16:55:46 -07001/*
2 * Copyright 2014, 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#ifndef MEDIA_CODEC_INFO_H_
18
19#define MEDIA_CODEC_INFO_H_
20
21#include <binder/Parcel.h>
22#include <media/stagefright/foundation/ABase.h>
23#include <media/stagefright/foundation/AString.h>
24
25#include <sys/types.h>
26#include <utils/Errors.h>
27#include <utils/KeyedVector.h>
28#include <utils/RefBase.h>
29#include <utils/Vector.h>
30#include <utils/StrongPointer.h>
31
32namespace android {
33
34struct AMessage;
35struct Parcel;
36struct CodecCapabilities;
37
38struct MediaCodecInfo : public RefBase {
39 struct ProfileLevel {
40 uint32_t mProfile;
41 uint32_t mLevel;
42 };
43
44 struct Capabilities : public RefBase {
45 void getSupportedProfileLevels(Vector<ProfileLevel> *profileLevels) const;
46 void getSupportedColorFormats(Vector<uint32_t> *colorFormats) const;
47 uint32_t getFlags() const;
48 const sp<AMessage> &getDetails() const;
49
50 private:
51 Vector<ProfileLevel> mProfileLevels;
52 Vector<uint32_t> mColorFormats;
53 uint32_t mFlags;
54 sp<AMessage> mDetails;
55
56 Capabilities();
57
58 // read object from parcel even if object creation fails
59 static sp<Capabilities> FromParcel(const Parcel &parcel);
60 status_t writeToParcel(Parcel *parcel) const;
61
62 DISALLOW_EVIL_CONSTRUCTORS(Capabilities);
63
64 friend class MediaCodecInfo;
65 };
66
67 bool isEncoder() const;
68 bool hasQuirk(const char *name) const;
69 void getSupportedMimes(Vector<AString> *mimes) const;
70 const sp<Capabilities> &getCapabilitiesFor(const char *mime) const;
71 const char *getCodecName() const;
72
73 /**
74 * Serialization over Binder
75 */
76 static sp<MediaCodecInfo> FromParcel(const Parcel &parcel);
77 status_t writeToParcel(Parcel *parcel) const;
78
79private:
80 // variable set only in constructor - these are accessed by MediaCodecList
81 // to avoid duplication of same variables
82 AString mName;
83 bool mIsEncoder;
84 bool mHasSoleMime; // was initialized with mime
85
86 Vector<AString> mQuirks;
87 KeyedVector<AString, sp<Capabilities> > mCaps;
88
89 sp<Capabilities> mCurrentCaps; // currently initalized capabilities
90
91 ssize_t getCapabilityIndex(const char *mime) const;
92
93 /* Methods used by MediaCodecList to construct the info
94 * object from XML.
95 *
96 * After info object is created:
97 * - additional quirks can be added
98 * - additional mimes can be added
99 * - OMX codec capabilities can be set for the current mime-type
100 * - a capability detail can be set for the current mime-type
101 * - a feature can be set for the current mime-type
102 * - info object can be completed when parsing of a mime-type is done
103 */
104 MediaCodecInfo(AString name, bool encoder, const char *mime);
105 void addQuirk(const char *name);
106 status_t addMime(const char *mime);
107 status_t initializeCapabilities(const CodecCapabilities &caps);
108 void addDetail(const AString &key, const AString &value);
109 void addFeature(const AString &key, int32_t value);
Lajos Molnar6ff58f02014-08-11 16:46:15 -0700110 void removeMime(const char *mime);
Lajos Molnar60b1c0e2014-08-06 16:55:46 -0700111 void complete();
112
113 DISALLOW_EVIL_CONSTRUCTORS(MediaCodecInfo);
114
115 friend class MediaCodecList;
116};
117
118} // namespace android
119
120#endif // MEDIA_CODEC_INFO_H_
121
122