OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2017 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/win/dxgi_frame.h" |
| 12 |
| 13 #include <utility> |
| 14 |
| 15 #include "webrtc/base/checks.h" |
| 16 #include "webrtc/modules/desktop_capture/desktop_frame.h" |
| 17 |
| 18 namespace webrtc { |
| 19 |
| 20 DxgiFrame::DxgiFrame(SharedMemoryFactory* factory) |
| 21 : factory_(factory) {} |
| 22 |
| 23 DxgiFrame::~DxgiFrame() = default; |
| 24 |
| 25 bool DxgiFrame::Prepare(DesktopSize size, DesktopCapturer::SourceId source_id) { |
| 26 if (source_id != source_id_) { |
| 27 // Once the source has been changed, the entire source should be copied. |
| 28 source_id_ = source_id; |
| 29 context_.Reset(); |
| 30 } |
| 31 |
| 32 if (resolution_change_detector_.IsChanged(size)) { |
| 33 // Once the output size changed, recreate the SharedDesktopFrame. |
| 34 frame_.reset(); |
| 35 resolution_change_detector_.Reset(); |
| 36 } |
| 37 |
| 38 if (!frame_) { |
| 39 std::unique_ptr<DesktopFrame> frame; |
| 40 if (factory_) { |
| 41 frame = SharedMemoryDesktopFrame::Create(size, factory_); |
| 42 } else { |
| 43 frame.reset(new BasicDesktopFrame(size)); |
| 44 } |
| 45 if (!frame) { |
| 46 return false; |
| 47 } |
| 48 |
| 49 frame_ = SharedDesktopFrame::Wrap(std::move(frame)); |
| 50 } |
| 51 |
| 52 return !!frame_; |
| 53 } |
| 54 |
| 55 SharedDesktopFrame* DxgiFrame::frame() const { |
| 56 RTC_DCHECK(frame_); |
| 57 return frame_.get(); |
| 58 } |
| 59 |
| 60 DxgiDuplicatorController::Context* DxgiFrame::context() { |
| 61 RTC_DCHECK(frame_); |
| 62 return &context_; |
| 63 } |
| 64 |
| 65 } // namespace webrtc |
OLD | NEW |