mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Update tgcalls to use ffmpeg instead of opusfile.
This commit is contained in:
parent
361e3565d4
commit
5bea88fd66
3 changed files with 48 additions and 22 deletions
|
@ -74,11 +74,15 @@ class GroupCall::LoadPartTask final : public tgcalls::BroadcastPartTask {
|
||||||
public:
|
public:
|
||||||
LoadPartTask(
|
LoadPartTask(
|
||||||
base::weak_ptr<GroupCall> call,
|
base::weak_ptr<GroupCall> call,
|
||||||
TimeId date,
|
int64 time,
|
||||||
|
int64 period,
|
||||||
Fn<void(tgcalls::BroadcastPart&&)> done);
|
Fn<void(tgcalls::BroadcastPart&&)> done);
|
||||||
|
|
||||||
[[nodiscard]] TimeId date() const {
|
[[nodiscard]] int64 time() const {
|
||||||
return _date;
|
return _time;
|
||||||
|
}
|
||||||
|
[[nodiscard]] int32 scale() const {
|
||||||
|
return _scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void done(tgcalls::BroadcastPart &&part);
|
void done(tgcalls::BroadcastPart &&part);
|
||||||
|
@ -86,7 +90,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const base::weak_ptr<GroupCall> _call;
|
const base::weak_ptr<GroupCall> _call;
|
||||||
const TimeId _date = 0;
|
const int64 _time = 0;
|
||||||
|
const int32 _scale = 0;
|
||||||
Fn<void(tgcalls::BroadcastPart &&)> _done;
|
Fn<void(tgcalls::BroadcastPart &&)> _done;
|
||||||
QMutex _mutex;
|
QMutex _mutex;
|
||||||
|
|
||||||
|
@ -120,10 +125,20 @@ private:
|
||||||
|
|
||||||
GroupCall::LoadPartTask::LoadPartTask(
|
GroupCall::LoadPartTask::LoadPartTask(
|
||||||
base::weak_ptr<GroupCall> call,
|
base::weak_ptr<GroupCall> call,
|
||||||
TimeId date,
|
int64 time,
|
||||||
|
int64 period,
|
||||||
Fn<void(tgcalls::BroadcastPart &&)> done)
|
Fn<void(tgcalls::BroadcastPart &&)> done)
|
||||||
: _call(std::move(call))
|
: _call(std::move(call))
|
||||||
, _date(date ? date : base::unixtime::now())
|
, _time(time ? time : (base::unixtime::now() * int64(1000)))
|
||||||
|
, _scale([&] {
|
||||||
|
switch (period) {
|
||||||
|
case 1000: return 0;
|
||||||
|
case 500: return 1;
|
||||||
|
case 250: return 2;
|
||||||
|
case 125: return 3;
|
||||||
|
}
|
||||||
|
Unexpected("Period in LoadPartTask.");
|
||||||
|
}())
|
||||||
, _done(std::move(done)) {
|
, _done(std::move(done)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -901,11 +916,13 @@ void GroupCall::ensureControllerCreated() {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
.requestBroadcastPart = [=](
|
.requestBroadcastPart = [=](
|
||||||
int32_t date,
|
int64_t time,
|
||||||
|
int64_t period,
|
||||||
std::function<void(tgcalls::BroadcastPart &&)> done) {
|
std::function<void(tgcalls::BroadcastPart &&)> done) {
|
||||||
auto result = std::make_shared<LoadPartTask>(
|
auto result = std::make_shared<LoadPartTask>(
|
||||||
weak,
|
weak,
|
||||||
date,
|
time,
|
||||||
|
period,
|
||||||
std::move(done));
|
std::move(done));
|
||||||
crl::on_main(weak, [=]() mutable {
|
crl::on_main(weak, [=]() mutable {
|
||||||
broadcastPartStart(std::move(result));
|
broadcastPartStart(std::move(result));
|
||||||
|
@ -940,7 +957,8 @@ void GroupCall::ensureControllerCreated() {
|
||||||
|
|
||||||
void GroupCall::broadcastPartStart(std::shared_ptr<LoadPartTask> task) {
|
void GroupCall::broadcastPartStart(std::shared_ptr<LoadPartTask> task) {
|
||||||
const auto raw = task.get();
|
const auto raw = task.get();
|
||||||
const auto date = raw->date();
|
const auto time = raw->time();
|
||||||
|
const auto scale = raw->scale();
|
||||||
const auto finish = [=](tgcalls::BroadcastPart &&part) {
|
const auto finish = [=](tgcalls::BroadcastPart &&part) {
|
||||||
raw->done(std::move(part));
|
raw->done(std::move(part));
|
||||||
_broadcastParts.erase(raw);
|
_broadcastParts.erase(raw);
|
||||||
|
@ -950,8 +968,8 @@ void GroupCall::broadcastPartStart(std::shared_ptr<LoadPartTask> task) {
|
||||||
MTP_flags(0),
|
MTP_flags(0),
|
||||||
MTP_inputGroupCallStream(
|
MTP_inputGroupCallStream(
|
||||||
inputCall(),
|
inputCall(),
|
||||||
MTP_long(uint64(date) * 1000),
|
MTP_long(time),
|
||||||
MTP_int(0)),
|
MTP_int(scale)),
|
||||||
MTP_int(0),
|
MTP_int(0),
|
||||||
MTP_int(128 * 1024)
|
MTP_int(128 * 1024)
|
||||||
)).done([=](const MTPupload_File &result) {
|
)).done([=](const MTPupload_File &result) {
|
||||||
|
@ -960,26 +978,34 @@ void GroupCall::broadcastPartStart(std::shared_ptr<LoadPartTask> task) {
|
||||||
auto bytes = std::vector<uint8_t>(size);
|
auto bytes = std::vector<uint8_t>(size);
|
||||||
memcpy(bytes.data(), data.vbytes().v.constData(), size);
|
memcpy(bytes.data(), data.vbytes().v.constData(), size);
|
||||||
finish({
|
finish({
|
||||||
.timestamp = date,
|
.timestampMilliseconds = time,
|
||||||
.responseTimestamp = date + 1., // #TODO calls extract from mtproto
|
.responseTimestamp = (time / 1000.) + 1., // #TODO calls extract from mtproto
|
||||||
.status = Status::Success,
|
.status = Status::Success,
|
||||||
.oggData = std::move(bytes),
|
.oggData = std::move(bytes),
|
||||||
});
|
});
|
||||||
}, [&](const MTPDupload_fileCdnRedirect &data) {
|
}, [&](const MTPDupload_fileCdnRedirect &data) {
|
||||||
LOG(("Voice Chat Stream Error: fileCdnRedirect received."));
|
LOG(("Voice Chat Stream Error: fileCdnRedirect received."));
|
||||||
finish({
|
finish({
|
||||||
.timestamp = date,
|
.timestampMilliseconds = time,
|
||||||
.responseTimestamp = date + 1., // #TODO calls extract from mtproto
|
.responseTimestamp = (time / 1000.) + 1., // #TODO calls extract from mtproto
|
||||||
.status = Status::TooOld,
|
.status = Status::ResyncNeeded,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).fail([=](const RPCError &error) {
|
}).fail([=](const RPCError &error) {
|
||||||
const auto status = MTP::isTemporaryError(error)
|
if (error.type() == u"GROUPCALL_JOIN_MISSING"_q) {
|
||||||
|
for (const auto &[task, part] : _broadcastParts) {
|
||||||
|
_api.request(part.requestId).cancel();
|
||||||
|
}
|
||||||
|
setState(State::Joining);
|
||||||
|
rejoin();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto status = MTP::isFloodError(error)
|
||||||
? Status::NotReady
|
? Status::NotReady
|
||||||
: Status::TooOld;
|
: Status::ResyncNeeded;
|
||||||
finish({
|
finish({
|
||||||
.timestamp = date,
|
.timestampMilliseconds = time,
|
||||||
.responseTimestamp = date + 1., // #TODO calls extract from mtproto
|
.responseTimestamp = (time / 1000.) + 1., // #TODO calls extract from mtproto
|
||||||
.status = status,
|
.status = status,
|
||||||
});
|
});
|
||||||
}).handleAllErrors().toDC(
|
}).handleAllErrors().toDC(
|
||||||
|
|
2
Telegram/ThirdParty/tgcalls
vendored
2
Telegram/ThirdParty/tgcalls
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 71addf5b41cb6bb6844f75e977edae0020938930
|
Subproject commit c3c3473f0f0373ff417675c8825a3b091649e563
|
|
@ -125,7 +125,7 @@ PRIVATE
|
||||||
target_link_libraries(lib_tgcalls
|
target_link_libraries(lib_tgcalls
|
||||||
PRIVATE
|
PRIVATE
|
||||||
desktop-app::external_webrtc
|
desktop-app::external_webrtc
|
||||||
desktop-app::external_opus
|
desktop-app::external_ffmpeg
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_definitions(lib_tgcalls
|
target_compile_definitions(lib_tgcalls
|
||||||
|
|
Loading…
Add table
Reference in a new issue