blob: d0c1dabf93138ea8f411177d724d65123595bbce [file] [log] [blame]
Andreas Huber83f70f42012-02-01 11:47:54 -08001/*
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_AMRWB_ENCODER_H_
18
19#define SOFT_AMRWB_ENCODER_H_
20
21#include "SimpleSoftOMXComponent.h"
22
23#include "voAMRWB.h"
24
25struct VO_AUDIO_CODECAPI;
26struct VO_MEM_OPERATOR;
27
28namespace android {
29
30struct SoftAMRWBEncoder : public SimpleSoftOMXComponent {
31 SoftAMRWBEncoder(
32 const char *name,
33 const OMX_CALLBACKTYPE *callbacks,
34 OMX_PTR appData,
35 OMX_COMPONENTTYPE **component);
36
37protected:
38 virtual ~SoftAMRWBEncoder();
39
40 virtual OMX_ERRORTYPE internalGetParameter(
41 OMX_INDEXTYPE index, OMX_PTR params);
42
43 virtual OMX_ERRORTYPE internalSetParameter(
44 OMX_INDEXTYPE index, const OMX_PTR params);
45
46 virtual void onQueueFilled(OMX_U32 portIndex);
47
48private:
49 enum {
50 kNumBuffers = 4,
51 kNumSamplesPerFrame = 320,
52 };
53
54 void *mEncoderHandle;
55 VO_AUDIO_CODECAPI *mApiHandle;
56 VO_MEM_OPERATOR *mMemOperator;
57
58 OMX_U32 mBitRate;
59 VOAMRWBMODE mMode;
60
61 size_t mInputSize;
62 int16_t mInputFrame[kNumSamplesPerFrame];
63 int64_t mInputTimeUs;
64
65 bool mSawInputEOS;
66 bool mSignalledError;
67
68 void initPorts();
69 status_t initEncoder();
70
71 DISALLOW_EVIL_CONSTRUCTORS(SoftAMRWBEncoder);
72};
73
74} // namespace android
75
76#endif // SOFT_AMRWB_ENCODER_H_