blob: 97e9269527a48cb88cb55583942fc9cc05f85ddf [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 {
Andy Hung202bce12014-12-03 11:47:36 -080032 DecoderBase(const sp<AMessage> &notify);
Chong Zhang7137ec72014-11-12 16:41:05 -080033
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 Zhang66704af2015-03-03 19:32:35 -080068 virtual void onFlush() = 0;
Chong Zhang7137ec72014-11-12 16:41:05 -080069 virtual void onShutdown(bool notifyComplete) = 0;
70
71 void onRequestInputBuffers();
72 void scheduleRequestBuffers();
73 virtual void doRequestBuffers() = 0;
Andy Hung202bce12014-12-03 11:47:36 -080074 virtual void handleError(int32_t err);
75
76 sp<AMessage> mNotify;
77 int32_t mBufferGeneration;
Chong Zhang7137ec72014-11-12 16:41:05 -080078
79private:
80 enum {
81 kWhatConfigure = 'conf',
82 kWhatSetRenderer = 'setR',
83 kWhatGetInputBuffers = 'gInB',
84 kWhatRequestInputBuffers = 'reqB',
85 kWhatFlush = 'flus',
86 kWhatShutdown = 'shuD',
87 };
88
89 sp<ALooper> mDecoderLooper;
90 bool mRequestInputBuffersPending;
91
92 DISALLOW_EVIL_CONSTRUCTORS(DecoderBase);
93};
94
95} // namespace android
96
97#endif // NUPLAYER_DECODER_BASE_H_