From 14a2b1098933ff0f37929e0aad4e7ca7224453f9 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 23 Jun 2021 12:04:05 +0400 Subject: [PATCH] Show error if camera could not be enabled. --- Telegram/Resources/langs/lang.strings | 1 + .../SourceFiles/calls/group/calls_group_call.cpp | 12 +++++++++++- .../SourceFiles/calls/group/calls_group_common.h | 1 + .../SourceFiles/calls/group/calls_group_toasts.cpp | 2 ++ Telegram/ThirdParty/tgcalls | 2 +- 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index c7c9845d1..b2e4ec099 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2030,6 +2030,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_group_call_chat_no_camera" = "You can't turn on video in this chat."; "lng_group_call_chat_no_screen" = "You can't share your screen in this chat."; "lng_group_call_failed_screen" = "An error occured. Screencast has stopped."; +"lng_group_call_failed_camera" = "Could not enable camera. Perhaps another app is using the camera already. Try closing other apps."; "lng_group_call_tooltip_screen" = "Share screen"; "lng_group_call_tooltip_camera" = "Your camera is off. Click here to enable camera."; "lng_group_call_tooltip_microphone" = "You are on mute. Click here to speak."; diff --git a/Telegram/SourceFiles/calls/group/calls_group_call.cpp b/Telegram/SourceFiles/calls/group/calls_group_call.cpp index 5cdaf5652..dae5d4255 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_call.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_call.cpp @@ -1989,6 +1989,10 @@ bool GroupCall::emitShareCameraError() { void GroupCall::emitShareCameraError(Error error) { _cameraState = Webrtc::VideoState::Inactive; + if (error == Error::CameraFailed + && Webrtc::GetVideoInputList().empty()) { + error = Error::NoCamera; + } _errors.fire_copy(error); } @@ -2042,8 +2046,14 @@ void GroupCall::setupOutgoingVideo() { _cameraCapture = _delegate->groupCallGetVideoCapture( _cameraInputId); if (!_cameraCapture) { - return emitShareCameraError(Error::NoCamera); + return emitShareCameraError(Error::CameraFailed); } + const auto weak = base::make_weak(this); + _cameraCapture->setOnFatalError([=] { + crl::on_main(weak, [=] { + emitShareCameraError(Error::CameraFailed); + }); + }); } else { _cameraCapture->switchToDevice(_cameraInputId.toStdString()); } diff --git a/Telegram/SourceFiles/calls/group/calls_group_common.h b/Telegram/SourceFiles/calls/group/calls_group_common.h index dd9a947ef..ce84f94ef 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_common.h +++ b/Telegram/SourceFiles/calls/group/calls_group_common.h @@ -61,6 +61,7 @@ enum class VideoQuality { enum class Error { NoCamera, + CameraFailed, ScreenFailed, MutedNoCamera, MutedNoScreen, diff --git a/Telegram/SourceFiles/calls/group/calls_group_toasts.cpp b/Telegram/SourceFiles/calls/group/calls_group_toasts.cpp index 54a8110cd..7d8d3c217 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_toasts.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_toasts.cpp @@ -155,6 +155,8 @@ void Toasts::setupError() { const auto key = [&] { switch (error) { case Error::NoCamera: return tr::lng_call_error_no_camera; + case Error::CameraFailed: + return tr::lng_group_call_failed_camera; case Error::ScreenFailed: return tr::lng_group_call_failed_screen; case Error::MutedNoCamera: diff --git a/Telegram/ThirdParty/tgcalls b/Telegram/ThirdParty/tgcalls index c17d43262..22331d17e 160000 --- a/Telegram/ThirdParty/tgcalls +++ b/Telegram/ThirdParty/tgcalls @@ -1 +1 @@ -Subproject commit c17d4326200e5f544fa73addaa41c20c02d07dbd +Subproject commit 22331d17e2e52dd21c6563f3e37ed74864be9584