blob: e1105382bf7f12400c0bf5449dc9f21a0782c12b [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
2 * Copyright (c) 2011 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_UTILITY_SOURCE_VIDEO_FRAMES_QUEUE_H_
12#define WEBRTC_MODULES_UTILITY_SOURCE_VIDEO_FRAMES_QUEUE_H_
13
14#ifdef WEBRTC_MODULE_UTILITY_VIDEO
15
mikhal@webrtc.org9fedff72012-10-24 18:33:04 +000016#include "common_video/interface/i420_video_frame.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000017#include "engine_configurations.h"
18#include "list_wrapper.h"
19#include "typedefs.h"
20
21namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000022
23class VideoFramesQueue
24{
25public:
26 VideoFramesQueue();
27 ~VideoFramesQueue();
28
29 // Put newFrame (last) in the queue.
mikhal@webrtc.org9fedff72012-10-24 18:33:04 +000030 WebRtc_Word32 AddFrame(const I420VideoFrame& newFrame);
niklase@google.com470e71d2011-07-07 08:21:25 +000031
32 // Return the most current frame. I.e. the frame with the highest
33 // VideoFrame::RenderTimeMs() that is lower than
34 // TickTime::MillisecondTimestamp().
mikhal@webrtc.org9fedff72012-10-24 18:33:04 +000035 I420VideoFrame* FrameToRecord();
niklase@google.com470e71d2011-07-07 08:21:25 +000036
37 // Set the render delay estimate to renderDelay ms.
38 WebRtc_Word32 SetRenderDelay(WebRtc_UWord32 renderDelay);
39
40protected:
41 // Make ptrOldFrame available for re-use. I.e. put it in the empty frames
42 // queue.
mikhal@webrtc.org9fedff72012-10-24 18:33:04 +000043 WebRtc_Word32 ReturnFrame(I420VideoFrame* ptrOldFrame);
niklase@google.com470e71d2011-07-07 08:21:25 +000044
45private:
46 // Don't allow the buffer to expand beyond KMaxNumberOfFrames VideoFrames.
47 // 300 frames correspond to 10 seconds worth of frames at 30 fps.
48 enum {KMaxNumberOfFrames = 300};
49
50 // List of VideoFrame pointers. The list is sorted in the order of when the
51 // VideoFrame was inserted into the list. The first VideoFrame in the list
52 // was inserted first.
53 ListWrapper _incomingFrames;
54 // A list of frames that are free to be re-used.
55 ListWrapper _emptyFrames;
56
57 // Estimated render delay.
58 WebRtc_UWord32 _renderDelayMs;
59};
60} // namespace webrtc
61#endif // WEBRTC_MODULE_UTILITY_VIDEO
62#endif // WEBRTC_MODULES_UTILITY_SOURCE_VIDEO_FRAMES_QUEUE_H_