blob: 1b24c4f1c7d76c9406eede810ca2d4e16b54a0e5 [file] [log] [blame]
Chong Zhang7137ec72014-11-12 16:41:05 -08001/*
2 * Copyright (C) 2010 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 NUPLAYER_DECODER_BASE_H_
18
19#define NUPLAYER_DECODER_BASE_H_
20
21#include "NuPlayer.h"
22
23#include <media/stagefright/foundation/AHandler.h>
24
25namespace android {
26
27struct ABuffer;
28struct MediaCodec;
29struct MediaBuffer;
30
31struct NuPlayer::DecoderBase : public AHandler {
32 DecoderBase();
33
34 void configure(const sp<AMessage> &format);
35 void init();
36
37 void setRenderer(const sp<Renderer> &renderer);
38
39 status_t getInputBuffers(Vector<sp<ABuffer> > *dstBuffers) const;
40 void signalFlush();
41 void signalResume();
42 void initiateShutdown();
43
44 virtual void getStats(
45 int64_t *mNumFramesTotal,
46 int64_t *mNumFramesDropped) const = 0;
47
48 enum {
49 kWhatInputDiscontinuity = 'inDi',
50 kWhatVideoSizeChanged = 'viSC',
51 kWhatFlushCompleted = 'flsC',
52 kWhatShutdownCompleted = 'shDC',
53 kWhatEOS = 'eos ',
54 kWhatError = 'err ',
55 };
56
57protected:
58
59 virtual ~DecoderBase();
60
61 virtual void onMessageReceived(const sp<AMessage> &msg);
62
63 virtual void onConfigure(const sp<AMessage> &format) = 0;
64 virtual void onSetRenderer(const sp<Renderer> &renderer) = 0;
65 virtual void onGetInputBuffers(Vector<sp<ABuffer> > *dstBuffers) = 0;
66 virtual void onResume() = 0;
67 virtual void onFlush(bool notifyComplete) = 0;
68 virtual void onShutdown(bool notifyComplete) = 0;
69
70 void onRequestInputBuffers();
71 void scheduleRequestBuffers();
72 virtual void doRequestBuffers() = 0;
73
74private:
75 enum {
76 kWhatConfigure = 'conf',
77 kWhatSetRenderer = 'setR',
78 kWhatGetInputBuffers = 'gInB',
79 kWhatRequestInputBuffers = 'reqB',
80 kWhatFlush = 'flus',
81 kWhatShutdown = 'shuD',
82 };
83
84 sp<ALooper> mDecoderLooper;
85 bool mRequestInputBuffersPending;
86
87 DISALLOW_EVIL_CONSTRUCTORS(DecoderBase);
88};
89
90} // namespace android
91
92#endif // NUPLAYER_DECODER_BASE_H_