1/*
2 * Copyright 2012, 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 MEDIA_PULLER_H_
18
19#define MEDIA_PULLER_H_
20
21#include <media/stagefright/foundation/AHandler.h>
22
23namespace android {
24
25struct MediaSource;
26
27struct MediaPuller : public AHandler {
28    enum {
29        kWhatEOS,
30        kWhatAccessUnit
31    };
32
33    MediaPuller(const sp<MediaSource> &source, const sp<AMessage> &notify);
34
35    status_t start();
36    void stopAsync(const sp<AMessage> &notify);
37
38protected:
39    virtual void onMessageReceived(const sp<AMessage> &msg);
40    virtual ~MediaPuller();
41
42private:
43    enum {
44        kWhatStart,
45        kWhatStop,
46        kWhatPull,
47    };
48
49    sp<MediaSource> mSource;
50    sp<AMessage> mNotify;
51    int32_t mPullGeneration;
52    bool mIsAudio;
53
54    status_t postSynchronouslyAndReturnError(const sp<AMessage> &msg);
55    void schedulePull();
56
57    DISALLOW_EVIL_CONSTRUCTORS(MediaPuller);
58};
59
60}  // namespace android
61
62#endif  // MEDIA_PULLER_H_
63