• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef COMMON_VIDEO_VIDEO_RENDER_FRAMES_H_
12 #define COMMON_VIDEO_VIDEO_RENDER_FRAMES_H_
13 
14 #include <stddef.h>
15 #include <stdint.h>
16 
17 #include <list>
18 
19 #include "absl/types/optional.h"
20 #include "api/video/video_frame.h"
21 
22 namespace webrtc {
23 
24 // Class definitions
25 class VideoRenderFrames {
26  public:
27   explicit VideoRenderFrames(uint32_t render_delay_ms);
28   VideoRenderFrames(const VideoRenderFrames&) = delete;
29   ~VideoRenderFrames();
30 
31   // Add a frame to the render queue
32   int32_t AddFrame(VideoFrame&& new_frame);
33 
34   // Get a frame for rendering, or false if it's not time to render.
35   absl::optional<VideoFrame> FrameToRender();
36 
37   // Returns the number of ms to next frame to render
38   uint32_t TimeToNextFrameRelease();
39 
40   bool HasPendingFrames() const;
41 
42  private:
43   // Sorted list with framed to be rendered, oldest first.
44   std::list<VideoFrame> incoming_frames_;
45 
46   // Estimated delay from a frame is released until it's rendered.
47   const uint32_t render_delay_ms_;
48 
49   int64_t last_render_time_ms_ = 0;
50   size_t frames_dropped_ = 0;
51 };
52 
53 }  // namespace webrtc
54 
55 #endif  // COMMON_VIDEO_VIDEO_RENDER_FRAMES_H_
56