From e8f0be80bb540dc7231981ddc45702c9772656bd Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 1 Mar 2022 08:19:00 +0300 Subject: [PATCH] Moved RTMP data to common struct. --- .../calls/group/calls_group_call.cpp | 34 ++++++++----------- .../calls/group/calls_group_call.h | 7 ++-- .../calls/group/calls_group_common.h | 7 +++- .../calls/group/calls_group_panel.cpp | 2 +- .../calls/group/calls_group_rtmp.cpp | 11 +++--- .../calls/group/calls_group_rtmp.h | 12 +++---- .../calls/group/calls_group_settings.cpp | 9 +++-- 7 files changed, 37 insertions(+), 45 deletions(-) diff --git a/Telegram/SourceFiles/calls/group/calls_group_call.cpp b/Telegram/SourceFiles/calls/group/calls_group_call.cpp index 0f9ce5bb1..dd0f151a8 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_call.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_call.cpp @@ -94,8 +94,7 @@ struct JoinVideoEndpoint { struct JoinBroadcastStream { bool rtmp = false; - QString rtmpUrl; - QString rtmpKey; + Group::RtmpInfo rtmpInfo; }; using JoinClientFields = std::variant< @@ -119,8 +118,10 @@ using JoinClientFields = std::variant< if (document.object().value("stream").toBool()) { return JoinBroadcastStream{ .rtmp = document.object().value("rtmp").toBool(), - .rtmpUrl = document.object().value("rtmp_stream_url").toString(), - .rtmpKey = document.object().value("rtmp_stream_key").toString(), + .rtmpInfo = { + .url = document.object().value("rtmp_stream_url").toString(), + .key = document.object().value("rtmp_stream_key").toString(), + }, }; } const auto video = document.object().value("video").toObject(); @@ -582,8 +583,8 @@ GroupCall::GroupCall( , _joinAs(info.joinAs) , _possibleJoinAs(std::move(info.possibleJoinAs)) , _joinHash(info.joinHash) -, _rtmpUrl(info.rtmpUrl) -, _rtmpKey(info.rtmpKey) +, _rtmpUrl(info.rtmpInfo.url) +, _rtmpKey(info.rtmpInfo.key) , _canManage(Data::CanManageGroupCallValue(_peer)) , _id(inputCall.c_inputGroupCall().vid().v) , _scheduleDate(info.scheduleDate) @@ -1028,20 +1029,13 @@ rpl::producer GroupCall::emptyRtmpValue() const { return _emptyRtmp.value(); } -QString GroupCall::rtmpUrl() const { - return _rtmpUrl; +Calls::Group::RtmpInfo GroupCall::rtmpInfo() const { + return { _rtmpUrl, _rtmpKey }; } -QString GroupCall::rtmpKey() const { - return _rtmpKey; -} - -void GroupCall::setRtmpUrl(const QString &value) { - _rtmpUrl = value; -} - -void GroupCall::setRtmpKey(const QString &value) { - _rtmpKey = value; +void GroupCall::setRtmpInfo(const Calls::Group::RtmpInfo &value) { + _rtmpUrl = value.url; + _rtmpKey = value.key; } Data::GroupCall *GroupCall::lookupReal() const { @@ -1889,8 +1883,8 @@ void GroupCall::handlePossibleCreateOrJoinResponse( } if (stream->rtmp) { _rtmp = true; - _rtmpUrl = stream->rtmpUrl; - _rtmpKey = stream->rtmpKey; + _rtmpUrl = stream->rtmpInfo.url; + _rtmpKey = stream->rtmpInfo.key; } setInstanceMode(InstanceMode::Stream); } else { diff --git a/Telegram/SourceFiles/calls/group/calls_group_call.h b/Telegram/SourceFiles/calls/group/calls_group_call.h index cf713265e..15b75e677 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_call.h +++ b/Telegram/SourceFiles/calls/group/calls_group_call.h @@ -48,6 +48,7 @@ struct VolumeRequest; struct ParticipantState; struct JoinInfo; struct RejoinEvent; +struct RtmpInfo; enum class VideoQuality; enum class Error; } // namespace Group @@ -236,11 +237,9 @@ public: [[nodiscard]] bool emptyRtmp() const; [[nodiscard]] rpl::producer emptyRtmpValue() const; - [[nodiscard]] QString rtmpUrl() const; - [[nodiscard]] QString rtmpKey() const; + [[nodiscard]] Group::RtmpInfo rtmpInfo() const; - void setRtmpUrl(const QString &value); - void setRtmpKey(const QString &value); + void setRtmpInfo(const Group::RtmpInfo &value); [[nodiscard]] Data::GroupCall *lookupReal() const; [[nodiscard]] rpl::producer> real() const; diff --git a/Telegram/SourceFiles/calls/group/calls_group_common.h b/Telegram/SourceFiles/calls/group/calls_group_common.h index 8899ebc6a..670378aa7 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_common.h +++ b/Telegram/SourceFiles/calls/group/calls_group_common.h @@ -46,12 +46,17 @@ struct RejoinEvent { not_null nowJoinAs; }; +struct RtmpInfo { + QString url; + QString key; +}; + struct JoinInfo { not_null peer; not_null joinAs; std::vector> possibleJoinAs; QString joinHash; - QString rtmpUrl, rtmpKey; + RtmpInfo rtmpInfo; TimeId scheduleDate = 0; bool rtmp = false; }; diff --git a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp index b044b943c..51deae529 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp @@ -1606,7 +1606,7 @@ void Panel::setupEmptyRtmp() { } else if (_emptyRtmp || _call->hasVideoWithFrames()) { return; } - auto text = _call->rtmpUrl().isEmpty() + auto text = _call->rtmpInfo().url.isEmpty() ? tr::lng_group_call_no_stream( lt_group, rpl::single(_peer->name)) diff --git a/Telegram/SourceFiles/calls/group/calls_group_rtmp.cpp b/Telegram/SourceFiles/calls/group/calls_group_rtmp.cpp index 85b06ef3d..a271c2a4d 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_rtmp.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_rtmp.cpp @@ -42,7 +42,7 @@ void StartWithBox( Fn revoke, Fn)> showBox, Fn showToast, - rpl::producer &&data) { + rpl::producer &&data) { struct State { base::unique_qptr menu; }; @@ -139,7 +139,7 @@ void StartRtmpProcess::requestUrl(bool revoke) { )).done([=](const MTPphone_GroupCallStreamRtmpUrl &result) { auto data = result.match([&]( const MTPDphone_groupCallStreamRtmpUrl &data) { - return Data{ .url = qs(data.vurl()), .key = qs(data.vkey()) }; + return RtmpInfo{ .url = qs(data.vurl()), .key = qs(data.vkey()) }; }); processUrl(std::move(data)); }).fail([=] { @@ -147,7 +147,7 @@ void StartRtmpProcess::requestUrl(bool revoke) { }).send(); } -void StartRtmpProcess::processUrl(Data data) { +void StartRtmpProcess::processUrl(RtmpInfo data) { if (!_request->box) { createBox(); } @@ -159,8 +159,7 @@ void StartRtmpProcess::finish(JoinInfo info) { const auto box = _request->box; const auto current = _request->data.current(); _request = nullptr; - info.rtmpUrl = current.url; - info.rtmpKey = current.key; + info.rtmpInfo = current; done(std::move(info)); if (const auto strong = box.data()) { strong->closeBox(); @@ -204,7 +203,7 @@ void StartRtmpProcess::FillRtmpRows( bool disabledMenuForLabels, Fn)> showBox, Fn showToast, - rpl::producer &&data, + rpl::producer &&data, const style::FlatLabel *labelStyle, const style::IconButton *showButtonStyle, const style::FlatLabel *subsectionTitleStyle, diff --git a/Telegram/SourceFiles/calls/group/calls_group_rtmp.h b/Telegram/SourceFiles/calls/group/calls_group_rtmp.h index 8fb5c91d3..37cb624ce 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_rtmp.h +++ b/Telegram/SourceFiles/calls/group/calls_group_rtmp.h @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/weak_ptr.h" #include "base/object_ptr.h" +#include "calls/group/calls_group_common.h" class PeerData; @@ -32,11 +33,6 @@ public: StartRtmpProcess() = default; ~StartRtmpProcess(); - struct Data { - QString url; - QString key; - }; - void start( not_null peer, Fn)> showBox, @@ -49,7 +45,7 @@ public: bool disabledMenuForLabels, Fn)> showBox, Fn showToast, - rpl::producer &&data, + rpl::producer &&data, const style::FlatLabel *labelStyle, const style::IconButton *showButtonStyle, const style::FlatLabel *subsectionTitleStyle, @@ -57,13 +53,13 @@ public: private: void requestUrl(bool revoke); - void processUrl(Data data); + void processUrl(RtmpInfo data); void createBox(); void finish(JoinInfo info); struct RtmpRequest { not_null peer; - rpl::variable data; + rpl::variable data; Fn)> showBox; Fn showToast; Fn done; diff --git a/Telegram/SourceFiles/calls/group/calls_group_settings.cpp b/Telegram/SourceFiles/calls/group/calls_group_settings.cpp index 5e25bd23a..05a9f5035 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_settings.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_settings.cpp @@ -632,7 +632,7 @@ void SettingsBox( struct State { base::unique_qptr menu; mtpRequestId requestId; - rpl::event_stream data; + rpl::event_stream data; }; const auto top = box->addTopButton(st::groupCallMenuToggle); const auto state = top->lifetime().make_state(); @@ -645,14 +645,13 @@ void SettingsBox( )).done([=](const MTPphone_GroupCallStreamRtmpUrl &result) { auto data = result.match([&]( const MTPDphone_groupCallStreamRtmpUrl &data) { - return StartRtmpProcess::Data{ + return RtmpInfo{ .url = qs(data.vurl()), .key = qs(data.vkey()), }; }); if (const auto call = weakCall.get()) { - call->setRtmpUrl(data.url); - call->setRtmpKey(data.key); + call->setRtmpInfo(data); } if (!top) { return; @@ -711,7 +710,7 @@ void SettingsBox( &st::groupCallSettingsRtmpShowButton, &st::groupCallSubsectionTitle, &st::groupCallAttentionBoxButton); - state->data.fire({ call->rtmpUrl(), call->rtmpKey() }); + state->data.fire(call->rtmpInfo()); } if (peer->canManageGroupCall()) {