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 16 #include <list> 17 18 #include "webrtc/common_video/interface/i420_video_frame.h" 19 #include "webrtc/engine_configurations.h" 20 #include "webrtc/typedefs.h" 21 22 namespace webrtc { 23 24 class VideoFramesQueue { 25 public: 26 VideoFramesQueue(); 27 ~VideoFramesQueue(); 28 29 // Put newFrame (last) in the queue. 30 int32_t AddFrame(const I420VideoFrame& newFrame); 31 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(); 36 37 // Set the render delay estimate to renderDelay ms. 38 int32_t SetRenderDelay(uint32_t renderDelay); 39 40 protected: 41 // Make ptrOldFrame available for re-use. I.e. put it in the empty frames 42 // queue. 43 int32_t ReturnFrame(I420VideoFrame* ptrOldFrame); 44 45 private: 46 typedef std::list<I420VideoFrame*> FrameList; 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}; 50 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. 54 FrameList _incomingFrames; 55 // A list of frames that are free to be re-used. 56 FrameList _emptyFrames; 57 58 // Estimated render delay. 59 uint32_t _renderDelayMs; 60 }; 61 } // namespace webrtc 62 #endif // WEBRTC_MODULE_UTILITY_VIDEO 63 #endif // WEBRTC_MODULES_UTILITY_SOURCE_VIDEO_FRAMES_QUEUE_H_ 64