blob: 450c1f2215fac7d01f59fc0968adefb0e7e85098 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
mflodman@webrtc.org327ada12012-05-30 10:45:18 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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öm9a638662015-05-13 13:28:11 +020011#ifndef WEBRTC_COMMON_VIDEO_VIDEO_RENDER_FRAMES_H_
12#define WEBRTC_COMMON_VIDEO_VIDEO_RENDER_FRAMES_H_
13
14#include <stdint.h>
niklase@google.com470e71d2011-07-07 08:21:25 +000015
henrike@webrtc.org79cf3ac2014-01-13 15:21:30 +000016#include <list>
17
Peter Boström9a638662015-05-13 13:28:11 +020018#include "webrtc/video_frame.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000019
20namespace webrtc {
21
22// Class definitions
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000023class VideoRenderFrames {
24 public:
25 VideoRenderFrames();
niklase@google.com470e71d2011-07-07 08:21:25 +000026
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000027 // Add a frame to the render queue
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -070028 int32_t AddFrame(const VideoFrame& new_frame);
niklase@google.com470e71d2011-07-07 08:21:25 +000029
magjed@webrtc.orgb73758d2015-03-12 12:25:16 +000030 // Get a frame for rendering, or a zero-size frame if it's not time to render.
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -070031 VideoFrame FrameToRender();
niklase@google.com470e71d2011-07-07 08:21:25 +000032
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000033 // Releases all frames
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000034 int32_t ReleaseAllFrames();
niklase@google.com470e71d2011-07-07 08:21:25 +000035
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000036 // Returns the number of ms to next frame to render
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000037 uint32_t TimeToNextFrameRelease();
niklase@google.com470e71d2011-07-07 08:21:25 +000038
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000039 // Sets estimates delay in renderer
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000040 int32_t SetRenderDelay(const uint32_t render_delay);
niklase@google.com470e71d2011-07-07 08:21:25 +000041
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000042 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.com470e71d2011-07-07 08:21:25 +000049
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000050 // Sorted list with framed to be rendered, oldest first.
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -070051 std::list<VideoFrame> incoming_frames_;
niklase@google.com470e71d2011-07-07 08:21:25 +000052
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000053 // Estimated delay from a frame is released until it's rendered.
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000054 uint32_t render_delay_ms_;
niklase@google.com470e71d2011-07-07 08:21:25 +000055};
56
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000057} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000058
Peter Boström9a638662015-05-13 13:28:11 +020059#endif // WEBRTC_COMMON_VIDEO_VIDEO_RENDER_FRAMES_H_