sergeyu@chromium.org | 6c82a7e | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 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 | #include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h" |
| 12 | |
| 13 | #include <algorithm> |
| 14 | |
| 15 | #include "webrtc/modules/desktop_capture/desktop_frame.h" |
| 16 | #include "webrtc/modules/desktop_capture/shared_desktop_frame.h" |
| 17 | #include "webrtc/system_wrappers/interface/logging.h" |
| 18 | #include "webrtc/typedefs.h" |
| 19 | |
| 20 | namespace webrtc { |
| 21 | |
| 22 | ScreenCaptureFrameQueue::ScreenCaptureFrameQueue() : current_(0) {} |
| 23 | |
| 24 | ScreenCaptureFrameQueue::~ScreenCaptureFrameQueue() {} |
| 25 | |
| 26 | void ScreenCaptureFrameQueue::MoveToNextFrame() { |
| 27 | current_ = (current_ + 1) % kQueueLength; |
| 28 | |
| 29 | // Verify that the frame is not shared, i.e. that consumer has released it |
| 30 | // before attempting to capture again. |
| 31 | assert(!frames_[current_].get() || !frames_[current_]->IsShared()); |
| 32 | } |
| 33 | |
| 34 | void ScreenCaptureFrameQueue::ReplaceCurrentFrame(DesktopFrame* frame) { |
| 35 | frames_[current_].reset(SharedDesktopFrame::Wrap(frame)); |
| 36 | } |
| 37 | |
| 38 | void ScreenCaptureFrameQueue::Reset() { |
| 39 | for (int i = 0; i < kQueueLength; ++i) |
| 40 | frames_[i].reset(); |
| 41 | } |
| 42 | |
| 43 | } // namespace webrtc |