RepeaterSource.h revision 77245813007cf903b4b73f5d0cd20313fbf0e510
1#ifndef REPEATER_SOURCE_H_ 2 3#define REPEATER_SOURCE_H_ 4 5#include <media/stagefright/foundation/ABase.h> 6#include <media/stagefright/foundation/AHandlerReflector.h> 7#include <media/stagefright/MediaSource.h> 8 9namespace android { 10 11// This MediaSource delivers frames at a constant rate by repeating buffers 12// if necessary. 13struct RepeaterSource : public MediaSource { 14 RepeaterSource(const sp<MediaSource> &source, double rateHz); 15 16 virtual status_t start(MetaData *params); 17 virtual status_t stop(); 18 virtual sp<MetaData> getFormat(); 19 20 virtual status_t read( 21 MediaBuffer **buffer, const ReadOptions *options); 22 23 void onMessageReceived(const sp<AMessage> &msg); 24 25protected: 26 virtual ~RepeaterSource(); 27 28private: 29 enum { 30 kWhatRead, 31 }; 32 33 Mutex mLock; 34 Condition mCondition; 35 36 bool mStarted; 37 38 sp<MediaSource> mSource; 39 double mRateHz; 40 41 sp<ALooper> mLooper; 42 sp<AHandlerReflector<RepeaterSource> > mReflector; 43 44 MediaBuffer *mBuffer; 45 status_t mResult; 46 47 int64_t mStartTimeUs; 48 int32_t mFrameCount; 49 50 void postRead(); 51 52 DISALLOW_EVIL_CONSTRUCTORS(RepeaterSource); 53}; 54 55} // namespace android 56 57#endif // REPEATER_SOURCE_H_ 58