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 | |
| 16 | #include "engine_configurations.h" |
| 17 | #include "list_wrapper.h" |
| 18 | #include "typedefs.h" |
| 19 | |
| 20 | namespace webrtc { |
| 21 | class VideoFrame; |
| 22 | |
| 23 | class VideoFramesQueue |
| 24 | { |
| 25 | public: |
| 26 | VideoFramesQueue(); |
| 27 | ~VideoFramesQueue(); |
| 28 | |
| 29 | // Put newFrame (last) in the queue. |
| 30 | WebRtc_Word32 AddFrame(const VideoFrame& 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 | VideoFrame* FrameToRecord(); |
| 36 | |
| 37 | // Set the render delay estimate to renderDelay ms. |
| 38 | WebRtc_Word32 SetRenderDelay(WebRtc_UWord32 renderDelay); |
| 39 | |
| 40 | protected: |
| 41 | // Make ptrOldFrame available for re-use. I.e. put it in the empty frames |
| 42 | // queue. |
| 43 | WebRtc_Word32 ReturnFrame(VideoFrame* ptrOldFrame); |
| 44 | |
| 45 | private: |
| 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_ |