blob: 5feb6a1e4f8144843db39e7d692322bef56db0cc [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();
Chong Zhangf8d71772014-11-26 15:08:34 -080041 void signalResume(bool notifyComplete);
Chong Zhang7137ec72014-11-12 16:41:05 -080042 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',
Chong Zhangf8d71772014-11-26 15:08:34 -080053 kWhatResumeCompleted = 'resC',
Chong Zhang7137ec72014-11-12 16:41:05 -080054 kWhatEOS = 'eos ',
55 kWhatError = 'err ',
56 };
57
58protected:
59
60 virtual ~DecoderBase();
61
62 virtual void onMessageReceived(const sp<AMessage> &msg);
63
64 virtual void onConfigure(const sp<AMessage> &format) = 0;
65 virtual void onSetRenderer(const sp<Renderer> &renderer) = 0;
66 virtual void onGetInputBuffers(Vector<sp<ABuffer> > *dstBuffers) = 0;
Chong Zhangf8d71772014-11-26 15:08:34 -080067 virtual void onResume(bool notifyComplete) = 0;
Chong Zhang7137ec72014-11-12 16:41:05 -080068 virtual void onFlush(bool notifyComplete) = 0;
69 virtual void onShutdown(bool notifyComplete) = 0;
70
71 void onRequestInputBuffers();
72 void scheduleRequestBuffers();
73 virtual void doRequestBuffers() = 0;
74
75private:
76 enum {
77 kWhatConfigure = 'conf',
78 kWhatSetRenderer = 'setR',
79 kWhatGetInputBuffers = 'gInB',
80 kWhatRequestInputBuffers = 'reqB',
81 kWhatFlush = 'flus',
82 kWhatShutdown = 'shuD',
83 };
84
85 sp<ALooper> mDecoderLooper;
86 bool mRequestInputBuffersPending;
87
88 DISALLOW_EVIL_CONSTRUCTORS(DecoderBase);
89};
90
91} // namespace android
92
93#endif // NUPLAYER_DECODER_BASE_H_