Show error if camera could not be enabled.

This commit is contained in:
John Preston 2021-06-23 12:04:05 +04:00
parent b29f8aa1e6
commit 14a2b10989
5 changed files with 16 additions and 2 deletions

View File

@ -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.";

View File

@ -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());
}

View File

@ -61,6 +61,7 @@ enum class VideoQuality {
enum class Error {
NoCamera,
CameraFailed,
ScreenFailed,
MutedNoCamera,
MutedNoScreen,

View File

@ -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:

@ -1 +1 @@
Subproject commit c17d4326200e5f544fa73addaa41c20c02d07dbd
Subproject commit 22331d17e2e52dd21c6563f3e37ed74864be9584