blob: 4316bf7c047bf144c8ae56842e8f08153de285bf [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
pbos@webrtc.org8b062002013-07-12 08:28:10 +000016#include "webrtc/common_video/interface/i420_video_frame.h"
17#include "webrtc/engine_configurations.h"
18#include "webrtc/system_wrappers/interface/list_wrapper.h"
19#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000020
21namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000022
mikhal@webrtc.orgc381a842012-10-30 18:22:02 +000023class VideoFramesQueue {
24 public:
25 VideoFramesQueue();
26 ~VideoFramesQueue();
niklase@google.com470e71d2011-07-07 08:21:25 +000027
mikhal@webrtc.orgc381a842012-10-30 18:22:02 +000028 // Put newFrame (last) in the queue.
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000029 int32_t AddFrame(const I420VideoFrame& newFrame);
niklase@google.com470e71d2011-07-07 08:21:25 +000030
mikhal@webrtc.orgc381a842012-10-30 18:22:02 +000031 // Return the most current frame. I.e. the frame with the highest
32 // VideoFrame::RenderTimeMs() that is lower than
33 // TickTime::MillisecondTimestamp().
34 I420VideoFrame* FrameToRecord();
niklase@google.com470e71d2011-07-07 08:21:25 +000035
mikhal@webrtc.orgc381a842012-10-30 18:22:02 +000036 // Set the render delay estimate to renderDelay ms.
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000037 int32_t SetRenderDelay(uint32_t renderDelay);
niklase@google.com470e71d2011-07-07 08:21:25 +000038
mikhal@webrtc.orgc381a842012-10-30 18:22:02 +000039 protected:
40 // Make ptrOldFrame available for re-use. I.e. put it in the empty frames
41 // queue.
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000042 int32_t ReturnFrame(I420VideoFrame* ptrOldFrame);
niklase@google.com470e71d2011-07-07 08:21:25 +000043
mikhal@webrtc.orgc381a842012-10-30 18:22:02 +000044 private:
45 // Don't allow the buffer to expand beyond KMaxNumberOfFrames VideoFrames.
46 // 300 frames correspond to 10 seconds worth of frames at 30 fps.
47 enum {KMaxNumberOfFrames = 300};
niklase@google.com470e71d2011-07-07 08:21:25 +000048
mikhal@webrtc.orgc381a842012-10-30 18:22:02 +000049 // List of VideoFrame pointers. The list is sorted in the order of when the
50 // VideoFrame was inserted into the list. The first VideoFrame in the list
51 // was inserted first.
52 ListWrapper _incomingFrames;
53 // A list of frames that are free to be re-used.
54 ListWrapper _emptyFrames;
niklase@google.com470e71d2011-07-07 08:21:25 +000055
mikhal@webrtc.orgc381a842012-10-30 18:22:02 +000056 // Estimated render delay.
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000057 uint32_t _renderDelayMs;
niklase@google.com470e71d2011-07-07 08:21:25 +000058};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000059} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000060#endif // WEBRTC_MODULE_UTILITY_VIDEO
61#endif // WEBRTC_MODULES_UTILITY_SOURCE_VIDEO_FRAMES_QUEUE_H_