FrameBuffer::NextFrame now return a ReturnReason and take an additional std::unique_ptr<FrameObject>* as output parameter.

In order to distinguish between a return caused by the FrameBuffer
being stopped and a return caused by a timeout we now return
a ReturnReason.

BUG=webrtc:5514
R=danilchap@webrtc.org, mflodman@webrtc.org

Review URL: https://codereview.webrtc.org/2302473002 .

Cr-Commit-Position: refs/heads/master@{#14065}
This commit is contained in:
philipel
2016-09-05 10:57:41 +02:00
parent c82f2e1613
commit 7556282a6c
3 changed files with 26 additions and 9 deletions

View File

@ -52,7 +52,9 @@ FrameBuffer::FrameBuffer(Clock* clock,
stopped_(false),
protection_mode_(kProtectionNack) {}
std::unique_ptr<FrameObject> FrameBuffer::NextFrame(int64_t max_wait_time_ms) {
FrameBuffer::ReturnReason FrameBuffer::NextFrame(
int64_t max_wait_time_ms,
std::unique_ptr<FrameObject>* frame_out) {
int64_t latest_return_time = clock_->TimeInMilliseconds() + max_wait_time_ms;
int64_t now = clock_->TimeInMilliseconds();
int64_t wait_ms = max_wait_time_ms;
@ -63,7 +65,7 @@ std::unique_ptr<FrameObject> FrameBuffer::NextFrame(int64_t max_wait_time_ms) {
rtc::CritScope lock(&crit_);
frame_inserted_event_.Reset();
if (stopped_)
return std::unique_ptr<FrameObject>();
return kStopped;
now = clock_->TimeInMilliseconds();
wait_ms = max_wait_time_ms;
@ -115,9 +117,10 @@ std::unique_ptr<FrameObject> FrameBuffer::NextFrame(int64_t max_wait_time_ms) {
decoded_frames_.insert(next_frame_it->first);
std::unique_ptr<FrameObject> frame = std::move(next_frame_it->second);
frames_.erase(frames_.begin(), ++next_frame_it);
return frame;
*frame_out = std::move(frame);
return kFrameFound;
} else {
return std::unique_ptr<FrameObject>();
return kTimeout;
}
}
}