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::Context::Context() = default; | |
22 | |
23 DxgiFrame::Context::~Context() { | |
24 DxgiDuplicatorController::Instance()->Unregister(this); | |
25 } | |
26 | |
27 void DxgiFrame::Context::Reset() { | |
28 identity = 0; | |
29 } | |
30 | |
31 DxgiFrame::DxgiFrame(SharedMemoryFactory* factory) | |
32 : factory_(factory) {} | |
33 | |
34 DxgiFrame::~DxgiFrame() = default; | |
35 | |
36 bool DxgiFrame::Prepare(DesktopSize size, DesktopCapturer::SourceId source_id) { | |
37 if (source_id != source_id_) { | |
Sergey Ulanov
2017/04/18 23:39:09
Do we need to reuse the same frame for multiple so
Hzj_jie
2017/04/19 04:35:54
I think that's a little bit less optimized. If the
Sergey Ulanov
2017/04/19 23:29:27
Frame allocation is relatively cheap and also sour
Hzj_jie
2017/04/20 01:07:28
That's not really the meaning of this function. He
| |
38 // Once the source has been changed, the entire source should be copied. | |
39 source_id_ = source_id; | |
40 context_.Reset(); | |
41 } | |
42 | |
43 if (resolution_change_detector_.IsChanged(size)) { | |
44 // Once the output size changed, recreate the SharedDesktopFrame. | |
45 frame_.reset(); | |
46 resolution_change_detector_.Reset(); | |
47 } | |
48 | |
49 if (!frame_) { | |
50 std::unique_ptr<DesktopFrame> frame; | |
51 if (factory_) { | |
52 frame = SharedMemoryDesktopFrame::Create(size, factory_); | |
53 } else { | |
54 frame.reset(new BasicDesktopFrame(size)); | |
55 } | |
56 if (!frame) { | |
57 return false; | |
58 } | |
59 | |
60 frame_ = SharedDesktopFrame::Wrap(std::move(frame)); | |
61 } | |
62 | |
63 return !!frame_; | |
64 } | |
65 | |
66 SharedDesktopFrame* DxgiFrame::frame() const { | |
67 RTC_DCHECK(frame_); | |
68 return frame_.get(); | |
69 } | |
70 | |
71 DxgiFrame::Context* DxgiFrame::context() { | |
72 RTC_DCHECK(frame_); | |
73 return &context_; | |
74 } | |
75 | |
76 } // namespace webrtc | |
OLD | NEW |