SoftVorbis.h revision d089c2540e4f0897c166693f4f13e2023241720e
1/*
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_VORBIS_H_
18
19#define SOFT_VORBIS_H_
20
21#include "SimpleSoftOMXComponent.h"
22
23struct vorbis_dsp_state;
24struct vorbis_info;
25
26namespace android {
27
28struct SoftVorbis : public SimpleSoftOMXComponent {
29    SoftVorbis(const char *name,
30            const OMX_CALLBACKTYPE *callbacks,
31            OMX_PTR appData,
32            OMX_COMPONENTTYPE **component);
33
34protected:
35    virtual ~SoftVorbis();
36
37    virtual OMX_ERRORTYPE internalGetParameter(
38            OMX_INDEXTYPE index, OMX_PTR params);
39
40    virtual OMX_ERRORTYPE internalSetParameter(
41            OMX_INDEXTYPE index, const OMX_PTR params);
42
43    virtual void onQueueFilled(OMX_U32 portIndex);
44    virtual void onPortFlushCompleted(OMX_U32 portIndex);
45    virtual void onPortEnableCompleted(OMX_U32 portIndex, bool enabled);
46    virtual void onReset();
47
48private:
49    enum {
50        kNumBuffers = 4,
51        kMaxNumSamplesPerBuffer = 8192 * 2
52    };
53
54    size_t mInputBufferCount;
55
56    vorbis_dsp_state *mState;
57    vorbis_info *mVi;
58
59    int64_t mAnchorTimeUs;
60    int64_t mNumFramesOutput;
61    int32_t mNumFramesLeftOnPage;
62    bool mSawInputEos;
63    bool mSignalledOutputEos;
64
65    enum {
66        NONE,
67        AWAITING_DISABLED,
68        AWAITING_ENABLED
69    } mOutputPortSettingsChange;
70
71    void initPorts();
72    status_t initDecoder();
73    bool isConfigured() const;
74
75    DISALLOW_EVIL_CONSTRUCTORS(SoftVorbis);
76};
77
78}  // namespace android
79
80#endif  // SOFT_VORBIS_H_
81
82