Line data Source code
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/shared_desktop_frame.h"
12 :
13 : #include <memory>
14 :
15 : #include "webrtc/base/constructormagic.h"
16 :
17 : namespace webrtc {
18 :
19 0 : SharedDesktopFrame::~SharedDesktopFrame() {}
20 :
21 : // static
22 0 : std::unique_ptr<SharedDesktopFrame> SharedDesktopFrame::Wrap(
23 : std::unique_ptr<DesktopFrame> desktop_frame) {
24 : return std::unique_ptr<SharedDesktopFrame>(
25 0 : new SharedDesktopFrame(new Core(std::move(desktop_frame))));
26 : }
27 :
28 0 : SharedDesktopFrame* SharedDesktopFrame::Wrap(DesktopFrame* desktop_frame) {
29 0 : return Wrap(std::unique_ptr<DesktopFrame>(desktop_frame)).release();
30 : }
31 :
32 0 : DesktopFrame* SharedDesktopFrame::GetUnderlyingFrame() {
33 0 : return core_->get();
34 : }
35 :
36 0 : std::unique_ptr<SharedDesktopFrame> SharedDesktopFrame::Share() {
37 0 : std::unique_ptr<SharedDesktopFrame> result(new SharedDesktopFrame(core_));
38 0 : result->set_dpi(dpi());
39 0 : result->set_capture_time_ms(capture_time_ms());
40 0 : *result->mutable_updated_region() = updated_region();
41 0 : return result;
42 : }
43 :
44 0 : bool SharedDesktopFrame::IsShared() {
45 0 : return !core_->HasOneRef();
46 : }
47 :
48 0 : SharedDesktopFrame::SharedDesktopFrame(rtc::scoped_refptr<Core> core)
49 0 : : DesktopFrame((*core)->size(),
50 0 : (*core)->stride(),
51 0 : (*core)->data(),
52 0 : (*core)->shared_memory()),
53 0 : core_(core) {}
54 :
55 : } // namespace webrtc
|