blob: afc64d9b71e3f4d5e971ec0499d01c889f2af480 [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
henrike@webrtc.org79cf3ac2014-01-13 15:21:30 +000016#include <list>
17
pbos@webrtc.org8b062002013-07-12 08:28:10 +000018#include "webrtc/common_video/interface/i420_video_frame.h"
19#include "webrtc/engine_configurations.h"
pbos@webrtc.org8b062002013-07-12 08:28:10 +000020#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000021
22namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000023
mikhal@webrtc.orgc381a842012-10-30 18:22:02 +000024class VideoFramesQueue {
25 public:
26 VideoFramesQueue();
27 ~VideoFramesQueue();
niklase@google.com470e71d2011-07-07 08:21:25 +000028
mikhal@webrtc.orgc381a842012-10-30 18:22:02 +000029 // Put newFrame (last) in the queue.
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000030 int32_t AddFrame(const I420VideoFrame& newFrame);
niklase@google.com470e71d2011-07-07 08:21:25 +000031
mikhal@webrtc.orgc381a842012-10-30 18:22:02 +000032 // Return the most current frame. I.e. the frame with the highest
33 // VideoFrame::RenderTimeMs() that is lower than
34 // TickTime::MillisecondTimestamp().
35 I420VideoFrame* FrameToRecord();
niklase@google.com470e71d2011-07-07 08:21:25 +000036
mikhal@webrtc.orgc381a842012-10-30 18:22:02 +000037 // Set the render delay estimate to renderDelay ms.
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000038 int32_t SetRenderDelay(uint32_t renderDelay);
niklase@google.com470e71d2011-07-07 08:21:25 +000039
mikhal@webrtc.orgc381a842012-10-30 18:22:02 +000040 protected:
41 // Make ptrOldFrame available for re-use. I.e. put it in the empty frames
42 // queue.
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000043 int32_t ReturnFrame(I420VideoFrame* ptrOldFrame);
niklase@google.com470e71d2011-07-07 08:21:25 +000044
mikhal@webrtc.orgc381a842012-10-30 18:22:02 +000045 private:
henrike@webrtc.org79cf3ac2014-01-13 15:21:30 +000046 typedef std::list<I420VideoFrame*> FrameList;
mikhal@webrtc.orgc381a842012-10-30 18:22:02 +000047 // Don't allow the buffer to expand beyond KMaxNumberOfFrames VideoFrames.
48 // 300 frames correspond to 10 seconds worth of frames at 30 fps.
49 enum {KMaxNumberOfFrames = 300};
niklase@google.com470e71d2011-07-07 08:21:25 +000050
mikhal@webrtc.orgc381a842012-10-30 18:22:02 +000051 // List of VideoFrame pointers. The list is sorted in the order of when the
52 // VideoFrame was inserted into the list. The first VideoFrame in the list
53 // was inserted first.
henrike@webrtc.org79cf3ac2014-01-13 15:21:30 +000054 FrameList _incomingFrames;
mikhal@webrtc.orgc381a842012-10-30 18:22:02 +000055 // A list of frames that are free to be re-used.
henrike@webrtc.org79cf3ac2014-01-13 15:21:30 +000056 FrameList _emptyFrames;
niklase@google.com470e71d2011-07-07 08:21:25 +000057
mikhal@webrtc.orgc381a842012-10-30 18:22:02 +000058 // Estimated render delay.
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000059 uint32_t _renderDelayMs;
niklase@google.com470e71d2011-07-07 08:21:25 +000060};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000061} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000062#endif // WEBRTC_MODULE_UTILITY_VIDEO
63#endif // WEBRTC_MODULES_UTILITY_SOURCE_VIDEO_FRAMES_QUEUE_H_