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