Moved RTMP data to common struct.

This commit is contained in:
23rd 2022-03-01 08:19:00 +03:00
parent a049a62397
commit e8f0be80bb
7 changed files with 37 additions and 45 deletions

View file

@ -94,8 +94,7 @@ struct JoinVideoEndpoint {
struct JoinBroadcastStream { struct JoinBroadcastStream {
bool rtmp = false; bool rtmp = false;
QString rtmpUrl; Group::RtmpInfo rtmpInfo;
QString rtmpKey;
}; };
using JoinClientFields = std::variant< using JoinClientFields = std::variant<
@ -119,8 +118,10 @@ using JoinClientFields = std::variant<
if (document.object().value("stream").toBool()) { if (document.object().value("stream").toBool()) {
return JoinBroadcastStream{ return JoinBroadcastStream{
.rtmp = document.object().value("rtmp").toBool(), .rtmp = document.object().value("rtmp").toBool(),
.rtmpUrl = document.object().value("rtmp_stream_url").toString(), .rtmpInfo = {
.rtmpKey = document.object().value("rtmp_stream_key").toString(), .url = document.object().value("rtmp_stream_url").toString(),
.key = document.object().value("rtmp_stream_key").toString(),
},
}; };
} }
const auto video = document.object().value("video").toObject(); const auto video = document.object().value("video").toObject();
@ -582,8 +583,8 @@ GroupCall::GroupCall(
, _joinAs(info.joinAs) , _joinAs(info.joinAs)
, _possibleJoinAs(std::move(info.possibleJoinAs)) , _possibleJoinAs(std::move(info.possibleJoinAs))
, _joinHash(info.joinHash) , _joinHash(info.joinHash)
, _rtmpUrl(info.rtmpUrl) , _rtmpUrl(info.rtmpInfo.url)
, _rtmpKey(info.rtmpKey) , _rtmpKey(info.rtmpInfo.key)
, _canManage(Data::CanManageGroupCallValue(_peer)) , _canManage(Data::CanManageGroupCallValue(_peer))
, _id(inputCall.c_inputGroupCall().vid().v) , _id(inputCall.c_inputGroupCall().vid().v)
, _scheduleDate(info.scheduleDate) , _scheduleDate(info.scheduleDate)
@ -1028,20 +1029,13 @@ rpl::producer<bool> GroupCall::emptyRtmpValue() const {
return _emptyRtmp.value(); return _emptyRtmp.value();
} }
QString GroupCall::rtmpUrl() const { Calls::Group::RtmpInfo GroupCall::rtmpInfo() const {
return _rtmpUrl; return { _rtmpUrl, _rtmpKey };
} }
QString GroupCall::rtmpKey() const { void GroupCall::setRtmpInfo(const Calls::Group::RtmpInfo &value) {
return _rtmpKey; _rtmpUrl = value.url;
} _rtmpKey = value.key;
void GroupCall::setRtmpUrl(const QString &value) {
_rtmpUrl = value;
}
void GroupCall::setRtmpKey(const QString &value) {
_rtmpKey = value;
} }
Data::GroupCall *GroupCall::lookupReal() const { Data::GroupCall *GroupCall::lookupReal() const {
@ -1889,8 +1883,8 @@ void GroupCall::handlePossibleCreateOrJoinResponse(
} }
if (stream->rtmp) { if (stream->rtmp) {
_rtmp = true; _rtmp = true;
_rtmpUrl = stream->rtmpUrl; _rtmpUrl = stream->rtmpInfo.url;
_rtmpKey = stream->rtmpKey; _rtmpKey = stream->rtmpInfo.key;
} }
setInstanceMode(InstanceMode::Stream); setInstanceMode(InstanceMode::Stream);
} else { } else {

View file

@ -48,6 +48,7 @@ struct VolumeRequest;
struct ParticipantState; struct ParticipantState;
struct JoinInfo; struct JoinInfo;
struct RejoinEvent; struct RejoinEvent;
struct RtmpInfo;
enum class VideoQuality; enum class VideoQuality;
enum class Error; enum class Error;
} // namespace Group } // namespace Group
@ -236,11 +237,9 @@ public:
[[nodiscard]] bool emptyRtmp() const; [[nodiscard]] bool emptyRtmp() const;
[[nodiscard]] rpl::producer<bool> emptyRtmpValue() const; [[nodiscard]] rpl::producer<bool> emptyRtmpValue() const;
[[nodiscard]] QString rtmpUrl() const; [[nodiscard]] Group::RtmpInfo rtmpInfo() const;
[[nodiscard]] QString rtmpKey() const;
void setRtmpUrl(const QString &value); void setRtmpInfo(const Group::RtmpInfo &value);
void setRtmpKey(const QString &value);
[[nodiscard]] Data::GroupCall *lookupReal() const; [[nodiscard]] Data::GroupCall *lookupReal() const;
[[nodiscard]] rpl::producer<not_null<Data::GroupCall*>> real() const; [[nodiscard]] rpl::producer<not_null<Data::GroupCall*>> real() const;

View file

@ -46,12 +46,17 @@ struct RejoinEvent {
not_null<PeerData*> nowJoinAs; not_null<PeerData*> nowJoinAs;
}; };
struct RtmpInfo {
QString url;
QString key;
};
struct JoinInfo { struct JoinInfo {
not_null<PeerData*> peer; not_null<PeerData*> peer;
not_null<PeerData*> joinAs; not_null<PeerData*> joinAs;
std::vector<not_null<PeerData*>> possibleJoinAs; std::vector<not_null<PeerData*>> possibleJoinAs;
QString joinHash; QString joinHash;
QString rtmpUrl, rtmpKey; RtmpInfo rtmpInfo;
TimeId scheduleDate = 0; TimeId scheduleDate = 0;
bool rtmp = false; bool rtmp = false;
}; };

View file

@ -1606,7 +1606,7 @@ void Panel::setupEmptyRtmp() {
} else if (_emptyRtmp || _call->hasVideoWithFrames()) { } else if (_emptyRtmp || _call->hasVideoWithFrames()) {
return; return;
} }
auto text = _call->rtmpUrl().isEmpty() auto text = _call->rtmpInfo().url.isEmpty()
? tr::lng_group_call_no_stream( ? tr::lng_group_call_no_stream(
lt_group, lt_group,
rpl::single(_peer->name)) rpl::single(_peer->name))

View file

@ -42,7 +42,7 @@ void StartWithBox(
Fn<void()> revoke, Fn<void()> revoke,
Fn<void(object_ptr<Ui::BoxContent>)> showBox, Fn<void(object_ptr<Ui::BoxContent>)> showBox,
Fn<void(QString)> showToast, Fn<void(QString)> showToast,
rpl::producer<StartRtmpProcess::Data> &&data) { rpl::producer<RtmpInfo> &&data) {
struct State { struct State {
base::unique_qptr<Ui::PopupMenu> menu; base::unique_qptr<Ui::PopupMenu> menu;
}; };
@ -139,7 +139,7 @@ void StartRtmpProcess::requestUrl(bool revoke) {
)).done([=](const MTPphone_GroupCallStreamRtmpUrl &result) { )).done([=](const MTPphone_GroupCallStreamRtmpUrl &result) {
auto data = result.match([&]( auto data = result.match([&](
const MTPDphone_groupCallStreamRtmpUrl &data) { 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)); processUrl(std::move(data));
}).fail([=] { }).fail([=] {
@ -147,7 +147,7 @@ void StartRtmpProcess::requestUrl(bool revoke) {
}).send(); }).send();
} }
void StartRtmpProcess::processUrl(Data data) { void StartRtmpProcess::processUrl(RtmpInfo data) {
if (!_request->box) { if (!_request->box) {
createBox(); createBox();
} }
@ -159,8 +159,7 @@ void StartRtmpProcess::finish(JoinInfo info) {
const auto box = _request->box; const auto box = _request->box;
const auto current = _request->data.current(); const auto current = _request->data.current();
_request = nullptr; _request = nullptr;
info.rtmpUrl = current.url; info.rtmpInfo = current;
info.rtmpKey = current.key;
done(std::move(info)); done(std::move(info));
if (const auto strong = box.data()) { if (const auto strong = box.data()) {
strong->closeBox(); strong->closeBox();
@ -204,7 +203,7 @@ void StartRtmpProcess::FillRtmpRows(
bool disabledMenuForLabels, bool disabledMenuForLabels,
Fn<void(object_ptr<Ui::BoxContent>)> showBox, Fn<void(object_ptr<Ui::BoxContent>)> showBox,
Fn<void(QString)> showToast, Fn<void(QString)> showToast,
rpl::producer<StartRtmpProcess::Data> &&data, rpl::producer<RtmpInfo> &&data,
const style::FlatLabel *labelStyle, const style::FlatLabel *labelStyle,
const style::IconButton *showButtonStyle, const style::IconButton *showButtonStyle,
const style::FlatLabel *subsectionTitleStyle, const style::FlatLabel *subsectionTitleStyle,

View file

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/weak_ptr.h" #include "base/weak_ptr.h"
#include "base/object_ptr.h" #include "base/object_ptr.h"
#include "calls/group/calls_group_common.h"
class PeerData; class PeerData;
@ -32,11 +33,6 @@ public:
StartRtmpProcess() = default; StartRtmpProcess() = default;
~StartRtmpProcess(); ~StartRtmpProcess();
struct Data {
QString url;
QString key;
};
void start( void start(
not_null<PeerData*> peer, not_null<PeerData*> peer,
Fn<void(object_ptr<Ui::BoxContent>)> showBox, Fn<void(object_ptr<Ui::BoxContent>)> showBox,
@ -49,7 +45,7 @@ public:
bool disabledMenuForLabels, bool disabledMenuForLabels,
Fn<void(object_ptr<Ui::BoxContent>)> showBox, Fn<void(object_ptr<Ui::BoxContent>)> showBox,
Fn<void(QString)> showToast, Fn<void(QString)> showToast,
rpl::producer<StartRtmpProcess::Data> &&data, rpl::producer<RtmpInfo> &&data,
const style::FlatLabel *labelStyle, const style::FlatLabel *labelStyle,
const style::IconButton *showButtonStyle, const style::IconButton *showButtonStyle,
const style::FlatLabel *subsectionTitleStyle, const style::FlatLabel *subsectionTitleStyle,
@ -57,13 +53,13 @@ public:
private: private:
void requestUrl(bool revoke); void requestUrl(bool revoke);
void processUrl(Data data); void processUrl(RtmpInfo data);
void createBox(); void createBox();
void finish(JoinInfo info); void finish(JoinInfo info);
struct RtmpRequest { struct RtmpRequest {
not_null<PeerData*> peer; not_null<PeerData*> peer;
rpl::variable<Data> data; rpl::variable<RtmpInfo> data;
Fn<void(object_ptr<Ui::BoxContent>)> showBox; Fn<void(object_ptr<Ui::BoxContent>)> showBox;
Fn<void(QString)> showToast; Fn<void(QString)> showToast;
Fn<void(JoinInfo)> done; Fn<void(JoinInfo)> done;

View file

@ -632,7 +632,7 @@ void SettingsBox(
struct State { struct State {
base::unique_qptr<Ui::PopupMenu> menu; base::unique_qptr<Ui::PopupMenu> menu;
mtpRequestId requestId; mtpRequestId requestId;
rpl::event_stream<StartRtmpProcess::Data> data; rpl::event_stream<RtmpInfo> data;
}; };
const auto top = box->addTopButton(st::groupCallMenuToggle); const auto top = box->addTopButton(st::groupCallMenuToggle);
const auto state = top->lifetime().make_state<State>(); const auto state = top->lifetime().make_state<State>();
@ -645,14 +645,13 @@ void SettingsBox(
)).done([=](const MTPphone_GroupCallStreamRtmpUrl &result) { )).done([=](const MTPphone_GroupCallStreamRtmpUrl &result) {
auto data = result.match([&]( auto data = result.match([&](
const MTPDphone_groupCallStreamRtmpUrl &data) { const MTPDphone_groupCallStreamRtmpUrl &data) {
return StartRtmpProcess::Data{ return RtmpInfo{
.url = qs(data.vurl()), .url = qs(data.vurl()),
.key = qs(data.vkey()), .key = qs(data.vkey()),
}; };
}); });
if (const auto call = weakCall.get()) { if (const auto call = weakCall.get()) {
call->setRtmpUrl(data.url); call->setRtmpInfo(data);
call->setRtmpKey(data.key);
} }
if (!top) { if (!top) {
return; return;
@ -711,7 +710,7 @@ void SettingsBox(
&st::groupCallSettingsRtmpShowButton, &st::groupCallSettingsRtmpShowButton,
&st::groupCallSubsectionTitle, &st::groupCallSubsectionTitle,
&st::groupCallAttentionBoxButton); &st::groupCallAttentionBoxButton);
state->data.fire({ call->rtmpUrl(), call->rtmpKey() }); state->data.fire(call->rtmpInfo());
} }
if (peer->canManageGroupCall()) { if (peer->canManageGroupCall()) {