niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef COMMON_VIDEO_VIDEO_RENDER_FRAMES_H_ |
| 12 | #define COMMON_VIDEO_VIDEO_RENDER_FRAMES_H_ |
Peter Boström | 9a63866 | 2015-05-13 13:28:11 +0200 | [diff] [blame] | 13 | |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame] | 14 | #include <stddef.h> |
Peter Boström | 9a63866 | 2015-05-13 13:28:11 +0200 | [diff] [blame] | 15 | #include <stdint.h> |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 16 | |
henrike@webrtc.org | 79cf3ac | 2014-01-13 15:21:30 +0000 | [diff] [blame] | 17 | #include <list> |
| 18 | |
Danil Chapovalov | 196100e | 2018-06-21 10:17:24 +0200 | [diff] [blame] | 19 | #include "absl/types/optional.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 20 | #include "api/video/video_frame.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | |
| 24 | // Class definitions |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 25 | class VideoRenderFrames { |
| 26 | public: |
tommi | 2e82f38 | 2016-06-21 00:26:43 -0700 | [diff] [blame] | 27 | explicit VideoRenderFrames(uint32_t render_delay_ms); |
| 28 | VideoRenderFrames(const VideoRenderFrames&) = delete; |
Mirko Bonadei | d93a51d | 2018-07-17 15:47:51 +0200 | [diff] [blame] | 29 | ~VideoRenderFrames(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 30 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 31 | // Add a frame to the render queue |
tommi | ede0759 | 2017-02-27 07:16:10 -0800 | [diff] [blame] | 32 | int32_t AddFrame(VideoFrame&& new_frame); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | |
nisse | e5e5292 | 2016-05-25 06:25:17 -0700 | [diff] [blame] | 34 | // Get a frame for rendering, or false if it's not time to render. |
Danil Chapovalov | 196100e | 2018-06-21 10:17:24 +0200 | [diff] [blame] | 35 | absl::optional<VideoFrame> FrameToRender(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 36 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 37 | // Returns the number of ms to next frame to render |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 38 | uint32_t TimeToNextFrameRelease(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | |
tommi | ede0759 | 2017-02-27 07:16:10 -0800 | [diff] [blame] | 40 | bool HasPendingFrames() const; |
tommi | 686aa37 | 2017-02-27 05:10:37 -0800 | [diff] [blame] | 41 | |
tommi | ede0759 | 2017-02-27 07:16:10 -0800 | [diff] [blame] | 42 | private: |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 43 | // Sorted list with framed to be rendered, oldest first. |
Miguel Casas-Sanchez | 4765070 | 2015-05-29 17:21:40 -0700 | [diff] [blame] | 44 | std::list<VideoFrame> incoming_frames_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 46 | // Estimated delay from a frame is released until it's rendered. |
tommi | 2e82f38 | 2016-06-21 00:26:43 -0700 | [diff] [blame] | 47 | const uint32_t render_delay_ms_; |
tommi | ede0759 | 2017-02-27 07:16:10 -0800 | [diff] [blame] | 48 | |
| 49 | int64_t last_render_time_ms_ = 0; |
Stefan Holmer | 0a5792e | 2018-10-05 13:47:12 +0200 | [diff] [blame] | 50 | size_t frames_dropped_ = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 51 | }; |
| 52 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 53 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 54 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 55 | #endif // COMMON_VIDEO_VIDEO_RENDER_FRAMES_H_ |