SoftGSM.h revision 2ed5cf016c1b45426ae25ab105e02ff4bb992f28
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_GSM_H_
18
19#define SOFT_GSM_H_
20
21#include "SimpleSoftOMXComponent.h"
22
23extern "C" {
24#include "gsm.h"
25}
26
27namespace android {
28
29struct SoftGSM : public SimpleSoftOMXComponent {
30    SoftGSM(const char *name,
31            const OMX_CALLBACKTYPE *callbacks,
32            OMX_PTR appData,
33            OMX_COMPONENTTYPE **component);
34
35protected:
36    virtual ~SoftGSM();
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        kMaxNumSamplesPerFrame = 16384,
50    };
51
52    bool mSignalledError;
53    gsm mGsm;
54
55    void initPorts();
56
57    static int DecodeGSM(gsm handle, int16_t *out, uint8_t *in, size_t inSize);
58
59    DISALLOW_EVIL_CONSTRUCTORS(SoftGSM);
60};
61
62}  // namespace android
63
64#endif  // SOFT_GSM_H_
65
66