Fix RTMP livestream starting while in another call.

Fixes #24862.
This commit is contained in:
John Preston 2022-08-08 16:39:44 +03:00
parent 068eb3fcd1
commit 3a3341fef8
5 changed files with 41 additions and 35 deletions

View file

@ -202,23 +202,11 @@ void Instance::startOutgoingCall(not_null<UserData*> user, bool video) {
}), video); }), video);
} }
void Instance::startOrJoinGroupCall( void Instance::showStartOrJoinGroupCall(
std::shared_ptr<Ui::Show> show, std::shared_ptr<Ui::Show> show,
not_null<PeerData*> peer, not_null<PeerData*> peer,
const StartGroupCallArgs &args) { const StartGroupCallArgs &args) {
using JoinConfirm = StartGroupCallArgs::JoinConfirm; using JoinConfirm = StartGroupCallArgs::JoinConfirm;
if (args.rtmpNeeded) {
_startWithRtmp->start(peer, [=](object_ptr<Ui::BoxContent> box) {
show->showBox(std::move(box), Ui::LayerOption::KeepOther);
}, [=](QString text) {
Ui::Toast::Show(show->toastParent(), text);
}, [=](Group::JoinInfo info) {
createGroupCall(
std::move(info),
MTP_inputGroupCall(MTPlong(), MTPlong()));
});
return;
}
const auto context = (args.confirm == JoinConfirm::Always) const auto context = (args.confirm == JoinConfirm::Always)
? Group::ChooseJoinAsProcess::Context::JoinWithConfirm ? Group::ChooseJoinAsProcess::Context::JoinWithConfirm
: peer->groupCall() : peer->groupCall()
@ -238,7 +226,19 @@ void Instance::startOrJoinGroupCall(
} }
createGroupCall( createGroupCall(
std::move(info), std::move(info),
call ? call->input() : MTP_inputGroupCall(MTPlong(), MTPlong())); call ? call->input() : MTP_inputGroupCall({}, {}));
});
}
void Instance::showStartWithRtmp(
std::shared_ptr<Ui::Show> show,
not_null<PeerData*> peer) {
_startWithRtmp->start(peer, [=](object_ptr<Ui::BoxContent> box) {
show->showBox(std::move(box), Ui::LayerOption::KeepOther);
}, [=](QString text) {
Ui::Toast::Show(show->toastParent(), text);
}, [=](Group::JoinInfo info) {
createGroupCall(std::move(info), MTP_inputGroupCall({}, {}));
}); });
} }

View file

@ -57,8 +57,6 @@ struct StartGroupCallArgs {
QString joinHash; QString joinHash;
JoinConfirm confirm = JoinConfirm::IfNowInAnother; JoinConfirm confirm = JoinConfirm::IfNowInAnother;
bool scheduleNeeded = false; bool scheduleNeeded = false;
bool rtmpNeeded = false;
bool useRtmp = false;
}; };
class Instance final : public base::has_weak_ptr { class Instance final : public base::has_weak_ptr {
@ -67,10 +65,13 @@ public:
~Instance(); ~Instance();
void startOutgoingCall(not_null<UserData*> user, bool video); void startOutgoingCall(not_null<UserData*> user, bool video);
void startOrJoinGroupCall( void showStartOrJoinGroupCall(
std::shared_ptr<Ui::Show> show, std::shared_ptr<Ui::Show> show,
not_null<PeerData*> peer, not_null<PeerData*> peer,
const StartGroupCallArgs &args); const StartGroupCallArgs &args);
void showStartWithRtmp(
std::shared_ptr<Ui::Show> show,
not_null<PeerData*> peer);
void handleUpdate( void handleUpdate(
not_null<Main::Session*> session, not_null<Main::Session*> session,
const MTPUpdate &update); const MTPUpdate &update);

View file

@ -341,7 +341,7 @@ void StartRtmpProcess::FillRtmpRows(
close(); close();
}, },
.confirmText = tr::lng_from_request_understand(), .confirmText = tr::lng_from_request_understand(),
.cancelText = tr::lng_close(), .cancelText = tr::lng_cancel(),
.confirmStyle = attentionButtonStyle, .confirmStyle = attentionButtonStyle,
.labelStyle = labelStyle, .labelStyle = labelStyle,
})); }));

View file

@ -328,24 +328,29 @@ void TopBarWidget::showGroupCallMenu(not_null<PeerData*> peer) {
const auto callback = [=](Calls::StartGroupCallArgs &&args) { const auto callback = [=](Calls::StartGroupCallArgs &&args) {
controller->startOrJoinGroupCall(peer, std::move(args)); controller->startOrJoinGroupCall(peer, std::move(args));
}; };
const auto rtmpCallback = [=] {
Core::App().calls().showStartWithRtmp(
std::make_shared<Window::Show>(controller),
peer);
};
const auto livestream = !peer->isMegagroup() && peer->isChannel(); const auto livestream = !peer->isMegagroup() && peer->isChannel();
_menu->addAction( _menu->addAction(
livestream (livestream
? tr::lng_menu_start_group_call_channel(tr::now) ? tr::lng_menu_start_group_call_channel
: tr::lng_menu_start_group_call(tr::now), : tr::lng_menu_start_group_call)(tr::now),
[=] { callback({}); }, [=] { callback({}); },
&st::menuIconStartStream); &st::menuIconStartStream);
_menu->addAction( _menu->addAction(
livestream (livestream
? tr::lng_menu_start_group_call_scheduled_channel(tr::now) ? tr::lng_menu_start_group_call_scheduled_channel
: tr::lng_menu_start_group_call_scheduled(tr::now), : tr::lng_menu_start_group_call_scheduled)(tr::now),
[=] { callback({ .scheduleNeeded = true }); }, [=] { callback({ .scheduleNeeded = true }); },
&st::menuIconReschedule); &st::menuIconReschedule);
_menu->addAction( _menu->addAction(
livestream (livestream
? tr::lng_menu_start_group_call_with_channel(tr::now) ? tr::lng_menu_start_group_call_with_channel
: tr::lng_menu_start_group_call_with(tr::now), : tr::lng_menu_start_group_call_with)(tr::now),
[=] { callback({ .rtmpNeeded = true }); }, rtmpCallback,
&st::menuIconStartStreamWith); &st::menuIconStartStreamWith);
_menu->setForcedOrigin(Ui::PanelAnimation::Origin::TopRight); _menu->setForcedOrigin(Ui::PanelAnimation::Origin::TopRight);
_menu->popup(mapToGlobal(QPoint( _menu->popup(mapToGlobal(QPoint(

View file

@ -1276,12 +1276,15 @@ void SessionController::startOrJoinGroupCall(
const Calls::StartGroupCallArgs &args) { const Calls::StartGroupCallArgs &args) {
using JoinConfirm = Calls::StartGroupCallArgs::JoinConfirm; using JoinConfirm = Calls::StartGroupCallArgs::JoinConfirm;
auto &calls = Core::App().calls(); auto &calls = Core::App().calls();
auto confirmedArgs = args;
confirmedArgs.confirm = JoinConfirm::None;
const auto askConfirmation = [&](QString text, QString button) { const auto askConfirmation = [&](QString text, QString button) {
show(Ui::MakeConfirmBox({ show(Ui::MakeConfirmBox({
.text = text, .text = text,
.confirmed = crl::guard(this,[=, hash = args.joinHash] { .confirmed = crl::guard(this,[=] {
hideLayer(); hideLayer();
startOrJoinGroupCall(peer, { hash, JoinConfirm::None }); startOrJoinGroupCall(peer, confirmedArgs);
}), }),
.confirmText = button, .confirmText = button,
})); }));
@ -1300,10 +1303,7 @@ void SessionController::startOrJoinGroupCall(
if (now == peer) { if (now == peer) {
calls.activateCurrentCall(args.joinHash); calls.activateCurrentCall(args.joinHash);
} else if (calls.currentGroupCall()->scheduleDate()) { } else if (calls.currentGroupCall()->scheduleDate()) {
calls.startOrJoinGroupCall( startOrJoinGroupCall(peer, confirmedArgs);
std::make_shared<Show>(this),
peer,
{args.joinHash});
} else { } else {
askConfirmation( askConfirmation(
((peer->isBroadcast() && now->isBroadcast()) ((peer->isBroadcast() && now->isBroadcast())
@ -1316,7 +1316,7 @@ void SessionController::startOrJoinGroupCall(
tr::lng_group_call_leave(tr::now)); tr::lng_group_call_leave(tr::now));
} }
} else { } else {
calls.startOrJoinGroupCall( calls.showStartOrJoinGroupCall(
std::make_shared<Show>(this), std::make_shared<Show>(this),
peer, peer,
args); args);