SoftVideoDecoderOMXComponent.h revision 7f616d3cc5366a4b8af20d3d0c768e3de1df0666
1/*
2 * Copyright (C) 2013 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_VIDEO_DECODER_OMX_COMPONENT_H_
18
19#define SOFT_VIDEO_DECODER_OMX_COMPONENT_H_
20
21#include "SimpleSoftOMXComponent.h"
22
23#include <media/stagefright/foundation/AHandlerReflector.h>
24#include <media/IOMX.h>
25
26#include <utils/RefBase.h>
27#include <utils/threads.h>
28#include <utils/Vector.h>
29
30#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
31
32namespace android {
33
34struct SoftVideoDecoderOMXComponent : public SimpleSoftOMXComponent {
35    SoftVideoDecoderOMXComponent(
36            const char *name,
37            const char *componentRole,
38            OMX_VIDEO_CODINGTYPE codingType,
39            const CodecProfileLevel *profileLevels,
40            size_t numProfileLevels,
41            int32_t width,
42            int32_t height,
43            const OMX_CALLBACKTYPE *callbacks,
44            OMX_PTR appData,
45            OMX_COMPONENTTYPE **component);
46
47protected:
48    virtual void onPortEnableCompleted(OMX_U32 portIndex, bool enabled);
49    virtual void onReset();
50
51    virtual OMX_ERRORTYPE internalGetParameter(
52            OMX_INDEXTYPE index, OMX_PTR params);
53
54    virtual OMX_ERRORTYPE internalSetParameter(
55            OMX_INDEXTYPE index, const OMX_PTR params);
56
57    virtual OMX_ERRORTYPE getConfig(
58            OMX_INDEXTYPE index, OMX_PTR params);
59
60    void initPorts(OMX_U32 numInputBuffers,
61            OMX_U32 inputBufferSize,
62            OMX_U32 numOutputBuffers,
63            const char *mimeType);
64
65    virtual void updatePortDefinitions();
66
67    enum {
68        kInputPortIndex  = 0,
69        kOutputPortIndex = 1,
70        kMaxPortIndex = 1,
71    };
72
73    uint32_t mWidth, mHeight;
74    uint32_t mCropLeft, mCropTop, mCropWidth, mCropHeight;
75
76    enum {
77        NONE,
78        AWAITING_DISABLED,
79        AWAITING_ENABLED
80    } mOutputPortSettingsChange;
81
82private:
83    const char *mComponentRole;
84    OMX_VIDEO_CODINGTYPE mCodingType;
85    const CodecProfileLevel *mProfileLevels;
86    size_t mNumProfileLevels;
87
88    DISALLOW_EVIL_CONSTRUCTORS(SoftVideoDecoderOMXComponent);
89};
90
91}  // namespace android
92
93#endif  // SOFT_VIDEO_DECODER_OMX_COMPONENT_H_
94