diff --git a/Telegram/SourceFiles/calls/group/calls_group_call.cpp b/Telegram/SourceFiles/calls/group/calls_group_call.cpp index 4a151422c8..dc9d1f6af3 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_call.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_call.cpp @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "calls/group/calls_group_call.h" #include "calls/group/calls_group_common.h" +#include "main/main_app_config.h" #include "main/main_session.h" #include "api/api_send_progress.h" #include "api/api_updates.h" @@ -756,7 +757,7 @@ void GroupCall::setupConferenceCall() { _conferenceCall->staleParticipantIds( ) | rpl::start_with_next([=](const base::flat_set &staleIds) { - removeConferenceParticipants(staleIds); + removeConferenceParticipants(staleIds, true); }, _lifetime); _e2e->participantsSetValue( ) | rpl::start_with_next([=](const TdE2E::ParticipantsSet &set) { @@ -775,7 +776,8 @@ void GroupCall::setupConferenceCall() { } void GroupCall::removeConferenceParticipants( - const base::flat_set userIds) { + const base::flat_set userIds, + bool removingStale) { Expects(_e2e != nullptr); Expects(!userIds.empty()); @@ -791,7 +793,9 @@ void GroupCall::removeConferenceParticipants( if (block.data.isEmpty()) { return; } + using Flag = MTPphone_DeleteConferenceCallParticipants::Flag; _api.request(MTPphone_DeleteConferenceCallParticipants( + MTP_flags(removingStale ? Flag::f_only_left : Flag::f_kick), inputCall(), MTP_vector(std::move(inputs)), MTP_bytes(block.data) @@ -2722,6 +2726,15 @@ void GroupCall::toggleRecording( }).send(); } +auto GroupCall::lookupVideoCodecPreferences() const +-> std::vector { + auto result = std::vector(); + if (_peer->session().appConfig().confcallPrioritizeVP8()) { + result.push_back(tgcalls::VideoCodecName::VP8); + } + return result; +} + bool GroupCall::tryCreateController() { if (_instance) { return false; @@ -2828,6 +2841,7 @@ bool GroupCall::tryCreateController() { .videoContentType = tgcalls::VideoContentType::Generic, .initialEnableNoiseSuppression = settings.groupCallNoiseSuppression(), + .videoCodecPreferences = lookupVideoCodecPreferences(), .requestMediaChannelDescriptions = [=, call = base::make_weak(this)]( const std::vector &ssrcs, std::functioncallbackEncryptDecrypt() : nullptr, }; @@ -3023,6 +3038,7 @@ bool GroupCall::mediaChannelDescriptionsFill( add(Channel{ .type = Channel::Type::Audio, .audioSsrc = ssrc, + .userId = int64_t(peerToUser(byAudio->id).bare), }); } else if (!resolved) { _unresolvedSsrcs.emplace(ssrc); @@ -3155,6 +3171,7 @@ void GroupCall::updateRequestedVideoChannels() { } channels.push_back({ .audioSsrc = participant->ssrc, + .userId = int64_t(peerToUser(participant->peer->id).bare), .endpointId = endpointId, .ssrcGroups = (params->camera.endpointId == endpointId ? params->camera.ssrcGroups diff --git a/Telegram/SourceFiles/calls/group/calls_group_call.h b/Telegram/SourceFiles/calls/group/calls_group_call.h index 80bce2fb9f..99c0a1e54c 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_call.h +++ b/Telegram/SourceFiles/calls/group/calls_group_call.h @@ -23,6 +23,7 @@ struct GroupLevelsUpdate; struct GroupNetworkState; struct GroupParticipantDescription; class VideoCaptureInterface; +enum class VideoCodecName; } // namespace tgcalls namespace base { @@ -285,7 +286,9 @@ public: void startScheduledNow(); void toggleScheduleStartSubscribed(bool subscribed); void setNoiseSuppression(bool enabled); - void removeConferenceParticipants(const base::flat_set userIds); + void removeConferenceParticipants( + const base::flat_set userIds, + bool removingStale = false); bool emitShareScreenError(); bool emitShareCameraError(); @@ -533,6 +536,8 @@ private: int subchain, const QVector &blocks, int next); + [[nodiscard]] auto lookupVideoCodecPreferences() const + -> std::vector; bool tryCreateController(); void destroyController(); bool tryCreateScreencast(); diff --git a/Telegram/SourceFiles/main/main_app_config.cpp b/Telegram/SourceFiles/main/main_app_config.cpp index 0e74bc4261..26d4aecfb0 100644 --- a/Telegram/SourceFiles/main/main_app_config.cpp +++ b/Telegram/SourceFiles/main/main_app_config.cpp @@ -108,6 +108,11 @@ int AppConfig::pinnedGiftsLimit() const { return get(u"stargifts_pinned_to_top_limit"_q, 6); } +bool AppConfig::confcallPrioritizeVP8() const { + AssertIsDebug(); + return true; +} + void AppConfig::refresh(bool force) { if (_requestId || !_api) { if (force) { diff --git a/Telegram/SourceFiles/main/main_app_config.h b/Telegram/SourceFiles/main/main_app_config.h index 1cf3aa89cd..a5a804cdcc 100644 --- a/Telegram/SourceFiles/main/main_app_config.h +++ b/Telegram/SourceFiles/main/main_app_config.h @@ -79,6 +79,8 @@ public: [[nodiscard]] int pinnedGiftsLimit() const; + [[nodiscard]] bool confcallPrioritizeVP8() const; + void refresh(bool force = false); private: diff --git a/Telegram/SourceFiles/mtproto/scheme/api.tl b/Telegram/SourceFiles/mtproto/scheme/api.tl index a8a7efaa62..9b1250e1b7 100644 --- a/Telegram/SourceFiles/mtproto/scheme/api.tl +++ b/Telegram/SourceFiles/mtproto/scheme/api.tl @@ -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; 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; -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 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 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; 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.saveCallLog#41248786 peer:InputPhoneCall file:InputFile = Bool; phone.createConferenceCall#fbcefee6 random_id:int = phone.GroupCall; -phone.deleteConferenceCallParticipants#f9231114 call:InputGroupCall ids:Vector block:bytes = Updates; +phone.deleteConferenceCallParticipants#8ca60525 flags:# only_left:flags.0?true kick:flags.1?true call:InputGroupCall ids:Vector 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.declineConferenceCallInvite#3c479971 msg_id:int = Updates; diff --git a/Telegram/SourceFiles/tde2e/tde2e_api.cpp b/Telegram/SourceFiles/tde2e/tde2e_api.cpp index a70ba8d6f5..8827677618 100644 --- a/Telegram/SourceFiles/tde2e/tde2e_api.cpp +++ b/Telegram/SourceFiles/tde2e/tde2e_api.cpp @@ -239,6 +239,7 @@ void Call::apply(int subchain, const Block &last) { } LOG_APPLY(-1, Slice(last.data)); const auto id = tde2e_api::call_create( + std::int64_t(_myUserId.v), std::int64_t(_myKeyId.v), Slice(last.data)); if (!id.is_ok()) { @@ -446,7 +447,7 @@ rpl::producer Call::emojiHashValue() const { } auto Call::callbackEncryptDecrypt() --> Fn(const std::vector&, bool)> { +-> Fn(const std::vector&, int64_t, bool)> { if (!_guardedId) { _guardedId = std::make_shared(); if (const auto raw = _id ? _guardedId.get() : nullptr) { @@ -454,15 +455,20 @@ auto Call::callbackEncryptDecrypt() raw->exists = true; } } - return [v = _guardedId](const std::vector &data, bool encrypt) { - if (!v->exists) { + return [id = _guardedId]( + const std::vector &data, + int64_t userId, + bool encrypt) { + const auto raw = id.get(); + if (!raw->exists) { return std::vector(); } - 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 result = encrypt - ? tde2e_api::call_encrypt(libId, slice) - : tde2e_api::call_decrypt(libId, slice); + ? tde2e_api::call_encrypt(libId, channelId, slice) + : tde2e_api::call_decrypt(libId, userId, channelId, slice); if (!result.is_ok()) { return std::vector(); } diff --git a/Telegram/SourceFiles/tde2e/tde2e_api.h b/Telegram/SourceFiles/tde2e/tde2e_api.h index 0b0e518657..53d8cdb61f 100644 --- a/Telegram/SourceFiles/tde2e/tde2e_api.h +++ b/Telegram/SourceFiles/tde2e/tde2e_api.h @@ -102,7 +102,10 @@ public: [[nodiscard]] rpl::producer participantsSetValue() const; [[nodiscard]] auto callbackEncryptDecrypt() - -> Fn(const std::vector&, bool)>; + -> Fn( + const std::vector&, + int64_t, + bool)>; private: static constexpr int kSubChainsCount = 2; diff --git a/Telegram/ThirdParty/tgcalls b/Telegram/ThirdParty/tgcalls index 4c2c1104b2..fd1cfbd815 160000 --- a/Telegram/ThirdParty/tgcalls +++ b/Telegram/ThirdParty/tgcalls @@ -1 +1 @@ -Subproject commit 4c2c1104b2c9a13651f4290512daf5bb2e42ac50 +Subproject commit fd1cfbd8151b2c32d5471a4f5431faa6274ce421