mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Use good bitrate for screen capture in calls.
This commit is contained in:
parent
73c8f16340
commit
91ef6f13c8
8 changed files with 49 additions and 36 deletions
|
@ -378,7 +378,8 @@ void Call::setupOutgoingVideo() {
|
||||||
Assert(state == Webrtc::VideoState::Active);
|
Assert(state == Webrtc::VideoState::Active);
|
||||||
if (!_videoCapture) {
|
if (!_videoCapture) {
|
||||||
_videoCapture = _delegate->callGetVideoCapture(
|
_videoCapture = _delegate->callGetVideoCapture(
|
||||||
_videoCaptureDeviceId);
|
_videoCaptureDeviceId,
|
||||||
|
_videoCaptureIsScreencast);
|
||||||
_videoCapture->setOutput(_videoOutgoing->sink());
|
_videoCapture->setOutput(_videoOutgoing->sink());
|
||||||
}
|
}
|
||||||
if (_instance) {
|
if (_instance) {
|
||||||
|
@ -985,7 +986,10 @@ void Call::setCurrentCameraDevice(const QString &deviceId) {
|
||||||
if (!_videoCaptureIsScreencast) {
|
if (!_videoCaptureIsScreencast) {
|
||||||
_videoCaptureDeviceId = deviceId;
|
_videoCaptureDeviceId = deviceId;
|
||||||
if (_videoCapture) {
|
if (_videoCapture) {
|
||||||
_videoCapture->switchToDevice(deviceId.toStdString());
|
_videoCapture->switchToDevice(deviceId.toStdString(), false);
|
||||||
|
if (_instance) {
|
||||||
|
_instance->sendVideoDeviceUpdated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1042,7 +1046,10 @@ void Call::toggleCameraSharing(bool enabled) {
|
||||||
const auto deviceId = Core::App().settings().callVideoInputDeviceId();
|
const auto deviceId = Core::App().settings().callVideoInputDeviceId();
|
||||||
_videoCaptureDeviceId = deviceId;
|
_videoCaptureDeviceId = deviceId;
|
||||||
if (_videoCapture) {
|
if (_videoCapture) {
|
||||||
_videoCapture->switchToDevice(deviceId.toStdString());
|
_videoCapture->switchToDevice(deviceId.toStdString(), false);
|
||||||
|
if (_instance) {
|
||||||
|
_instance->sendVideoDeviceUpdated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_videoOutgoing->setState(Webrtc::VideoState::Active);
|
_videoOutgoing->setState(Webrtc::VideoState::Active);
|
||||||
}), true);
|
}), true);
|
||||||
|
@ -1066,7 +1073,10 @@ void Call::toggleScreenSharing(std::optional<QString> uniqueId) {
|
||||||
_videoCaptureIsScreencast = true;
|
_videoCaptureIsScreencast = true;
|
||||||
_videoCaptureDeviceId = *uniqueId;
|
_videoCaptureDeviceId = *uniqueId;
|
||||||
if (_videoCapture) {
|
if (_videoCapture) {
|
||||||
_videoCapture->switchToDevice(uniqueId->toStdString());
|
_videoCapture->switchToDevice(uniqueId->toStdString(), true);
|
||||||
|
if (_instance) {
|
||||||
|
_instance->sendVideoDeviceUpdated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_videoOutgoing->setState(Webrtc::VideoState::Active);
|
_videoOutgoing->setState(Webrtc::VideoState::Active);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,8 +77,10 @@ public:
|
||||||
Fn<void()> onSuccess,
|
Fn<void()> onSuccess,
|
||||||
bool video) = 0;
|
bool video) = 0;
|
||||||
|
|
||||||
virtual auto callGetVideoCapture(const QString &deviceId)
|
virtual auto callGetVideoCapture(
|
||||||
-> std::shared_ptr<tgcalls::VideoCaptureInterface> = 0;
|
const QString &deviceId,
|
||||||
|
bool isScreenCapture)
|
||||||
|
-> std::shared_ptr<tgcalls::VideoCaptureInterface> = 0;
|
||||||
|
|
||||||
virtual ~Delegate() = default;
|
virtual ~Delegate() = default;
|
||||||
|
|
||||||
|
|
|
@ -64,8 +64,10 @@ public:
|
||||||
Fn<void()> onSuccess,
|
Fn<void()> onSuccess,
|
||||||
bool video) override;
|
bool video) override;
|
||||||
void callPlaySound(CallSound sound) override;
|
void callPlaySound(CallSound sound) override;
|
||||||
auto callGetVideoCapture(const QString &deviceId)
|
auto callGetVideoCapture(
|
||||||
-> std::shared_ptr<tgcalls::VideoCaptureInterface> override;
|
const QString &deviceId,
|
||||||
|
bool isScreenCapture)
|
||||||
|
-> std::shared_ptr<tgcalls::VideoCaptureInterface> override;
|
||||||
|
|
||||||
void groupCallFinished(not_null<GroupCall*> call) override;
|
void groupCallFinished(not_null<GroupCall*> call) override;
|
||||||
void groupCallFailed(not_null<GroupCall*> call) override;
|
void groupCallFailed(not_null<GroupCall*> call) override;
|
||||||
|
@ -123,9 +125,11 @@ void Instance::Delegate::callPlaySound(CallSound sound) {
|
||||||
}());
|
}());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Instance::Delegate::callGetVideoCapture(const QString &deviceId)
|
auto Instance::Delegate::callGetVideoCapture(
|
||||||
|
const QString &deviceId,
|
||||||
|
bool isScreenCapture)
|
||||||
-> std::shared_ptr<tgcalls::VideoCaptureInterface> {
|
-> std::shared_ptr<tgcalls::VideoCaptureInterface> {
|
||||||
return _instance->getVideoCapture(deviceId);
|
return _instance->getVideoCapture(deviceId, isScreenCapture);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instance::Delegate::groupCallFinished(not_null<GroupCall*> call) {
|
void Instance::Delegate::groupCallFinished(not_null<GroupCall*> call) {
|
||||||
|
@ -159,7 +163,7 @@ void Instance::Delegate::groupCallPlaySound(GroupCallSound sound) {
|
||||||
|
|
||||||
auto Instance::Delegate::groupCallGetVideoCapture(const QString &deviceId)
|
auto Instance::Delegate::groupCallGetVideoCapture(const QString &deviceId)
|
||||||
-> std::shared_ptr<tgcalls::VideoCaptureInterface> {
|
-> std::shared_ptr<tgcalls::VideoCaptureInterface> {
|
||||||
return _instance->getVideoCapture(deviceId);
|
return _instance->getVideoCapture(deviceId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
FnMut<void()> Instance::Delegate::groupCallAddAsyncWaiter() {
|
FnMut<void()> Instance::Delegate::groupCallAddAsyncWaiter() {
|
||||||
|
@ -699,12 +703,15 @@ void Instance::requestPermissionOrFail(Platform::PermissionType type, Fn<void()>
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<tgcalls::VideoCaptureInterface> Instance::getVideoCapture(
|
std::shared_ptr<tgcalls::VideoCaptureInterface> Instance::getVideoCapture(
|
||||||
std::optional<QString> deviceId) {
|
std::optional<QString> deviceId,
|
||||||
|
bool isScreenCapture) {
|
||||||
if (auto result = _videoCapture.lock()) {
|
if (auto result = _videoCapture.lock()) {
|
||||||
if (deviceId) {
|
if (deviceId) {
|
||||||
result->switchToDevice((deviceId->isEmpty()
|
result->switchToDevice(
|
||||||
? Core::App().settings().callVideoInputDeviceId()
|
(deviceId->isEmpty()
|
||||||
: *deviceId).toStdString());
|
? Core::App().settings().callVideoInputDeviceId()
|
||||||
|
: *deviceId).toStdString(),
|
||||||
|
isScreenCapture);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,8 @@ public:
|
||||||
bool minimizeCurrentActiveCall();
|
bool minimizeCurrentActiveCall();
|
||||||
bool closeCurrentActiveCall();
|
bool closeCurrentActiveCall();
|
||||||
[[nodiscard]] auto getVideoCapture(
|
[[nodiscard]] auto getVideoCapture(
|
||||||
std::optional<QString> deviceId = std::nullopt)
|
std::optional<QString> deviceId = std::nullopt,
|
||||||
|
bool isScreenCapture = false)
|
||||||
-> std::shared_ptr<tgcalls::VideoCaptureInterface>;
|
-> std::shared_ptr<tgcalls::VideoCaptureInterface>;
|
||||||
void requestPermissionsOrFail(Fn<void()> onSuccess, bool video = true);
|
void requestPermissionsOrFail(Fn<void()> onSuccess, bool video = true);
|
||||||
|
|
||||||
|
|
|
@ -654,7 +654,7 @@ void GroupCall::toggleScreenSharing(
|
||||||
_screenWithAudio = withAudio;
|
_screenWithAudio = withAudio;
|
||||||
_screenState = Webrtc::VideoState::Active;
|
_screenState = Webrtc::VideoState::Active;
|
||||||
if (changed && wasSharing && isSharingScreen()) {
|
if (changed && wasSharing && isSharingScreen()) {
|
||||||
_screenCapture->switchToDevice(uniqueId->toStdString());
|
_screenCapture->switchToDevice(uniqueId->toStdString(), true);
|
||||||
}
|
}
|
||||||
if (_screenInstance) {
|
if (_screenInstance) {
|
||||||
_screenInstance->setIsMuted(!withAudio);
|
_screenInstance->setIsMuted(!withAudio);
|
||||||
|
@ -1951,7 +1951,7 @@ void GroupCall::setupMediaDevices() {
|
||||||
) | rpl::start_with_next([=](QString id) {
|
) | rpl::start_with_next([=](QString id) {
|
||||||
_cameraInputId = id;
|
_cameraInputId = id;
|
||||||
if (_cameraCapture) {
|
if (_cameraCapture) {
|
||||||
_cameraCapture->switchToDevice(id.toStdString());
|
_cameraCapture->switchToDevice(id.toStdString(), false);
|
||||||
}
|
}
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
}
|
}
|
||||||
|
@ -2064,7 +2064,9 @@ void GroupCall::setupOutgoingVideo() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
_cameraCapture->switchToDevice(_cameraInputId.toStdString());
|
_cameraCapture->switchToDevice(
|
||||||
|
_cameraInputId.toStdString(),
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
if (_instance) {
|
if (_instance) {
|
||||||
_instance->setVideoCapture(_cameraCapture);
|
_instance->setVideoCapture(_cameraCapture);
|
||||||
|
@ -2131,7 +2133,8 @@ void GroupCall::setupOutgoingVideo() {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
_screenCapture->switchToDevice(
|
_screenCapture->switchToDevice(
|
||||||
_screenDeviceId.toStdString());
|
_screenDeviceId.toStdString(),
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
if (_screenInstance) {
|
if (_screenInstance) {
|
||||||
_screenInstance->setVideoCapture(_screenCapture);
|
_screenInstance->setVideoCapture(_screenCapture);
|
||||||
|
|
|
@ -124,7 +124,9 @@ void Calls::setupContent() {
|
||||||
call->setCurrentCameraDevice(deviceId);
|
call->setCurrentCameraDevice(deviceId);
|
||||||
}
|
}
|
||||||
if (*capturerOwner) {
|
if (*capturerOwner) {
|
||||||
(*capturerOwner)->switchToDevice(deviceId.toStdString());
|
(*capturerOwner)->switchToDevice(
|
||||||
|
deviceId.toStdString(),
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
_controller->show(Box([=](not_null<Ui::GenericBox*> box) {
|
_controller->show(Box([=](not_null<Ui::GenericBox*> box) {
|
||||||
|
@ -179,7 +181,8 @@ void Calls::setupContent() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*capturerOwner = Core::App().calls().getVideoCapture(
|
*capturerOwner = Core::App().calls().getVideoCapture(
|
||||||
Core::App().settings().callVideoInputDeviceId());
|
Core::App().settings().callVideoInputDeviceId(),
|
||||||
|
false);
|
||||||
(*capturerOwner)->setPreferredAspectRatio(0.);
|
(*capturerOwner)->setPreferredAspectRatio(0.);
|
||||||
track->setState(VideoState::Active);
|
track->setState(VideoState::Active);
|
||||||
(*capturerOwner)->setState(tgcalls::VideoState::Active);
|
(*capturerOwner)->setState(tgcalls::VideoState::Active);
|
||||||
|
|
2
Telegram/ThirdParty/tgcalls
vendored
2
Telegram/ThirdParty/tgcalls
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 6f2746e04c9b040f8c8dfc64d916a1853d09c4ce
|
Subproject commit ae2a132788a1b03a47c449bf5b933daeb1907247
|
|
@ -177,19 +177,11 @@ PRIVATE
|
||||||
)
|
)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_compile_definitions(lib_tgcalls
|
|
||||||
PRIVATE
|
|
||||||
WEBRTC_WIN
|
|
||||||
)
|
|
||||||
elseif (APPLE)
|
elseif (APPLE)
|
||||||
target_compile_options(lib_tgcalls
|
target_compile_options(lib_tgcalls
|
||||||
PRIVATE
|
PRIVATE
|
||||||
-fobjc-arc
|
-fobjc-arc
|
||||||
)
|
)
|
||||||
target_compile_definitions(lib_tgcalls
|
|
||||||
PRIVATE
|
|
||||||
WEBRTC_MAC
|
|
||||||
)
|
|
||||||
remove_target_sources(lib_tgcalls ${tgcalls_loc}
|
remove_target_sources(lib_tgcalls ${tgcalls_loc}
|
||||||
platform/darwin/DesktopCaptureSourceView.h
|
platform/darwin/DesktopCaptureSourceView.h
|
||||||
platform/darwin/DesktopCaptureSourceView.mm
|
platform/darwin/DesktopCaptureSourceView.mm
|
||||||
|
@ -212,11 +204,6 @@ elseif (APPLE)
|
||||||
platform/tdesktop/VideoCameraCapturer.cpp
|
platform/tdesktop/VideoCameraCapturer.cpp
|
||||||
platform/tdesktop/VideoCameraCapturer.h
|
platform/tdesktop/VideoCameraCapturer.h
|
||||||
)
|
)
|
||||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
||||||
target_compile_definitions(lib_tgcalls
|
|
||||||
PRIVATE
|
|
||||||
WEBRTC_LINUX
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
|
|
Loading…
Add table
Reference in a new issue