diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 521be15f9..545a3a8cf 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2170,8 +2170,11 @@ groupCallRecentSpeaker participant_id:MessageSender is_speaking:Bool = GroupCall //@duration Call duration; for ended calls only groupCall id:int32 title:string scheduled_start_date:int32 enabled_start_notification:Bool is_active:Bool is_joined:Bool need_rejoin:Bool can_be_managed:Bool participant_count:int32 loaded_all_participants:Bool recent_speakers:vector is_my_video_enabled:Bool can_start_video:Bool mute_new_participants:Bool can_change_mute_new_participants:Bool record_duration:int32 duration:int32 = GroupCall; -//@description Contains information about a group call participant's video channel @source_ids List of video channel synchronization source identifiers @endpoint_id Video channel endpoint identifier @param_description Detailed description of the video channel -groupCallParticipantVideoInfo source_ids:vector endpoint_id:string description:string = GroupCallParticipantVideoInfo; +//@description Describes a group of video synchronization source identifiers @semantics The semantics of sources, one of "SIM" or "FID" @source_ids The list of synchronization source identifiers +groupCallVideoSourceGroup semantics:string source_ids:vector = GroupCallVideoSourceGroup; + +//@description Contains information about a group call participant's video channel @source_groups List of synchronization source groups of the video @endpoint_id Video channel endpoint identifier +groupCallParticipantVideoInfo source_groups:vector endpoint_id:string = GroupCallParticipantVideoInfo; //@description Represents a group call participant //@participant_id Identifier of the group call participant diff --git a/td/generate/scheme/telegram_api.tl b/td/generate/scheme/telegram_api.tl index bb2fa262c..f23a07eb1 100644 --- a/td/generate/scheme/telegram_api.tl +++ b/td/generate/scheme/telegram_api.tl @@ -213,7 +213,7 @@ peerNotifySettings#af509d20 flags:# show_previews:flags.0?Bool silent:flags.1?Bo peerSettings#733f2961 flags:# report_spam:flags.0?true add_contact:flags.1?true block_contact:flags.2?true share_contact:flags.3?true need_contacts_exception:flags.4?true report_geo:flags.5?true autoarchived:flags.7?true invite_members:flags.8?true geo_distance:flags.6?int = PeerSettings; wallPaper#a437c3ed id:long flags:# creator:flags.0?true default:flags.1?true pattern:flags.3?true dark:flags.4?true access_hash:long slug:string document:Document settings:flags.2?WallPaperSettings = WallPaper; -wallPaperNoFile#8af40b25 flags:# default:flags.1?true dark:flags.4?true settings:flags.2?WallPaperSettings = WallPaper; +wallPaperNoFile#e0804116 id:long flags:# default:flags.1?true dark:flags.4?true settings:flags.2?WallPaperSettings = WallPaper; inputReportReasonSpam#58dbcab8 = ReportReason; inputReportReasonViolence#1e22c78d = ReportReason; @@ -1060,7 +1060,7 @@ chatBannedRights#9f120418 flags:# view_messages:flags.0?true send_messages:flags inputWallPaper#e630b979 id:long access_hash:long = InputWallPaper; inputWallPaperSlug#72091c80 slug:string = InputWallPaper; -inputWallPaperNoFile#8427bbac = InputWallPaper; +inputWallPaperNoFile#967a462e id:long = InputWallPaper; account.wallPapersNotModified#1c199183 = account.WallPapers; account.wallPapers#702b65a9 hash:int wallpapers:Vector = account.WallPapers; @@ -1199,7 +1199,7 @@ groupCall#653dbaad flags:# join_muted:flags.1?true can_change_join_muted:flags.2 inputGroupCall#d8aa840f id:long access_hash:long = InputGroupCall; -groupCallParticipant#a8ba51a7 flags:# muted:flags.0?true left:flags.1?true can_self_unmute:flags.2?true just_joined:flags.4?true versioned:flags.5?true min:flags.8?true muted_by_you:flags.9?true volume_by_admin:flags.10?true self:flags.12?true peer:Peer date:int active_date:flags.3?int source:int volume:flags.7?int about:flags.11?string raise_hand_rating:flags.13?long video:flags.6?DataJSON presentation:flags.14?DataJSON = GroupCallParticipant; +groupCallParticipant#eba636fe flags:# muted:flags.0?true left:flags.1?true can_self_unmute:flags.2?true just_joined:flags.4?true versioned:flags.5?true min:flags.8?true muted_by_you:flags.9?true volume_by_admin:flags.10?true self:flags.12?true video_joined:flags.15?true peer:Peer date:int active_date:flags.3?int source:int volume:flags.7?int about:flags.11?string raise_hand_rating:flags.13?long video:flags.6?GroupCallParticipantVideo presentation:flags.14?GroupCallParticipantVideo = GroupCallParticipant; phone.groupCall#9e727aad call:GroupCall participants:Vector participants_next_offset:string chats:Vector users:Vector = phone.GroupCall; @@ -1236,6 +1236,10 @@ phone.joinAsPeers#afe5623f peers:Vector chats:Vector users:Vector = GroupCallParticipantVideoSourceGroup; + +groupCallParticipantVideo#78e41663 flags:# paused:flags.0?true endpoint:string source_groups:Vector = GroupCallParticipantVideo; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -1608,7 +1612,7 @@ phone.setCallRating#59ead627 flags:# user_initiative:flags.0?true peer:InputPhon phone.saveCallDebug#277add7e peer:InputPhoneCall debug:DataJSON = Bool; phone.sendSignalingData#ff7a9383 peer:InputPhoneCall data:bytes = Bool; phone.createGroupCall#48cdc6d8 flags:# peer:InputPeer random_id:int title:flags.0?string schedule_date:flags.1?int = Updates; -phone.joinGroupCall#b132ff7b flags:# muted:flags.0?true video_muted:flags.2?true call:InputGroupCall join_as:InputPeer invite_hash:flags.1?string params:DataJSON = Updates; +phone.joinGroupCall#b132ff7b flags:# muted:flags.0?true video_stopped:flags.2?true call:InputGroupCall join_as:InputPeer invite_hash:flags.1?string params:DataJSON = Updates; phone.leaveGroupCall#500377f9 call:InputGroupCall source:int = Updates; phone.inviteToGroupCall#7b393160 call:InputGroupCall users:Vector = Updates; phone.discardGroupCall#7a777135 call:InputGroupCall = Updates; @@ -1617,7 +1621,7 @@ phone.getGroupCall#c7cb017 call:InputGroupCall = phone.GroupCall; phone.getGroupParticipants#c558d8ab call:InputGroupCall ids:Vector sources:Vector offset:string limit:int = phone.GroupParticipants; phone.checkGroupCall#b59cf977 call:InputGroupCall sources:Vector = Vector; phone.toggleGroupCallRecord#c02a66d7 flags:# start:flags.0?true call:InputGroupCall title:flags.1?string = Updates; -phone.editGroupCallParticipant#aec610e4 flags:# call:InputGroupCall participant:InputPeer muted:flags.0?Bool volume:flags.1?int raise_hand:flags.2?Bool video_muted:flags.3?Bool = Updates; +phone.editGroupCallParticipant#a5273abf flags:# call:InputGroupCall participant:InputPeer muted:flags.0?Bool volume:flags.1?int raise_hand:flags.2?Bool video_stopped:flags.3?Bool video_paused:flags.4?Bool presentation_paused:flags.5?Bool = Updates; phone.editGroupCallTitle#1ca6ac0a call:InputGroupCall title:string = Updates; phone.getGroupCallJoinAs#ef7c213a peer:InputPeer = phone.JoinAsPeers; phone.exportGroupCallInvite#e6aa647f flags:# can_self_unmute:flags.0?true call:InputGroupCall = phone.ExportedGroupCallInvite; diff --git a/td/telegram/GroupCallManager.cpp b/td/telegram/GroupCallManager.cpp index f76d831ed..90c6fea2e 100644 --- a/td/telegram/GroupCallManager.cpp +++ b/td/telegram/GroupCallManager.cpp @@ -358,7 +358,7 @@ class JoinGroupCallQuery : public Td::ResultHandler { } NetQueryRef send(InputGroupCallId input_group_call_id, DialogId as_dialog_id, const string &payload, bool is_muted, - bool is_video_muted, const string &invite_hash, uint64 generation) { + bool is_video_stopped, const string &invite_hash, uint64 generation) { input_group_call_id_ = input_group_call_id; as_dialog_id_ = as_dialog_id; generation_ = generation; @@ -378,8 +378,8 @@ class JoinGroupCallQuery : public Td::ResultHandler { if (!invite_hash.empty()) { flags |= telegram_api::phone_joinGroupCall::INVITE_HASH_MASK; } - if (is_video_muted) { - flags |= telegram_api::phone_joinGroupCall::VIDEO_MUTED_MASK; + if (is_video_stopped) { + flags |= telegram_api::phone_joinGroupCall::VIDEO_STOPPED_MASK; } auto query = G()->net_query_creator().create(telegram_api::phone_joinGroupCall( flags, false /*ignored*/, false /*ignored*/, input_group_call_id.get_input_group_call(), @@ -675,7 +675,8 @@ class EditGroupCallParticipantQuery : public Td::ResultHandler { } void send(InputGroupCallId input_group_call_id, DialogId dialog_id, bool set_is_mited, bool is_muted, - int32 volume_level, bool set_raise_hand, bool raise_hand, bool set_video_is_muted, bool video_is_muted) { + int32 volume_level, bool set_raise_hand, bool raise_hand, bool set_video_is_stopped, + bool video_is_stopped) { auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Know); if (input_peer == nullptr) { return on_error(0, Status::Error(400, "Can't access the chat")); @@ -688,13 +689,13 @@ class EditGroupCallParticipantQuery : public Td::ResultHandler { flags |= telegram_api::phone_editGroupCallParticipant::VOLUME_MASK; } else if (set_is_mited) { flags |= telegram_api::phone_editGroupCallParticipant::MUTED_MASK; - } else if (set_video_is_muted) { - flags |= telegram_api::phone_editGroupCallParticipant::VIDEO_MUTED_MASK; + } else if (set_video_is_stopped) { + flags |= telegram_api::phone_editGroupCallParticipant::VIDEO_STOPPED_MASK; } send_query(G()->net_query_creator().create(telegram_api::phone_editGroupCallParticipant( flags, input_group_call_id.get_input_group_call(), std::move(input_peer), is_muted, volume_level, raise_hand, - video_is_muted))); + video_is_stopped, false, false))); } void on_result(uint64 id, BufferSlice packet) override { @@ -2454,7 +2455,7 @@ void GroupCallManager::join_group_call(GroupCallId group_call_id, DialogId as_di // it contains reasonable default "!call.mute_new_participants || call.can_be_managed" participant.server_is_muted_by_admin = !group_call->can_self_unmute && !can_manage_group_call(input_group_call_id); participant.server_is_muted_by_themselves = is_muted && !participant.server_is_muted_by_admin; - participant.server_is_video_muted = !is_my_video_enabled || participant.server_is_muted_by_admin; + participant.server_is_video_stopped = !is_my_video_enabled || participant.server_is_muted_by_admin; participant.is_just_joined = !is_rejoin; participant.is_fake = true; int diff = process_group_call_participant(input_group_call_id, std::move(participant)); @@ -3292,18 +3293,20 @@ void GroupCallManager::get_group_call_media_channel_descriptions( result.push_back( td_api::make_object(participant.audio_source, false, string())); } - for (auto &source_id : participant.video_payload.sources) { - if (source_ids_set.count(source_id)) { - source_ids_set.erase(source_id); - result.push_back(td_api::make_object( - source_id, true, participant.video_payload.json_payload)); + for (auto &group : participant.video_payload.source_groups) { + for (auto &source_id : group.source_ids) { + if (source_ids_set.count(source_id)) { + source_ids_set.erase(source_id); + result.push_back(td_api::make_object(source_id, true, string())); + } } } - for (auto &source_id : participant.presentation_payload.sources) { - if (source_ids_set.count(source_id)) { - source_ids_set.erase(source_id); - result.push_back(td_api::make_object( - source_id, true, participant.presentation_payload.json_payload)); + for (auto &group : participant.presentation_payload.source_groups) { + for (auto &source_id : group.source_ids) { + if (source_ids_set.count(source_id)) { + source_ids_set.erase(source_id); + result.push_back(td_api::make_object(source_id, true, string())); + } } } } diff --git a/td/telegram/GroupCallParticipant.cpp b/td/telegram/GroupCallParticipant.cpp index cf51b2103..918451b15 100644 --- a/td/telegram/GroupCallParticipant.cpp +++ b/td/telegram/GroupCallParticipant.cpp @@ -57,10 +57,10 @@ GroupCallParticipant::GroupCallParticipant(const tl_object_ptrvideo_ != nullptr) { - video_payload = get_group_call_video_payload(participant->video_->data_); + video_payload = get_group_call_video_payload(participant->video_.get()); } if (participant->presentation_ != nullptr) { - presentation_payload = get_group_call_video_payload(participant->presentation_->data_); + presentation_payload = get_group_call_video_payload(participant->presentation_.get()); } } diff --git a/td/telegram/GroupCallParticipant.h b/td/telegram/GroupCallParticipant.h index 9bd518fc7..3bb29f1b1 100644 --- a/td/telegram/GroupCallParticipant.h +++ b/td/telegram/GroupCallParticipant.h @@ -33,7 +33,7 @@ struct GroupCallParticipant { bool server_is_muted_by_themselves = false; bool server_is_muted_by_admin = false; bool server_is_muted_locally = false; - bool server_is_video_muted = false; + bool server_is_video_stopped = false; bool is_self = false; bool can_be_muted_for_all_users = false; diff --git a/td/telegram/GroupCallVideoPayload.cpp b/td/telegram/GroupCallVideoPayload.cpp index 05bb829c0..7361aef17 100644 --- a/td/telegram/GroupCallVideoPayload.cpp +++ b/td/telegram/GroupCallVideoPayload.cpp @@ -7,84 +7,40 @@ #include "td/telegram/GroupCallVideoPayload.h" #include "td/utils/algorithm.h" -#include "td/utils/JsonBuilder.h" -#include "td/utils/misc.h" - -#include namespace td { +static bool operator==(const GroupCallVideoSourceGroup &lhs, const GroupCallVideoSourceGroup &rhs) { + return lhs.semantics == rhs.semantics && lhs.source_ids == rhs.source_ids; +} + bool operator==(const GroupCallVideoPayload &lhs, const GroupCallVideoPayload &rhs) { - return lhs.sources == rhs.sources && lhs.endpoint == rhs.endpoint && lhs.json_payload == rhs.json_payload; + return lhs.source_groups == rhs.source_groups && lhs.endpoint == rhs.endpoint; +} + +static td_api::object_ptr get_group_call_video_source_group_object( + const GroupCallVideoSourceGroup &group) { + return td_api::make_object(group.semantics, vector(group.source_ids)); } td_api::object_ptr get_group_call_participant_video_info_object( const GroupCallVideoPayload &payload) { - if (payload.endpoint.empty() || payload.sources.empty()) { + if (payload.endpoint.empty() || payload.source_groups.empty()) { return nullptr; } - return td_api::make_object(vector(payload.sources), payload.endpoint, - payload.json_payload); + return td_api::make_object( + transform(payload.source_groups, get_group_call_video_source_group_object), payload.endpoint); } -static vector get_group_call_video_sources(JsonValue &&value) { - if (value.type() != JsonValue::Type::Object) { - return {}; - } - - vector result; - auto &value_object = value.get_object(); - auto r_sources = get_json_object_field(value_object, "sources", JsonValue::Type::Array, false); - if (r_sources.is_error()) { - return {}; - } - auto sources = r_sources.move_as_ok(); - - for (auto &source : sources.get_array()) { - Slice source_str; - if (source.type() == JsonValue::Type::String) { - source_str = source.get_string(); - } else if (source.type() == JsonValue::Type::Number) { - source_str = source.get_number(); - } - auto r_source_id = to_integer_safe(source_str); - if (r_source_id.is_ok()) { - result.push_back(static_cast(r_source_id.ok())); - } - } - - return result; -} - -GroupCallVideoPayload get_group_call_video_payload(string json) { - string json_copy = json; - auto r_value = json_decode(json_copy); - if (r_value.is_error()) { - return GroupCallVideoPayload(); - } - - auto value = r_value.move_as_ok(); - if (value.type() != JsonValue::Type::Object) { - return GroupCallVideoPayload(); - } - +GroupCallVideoPayload get_group_call_video_payload(const telegram_api::groupCallParticipantVideo *video) { GroupCallVideoPayload result; - result.json_payload = std::move(json); - - auto &value_object = value.get_object(); - auto r_endpoint = get_json_object_string_field(value_object, "endpoint", true); - if (r_endpoint.is_ok()) { - result.endpoint = r_endpoint.move_as_ok(); - } - - auto r_source_groups = get_json_object_field(value_object, "ssrc-groups", JsonValue::Type::Array, false); - if (r_source_groups.is_ok()) { - auto source_groups = r_source_groups.move_as_ok(); - for (auto &source_group_object : source_groups.get_array()) { - append(result.sources, get_group_call_video_sources(std::move(source_group_object))); - } - td::unique(result.sources); - } + result.endpoint = video->endpoint_; + result.source_groups = transform(video->source_groups_, [](auto &&source_group) { + GroupCallVideoSourceGroup result; + result.semantics = source_group->semantics_; + result.source_ids = source_group->sources_; + return result; + }); return result; } diff --git a/td/telegram/GroupCallVideoPayload.h b/td/telegram/GroupCallVideoPayload.h index c47507be0..0753dbc23 100644 --- a/td/telegram/GroupCallVideoPayload.h +++ b/td/telegram/GroupCallVideoPayload.h @@ -7,16 +7,21 @@ #pragma once #include "td/telegram/td_api.h" +#include "td/telegram/telegram_api.h" #include "td/utils/common.h" #include "td/utils/Status.h" namespace td { +struct GroupCallVideoSourceGroup { + string semantics; + vector source_ids; +}; + struct GroupCallVideoPayload { - vector sources; + vector source_groups; string endpoint; - string json_payload; }; bool operator==(const GroupCallVideoPayload &lhs, const GroupCallVideoPayload &rhs); @@ -24,6 +29,6 @@ bool operator==(const GroupCallVideoPayload &lhs, const GroupCallVideoPayload &r td_api::object_ptr get_group_call_participant_video_info_object( const GroupCallVideoPayload &payload); -GroupCallVideoPayload get_group_call_video_payload(string json); +GroupCallVideoPayload get_group_call_video_payload(const telegram_api::groupCallParticipantVideo *video); } // namespace td