Update API scheme on layer 202.

This commit is contained in:
John Preston 2025-04-04 11:18:10 +04:00
parent 502045f1fa
commit a5fa595627
8 changed files with 51 additions and 13 deletions

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "calls/group/calls_group_call.h" #include "calls/group/calls_group_call.h"
#include "calls/group/calls_group_common.h" #include "calls/group/calls_group_common.h"
#include "main/main_app_config.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "api/api_send_progress.h" #include "api/api_send_progress.h"
#include "api/api_updates.h" #include "api/api_updates.h"
@ -756,7 +757,7 @@ void GroupCall::setupConferenceCall() {
_conferenceCall->staleParticipantIds( _conferenceCall->staleParticipantIds(
) | rpl::start_with_next([=](const base::flat_set<UserId> &staleIds) { ) | rpl::start_with_next([=](const base::flat_set<UserId> &staleIds) {
removeConferenceParticipants(staleIds); removeConferenceParticipants(staleIds, true);
}, _lifetime); }, _lifetime);
_e2e->participantsSetValue( _e2e->participantsSetValue(
) | rpl::start_with_next([=](const TdE2E::ParticipantsSet &set) { ) | rpl::start_with_next([=](const TdE2E::ParticipantsSet &set) {
@ -775,7 +776,8 @@ void GroupCall::setupConferenceCall() {
} }
void GroupCall::removeConferenceParticipants( void GroupCall::removeConferenceParticipants(
const base::flat_set<UserId> userIds) { const base::flat_set<UserId> userIds,
bool removingStale) {
Expects(_e2e != nullptr); Expects(_e2e != nullptr);
Expects(!userIds.empty()); Expects(!userIds.empty());
@ -791,7 +793,9 @@ void GroupCall::removeConferenceParticipants(
if (block.data.isEmpty()) { if (block.data.isEmpty()) {
return; return;
} }
using Flag = MTPphone_DeleteConferenceCallParticipants::Flag;
_api.request(MTPphone_DeleteConferenceCallParticipants( _api.request(MTPphone_DeleteConferenceCallParticipants(
MTP_flags(removingStale ? Flag::f_only_left : Flag::f_kick),
inputCall(), inputCall(),
MTP_vector<MTPlong>(std::move(inputs)), MTP_vector<MTPlong>(std::move(inputs)),
MTP_bytes(block.data) MTP_bytes(block.data)
@ -2722,6 +2726,15 @@ void GroupCall::toggleRecording(
}).send(); }).send();
} }
auto GroupCall::lookupVideoCodecPreferences() const
-> std::vector<tgcalls::VideoCodecName> {
auto result = std::vector<tgcalls::VideoCodecName>();
if (_peer->session().appConfig().confcallPrioritizeVP8()) {
result.push_back(tgcalls::VideoCodecName::VP8);
}
return result;
}
bool GroupCall::tryCreateController() { bool GroupCall::tryCreateController() {
if (_instance) { if (_instance) {
return false; return false;
@ -2828,6 +2841,7 @@ bool GroupCall::tryCreateController() {
.videoContentType = tgcalls::VideoContentType::Generic, .videoContentType = tgcalls::VideoContentType::Generic,
.initialEnableNoiseSuppression .initialEnableNoiseSuppression
= settings.groupCallNoiseSuppression(), = settings.groupCallNoiseSuppression(),
.videoCodecPreferences = lookupVideoCodecPreferences(),
.requestMediaChannelDescriptions = [=, call = base::make_weak(this)]( .requestMediaChannelDescriptions = [=, call = base::make_weak(this)](
const std::vector<uint32_t> &ssrcs, const std::vector<uint32_t> &ssrcs,
std::function<void( std::function<void(
@ -2893,6 +2907,7 @@ bool GroupCall::tryCreateScreencast() {
.createAudioDeviceModule = Webrtc::LoopbackAudioDeviceModuleCreator(), .createAudioDeviceModule = Webrtc::LoopbackAudioDeviceModuleCreator(),
.videoCapture = _screenCapture, .videoCapture = _screenCapture,
.videoContentType = tgcalls::VideoContentType::Screencast, .videoContentType = tgcalls::VideoContentType::Screencast,
.videoCodecPreferences = lookupVideoCodecPreferences(),
.e2eEncryptDecrypt = _e2e ? _e2e->callbackEncryptDecrypt() : nullptr, .e2eEncryptDecrypt = _e2e ? _e2e->callbackEncryptDecrypt() : nullptr,
}; };
@ -3023,6 +3038,7 @@ bool GroupCall::mediaChannelDescriptionsFill(
add(Channel{ add(Channel{
.type = Channel::Type::Audio, .type = Channel::Type::Audio,
.audioSsrc = ssrc, .audioSsrc = ssrc,
.userId = int64_t(peerToUser(byAudio->id).bare),
}); });
} else if (!resolved) { } else if (!resolved) {
_unresolvedSsrcs.emplace(ssrc); _unresolvedSsrcs.emplace(ssrc);
@ -3155,6 +3171,7 @@ void GroupCall::updateRequestedVideoChannels() {
} }
channels.push_back({ channels.push_back({
.audioSsrc = participant->ssrc, .audioSsrc = participant->ssrc,
.userId = int64_t(peerToUser(participant->peer->id).bare),
.endpointId = endpointId, .endpointId = endpointId,
.ssrcGroups = (params->camera.endpointId == endpointId .ssrcGroups = (params->camera.endpointId == endpointId
? params->camera.ssrcGroups ? params->camera.ssrcGroups

View file

@ -23,6 +23,7 @@ struct GroupLevelsUpdate;
struct GroupNetworkState; struct GroupNetworkState;
struct GroupParticipantDescription; struct GroupParticipantDescription;
class VideoCaptureInterface; class VideoCaptureInterface;
enum class VideoCodecName;
} // namespace tgcalls } // namespace tgcalls
namespace base { namespace base {
@ -285,7 +286,9 @@ public:
void startScheduledNow(); void startScheduledNow();
void toggleScheduleStartSubscribed(bool subscribed); void toggleScheduleStartSubscribed(bool subscribed);
void setNoiseSuppression(bool enabled); void setNoiseSuppression(bool enabled);
void removeConferenceParticipants(const base::flat_set<UserId> userIds); void removeConferenceParticipants(
const base::flat_set<UserId> userIds,
bool removingStale = false);
bool emitShareScreenError(); bool emitShareScreenError();
bool emitShareCameraError(); bool emitShareCameraError();
@ -533,6 +536,8 @@ private:
int subchain, int subchain,
const QVector<MTPbytes> &blocks, const QVector<MTPbytes> &blocks,
int next); int next);
[[nodiscard]] auto lookupVideoCodecPreferences() const
-> std::vector<tgcalls::VideoCodecName>;
bool tryCreateController(); bool tryCreateController();
void destroyController(); void destroyController();
bool tryCreateScreencast(); bool tryCreateScreencast();

View file

@ -108,6 +108,11 @@ int AppConfig::pinnedGiftsLimit() const {
return get<int>(u"stargifts_pinned_to_top_limit"_q, 6); return get<int>(u"stargifts_pinned_to_top_limit"_q, 6);
} }
bool AppConfig::confcallPrioritizeVP8() const {
AssertIsDebug();
return true;
}
void AppConfig::refresh(bool force) { void AppConfig::refresh(bool force) {
if (_requestId || !_api) { if (_requestId || !_api) {
if (force) { if (force) {

View file

@ -79,6 +79,8 @@ public:
[[nodiscard]] int pinnedGiftsLimit() const; [[nodiscard]] int pinnedGiftsLimit() const;
[[nodiscard]] bool confcallPrioritizeVP8() const;
void refresh(bool force = false); void refresh(bool force = false);
private: private:

View file

@ -961,7 +961,7 @@ phoneCallEmpty#5366c915 id:long = PhoneCall;
phoneCallWaiting#c5226f17 flags:# video:flags.6?true id:long access_hash:long date:int admin_id:long participant_id:long protocol:PhoneCallProtocol receive_date:flags.0?int = PhoneCall; phoneCallWaiting#c5226f17 flags:# video:flags.6?true id:long access_hash:long date:int admin_id:long participant_id:long protocol:PhoneCallProtocol receive_date:flags.0?int = PhoneCall;
phoneCallRequested#14b0ed0c flags:# video:flags.6?true id:long access_hash:long date:int admin_id:long participant_id:long g_a_hash:bytes protocol:PhoneCallProtocol = PhoneCall; phoneCallRequested#14b0ed0c flags:# video:flags.6?true id:long access_hash:long date:int admin_id:long participant_id:long g_a_hash:bytes protocol:PhoneCallProtocol = PhoneCall;
phoneCallAccepted#3660c311 flags:# video:flags.6?true id:long access_hash:long date:int admin_id:long participant_id:long g_b:bytes protocol:PhoneCallProtocol = PhoneCall; phoneCallAccepted#3660c311 flags:# video:flags.6?true id:long access_hash:long date:int admin_id:long participant_id:long g_b:bytes protocol:PhoneCallProtocol = PhoneCall;
phoneCall#30535af5 flags:# p2p_allowed:flags.5?true video:flags.6?true id:long access_hash:long date:int admin_id:long participant_id:long g_a_or_b:bytes key_fingerprint:long protocol:PhoneCallProtocol connections:Vector<PhoneConnection> start_date:int custom_parameters:flags.7?DataJSON = PhoneCall; phoneCall#30535af5 flags:# p2p_allowed:flags.5?true video:flags.6?true conference_supported:flags.8?true id:long access_hash:long date:int admin_id:long participant_id:long g_a_or_b:bytes key_fingerprint:long protocol:PhoneCallProtocol connections:Vector<PhoneConnection> start_date:int custom_parameters:flags.7?DataJSON = PhoneCall;
phoneCallDiscarded#50ca4de1 flags:# need_rating:flags.2?true need_debug:flags.3?true video:flags.6?true id:long reason:flags.0?PhoneCallDiscardReason duration:flags.1?int = PhoneCall; phoneCallDiscarded#50ca4de1 flags:# need_rating:flags.2?true need_debug:flags.3?true video:flags.6?true id:long reason:flags.0?PhoneCallDiscardReason duration:flags.1?int = PhoneCall;
phoneConnection#9cc123c7 flags:# tcp:flags.0?true id:long ip:string ipv6:string port:int peer_tag:bytes = PhoneConnection; phoneConnection#9cc123c7 flags:# tcp:flags.0?true id:long ip:string ipv6:string port:int peer_tag:bytes = PhoneConnection;
@ -2609,7 +2609,7 @@ phone.getGroupCallStreamChannels#1ab21940 call:InputGroupCall = phone.GroupCallS
phone.getGroupCallStreamRtmpUrl#deb3abbf peer:InputPeer revoke:Bool = phone.GroupCallStreamRtmpUrl; phone.getGroupCallStreamRtmpUrl#deb3abbf peer:InputPeer revoke:Bool = phone.GroupCallStreamRtmpUrl;
phone.saveCallLog#41248786 peer:InputPhoneCall file:InputFile = Bool; phone.saveCallLog#41248786 peer:InputPhoneCall file:InputFile = Bool;
phone.createConferenceCall#fbcefee6 random_id:int = phone.GroupCall; phone.createConferenceCall#fbcefee6 random_id:int = phone.GroupCall;
phone.deleteConferenceCallParticipants#f9231114 call:InputGroupCall ids:Vector<long> block:bytes = Updates; phone.deleteConferenceCallParticipants#8ca60525 flags:# only_left:flags.0?true kick:flags.1?true call:InputGroupCall ids:Vector<long> block:bytes = Updates;
phone.sendConferenceCallBroadcast#c6701900 call:InputGroupCall block:bytes = Updates; phone.sendConferenceCallBroadcast#c6701900 call:InputGroupCall block:bytes = Updates;
phone.inviteConferenceCallParticipant#bcf22685 flags:# video:flags.0?true call:InputGroupCall user_id:InputUser = Updates; phone.inviteConferenceCallParticipant#bcf22685 flags:# video:flags.0?true call:InputGroupCall user_id:InputUser = Updates;
phone.declineConferenceCallInvite#3c479971 msg_id:int = Updates; phone.declineConferenceCallInvite#3c479971 msg_id:int = Updates;

View file

@ -239,6 +239,7 @@ void Call::apply(int subchain, const Block &last) {
} }
LOG_APPLY(-1, Slice(last.data)); LOG_APPLY(-1, Slice(last.data));
const auto id = tde2e_api::call_create( const auto id = tde2e_api::call_create(
std::int64_t(_myUserId.v),
std::int64_t(_myKeyId.v), std::int64_t(_myKeyId.v),
Slice(last.data)); Slice(last.data));
if (!id.is_ok()) { if (!id.is_ok()) {
@ -446,7 +447,7 @@ rpl::producer<QByteArray> Call::emojiHashValue() const {
} }
auto Call::callbackEncryptDecrypt() auto Call::callbackEncryptDecrypt()
-> Fn<std::vector<uint8_t>(const std::vector<uint8_t>&, bool)> { -> Fn<std::vector<uint8_t>(const std::vector<uint8_t>&, int64_t, bool)> {
if (!_guardedId) { if (!_guardedId) {
_guardedId = std::make_shared<GuardedCallId>(); _guardedId = std::make_shared<GuardedCallId>();
if (const auto raw = _id ? _guardedId.get() : nullptr) { if (const auto raw = _id ? _guardedId.get() : nullptr) {
@ -454,15 +455,20 @@ auto Call::callbackEncryptDecrypt()
raw->exists = true; raw->exists = true;
} }
} }
return [v = _guardedId](const std::vector<uint8_t> &data, bool encrypt) { return [id = _guardedId](
if (!v->exists) { const std::vector<uint8_t> &data,
int64_t userId,
bool encrypt) {
const auto raw = id.get();
if (!raw->exists) {
return std::vector<uint8_t>(); return std::vector<uint8_t>();
} }
const auto libId = std::int64_t(v->value.v); const auto libId = std::int64_t(raw->value.v);
const auto channelId = tde2e_api::CallChannelId(0);
const auto slice = Slice(data); const auto slice = Slice(data);
const auto result = encrypt const auto result = encrypt
? tde2e_api::call_encrypt(libId, slice) ? tde2e_api::call_encrypt(libId, channelId, slice)
: tde2e_api::call_decrypt(libId, slice); : tde2e_api::call_decrypt(libId, userId, channelId, slice);
if (!result.is_ok()) { if (!result.is_ok()) {
return std::vector<uint8_t>(); return std::vector<uint8_t>();
} }

View file

@ -102,7 +102,10 @@ public:
[[nodiscard]] rpl::producer<ParticipantsSet> participantsSetValue() const; [[nodiscard]] rpl::producer<ParticipantsSet> participantsSetValue() const;
[[nodiscard]] auto callbackEncryptDecrypt() [[nodiscard]] auto callbackEncryptDecrypt()
-> Fn<std::vector<uint8_t>(const std::vector<uint8_t>&, bool)>; -> Fn<std::vector<uint8_t>(
const std::vector<uint8_t>&,
int64_t,
bool)>;
private: private:
static constexpr int kSubChainsCount = 2; static constexpr int kSubChainsCount = 2;

@ -1 +1 @@
Subproject commit 4c2c1104b2c9a13651f4290512daf5bb2e42ac50 Subproject commit fd1cfbd8151b2c32d5471a4f5431faa6274ce421