1/*
2 *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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
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
13
14#include <list>
15
16#include "webrtc/modules/video_render/include/video_render.h"
17
18namespace webrtc {
19
20// Class definitions
21class VideoRenderFrames {
22 public:
23  VideoRenderFrames();
24  ~VideoRenderFrames();
25
26  // Add a frame to the render queue
27  int32_t AddFrame(I420VideoFrame* new_frame);
28
29  // Get a frame for rendering, if it's time to render.
30  I420VideoFrame* FrameToRender();
31
32  // Return an old frame
33  int32_t ReturnFrame(I420VideoFrame* old_frame);
34
35  // Releases all frames
36  int32_t ReleaseAllFrames();
37
38  // Returns the number of ms to next frame to render
39  uint32_t TimeToNextFrameRelease();
40
41  // Sets estimates delay in renderer
42  int32_t SetRenderDelay(const uint32_t render_delay);
43
44 private:
45  typedef std::list<I420VideoFrame*> FrameList;
46
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 };
53
54  // Sorted list with framed to be rendered, oldest first.
55  FrameList incoming_frames_;
56  // Empty frames.
57  FrameList empty_frames_;
58
59  // Estimated delay from a frame is released until it's rendered.
60  uint32_t render_delay_ms_;
61};
62
63}  // namespace webrtc
64
65#endif  // WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_VIDEO_RENDER_FRAMES_H_  // NOLINT
66