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 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 11 | #ifndef WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_VIDEO_RENDER_FRAMES_H_ // NOLINT |
| 12 | #define WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_VIDEO_RENDER_FRAMES_H_ // NOLINT |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
henrike@webrtc.org | 79cf3ac | 2014-01-13 15:21:30 +0000 | [diff] [blame^] | 14 | #include <list> |
| 15 | |
andrew@webrtc.org | 9841d92 | 2012-10-31 05:22:11 +0000 | [diff] [blame] | 16 | #include "webrtc/modules/video_render/include/video_render.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 17 | |
| 18 | namespace webrtc { |
| 19 | |
| 20 | // Class definitions |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 21 | class VideoRenderFrames { |
| 22 | public: |
| 23 | VideoRenderFrames(); |
| 24 | ~VideoRenderFrames(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 25 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 26 | // Add a frame to the render queue |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 27 | int32_t AddFrame(I420VideoFrame* new_frame); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 28 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 29 | // Get a frame for rendering, if it's time to render. |
mikhal@webrtc.org | 9fedff7 | 2012-10-24 18:33:04 +0000 | [diff] [blame] | 30 | I420VideoFrame* FrameToRender(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 31 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 32 | // Return an old frame |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 33 | int32_t ReturnFrame(I420VideoFrame* old_frame); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 34 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 35 | // Releases all frames |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 36 | int32_t ReleaseAllFrames(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 37 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 38 | // Returns the number of ms to next frame to render |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 39 | uint32_t TimeToNextFrameRelease(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 40 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 41 | // Sets estimates delay in renderer |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 42 | int32_t SetRenderDelay(const uint32_t render_delay); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 43 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 44 | private: |
henrike@webrtc.org | 79cf3ac | 2014-01-13 15:21:30 +0000 | [diff] [blame^] | 45 | typedef std::list<I420VideoFrame*> FrameList; |
| 46 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 47 | // 10 seconds for 30 fps. |
| 48 | enum { KMaxNumberOfFrames = 300 }; |
| 49 | // Don't render frames with timestamp older than 500ms from now. |
| 50 | enum { KOldRenderTimestampMS = 500 }; |
| 51 | // Don't render frames with timestamp more than 10s into the future. |
| 52 | enum { KFutureRenderTimestampMS = 10000 }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 53 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 54 | // Sorted list with framed to be rendered, oldest first. |
henrike@webrtc.org | 79cf3ac | 2014-01-13 15:21:30 +0000 | [diff] [blame^] | 55 | FrameList incoming_frames_; |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 56 | // Empty frames. |
henrike@webrtc.org | 79cf3ac | 2014-01-13 15:21:30 +0000 | [diff] [blame^] | 57 | FrameList empty_frames_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 58 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 59 | // Estimated delay from a frame is released until it's rendered. |
pbos@webrtc.org | ddf94e7 | 2013-04-10 08:09:04 +0000 | [diff] [blame] | 60 | uint32_t render_delay_ms_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 63 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 64 | |
mflodman@webrtc.org | 327ada1 | 2012-05-30 10:45:18 +0000 | [diff] [blame] | 65 | #endif // WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_VIDEO_RENDER_FRAMES_H_ // NOLINT |