blob: bff0c68cb1dd83469b51334b370b51bf778af47f [file] [log] [blame]
Andreas Huber4b3913a2011-05-11 14:13:42 -07001/*
2 * Copyright (C) 2011 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_G711_H_
18
19#define SOFT_G711_H_
20
21#include "SimpleSoftOMXComponent.h"
22
23namespace android {
24
25struct SoftG711 : public SimpleSoftOMXComponent {
26 SoftG711(const char *name,
27 const OMX_CALLBACKTYPE *callbacks,
28 OMX_PTR appData,
29 OMX_COMPONENTTYPE **component);
30
31protected:
32 virtual ~SoftG711();
33
34 virtual OMX_ERRORTYPE internalGetParameter(
35 OMX_INDEXTYPE index, OMX_PTR params);
36
37 virtual OMX_ERRORTYPE internalSetParameter(
38 OMX_INDEXTYPE index, const OMX_PTR params);
39
40 virtual void onQueueFilled(OMX_U32 portIndex);
41
42private:
43 enum {
44 kNumBuffers = 4,
45 kMaxNumSamplesPerFrame = 16384,
46 };
47
48 bool mIsMLaw;
49 OMX_U32 mNumChannels;
50 bool mSignalledError;
51
52 void initPorts();
53
54 static void DecodeALaw(int16_t *out, const uint8_t *in, size_t inSize);
55 static void DecodeMLaw(int16_t *out, const uint8_t *in, size_t inSize);
56
57 DISALLOW_EVIL_CONSTRUCTORS(SoftG711);
58};
59
60} // namespace android
61
62#endif // SOFT_G711_H_
63