Move can_enable_video to groupCall.

This commit is contained in:
levlam 2021-07-08 19:59:16 +03:00
parent 5ff49b13ec
commit 1464e85a5b
5 changed files with 40 additions and 21 deletions

View File

@ -2170,12 +2170,12 @@ groupCallRecentSpeaker participant_id:MessageSender is_speaking:Bool = GroupCall
//@recent_speakers Recently speaking users in the group call
//@is_my_video_enabled True, if the current user's video is enabled
//@is_my_video_paused True, if the current user's video is paused
//@can_start_video True, if video can be enabled by group call participants. This flag is generally useless after the user has already joined the group call
//@can_enable_video True, if the user can broadcast video or share screen
//@mute_new_participants True, if only group call administrators can unmute new participants
//@can_change_mute_new_participants True, if the current user can enable or disable mute_new_participants setting
//@record_duration Duration of the ongoing group call recording, in seconds; 0 if none. An updateGroupCall update is not triggered when value of this field changes, but the same recording goes on
//@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<groupCallRecentSpeaker> is_my_video_enabled:Bool is_my_video_paused:Bool can_start_video:Bool mute_new_participants:Bool can_change_mute_new_participants:Bool record_duration:int32 duration:int32 = GroupCall;
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<groupCallRecentSpeaker> is_my_video_enabled:Bool is_my_video_paused:Bool can_enable_video:Bool mute_new_participants:Bool can_change_mute_new_participants:Bool record_duration:int32 duration:int32 = GroupCall;
//@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<int32> = GroupCallVideoSourceGroup;
@ -2188,7 +2188,6 @@ groupCallParticipantVideoInfo source_groups:vector<groupCallVideoSourceGroup> en
//@participant_id Identifier of the group call participant
//@audio_source_id User's audio channel synchronization source identifier
//@screen_sharing_audio_source_id User's screen sharing audio channel synchronization source identifier
//@can_enable_video True, if the user can broadcast video or share screen
//@video_info Information about user's video channel; may be null if there is no active video
//@screen_sharing_video_info Information about user's screen sharing video channel; may be null if there is no active screen sharing video
//@bio The participant user's bio or the participant chat's description
@ -2204,7 +2203,7 @@ groupCallParticipantVideoInfo source_groups:vector<groupCallVideoSourceGroup> en
//@can_unmute_self True, if the participant is muted for all users, but can unmute themselves
//@volume_level Participant's volume level; 1-20000 in hundreds of percents
//@order User's order in the group call participant list. Orders must be compared lexicographically. The bigger is order, the higher is user in the list. If order is empty, the user must be removed from the participant list
groupCallParticipant participant_id:MessageSender audio_source_id:int32 screen_sharing_audio_source_id:int32 can_enable_video:Bool video_info:groupCallParticipantVideoInfo screen_sharing_video_info:groupCallParticipantVideoInfo bio:string is_current_user:Bool is_speaking:Bool is_hand_raised:Bool can_be_muted_for_all_users:Bool can_be_unmuted_for_all_users:Bool can_be_muted_for_current_user:Bool can_be_unmuted_for_current_user:Bool is_muted_for_all_users:Bool is_muted_for_current_user:Bool can_unmute_self:Bool volume_level:int32 order:string = GroupCallParticipant;
groupCallParticipant participant_id:MessageSender audio_source_id:int32 screen_sharing_audio_source_id:int32 video_info:groupCallParticipantVideoInfo screen_sharing_video_info:groupCallParticipantVideoInfo bio:string is_current_user:Bool is_speaking:Bool is_hand_raised:Bool can_be_muted_for_all_users:Bool can_be_unmuted_for_all_users:Bool can_be_muted_for_current_user:Bool can_be_unmuted_for_current_user:Bool is_muted_for_all_users:Bool is_muted_for_current_user:Bool can_unmute_self:Bool volume_level:int32 order:string = GroupCallParticipant;
//@class CallProblem @description Describes the exact type of a problem with a call

View File

@ -823,7 +823,6 @@ struct GroupCallManager::GroupCall {
bool is_speaking = false;
bool can_self_unmute = false;
bool can_be_managed = false;
bool can_start_video = false;
bool syncing_participants = false;
bool need_syncing_participants = false;
bool loaded_all_participants = false;
@ -840,14 +839,16 @@ struct GroupCallManager::GroupCall {
int32 audio_source = 0;
int32 joined_date = 0;
int32 record_start_date = 0;
int32 unmuted_video_count = 0;
int32 unmuted_video_limit = 0;
DcId stream_dc_id;
DialogId as_dialog_id;
int32 version = -1;
int32 leave_version = -1;
int32 title_version = -1;
int32 can_start_video_version = -1;
int32 start_subscribed_version = -1;
int32 can_enable_video_version = -1;
int32 mute_version = -1;
int32 stream_dc_id_version = -1;
int32 record_start_date_version = -1;
@ -1498,6 +1499,14 @@ bool GroupCallManager::get_group_call_has_recording(const GroupCall *group_call)
return get_group_call_record_start_date(group_call) != 0;
}
bool GroupCallManager::get_group_call_can_enable_video(const GroupCall *group_call) {
CHECK(group_call != nullptr);
if (group_call->unmuted_video_limit <= 0) {
return true;
}
return group_call->unmuted_video_count < group_call->unmuted_video_limit;
}
bool GroupCallManager::need_group_call_participants(InputGroupCallId input_group_call_id) const {
return need_group_call_participants(input_group_call_id, get_group_call(input_group_call_id));
}
@ -2478,7 +2487,6 @@ 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.can_enable_video = !participant.server_is_muted_by_admin && group_call->can_start_video;
participant.is_just_joined = !is_rejoin;
participant.is_fake = true;
int diff = process_group_call_participant(input_group_call_id, std::move(participant));
@ -4043,18 +4051,21 @@ InputGroupCallId GroupCallManager::update_group_call(const tl_object_ptr<telegra
input_group_call_id = InputGroupCallId(group_call->id_, group_call->access_hash_);
call.is_active = true;
call.title = std::move(group_call->title_);
call.can_start_video = group_call->can_start_video_;
call.start_subscribed = group_call->schedule_start_subscribed_;
call.mute_new_participants = group_call->join_muted_;
call.joined_date_asc = group_call->join_date_asc_;
call.allowed_change_mute_new_participants = group_call->can_change_join_muted_;
call.participant_count = group_call->participants_count_;
call.unmuted_video_count = group_call->unmuted_video_count_;
call.unmuted_video_limit = group_call->unmuted_video_limit_;
if ((group_call->flags_ & telegram_api::groupCall::STREAM_DC_ID_MASK) != 0) {
call.stream_dc_id = DcId::create(group_call->stream_dc_id_);
if (!call.stream_dc_id.is_exact()) {
LOG(ERROR) << "Receive invalid stream DC ID " << call.stream_dc_id << " in " << input_group_call_id;
call.stream_dc_id = DcId();
}
} else {
call.stream_dc_id = DcId();
}
if ((group_call->flags_ & telegram_api::groupCall::RECORD_START_DATE_MASK) != 0) {
call.record_start_date = group_call->record_start_date_;
@ -4063,6 +4074,8 @@ InputGroupCallId GroupCallManager::update_group_call(const tl_object_ptr<telegra
<< input_group_call_id;
call.record_start_date = 0;
}
} else {
call.record_start_date = 0;
}
if ((group_call->flags_ & telegram_api::groupCall::SCHEDULE_DATE_MASK) != 0) {
call.scheduled_start_date = group_call->schedule_date_;
@ -4071,13 +4084,16 @@ InputGroupCallId GroupCallManager::update_group_call(const tl_object_ptr<telegra
<< input_group_call_id;
call.scheduled_start_date = 0;
}
} else {
call.scheduled_start_date = 0;
}
if (call.scheduled_start_date == 0) {
call.start_subscribed = false;
}
call.version = group_call->version_;
call.title_version = group_call->version_;
call.can_start_video_version = group_call->version_;
call.can_enable_video_version = group_call->version_;
call.start_subscribed_version = group_call->version_;
call.mute_version = group_call->version_;
call.stream_dc_id_version = group_call->version_;
@ -4153,11 +4169,16 @@ InputGroupCallId GroupCallManager::update_group_call(const tl_object_ptr<telegra
*group_call = std::move(call);
need_update = true;
} else {
if (call.can_start_video != group_call->can_start_video &&
call.can_start_video_version >= group_call->can_start_video_version) {
group_call->can_start_video = call.can_start_video;
group_call->can_start_video_version = call.can_start_video_version;
need_update = true;
if ((call.unmuted_video_count != group_call->unmuted_video_count ||
call.unmuted_video_limit != group_call->unmuted_video_limit) &&
call.can_enable_video_version >= group_call->can_enable_video_version) {
auto old_can_enable_video = get_group_call_can_enable_video(group_call);
group_call->unmuted_video_count = call.unmuted_video_count;
group_call->unmuted_video_limit = call.unmuted_video_limit;
group_call->can_enable_video_version = call.can_enable_video_version;
if (old_can_enable_video != get_group_call_can_enable_video(group_call)) {
need_update = true;
}
}
if (call.start_subscribed != group_call->start_subscribed &&
call.start_subscribed_version >= group_call->start_subscribed_version) {
@ -4567,14 +4588,14 @@ tl_object_ptr<td_api::groupCall> GroupCallManager::get_group_call_object(
bool mute_new_participants = get_group_call_mute_new_participants(group_call);
bool can_change_mute_new_participants =
group_call->is_active && group_call->can_be_managed && group_call->allowed_change_mute_new_participants;
bool can_enable_video = get_group_call_can_enable_video(group_call);
int32 record_start_date = get_group_call_record_start_date(group_call);
int32 record_duration = record_start_date == 0 ? 0 : max(G()->unix_time() - record_start_date + 1, 1);
return td_api::make_object<td_api::groupCall>(
group_call->group_call_id.get(), get_group_call_title(group_call), scheduled_start_date, start_subscribed,
is_active, is_joined, group_call->need_rejoin, group_call->can_be_managed, group_call->participant_count,
group_call->loaded_all_participants, std::move(recent_speakers), is_my_video_enabled, is_my_video_paused,
group_call->can_start_video, mute_new_participants, can_change_mute_new_participants, record_duration,
group_call->duration);
can_enable_video, mute_new_participants, can_change_mute_new_participants, record_duration, group_call->duration);
}
tl_object_ptr<td_api::updateGroupCall> GroupCallManager::get_update_group_call_object(

View File

@ -215,6 +215,8 @@ class GroupCallManager final : public Actor {
static bool get_group_call_has_recording(const GroupCall *group_call);
static bool get_group_call_can_enable_video(const GroupCall *group_call);
bool need_group_call_participants(InputGroupCallId input_group_call_id) const;
bool need_group_call_participants(InputGroupCallId input_group_call_id, const GroupCall *group_call) const;

View File

@ -25,7 +25,6 @@ GroupCallParticipant::GroupCallParticipant(const tl_object_ptr<telegram_api::gro
server_is_muted_by_themselves = participant->can_self_unmute_;
server_is_muted_by_admin = participant->muted_ && !participant->can_self_unmute_;
server_is_muted_locally = participant->muted_by_you_;
can_enable_video = participant->video_joined_;
is_self = participant->self_;
if ((participant->flags_ & telegram_api::groupCallParticipant::VOLUME_MASK) != 0) {
volume_level = participant->volume_;
@ -259,7 +258,7 @@ td_api::object_ptr<td_api::groupCallParticipant> GroupCallParticipant::get_group
return td_api::make_object<td_api::groupCallParticipant>(
td->messages_manager_->get_message_sender_object(dialog_id), audio_source, presentation_audio_source,
can_enable_video, get_group_call_participant_video_info_object(video_payload),
get_group_call_participant_video_info_object(video_payload),
get_group_call_participant_video_info_object(presentation_payload), about, is_self, is_speaking,
get_is_hand_raised(), can_be_muted_for_all_users, can_be_unmuted_for_all_users, can_be_muted_only_for_self,
can_be_unmuted_only_for_self, get_is_muted_for_all_users(), get_is_muted_locally(), get_is_muted_by_themselves(),
@ -268,8 +267,7 @@ td_api::object_ptr<td_api::groupCallParticipant> GroupCallParticipant::get_group
bool operator==(const GroupCallParticipant &lhs, const GroupCallParticipant &rhs) {
return lhs.dialog_id == rhs.dialog_id && lhs.audio_source == rhs.audio_source &&
lhs.presentation_audio_source == rhs.presentation_audio_source &&
lhs.can_enable_video == rhs.can_enable_video && lhs.video_payload == rhs.video_payload &&
lhs.presentation_audio_source == rhs.presentation_audio_source && lhs.video_payload == rhs.video_payload &&
lhs.presentation_payload == rhs.presentation_payload && lhs.about == rhs.about && lhs.is_self == rhs.is_self &&
lhs.is_speaking == rhs.is_speaking && lhs.get_is_hand_raised() == rhs.get_is_hand_raised() &&
lhs.can_be_muted_for_all_users == rhs.can_be_muted_for_all_users &&

View File

@ -30,7 +30,6 @@ struct GroupCallParticipant {
int32 active_date = 0;
int32 volume_level = 10000;
int64 raise_hand_rating = 0;
bool can_enable_video = false;
bool is_volume_level_local = false;
bool server_is_muted_by_themselves = false;
bool server_is_muted_by_admin = false;