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}
diff --git a/webrtc/modules/video_coding/frame_buffer2.h b/webrtc/modules/video_coding/frame_buffer2.h
index 0af2bf9..d0f8961 100644
--- a/webrtc/modules/video_coding/frame_buffer2.h
+++ b/webrtc/modules/video_coding/frame_buffer2.h
@@ -36,6 +36,8 @@
 
 class FrameBuffer {
  public:
+  enum ReturnReason { kFrameFound, kTimeout, kStopped };
+
   FrameBuffer(Clock* clock,
               VCMJitterEstimator* jitter_estimator,
               VCMTiming* timing);
@@ -44,9 +46,14 @@
   void InsertFrame(std::unique_ptr<FrameObject> frame);
 
   // Get the next frame for decoding. Will return at latest after
-  // |max_wait_time_ms|, with either a managed FrameObject or an empty
-  // unique ptr if there is no available frame for decoding.
-  std::unique_ptr<FrameObject> NextFrame(int64_t max_wait_time_ms);
+  // |max_wait_time_ms|.
+  //  - If a frame is availiable within |max_wait_time_ms| it will return
+  //    kFrameFound and set |frame_out| to the resulting frame.
+  //  - If no frame is available after |max_wait_time_ms| it will return
+  //    kTimeout.
+  //  - If the FrameBuffer is stopped then it will return kStopped.
+  ReturnReason NextFrame(int64_t max_wait_time_ms,
+                         std::unique_ptr<FrameObject>* frame_out);
 
   // Tells the FrameBuffer which protection mode that is in use. Affects
   // the frame timing.