1e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber/*
2e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber * Copyright 2012, The Android Open Source Project
3e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber *
4e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber * Licensed under the Apache License, Version 2.0 (the "License");
5e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber * you may not use this file except in compliance with the License.
6e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber * You may obtain a copy of the License at
7e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber *
8e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber *     http://www.apache.org/licenses/LICENSE-2.0
9e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber *
10e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber * Unless required by applicable law or agreed to in writing, software
11e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber * distributed under the License is distributed on an "AS IS" BASIS,
12e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber * See the License for the specific language governing permissions and
14e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber * limitations under the License.
15e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber */
16e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber
17e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber#ifndef MEDIA_PULLER_H_
18e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber
19e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber#define MEDIA_PULLER_H_
20e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber
21e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber#include <media/stagefright/foundation/AHandler.h>
22e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber
23e1957358f11031a554c57d4fb46988dd6044acc1Andreas Hubernamespace android {
24e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber
25e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huberstruct MediaSource;
26e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber
27e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huberstruct MediaPuller : public AHandler {
28e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber    enum {
29e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber        kWhatEOS,
30e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber        kWhatAccessUnit
31e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber    };
32e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber
33e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber    MediaPuller(const sp<MediaSource> &source, const sp<AMessage> &notify);
34e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber
35e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber    status_t start();
3696fc6cc65ca93009a759a3a874b82a35771b9714Andreas Huber    void stopAsync(const sp<AMessage> &notify);
37e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber
38e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huberprotected:
39e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber    virtual void onMessageReceived(const sp<AMessage> &msg);
40e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber    virtual ~MediaPuller();
41e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber
42e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huberprivate:
43e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber    enum {
44e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber        kWhatStart,
45e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber        kWhatStop,
46e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber        kWhatPull,
47e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber    };
48e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber
49e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber    sp<MediaSource> mSource;
50e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber    sp<AMessage> mNotify;
51e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber    int32_t mPullGeneration;
52a438123bd96c7faf145683876702387efe5628d9Andreas Huber    bool mIsAudio;
53e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber
54e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber    status_t postSynchronouslyAndReturnError(const sp<AMessage> &msg);
55e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber    void schedulePull();
56e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber
57e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber    DISALLOW_EVIL_CONSTRUCTORS(MediaPuller);
58e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber};
59e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber
60e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber}  // namespace android
61e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber
62e1957358f11031a554c57d4fb46988dd6044acc1Andreas Huber#endif  // MEDIA_PULLER_H_
63