2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Add proof-of-concept screen sharing on macOS.

This commit is contained in:
John Preston
2021-04-19 13:41:32 +04:00
parent fef1f80570
commit fb49b0ca27
7 changed files with 60 additions and 24 deletions

View File

@@ -383,7 +383,14 @@ GroupCall::GroupCall(
GroupCall::~GroupCall() {
destroyController();
switchToCamera();
const auto wasScreenSharing = isScreenSharing();
const auto weak = wasScreenSharing
? std::weak_ptr<tgcalls::VideoCaptureInterface>(_videoCapture)
: std::weak_ptr<tgcalls::VideoCaptureInterface>();
_videoCapture = nullptr;
if (const auto strong = weak.lock()) {
strong->switchToDevice(_videoDeviceId.toStdString());
}
}
bool GroupCall::isScreenSharing() const {
@@ -402,7 +409,7 @@ void GroupCall::switchToScreenSharing() {
if (isScreenSharing()) {
return;
}
_videoDeviceId = "desktop_capturer_";
_videoDeviceId = "desktop_capturer_screen_0";
_videoCapture->switchToDevice(_videoDeviceId.toStdString());
}

View File

@@ -650,14 +650,16 @@ auto Row::generatePaintUserpicCallback() -> PaintRoundImageCallback {
? QSize(videoSize.width() * size / videoSize.height(), size)
: QSize(size, videoSize.height() * size / videoSize.width());
const auto request = Webrtc::FrameRequest{
.resize = resize,
.outer = QSize(size, size),
.resize = resize * cIntRetinaFactor(),
.outer = QSize(size, size) * cIntRetinaFactor(),
};
const auto frame = _videoTrackShown->frame(request);
auto copy = frame; // #TODO calls optimize.
copy.detach();
Images::prepareCircle(copy);
p.drawImage(x, y, copy);
p.drawImage(
QRect(QPoint(x, y), copy.size() / cIntRetinaFactor()),
copy);
_videoTrackShown->markFrameShown();
return;
} else if (_videoTrackShown) {