mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 07:37:11 +02:00
Moved RTMP data to common struct.
This commit is contained in:
parent
a049a62397
commit
e8f0be80bb
7 changed files with 37 additions and 45 deletions
|
@ -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<bool> 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 {
|
||||
|
|
|
@ -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<bool> 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<not_null<Data::GroupCall*>> real() const;
|
||||
|
|
|
@ -46,12 +46,17 @@ struct RejoinEvent {
|
|||
not_null<PeerData*> nowJoinAs;
|
||||
};
|
||||
|
||||
struct RtmpInfo {
|
||||
QString url;
|
||||
QString key;
|
||||
};
|
||||
|
||||
struct JoinInfo {
|
||||
not_null<PeerData*> peer;
|
||||
not_null<PeerData*> joinAs;
|
||||
std::vector<not_null<PeerData*>> possibleJoinAs;
|
||||
QString joinHash;
|
||||
QString rtmpUrl, rtmpKey;
|
||||
RtmpInfo rtmpInfo;
|
||||
TimeId scheduleDate = 0;
|
||||
bool rtmp = false;
|
||||
};
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -42,7 +42,7 @@ void StartWithBox(
|
|||
Fn<void()> revoke,
|
||||
Fn<void(object_ptr<Ui::BoxContent>)> showBox,
|
||||
Fn<void(QString)> showToast,
|
||||
rpl::producer<StartRtmpProcess::Data> &&data) {
|
||||
rpl::producer<RtmpInfo> &&data) {
|
||||
struct State {
|
||||
base::unique_qptr<Ui::PopupMenu> 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<void(object_ptr<Ui::BoxContent>)> showBox,
|
||||
Fn<void(QString)> showToast,
|
||||
rpl::producer<StartRtmpProcess::Data> &&data,
|
||||
rpl::producer<RtmpInfo> &&data,
|
||||
const style::FlatLabel *labelStyle,
|
||||
const style::IconButton *showButtonStyle,
|
||||
const style::FlatLabel *subsectionTitleStyle,
|
||||
|
|
|
@ -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<PeerData*> peer,
|
||||
Fn<void(object_ptr<Ui::BoxContent>)> showBox,
|
||||
|
@ -49,7 +45,7 @@ public:
|
|||
bool disabledMenuForLabels,
|
||||
Fn<void(object_ptr<Ui::BoxContent>)> showBox,
|
||||
Fn<void(QString)> showToast,
|
||||
rpl::producer<StartRtmpProcess::Data> &&data,
|
||||
rpl::producer<RtmpInfo> &&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<PeerData*> peer;
|
||||
rpl::variable<Data> data;
|
||||
rpl::variable<RtmpInfo> data;
|
||||
Fn<void(object_ptr<Ui::BoxContent>)> showBox;
|
||||
Fn<void(QString)> showToast;
|
||||
Fn<void(JoinInfo)> done;
|
||||
|
|
|
@ -632,7 +632,7 @@ void SettingsBox(
|
|||
struct State {
|
||||
base::unique_qptr<Ui::PopupMenu> menu;
|
||||
mtpRequestId requestId;
|
||||
rpl::event_stream<StartRtmpProcess::Data> data;
|
||||
rpl::event_stream<RtmpInfo> data;
|
||||
};
|
||||
const auto top = box->addTopButton(st::groupCallMenuToggle);
|
||||
const auto state = top->lifetime().make_state<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()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue