niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 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.org | 79cf3ac | 2014-01-13 15:21:30 +0000 | [diff] [blame^] | 16 | #include <list> |
| 17 | |
pbos@webrtc.org | 8b06200 | 2013-07-12 08:28:10 +0000 | [diff] [blame] | 18 | #include "webrtc/common_video/interface/i420_video_frame.h" |
| 19 | #include "webrtc/engine_configurations.h" |
pbos@webrtc.org | 8b06200 | 2013-07-12 08:28:10 +0000 | [diff] [blame] | 20 | #include "webrtc/typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 23 | |
mikhal@webrtc.org | c381a84 | 2012-10-30 18:22:02 +0000 | [diff] [blame] | 24 | class VideoFramesQueue { |
| 25 | public: |
| 26 | VideoFramesQueue(); |
| 27 | ~VideoFramesQueue(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 28 | |
mikhal@webrtc.org | c381a84 | 2012-10-30 18:22:02 +0000 | [diff] [blame] | 29 | // Put newFrame (last) in the queue. |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 30 | int32_t AddFrame(const I420VideoFrame& newFrame); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 31 | |
mikhal@webrtc.org | c381a84 | 2012-10-30 18:22:02 +0000 | [diff] [blame] | 32 | // 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 36 | |
mikhal@webrtc.org | c381a84 | 2012-10-30 18:22:02 +0000 | [diff] [blame] | 37 | // Set the render delay estimate to renderDelay ms. |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 38 | int32_t SetRenderDelay(uint32_t renderDelay); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | |
mikhal@webrtc.org | c381a84 | 2012-10-30 18:22:02 +0000 | [diff] [blame] | 40 | protected: |
| 41 | // Make ptrOldFrame available for re-use. I.e. put it in the empty frames |
| 42 | // queue. |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 43 | int32_t ReturnFrame(I420VideoFrame* ptrOldFrame); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | |
mikhal@webrtc.org | c381a84 | 2012-10-30 18:22:02 +0000 | [diff] [blame] | 45 | private: |
henrike@webrtc.org | 79cf3ac | 2014-01-13 15:21:30 +0000 | [diff] [blame^] | 46 | typedef std::list<I420VideoFrame*> FrameList; |
mikhal@webrtc.org | c381a84 | 2012-10-30 18:22:02 +0000 | [diff] [blame] | 47 | // 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 50 | |
mikhal@webrtc.org | c381a84 | 2012-10-30 18:22:02 +0000 | [diff] [blame] | 51 | // 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.org | 79cf3ac | 2014-01-13 15:21:30 +0000 | [diff] [blame^] | 54 | FrameList _incomingFrames; |
mikhal@webrtc.org | c381a84 | 2012-10-30 18:22:02 +0000 | [diff] [blame] | 55 | // A list of frames that are free to be re-used. |
henrike@webrtc.org | 79cf3ac | 2014-01-13 15:21:30 +0000 | [diff] [blame^] | 56 | FrameList _emptyFrames; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 57 | |
mikhal@webrtc.org | c381a84 | 2012-10-30 18:22:02 +0000 | [diff] [blame] | 58 | // Estimated render delay. |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 59 | uint32_t _renderDelayMs; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 60 | }; |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 61 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 62 | #endif // WEBRTC_MODULE_UTILITY_VIDEO |
| 63 | #endif // WEBRTC_MODULES_UTILITY_SOURCE_VIDEO_FRAMES_QUEUE_H_ |