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 | |
Peter Boström | 9a63866 | 2015-05-13 13:28:11 +0200 | [diff] [blame] | 11 | #ifndef WEBRTC_COMMON_VIDEO_VIDEO_RENDER_FRAMES_H_ |
| 12 | #define WEBRTC_COMMON_VIDEO_VIDEO_RENDER_FRAMES_H_ |
| 13 | |
| 14 | #include <stdint.h> |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 15 | |
henrike@webrtc.org | 79cf3ac | 2014-01-13 15:21:30 +0000 | [diff] [blame] | 16 | #include <list> |
| 17 | |
Peter Boström | 9a63866 | 2015-05-13 13:28:11 +0200 | [diff] [blame] | 18 | #include "webrtc/video_frame.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
| 21 | |
| 22 | // Class definitions |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 23 | class VideoRenderFrames { |
| 24 | public: |
| 25 | VideoRenderFrames(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 26 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 27 | // Add a frame to the render queue |
Miguel Casas-Sanchez | 4765070 | 2015-05-29 17:21:40 -0700 | [diff] [blame^] | 28 | int32_t AddFrame(const VideoFrame& new_frame); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | |
magjed@webrtc.org | b73758d | 2015-03-12 12:25:16 +0000 | [diff] [blame] | 30 | // Get a frame for rendering, or a zero-size frame if it's not time to render. |
Miguel Casas-Sanchez | 4765070 | 2015-05-29 17:21:40 -0700 | [diff] [blame^] | 31 | VideoFrame FrameToRender(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 33 | // Releases all frames |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 34 | int32_t ReleaseAllFrames(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 35 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 36 | // Returns the number of ms to next frame to render |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 37 | uint32_t TimeToNextFrameRelease(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 39 | // Sets estimates delay in renderer |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 40 | int32_t SetRenderDelay(const uint32_t render_delay); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 42 | private: |
| 43 | // 10 seconds for 30 fps. |
| 44 | enum { KMaxNumberOfFrames = 300 }; |
| 45 | // Don't render frames with timestamp older than 500ms from now. |
| 46 | enum { KOldRenderTimestampMS = 500 }; |
| 47 | // Don't render frames with timestamp more than 10s into the future. |
| 48 | enum { KFutureRenderTimestampMS = 10000 }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 49 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 50 | // Sorted list with framed to be rendered, oldest first. |
Miguel Casas-Sanchez | 4765070 | 2015-05-29 17:21:40 -0700 | [diff] [blame^] | 51 | std::list<VideoFrame> incoming_frames_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 52 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 53 | // Estimated delay from a frame is released until it's rendered. |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 54 | uint32_t render_delay_ms_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 55 | }; |
| 56 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 57 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 58 | |
Peter Boström | 9a63866 | 2015-05-13 13:28:11 +0200 | [diff] [blame] | 59 | #endif // WEBRTC_COMMON_VIDEO_VIDEO_RENDER_FRAMES_H_ |