blob: b9be12cbc5b3e8a1361c853642025f01f0646b83 [file] [log] [blame]
Andreas Hubera1587462010-12-15 15:17:42 -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 DECODER_WRAPPER_H_
18
19#define DECODER_WRAPPER_H_
20
21#include <media/stagefright/foundation/AHandler.h>
22
23namespace android {
24
25struct MediaSource;
26
27struct DecoderWrapper : public AHandler {
28 DecoderWrapper();
29
30 void setNotificationMessage(const sp<AMessage> &msg);
31 void initiateSetup(const sp<AMessage> &msg);
32 void initiateShutdown();
33 void signalFlush();
34 void signalResume();
35
36protected:
37 virtual ~DecoderWrapper();
38
39 virtual void onMessageReceived(const sp<AMessage> &msg);
40
41private:
42 struct WrapperSource;
43 struct WrapperReader;
44
45 enum {
46 kWhatSetup,
47 kWhatInputBufferFilled,
48 kWhatOutputBufferDrained,
49 kWhatShutdown,
50 kWhatFillBufferDone,
51 kWhatInputDataRequested,
52 kWhatFlush,
53 kWhatResume,
54 };
55
56 sp<AMessage> mNotify;
57
58 sp<WrapperSource> mSource;
59
60 sp<ALooper> mReaderLooper;
61 sp<WrapperReader> mReader;
62
63 int32_t mNumOutstandingInputBuffers;
64 int32_t mNumOutstandingOutputBuffers;
65 int32_t mNumPendingDecodes;
66 bool mFlushing;
67
68 void onSetup(const sp<AMessage> &msg);
Andreas Huber41c3f742010-12-21 10:22:33 -080069 void onShutdown();
Andreas Hubera1587462010-12-15 15:17:42 -080070 void onFlush();
71 void onResume();
72
73 void postFillBuffer();
74 void completeFlushIfPossible();
75
76 DISALLOW_EVIL_CONSTRUCTORS(DecoderWrapper);
77};
78
79} // namespace android
80
81#endif // DECODER_WRAPPER_H_
82