blob: 1a5d64d8072eff2dbfbc9b09e78be7332a455627 [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
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000011#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.com470e71d2011-07-07 08:21:25 +000013
andrew@webrtc.org9841d922012-10-31 05:22:11 +000014#include "webrtc/modules/video_render/include/video_render.h"
pbos@webrtc.org5aa3f1b2013-07-12 08:12:08 +000015#include "webrtc/system_wrappers/interface/list_wrapper.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000016
17namespace webrtc {
18
19// Class definitions
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000020class VideoRenderFrames {
21 public:
22 VideoRenderFrames();
23 ~VideoRenderFrames();
niklase@google.com470e71d2011-07-07 08:21:25 +000024
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000025 // Add a frame to the render queue
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000026 int32_t AddFrame(I420VideoFrame* new_frame);
niklase@google.com470e71d2011-07-07 08:21:25 +000027
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000028 // Get a frame for rendering, if it's time to render.
mikhal@webrtc.org9fedff72012-10-24 18:33:04 +000029 I420VideoFrame* FrameToRender();
niklase@google.com470e71d2011-07-07 08:21:25 +000030
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000031 // Return an old frame
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000032 int32_t ReturnFrame(I420VideoFrame* old_frame);
niklase@google.com470e71d2011-07-07 08:21:25 +000033
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000034 // Releases all frames
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000035 int32_t ReleaseAllFrames();
niklase@google.com470e71d2011-07-07 08:21:25 +000036
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000037 // Returns the number of ms to next frame to render
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000038 uint32_t TimeToNextFrameRelease();
niklase@google.com470e71d2011-07-07 08:21:25 +000039
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000040 // Sets estimates delay in renderer
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000041 int32_t SetRenderDelay(const uint32_t render_delay);
niklase@google.com470e71d2011-07-07 08:21:25 +000042
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000043 private:
44 // 10 seconds for 30 fps.
45 enum { KMaxNumberOfFrames = 300 };
46 // Don't render frames with timestamp older than 500ms from now.
47 enum { KOldRenderTimestampMS = 500 };
48 // Don't render frames with timestamp more than 10s into the future.
49 enum { KFutureRenderTimestampMS = 10000 };
niklase@google.com470e71d2011-07-07 08:21:25 +000050
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000051 // Sorted list with framed to be rendered, oldest first.
52 ListWrapper incoming_frames_;
53 // Empty frames.
54 ListWrapper empty_frames_;
niklase@google.com470e71d2011-07-07 08:21:25 +000055
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000056 // Estimated delay from a frame is released until it's rendered.
pbos@webrtc.orgddf94e72013-04-10 08:09:04 +000057 uint32_t render_delay_ms_;
niklase@google.com470e71d2011-07-07 08:21:25 +000058};
59
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000060} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000061
mflodman@webrtc.org327ada12012-05-30 10:45:18 +000062#endif // WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_VIDEO_RENDER_FRAMES_H_ // NOLINT