SoftAACEncoder.h revision 2b1892db4a2ab47bfc09e59a4c11751aea99e4ea
1/*
2 * Copyright (C) 2012 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 SOFT_AAC_ENCODER_H_
18
19#define SOFT_AAC_ENCODER_H_
20
21#include "SimpleSoftOMXComponent.h"
22
23struct VO_AUDIO_CODECAPI;
24struct VO_MEM_OPERATOR;
25
26namespace android {
27
28struct SoftAACEncoder : public SimpleSoftOMXComponent {
29    SoftAACEncoder(
30            const char *name,
31            const OMX_CALLBACKTYPE *callbacks,
32            OMX_PTR appData,
33            OMX_COMPONENTTYPE **component);
34
35protected:
36    virtual ~SoftAACEncoder();
37
38    virtual OMX_ERRORTYPE internalGetParameter(
39            OMX_INDEXTYPE index, OMX_PTR params);
40
41    virtual OMX_ERRORTYPE internalSetParameter(
42            OMX_INDEXTYPE index, const OMX_PTR params);
43
44    virtual void onQueueFilled(OMX_U32 portIndex);
45
46private:
47    enum {
48        kNumBuffers             = 4,
49        kNumSamplesPerFrame     = 1024,
50    };
51
52    void *mEncoderHandle;
53    VO_AUDIO_CODECAPI *mApiHandle;
54    VO_MEM_OPERATOR  *mMemOperator;
55
56    OMX_U32 mNumChannels;
57    OMX_U32 mSampleRate;
58    OMX_U32 mBitRate;
59
60    bool mSentCodecSpecificData;
61    size_t mInputSize;
62    int16_t *mInputFrame;
63    int64_t mInputTimeUs;
64
65    bool mSawInputEOS;
66
67    uint8_t mAudioSpecificConfigData[2];
68
69    bool mSignalledError;
70
71    void initPorts();
72    status_t initEncoder();
73
74    status_t setAudioSpecificConfigData();
75    status_t setAudioParams();
76
77    DISALLOW_EVIL_CONSTRUCTORS(SoftAACEncoder);
78};
79
80}  // namespace android
81
82#endif  // SOFT_AAC_ENCODER_H_
83