mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +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);
|
||||
if (!_videoCapture) {
|
||||
_videoCapture = _delegate->callGetVideoCapture(
|
||||
_videoCaptureDeviceId);
|
||||
_videoCaptureDeviceId,
|
||||
_videoCaptureIsScreencast);
|
||||
_videoCapture->setOutput(_videoOutgoing->sink());
|
||||
}
|
||||
if (_instance) {
|
||||
|
@ -985,7 +986,10 @@ void Call::setCurrentCameraDevice(const QString &deviceId) {
|
|||
if (!_videoCaptureIsScreencast) {
|
||||
_videoCaptureDeviceId = deviceId;
|
||||
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();
|
||||
_videoCaptureDeviceId = deviceId;
|
||||
if (_videoCapture) {
|
||||
_videoCapture->switchToDevice(deviceId.toStdString());
|
||||
_videoCapture->switchToDevice(deviceId.toStdString(), false);
|
||||
if (_instance) {
|
||||
_instance->sendVideoDeviceUpdated();
|
||||
}
|
||||
}
|
||||
_videoOutgoing->setState(Webrtc::VideoState::Active);
|
||||
}), true);
|
||||
|
@ -1066,7 +1073,10 @@ void Call::toggleScreenSharing(std::optional<QString> uniqueId) {
|
|||
_videoCaptureIsScreencast = true;
|
||||
_videoCaptureDeviceId = *uniqueId;
|
||||
if (_videoCapture) {
|
||||
_videoCapture->switchToDevice(uniqueId->toStdString());
|
||||
_videoCapture->switchToDevice(uniqueId->toStdString(), true);
|
||||
if (_instance) {
|
||||
_instance->sendVideoDeviceUpdated();
|
||||
}
|
||||
}
|
||||
_videoOutgoing->setState(Webrtc::VideoState::Active);
|
||||
}
|
||||
|
|
|
@ -77,8 +77,10 @@ public:
|
|||
Fn<void()> onSuccess,
|
||||
bool video) = 0;
|
||||
|
||||
virtual auto callGetVideoCapture(const QString &deviceId)
|
||||
-> std::shared_ptr<tgcalls::VideoCaptureInterface> = 0;
|
||||
virtual auto callGetVideoCapture(
|
||||
const QString &deviceId,
|
||||
bool isScreenCapture)
|
||||
-> std::shared_ptr<tgcalls::VideoCaptureInterface> = 0;
|
||||
|
||||
virtual ~Delegate() = default;
|
||||
|
||||
|
|
|
@ -64,8 +64,10 @@ public:
|
|||
Fn<void()> onSuccess,
|
||||
bool video) override;
|
||||
void callPlaySound(CallSound sound) override;
|
||||
auto callGetVideoCapture(const QString &deviceId)
|
||||
-> std::shared_ptr<tgcalls::VideoCaptureInterface> override;
|
||||
auto callGetVideoCapture(
|
||||
const QString &deviceId,
|
||||
bool isScreenCapture)
|
||||
-> std::shared_ptr<tgcalls::VideoCaptureInterface> override;
|
||||
|
||||
void groupCallFinished(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> {
|
||||
return _instance->getVideoCapture(deviceId);
|
||||
return _instance->getVideoCapture(deviceId, isScreenCapture);
|
||||
}
|
||||
|
||||
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)
|
||||
-> std::shared_ptr<tgcalls::VideoCaptureInterface> {
|
||||
return _instance->getVideoCapture(deviceId);
|
||||
return _instance->getVideoCapture(deviceId, false);
|
||||
}
|
||||
|
||||
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::optional<QString> deviceId) {
|
||||
std::optional<QString> deviceId,
|
||||
bool isScreenCapture) {
|
||||
if (auto result = _videoCapture.lock()) {
|
||||
if (deviceId) {
|
||||
result->switchToDevice((deviceId->isEmpty()
|
||||
? Core::App().settings().callVideoInputDeviceId()
|
||||
: *deviceId).toStdString());
|
||||
result->switchToDevice(
|
||||
(deviceId->isEmpty()
|
||||
? Core::App().settings().callVideoInputDeviceId()
|
||||
: *deviceId).toStdString(),
|
||||
isScreenCapture);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,8 @@ public:
|
|||
bool minimizeCurrentActiveCall();
|
||||
bool closeCurrentActiveCall();
|
||||
[[nodiscard]] auto getVideoCapture(
|
||||
std::optional<QString> deviceId = std::nullopt)
|
||||
std::optional<QString> deviceId = std::nullopt,
|
||||
bool isScreenCapture = false)
|
||||
-> std::shared_ptr<tgcalls::VideoCaptureInterface>;
|
||||
void requestPermissionsOrFail(Fn<void()> onSuccess, bool video = true);
|
||||
|
||||
|
|
|
@ -654,7 +654,7 @@ void GroupCall::toggleScreenSharing(
|
|||
_screenWithAudio = withAudio;
|
||||
_screenState = Webrtc::VideoState::Active;
|
||||
if (changed && wasSharing && isSharingScreen()) {
|
||||
_screenCapture->switchToDevice(uniqueId->toStdString());
|
||||
_screenCapture->switchToDevice(uniqueId->toStdString(), true);
|
||||
}
|
||||
if (_screenInstance) {
|
||||
_screenInstance->setIsMuted(!withAudio);
|
||||
|
@ -1951,7 +1951,7 @@ void GroupCall::setupMediaDevices() {
|
|||
) | rpl::start_with_next([=](QString id) {
|
||||
_cameraInputId = id;
|
||||
if (_cameraCapture) {
|
||||
_cameraCapture->switchToDevice(id.toStdString());
|
||||
_cameraCapture->switchToDevice(id.toStdString(), false);
|
||||
}
|
||||
}, _lifetime);
|
||||
}
|
||||
|
@ -2064,7 +2064,9 @@ void GroupCall::setupOutgoingVideo() {
|
|||
});
|
||||
});
|
||||
} else {
|
||||
_cameraCapture->switchToDevice(_cameraInputId.toStdString());
|
||||
_cameraCapture->switchToDevice(
|
||||
_cameraInputId.toStdString(),
|
||||
false);
|
||||
}
|
||||
if (_instance) {
|
||||
_instance->setVideoCapture(_cameraCapture);
|
||||
|
@ -2131,7 +2133,8 @@ void GroupCall::setupOutgoingVideo() {
|
|||
});
|
||||
} else {
|
||||
_screenCapture->switchToDevice(
|
||||
_screenDeviceId.toStdString());
|
||||
_screenDeviceId.toStdString(),
|
||||
true);
|
||||
}
|
||||
if (_screenInstance) {
|
||||
_screenInstance->setVideoCapture(_screenCapture);
|
||||
|
|
|
@ -124,7 +124,9 @@ void Calls::setupContent() {
|
|||
call->setCurrentCameraDevice(deviceId);
|
||||
}
|
||||
if (*capturerOwner) {
|
||||
(*capturerOwner)->switchToDevice(deviceId.toStdString());
|
||||
(*capturerOwner)->switchToDevice(
|
||||
deviceId.toStdString(),
|
||||
false);
|
||||
}
|
||||
});
|
||||
_controller->show(Box([=](not_null<Ui::GenericBox*> box) {
|
||||
|
@ -179,7 +181,8 @@ void Calls::setupContent() {
|
|||
return;
|
||||
}
|
||||
*capturerOwner = Core::App().calls().getVideoCapture(
|
||||
Core::App().settings().callVideoInputDeviceId());
|
||||
Core::App().settings().callVideoInputDeviceId(),
|
||||
false);
|
||||
(*capturerOwner)->setPreferredAspectRatio(0.);
|
||||
track->setState(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)
|
||||
target_compile_definitions(lib_tgcalls
|
||||
PRIVATE
|
||||
WEBRTC_WIN
|
||||
)
|
||||
elseif (APPLE)
|
||||
target_compile_options(lib_tgcalls
|
||||
PRIVATE
|
||||
-fobjc-arc
|
||||
)
|
||||
target_compile_definitions(lib_tgcalls
|
||||
PRIVATE
|
||||
WEBRTC_MAC
|
||||
)
|
||||
remove_target_sources(lib_tgcalls ${tgcalls_loc}
|
||||
platform/darwin/DesktopCaptureSourceView.h
|
||||
platform/darwin/DesktopCaptureSourceView.mm
|
||||
|
@ -212,11 +204,6 @@ elseif (APPLE)
|
|||
platform/tdesktop/VideoCameraCapturer.cpp
|
||||
platform/tdesktop/VideoCameraCapturer.h
|
||||
)
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
target_compile_definitions(lib_tgcalls
|
||||
PRIVATE
|
||||
WEBRTC_LINUX
|
||||
)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
|
|
Loading…
Add table
Reference in a new issue