2013-06-04 18:51:23 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "webrtc/modules/desktop_capture/shared_desktop_frame.h"
|
|
|
|
|
|
2016-03-16 15:58:08 -07:00
|
|
|
#include <memory>
|
|
|
|
|
|
2017-07-06 19:44:34 +02:00
|
|
|
#include "webrtc/rtc_base/constructormagic.h"
|
2013-06-04 18:51:23 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
SharedDesktopFrame::~SharedDesktopFrame() {}
|
|
|
|
|
|
|
|
|
|
// static
|
2016-06-07 16:41:58 -07:00
|
|
|
std::unique_ptr<SharedDesktopFrame> SharedDesktopFrame::Wrap(
|
|
|
|
|
std::unique_ptr<DesktopFrame> desktop_frame) {
|
|
|
|
|
return std::unique_ptr<SharedDesktopFrame>(
|
2016-06-08 15:52:21 -07:00
|
|
|
new SharedDesktopFrame(new Core(std::move(desktop_frame))));
|
2016-06-07 16:41:58 -07:00
|
|
|
}
|
|
|
|
|
|
2016-04-22 16:08:39 -07:00
|
|
|
SharedDesktopFrame* SharedDesktopFrame::Wrap(DesktopFrame* desktop_frame) {
|
2016-06-07 16:41:58 -07:00
|
|
|
return Wrap(std::unique_ptr<DesktopFrame>(desktop_frame)).release();
|
2013-06-04 18:51:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DesktopFrame* SharedDesktopFrame::GetUnderlyingFrame() {
|
2016-06-07 16:41:58 -07:00
|
|
|
return core_->get();
|
2013-06-04 18:51:23 +00:00
|
|
|
}
|
|
|
|
|
|
2016-06-07 16:41:58 -07:00
|
|
|
std::unique_ptr<SharedDesktopFrame> SharedDesktopFrame::Share() {
|
|
|
|
|
std::unique_ptr<SharedDesktopFrame> result(new SharedDesktopFrame(core_));
|
2013-06-04 18:51:23 +00:00
|
|
|
result->set_dpi(dpi());
|
|
|
|
|
result->set_capture_time_ms(capture_time_ms());
|
2017-04-03 11:51:18 -07:00
|
|
|
result->set_capturer_id(capturer_id());
|
2013-06-04 18:51:23 +00:00
|
|
|
*result->mutable_updated_region() = updated_region();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SharedDesktopFrame::IsShared() {
|
|
|
|
|
return !core_->HasOneRef();
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-04 15:18:17 +02:00
|
|
|
SharedDesktopFrame::SharedDesktopFrame(rtc::scoped_refptr<Core> core)
|
2016-06-07 16:41:58 -07:00
|
|
|
: DesktopFrame((*core)->size(),
|
|
|
|
|
(*core)->stride(),
|
|
|
|
|
(*core)->data(),
|
|
|
|
|
(*core)->shared_memory()),
|
|
|
|
|
core_(core) {}
|
2013-06-04 18:51:23 +00:00
|
|
|
|
|
|
|
|
} // namespace webrtc
|