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