2 * Copyright 2008-2010 Stephan Aßmus <superstippi@gmx.de>
3 * All rights reserved. Distributed under the terms of the MIT licensce.
7 #include "ProxyVideoSupplier.h"
15 #include "VideoTrackSupplier.h"
18 ProxyVideoSupplier::ProxyVideoSupplier()
20 fSupplierLock("video supplier lock"),
26 ProxyVideoSupplier::~ProxyVideoSupplier()
32 ProxyVideoSupplier::FillBuffer(int64 startFrame
, void* buffer
,
33 const media_raw_video_format
& format
, bool forceGeneration
,
36 bigtime_t now
= system_time();
38 BAutolock
_(fSupplierLock
);
39 //printf("ProxyVideoSupplier::FillBuffer(%lld)\n", startFrame);
40 if (fSupplier
== NULL
)
43 if (fSupplier
->CurrentFrame() == startFrame
+ 1) {
50 bigtime_t performanceTime
= 0;
51 if (fSupplier
->CurrentFrame() != startFrame
) {
52 int64 frame
= startFrame
;
53 ret
= fSupplier
->SeekToFrame(&frame
);
56 // Read frames until we reach the frame before the one we want to read.
57 // But don't do it for more than 5 frames, or we will take too much
58 // time. Doing it this way will still catch up to the next keyframe
59 // eventually (we may return the wrong frames until the next keyframe).
60 if (!forceGeneration
&& startFrame
- frame
> 5)
62 while (frame
< startFrame
) {
63 ret
= fSupplier
->ReadFrame(buffer
, &performanceTime
, format
,
71 ret
= fSupplier
->ReadFrame(buffer
, &performanceTime
, format
, wasCached
);
73 fProcessingLatency
= system_time() - now
;
80 ProxyVideoSupplier::DeleteCaches()
86 ProxyVideoSupplier::SetSupplier(VideoTrackSupplier
* supplier
)
88 BAutolock
_(fSupplierLock
);