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> ¬ify); 34 35 status_t start(); 36 void stopAsync(const sp<AMessage> ¬ify); 37 38 void pause(); 39 void resume(); 40 41protected: 42 virtual void onMessageReceived(const sp<AMessage> &msg); 43 virtual ~MediaPuller(); 44 45private: 46 enum { 47 kWhatStart, 48 kWhatStop, 49 kWhatPull, 50 kWhatPause, 51 kWhatResume, 52 }; 53 54 sp<MediaSource> mSource; 55 sp<AMessage> mNotify; 56 int32_t mPullGeneration; 57 bool mIsAudio; 58 bool mPaused; 59 60 status_t postSynchronouslyAndReturnError(const sp<AMessage> &msg); 61 void schedulePull(); 62 63 DISALLOW_EVIL_CONSTRUCTORS(MediaPuller); 64}; 65 66} // namespace android 67 68#endif // MEDIA_PULLER_H_ 69