1693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber/*
2693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber * Copyright (C) 2009 The Android Open Source Project
3693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber *
4693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber * Licensed under the Apache License, Version 2.0 (the "License");
5693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber * you may not use this file except in compliance with the License.
6693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber * You may obtain a copy of the License at
7693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber *
8693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber *      http://www.apache.org/licenses/LICENSE-2.0
9693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber *
10693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber * Unless required by applicable law or agreed to in writing, software
11693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber * distributed under the License is distributed on an "AS IS" BASIS,
12693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber * See the License for the specific language governing permissions and
14693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber * limitations under the License.
15693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber */
16693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
17693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber#ifndef OMX_CODEC_H_
18693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
19693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber#define OMX_CODEC_H_
20693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
216a9da9fc558263548ebfbae2cbf177eb7454a41bJamie Gennis#include <android/native_window.h>
22693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber#include <media/IOMX.h>
23693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber#include <media/stagefright/MediaBuffer.h>
24693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber#include <media/stagefright/MediaSource.h>
25693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber#include <utils/threads.h>
26693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
27c1d8115e8a0bdaeb2b723d395b9a85a02c90c933Andreas Huber#include <OMX_Audio.h>
28c1d8115e8a0bdaeb2b723d395b9a85a02c90c933Andreas Huber
29693d271e62a3726689ff68f4505ba49228eb94b2Andreas Hubernamespace android {
30693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
3160b1c0e79d12a1c70758bc8d060156924635f8baLajos Molnarstruct MediaCodecInfo;
32693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huberclass MemoryDealer;
33693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huberstruct OMXCodecObserver;
34145bfe5eb3e08c9689c28f6bf3287a979438b04bJames Dongstruct CodecProfileLevel;
35a98478bfbcc0f7fb4b164d3dce40ca96df75667dMarco Nelissenclass SkipCutBuffer;
36693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
37693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huberstruct OMXCodec : public MediaSource,
38693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber                  public MediaBufferObserver {
39ba229b3faa98b3bb6567cf95040062be2d9c2b3fAndreas Huber    enum CreationFlags {
402a4d22d79e927f2245537921e10fc5fda1c47a29Andreas Huber        kPreferSoftwareCodecs    = 1,
41f3712f026aad1fc46b1df18d1dba718281e39726Andreas Huber        kIgnoreCodecSpecificData = 2,
42f3712f026aad1fc46b1df18d1dba718281e39726Andreas Huber
43f3712f026aad1fc46b1df18d1dba718281e39726Andreas Huber        // The client wants to access the output buffer's video
44f3712f026aad1fc46b1df18d1dba718281e39726Andreas Huber        // data for example for thumbnail extraction.
45f3712f026aad1fc46b1df18d1dba718281e39726Andreas Huber        kClientNeedsFramebuffer  = 4,
46d332a72e8f71caea0d3dc898db6a9d7a929fad32James Dong
47d332a72e8f71caea0d3dc898db6a9d7a929fad32James Dong        // Request for software or hardware codecs. If request
48d332a72e8f71caea0d3dc898db6a9d7a929fad32James Dong        // can not be fullfilled, Create() returns NULL.
49d332a72e8f71caea0d3dc898db6a9d7a929fad32James Dong        kSoftwareCodecsOnly      = 8,
50d332a72e8f71caea0d3dc898db6a9d7a929fad32James Dong        kHardwareCodecsOnly      = 16,
518480835b4bc1350646376aa7f3ae33742a7adeb1James Dong
528480835b4bc1350646376aa7f3ae33742a7adeb1James Dong        // Store meta data in video buffers
538480835b4bc1350646376aa7f3ae33742a7adeb1James Dong        kStoreMetaDataInVideoBuffers = 32,
547757f5010a771fb8824b6fdf9788f588a1577e3fJames Dong
557757f5010a771fb8824b6fdf9788f588a1577e3fJames Dong        // Only submit one input buffer at one time.
567757f5010a771fb8824b6fdf9788f588a1577e3fJames Dong        kOnlySubmitOneInputBufferAtOneTime = 64,
572eb62955eb84b97695e8a7e56e14310cbb86412bGlenn Kasten
582eb62955eb84b97695e8a7e56e14310cbb86412bGlenn Kasten        // Enable GRALLOC_USAGE_PROTECTED for output buffers from native window
592eb62955eb84b97695e8a7e56e14310cbb86412bGlenn Kasten        kEnableGrallocUsageProtected = 128,
600bb6b4c5da2451ee0973372b0a3858b15c742689Andreas Huber
610bb6b4c5da2451ee0973372b0a3858b15c742689Andreas Huber        // Secure decoding mode
620bb6b4c5da2451ee0973372b0a3858b15c742689Andreas Huber        kUseSecureInputBuffers = 256,
63ba229b3faa98b3bb6567cf95040062be2d9c2b3fAndreas Huber    };
64bf697e37550d9e8376089b0b5e498613bede798cAndreas Huber    static sp<MediaSource> Create(
65693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber            const sp<IOMX> &omx,
66693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber            const sp<MetaData> &meta, bool createEncoder,
6718291bc20e55e8f3fd5feb786771a8ed32c19c59Andreas Huber            const sp<MediaSource> &source,
68ba229b3faa98b3bb6567cf95040062be2d9c2b3fAndreas Huber            const char *matchComponentName = NULL,
696a9da9fc558263548ebfbae2cbf177eb7454a41bJamie Gennis            uint32_t flags = 0,
706a9da9fc558263548ebfbae2cbf177eb7454a41bJamie Gennis            const sp<ANativeWindow> &nativeWindow = NULL);
7118291bc20e55e8f3fd5feb786771a8ed32c19c59Andreas Huber
7218291bc20e55e8f3fd5feb786771a8ed32c19c59Andreas Huber    static void setComponentRole(
7318291bc20e55e8f3fd5feb786771a8ed32c19c59Andreas Huber            const sp<IOMX> &omx, IOMX::node_id node, bool isEncoder,
7418291bc20e55e8f3fd5feb786771a8ed32c19c59Andreas Huber            const char *mime);
75693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
76693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    virtual status_t start(MetaData *params = NULL);
77693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    virtual status_t stop();
78693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
79693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    virtual sp<MetaData> getFormat();
80693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
81693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    virtual status_t read(
82693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber            MediaBuffer **buffer, const ReadOptions *options = NULL);
83693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
84d35bd5fb4e09c2cd8608497c279cbb2ef9c3a029Andreas Huber    virtual status_t pause();
85d35bd5fb4e09c2cd8608497c279cbb2ef9c3a029Andreas Huber
86693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    // from MediaBufferObserver
87693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    virtual void signalBufferReturned(MediaBuffer *buffer);
88693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
89afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber    enum Quirks {
90afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber        kNeedsFlushBeforeDisable              = 1,
91afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber        kWantsNALFragments                    = 2,
92afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber        kRequiresLoadedToIdleAfterAllocation  = 4,
93afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber        kRequiresAllocateBufferOnInputPorts   = 8,
94afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber        kRequiresFlushCompleteEmulation       = 16,
95afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber        kRequiresAllocateBufferOnOutputPorts  = 32,
96afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber        kRequiresFlushBeforeShutdown          = 64,
97afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber        kDefersOutputBufferAllocation         = 128,
98afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber        kDecoderLiesAboutNumberOfChannels     = 256,
99afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber        kInputBufferSizesAreBogus             = 512,
100afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber        kSupportsMultipleFramesPerInputBuffer = 1024,
101a6ee7bc5f9524c220377e37f6525e2d46c69b75bJames Dong        kRequiresLargerEncoderOutputBuffer    = 2048,
102a6ee7bc5f9524c220377e37f6525e2d46c69b75bJames Dong        kOutputBuffersAreUnreadable           = 4096,
103afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber    };
104afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber
105e671207115fac3914134c61b336d5fa0242c68caAndreas Huber    struct CodecNameAndQuirks {
106e671207115fac3914134c61b336d5fa0242c68caAndreas Huber        String8 mName;
107e671207115fac3914134c61b336d5fa0242c68caAndreas Huber        uint32_t mQuirks;
108e671207115fac3914134c61b336d5fa0242c68caAndreas Huber    };
109e671207115fac3914134c61b336d5fa0242c68caAndreas Huber
1101065b3f17d3048948e7d522049d1980b90df3dc1Andreas Huber    // for use by ACodec
1111065b3f17d3048948e7d522049d1980b90df3dc1Andreas Huber    static void findMatchingCodecs(
1121065b3f17d3048948e7d522049d1980b90df3dc1Andreas Huber            const char *mime,
1131065b3f17d3048948e7d522049d1980b90df3dc1Andreas Huber            bool createEncoder, const char *matchComponentName,
1141065b3f17d3048948e7d522049d1980b90df3dc1Andreas Huber            uint32_t flags,
115e671207115fac3914134c61b336d5fa0242c68caAndreas Huber            Vector<CodecNameAndQuirks> *matchingCodecNamesAndQuirks);
116afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber
117afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber    static uint32_t getComponentQuirks(
11860b1c0e79d12a1c70758bc8d060156924635f8baLajos Molnar            const sp<MediaCodecInfo> &list);
119afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber
120afc16d667afa23f5aa00154ccad62f8c45cf5419Andreas Huber    static bool findCodecQuirks(const char *componentName, uint32_t *quirks);
1211065b3f17d3048948e7d522049d1980b90df3dc1Andreas Huber
122693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huberprotected:
123693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    virtual ~OMXCodec();
124693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
125693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huberprivate:
12614c858e80dfe2030c9f343dc0c6e2048e030731bJames Dong
12714c858e80dfe2030c9f343dc0c6e2048e030731bJames Dong    // Make sure mLock is accessible to OMXCodecObserver
12814c858e80dfe2030c9f343dc0c6e2048e030731bJames Dong    friend class OMXCodecObserver;
12914c858e80dfe2030c9f343dc0c6e2048e030731bJames Dong
13014c858e80dfe2030c9f343dc0c6e2048e030731bJames Dong    // Call this with mLock hold
13114c858e80dfe2030c9f343dc0c6e2048e030731bJames Dong    void on_message(const omx_message &msg);
13214c858e80dfe2030c9f343dc0c6e2048e030731bJames Dong
133693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    enum State {
134693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        DEAD,
135693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        LOADED,
136693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        LOADED_TO_IDLE,
137693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        IDLE_TO_EXECUTING,
138693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        EXECUTING,
139693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        EXECUTING_TO_IDLE,
140693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        IDLE_TO_LOADED,
141693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        RECONFIGURING,
142693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        ERROR
143693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    };
144693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
145693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    enum {
146693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        kPortIndexInput  = 0,
147693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        kPortIndexOutput = 1
148693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    };
149693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
150693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    enum PortStatus {
151693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        ENABLED,
152693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        DISABLING,
153693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        DISABLED,
154693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        ENABLING,
155693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        SHUTTING_DOWN,
156693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    };
157693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
15892bf2f96c53d24adc1ace362439e82ca2cf6b856Andreas Huber    enum BufferStatus {
15992bf2f96c53d24adc1ace362439e82ca2cf6b856Andreas Huber        OWNED_BY_US,
16092bf2f96c53d24adc1ace362439e82ca2cf6b856Andreas Huber        OWNED_BY_COMPONENT,
16192bf2f96c53d24adc1ace362439e82ca2cf6b856Andreas Huber        OWNED_BY_NATIVE_WINDOW,
16292bf2f96c53d24adc1ace362439e82ca2cf6b856Andreas Huber        OWNED_BY_CLIENT,
16392bf2f96c53d24adc1ace362439e82ca2cf6b856Andreas Huber    };
16492bf2f96c53d24adc1ace362439e82ca2cf6b856Andreas Huber
165693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    struct BufferInfo {
166693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        IOMX::buffer_id mBuffer;
16792bf2f96c53d24adc1ace362439e82ca2cf6b856Andreas Huber        BufferStatus mStatus;
168693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        sp<IMemory> mMem;
169570a3cb7582daa030cb38eedc5eb6a06f86ecc7fAndreas Huber        size_t mSize;
170570a3cb7582daa030cb38eedc5eb6a06f86ecc7fAndreas Huber        void *mData;
171693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        MediaBuffer *mMediaBuffer;
172693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    };
173693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
174693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    struct CodecSpecificData {
175693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        size_t mSize;
176693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber        uint8_t mData[1];
177693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    };
178693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
179693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    sp<IOMX> mOMX;
1807eaa9c9385535b651064e02d05a8ffa4b2359281Andreas Huber    bool mOMXLivesLocally;
181693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    IOMX::node_id mNode;
182693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    uint32_t mQuirks;
1830bb6b4c5da2451ee0973372b0a3858b15c742689Andreas Huber
1840bb6b4c5da2451ee0973372b0a3858b15c742689Andreas Huber    // Flags specified in the creation of the codec.
1850bb6b4c5da2451ee0973372b0a3858b15c742689Andreas Huber    uint32_t mFlags;
1860bb6b4c5da2451ee0973372b0a3858b15c742689Andreas Huber
187693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    bool mIsEncoder;
1882b1892db4a2ab47bfc09e59a4c11751aea99e4eaAndreas Huber    bool mIsVideo;
189693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    char *mMIME;
190693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    char *mComponentName;
191693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    sp<MetaData> mOutputFormat;
192693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    sp<MediaSource> mSource;
193693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    Vector<CodecSpecificData *> mCodecSpecificData;
194693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    size_t mCodecSpecificDataIndex;
195693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
1967530e9c708275c273c134c36c68179f511c1940eAndreas Huber    sp<MemoryDealer> mDealer[2];
197693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
198693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    State mState;
199693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    Vector<BufferInfo> mPortBuffers[2];
200693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    PortStatus mPortStatus[2];
201284f513a4ce2c5aa0e250c07c873731aedb0be26Andreas Huber    bool mInitialBufferSubmit;
202693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    bool mSignalledEOS;
2035295c0c55d41a2906ea7f65a3f22e6278cb17d4bAndreas Huber    status_t mFinalStatus;
204693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    bool mNoMoreOutputData;
2057f281f87670c63775ea1ae8b24af31822d5ad416Andreas Huber    bool mOutputPortSettingsHaveChanged;
206693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    int64_t mSeekTimeUs;
207abd1f4f870925d6776dbe4b930b759a1ab6595caAndreas Huber    ReadOptions::SeekMode mSeekMode;
208abd1f4f870925d6776dbe4b930b759a1ab6595caAndreas Huber    int64_t mTargetTimeUs;
2099c0096378820e5a61db26e52a7e6df50ba9c872dAndreas Huber    bool mOutputPortSettingsChangedPending;
2108b71241ce7353731ab75322c46e090ee35014a33Marco Nelissen    sp<SkipCutBuffer> mSkipCutBuffer;
211693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
2127f498b90a4300ef9badf14d202b0a67c26e20931Andreas Huber    MediaBuffer *mLeftOverBuffer;
2137f498b90a4300ef9badf14d202b0a67c26e20931Andreas Huber
214693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    Mutex mLock;
215693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    Condition mAsyncCompletion;
216693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
217d35bd5fb4e09c2cd8608497c279cbb2ef9c3a029Andreas Huber    bool mPaused;
218d35bd5fb4e09c2cd8608497c279cbb2ef9c3a029Andreas Huber
2196a9da9fc558263548ebfbae2cbf177eb7454a41bJamie Gennis    sp<ANativeWindow> mNativeWindow;
2206a9da9fc558263548ebfbae2cbf177eb7454a41bJamie Gennis
2216a9da9fc558263548ebfbae2cbf177eb7454a41bJamie Gennis    // The index in each of the mPortBuffers arrays of the buffer that will be
2226a9da9fc558263548ebfbae2cbf177eb7454a41bJamie Gennis    // submitted to OMX next.  This only applies when using buffers from a
2236a9da9fc558263548ebfbae2cbf177eb7454a41bJamie Gennis    // native window.
2246a9da9fc558263548ebfbae2cbf177eb7454a41bJamie Gennis    size_t mNextNativeBufferIndex[2];
2256a9da9fc558263548ebfbae2cbf177eb7454a41bJamie Gennis
226693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    // A list of indices into mPortStatus[kPortIndexOutput] filled with data.
227693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    List<size_t> mFilledBuffers;
228693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    Condition mBufferFilled;
229693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
230965e4239ca1cf6c824c1f8ce23116f9ba8cf6ebdJames Dong    // Used to record the decoding time for an output picture from
231965e4239ca1cf6c824c1f8ce23116f9ba8cf6ebdJames Dong    // a video encoder.
232965e4239ca1cf6c824c1f8ce23116f9ba8cf6ebdJames Dong    List<int64_t> mDecodingTimeList;
233965e4239ca1cf6c824c1f8ce23116f9ba8cf6ebdJames Dong
2340bb6b4c5da2451ee0973372b0a3858b15c742689Andreas Huber    OMXCodec(const sp<IOMX> &omx, IOMX::node_id node,
2350bb6b4c5da2451ee0973372b0a3858b15c742689Andreas Huber             uint32_t quirks, uint32_t flags,
236693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber             bool isEncoder, const char *mime, const char *componentName,
2376a9da9fc558263548ebfbae2cbf177eb7454a41bJamie Gennis             const sp<MediaSource> &source,
2386a9da9fc558263548ebfbae2cbf177eb7454a41bJamie Gennis             const sp<ANativeWindow> &nativeWindow);
239693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
240693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    void addCodecSpecificData(const void *data, size_t size);
241693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    void clearCodecSpecificData();
242693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
2437a6b9e2eca7d20457ace3538c689640e5bfda4f3Andreas Huber    void setComponentRole();
2447a6b9e2eca7d20457ace3538c689640e5bfda4f3Andreas Huber
245956c553ab0ce72f8074ad0fda2ffd66a0305700cJames Dong    void setAMRFormat(bool isWAMR, int32_t bitRate);
246ed3e3e046840d5bf1ca84a8c0cc097425e89d6d6Andreas Huber
247ed3e3e046840d5bf1ca84a8c0cc097425e89d6d6Andreas Huber    status_t setAACFormat(
248ed3e3e046840d5bf1ca84a8c0cc097425e89d6d6Andreas Huber            int32_t numChannels, int32_t sampleRate, int32_t bitRate,
249aeb8fd460ed87d032b3fb8bb61e21eb542ce0f5bDave Burke            int32_t aacProfile, bool isADTS);
250ed3e3e046840d5bf1ca84a8c0cc097425e89d6d6Andreas Huber
251d3c079ae9859011d118f94616d0069c2987013edChangwan Ryu    status_t setAC3Format(int32_t numChannels, int32_t sampleRate);
252d3c079ae9859011d118f94616d0069c2987013edChangwan Ryu
253bbba88cb1bdc34705d1477208990a06904c022e7Andreas Huber    void setG711Format(int32_t numChannels);
254693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
255693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    status_t setVideoPortFormatType(
256693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber            OMX_U32 portIndex,
257693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber            OMX_VIDEO_CODINGTYPE compressionFormat,
258693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber            OMX_COLOR_FORMATTYPE colorFormat);
259693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
260693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    void setVideoInputFormat(
261