Add setGroupCallScreenSharingIsPaused.

This commit is contained in:
levlam 2021-06-02 00:38:08 +03:00
parent 6eb49775de
commit 63fd974e35
5 changed files with 143 additions and 8 deletions

View File

@ -4729,6 +4729,9 @@ joinGroupCall group_call_id:int32 participant_id:MessageSender audio_source_id:i
//@description Starts screen sharing in a joined group call. Returns join response payload for tgcalls @group_call_id Group call identifier @payload Group call join payload; received from tgcalls
startGroupCallScreenSharing group_call_id:int32 payload:string = Text;
//@description Pauses or unpauses screen sharing in a joined group call @group_call_id Group call identifier @is_paused True if screen sharing is paused
setGroupCallScreenSharingIsPaused group_call_id:int32 is_paused:Bool = Ok;
//@description Ends screen sharing in a joined group call @group_call_id Group call identifier
endGroupCallScreenSharing group_call_id:int32 = Ok;

View File

@ -676,7 +676,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_stopped, bool video_is_stopped,
bool set_video_is_paused, bool video_is_paused) {
bool set_video_is_paused, bool video_is_paused, bool set_presentation_is_paused,
bool presentation_is_paused) {
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"));
@ -693,11 +694,13 @@ class EditGroupCallParticipantQuery : public Td::ResultHandler {
flags |= telegram_api::phone_editGroupCallParticipant::VIDEO_STOPPED_MASK;
} else if (set_video_is_paused) {
flags |= telegram_api::phone_editGroupCallParticipant::VIDEO_PAUSED_MASK;
} else if (set_presentation_is_paused) {
flags |= telegram_api::phone_editGroupCallParticipant::PRESENTATION_PAUSED_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_stopped, video_is_paused, false)));
video_is_stopped, video_is_paused, presentation_is_paused)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -827,6 +830,7 @@ struct GroupCallManager::GroupCall {
bool start_subscribed = false;
bool is_my_video_paused = false;
bool is_my_video_enabled = false;
bool is_my_presentation_paused = false;
bool mute_new_participants = false;
bool allowed_change_mute_new_participants = false;
bool joined_date_asc = false;
@ -856,6 +860,8 @@ struct GroupCallManager::GroupCall {
bool pending_is_my_video_paused = false;
bool have_pending_is_my_video_enabled = false;
bool pending_is_my_video_enabled = false;
bool have_pending_is_my_presentation_paused = false;
bool pending_is_my_presentation_paused = false;
bool have_pending_mute_new_participants = false;
bool pending_mute_new_participants = false;
string pending_title;
@ -1477,6 +1483,12 @@ bool GroupCallManager::get_group_call_is_my_video_enabled(const GroupCall *group
: group_call->is_my_video_enabled;
}
bool GroupCallManager::get_group_call_is_my_presentation_paused(const GroupCall *group_call) {
CHECK(group_call != nullptr);
return group_call->have_pending_is_my_presentation_paused ? group_call->pending_is_my_presentation_paused
: group_call->is_my_presentation_paused;
}
bool GroupCallManager::get_group_call_mute_new_participants(const GroupCall *group_call) {
CHECK(group_call != nullptr);
return group_call->have_pending_mute_new_participants ? group_call->pending_mute_new_participants
@ -2559,6 +2571,9 @@ void GroupCallManager::end_group_call_screen_sharing(GroupCallId group_call_id,
cancel_join_group_call_presentation_request(input_group_call_id);
group_call->have_pending_is_my_presentation_paused = false;
group_call->pending_is_my_presentation_paused = false;
td_->create_handler<LeaveGroupCallPresentationQuery>(std::move(promise))->send(input_group_call_id);
}
@ -2877,7 +2892,8 @@ void GroupCallManager::send_toggle_group_call_is_my_video_paused_query(InputGrou
is_my_video_paused, std::move(result));
});
td_->create_handler<EditGroupCallParticipantQuery>(std::move(promise))
->send(input_group_call_id, as_dialog_id, false, false, 0, false, false, false, false, true, !is_my_video_paused);
->send(input_group_call_id, as_dialog_id, false, false, 0, false, false, false, false, true, !is_my_video_paused,
false, false);
}
void GroupCallManager::on_toggle_group_call_is_my_video_paused(InputGroupCallId input_group_call_id,
@ -2966,8 +2982,8 @@ void GroupCallManager::send_toggle_group_call_is_my_video_enabled_query(InputGro
is_my_video_enabled, std::move(result));
});
td_->create_handler<EditGroupCallParticipantQuery>(std::move(promise))
->send(input_group_call_id, as_dialog_id, false, false, 0, false, false, true, !is_my_video_enabled, false,
false);
->send(input_group_call_id, as_dialog_id, false, false, 0, false, false, true, !is_my_video_enabled, false, false,
false, false);
}
void GroupCallManager::on_toggle_group_call_is_my_video_enabled(InputGroupCallId input_group_call_id,
@ -3002,6 +3018,98 @@ void GroupCallManager::on_toggle_group_call_is_my_video_enabled(InputGroupCallId
}
}
void GroupCallManager::toggle_group_call_is_my_presentation_paused(GroupCallId group_call_id,
bool is_my_presentation_paused,
Promise<Unit> &&promise) {
if (G()->close_flag()) {
return promise.set_error(Status::Error(500, "Request aborted"));
}
TRY_RESULT_PROMISE(promise, input_group_call_id, get_input_group_call_id(group_call_id));
auto *group_call = get_group_call(input_group_call_id);
if (group_call == nullptr || !group_call->is_inited || !group_call->is_active) {
return promise.set_error(Status::Error(400, "GROUPCALL_JOIN_MISSING"));
}
if (!group_call->is_joined) {
if (is_group_call_being_joined(input_group_call_id) || group_call->need_rejoin) {
group_call->after_join.push_back(
PromiseCreator::lambda([actor_id = actor_id(this), group_call_id, is_my_presentation_paused,
promise = std::move(promise)](Result<Unit> &&result) mutable {
if (result.is_error()) {
promise.set_error(Status::Error(400, "GROUPCALL_JOIN_MISSING"));
} else {
send_closure(actor_id, &GroupCallManager::toggle_group_call_is_my_presentation_paused, group_call_id,
is_my_presentation_paused, std::move(promise));
}
}));
return;
}
return promise.set_error(Status::Error(400, "GROUPCALL_JOIN_MISSING"));
}
if (is_my_presentation_paused == get_group_call_is_my_presentation_paused(group_call)) {
return promise.set_value(Unit());
}
// there is no reason to save promise; we will send an update with actual value anyway
group_call->pending_is_my_presentation_paused = is_my_presentation_paused;
if (!group_call->have_pending_is_my_presentation_paused) {
group_call->have_pending_is_my_presentation_paused = true;
send_toggle_group_call_is_my_presentation_paused_query(input_group_call_id, group_call->as_dialog_id,
is_my_presentation_paused);
}
send_update_group_call(group_call, "toggle_group_call_is_my_presentation_paused");
promise.set_value(Unit());
}
void GroupCallManager::send_toggle_group_call_is_my_presentation_paused_query(InputGroupCallId input_group_call_id,
DialogId as_dialog_id,
bool is_my_presentation_paused) {
auto promise = PromiseCreator::lambda(
[actor_id = actor_id(this), input_group_call_id, is_my_presentation_paused](Result<Unit> result) {
send_closure(actor_id, &GroupCallManager::on_toggle_group_call_is_my_presentation_paused, input_group_call_id,
is_my_presentation_paused, std::move(result));
});
td_->create_handler<EditGroupCallParticipantQuery>(std::move(promise))
->send(input_group_call_id, as_dialog_id, false, false, 0, false, false, false, false, true,
!is_my_presentation_paused, false, false);
}
void GroupCallManager::on_toggle_group_call_is_my_presentation_paused(InputGroupCallId input_group_call_id,
bool is_my_presentation_paused,
Result<Unit> &&result) {
if (G()->close_flag()) {
return;
}
auto *group_call = get_group_call(input_group_call_id);
if (group_call == nullptr || !group_call->is_inited || !group_call->is_active ||
!group_call->have_pending_is_my_presentation_paused) {
return;
}
if (result.is_error()) {
group_call->have_pending_is_my_presentation_paused = false;
LOG(ERROR) << "Failed to set is_my_presentation_paused to " << is_my_presentation_paused << " in "
<< input_group_call_id << ": " << result.error();
if (group_call->pending_is_my_presentation_paused != group_call->is_my_presentation_paused) {
send_update_group_call(group_call, "on_toggle_group_call_is_my_presentation_paused failed");
}
} else {
group_call->is_my_presentation_paused = is_my_presentation_paused;
if (group_call->pending_is_my_presentation_paused != is_my_presentation_paused) {
// need to send another request
send_toggle_group_call_is_my_presentation_paused_query(input_group_call_id, group_call->as_dialog_id,
group_call->pending_is_my_presentation_paused);
return;
}
group_call->have_pending_is_my_presentation_paused = false;
}
}
void GroupCallManager::toggle_group_call_start_subscribed(GroupCallId group_call_id, bool start_subscribed,
Promise<Unit> &&promise) {
if (G()->close_flag()) {
@ -3585,7 +3693,7 @@ void GroupCallManager::toggle_group_call_participant_is_muted(GroupCallId group_
generation, std::move(promise));
});
td_->create_handler<EditGroupCallParticipantQuery>(std::move(query_promise))
->send(input_group_call_id, dialog_id, true, is_muted, 0, false, false, false, false, false, false);
->send(input_group_call_id, dialog_id, true, is_muted, 0, false, false, false, false, false, false, false, false);
}
void GroupCallManager::on_toggle_group_call_participant_is_muted(InputGroupCallId input_group_call_id,
@ -3680,7 +3788,8 @@ void GroupCallManager::set_group_call_participant_volume_level(GroupCallId group
dialog_id, generation, std::move(promise));
});
td_->create_handler<EditGroupCallParticipantQuery>(std::move(query_promise))
->send(input_group_call_id, dialog_id, false, false, volume_level, false, false, false, false, false, false);
->send(input_group_call_id, dialog_id, false, false, volume_level, false, false, false, false, false, false,
false, false);
}
void GroupCallManager::on_set_group_call_participant_volume_level(InputGroupCallId input_group_call_id,
@ -3778,7 +3887,8 @@ void GroupCallManager::toggle_group_call_participant_is_hand_raised(GroupCallId
dialog_id, generation, std::move(promise));
});
td_->create_handler<EditGroupCallParticipantQuery>(std::move(query_promise))
->send(input_group_call_id, dialog_id, false, false, 0, true, is_hand_raised, false, false, false, false);
->send(input_group_call_id, dialog_id, false, false, 0, true, is_hand_raised, false, false, false, false, false,
false);
}
void GroupCallManager::on_toggle_group_call_participant_is_hand_raised(InputGroupCallId input_group_call_id,
@ -3916,6 +4026,7 @@ void GroupCallManager::on_group_call_left_impl(GroupCall *group_call, bool need_
group_call->is_speaking = false;
group_call->is_my_video_paused = false;
group_call->is_my_video_enabled = false;
group_call->is_my_presentation_paused = false;
group_call->have_pending_is_my_video_enabled = false;
if (!group_call->is_active) {
group_call->can_be_managed = false;
@ -4103,6 +4214,7 @@ InputGroupCallId GroupCallManager::update_group_call(const tl_object_ptr<telegra
call.is_speaking = group_call->is_speaking;
call.is_my_video_paused = group_call->is_my_video_paused;
call.is_my_video_enabled = group_call->is_my_video_enabled;
call.is_my_presentation_paused = group_call->is_my_presentation_paused;
call.syncing_participants = group_call->syncing_participants;
call.need_syncing_participants = group_call->need_syncing_participants;
call.loaded_all_participants = group_call->loaded_all_participants;

View File

@ -79,6 +79,9 @@ class GroupCallManager : public Actor {
void toggle_group_call_is_my_video_enabled(GroupCallId group_call_id, bool is_my_video_enabled,
Promise<Unit> &&promise);
void toggle_group_call_is_my_presentation_paused(GroupCallId group_call_id, bool is_my_presentation_paused,
Promise<Unit> &&promise);
void toggle_group_call_start_subscribed(GroupCallId group_call_id, bool start_subscribed, Promise<Unit> &&promise);
void toggle_group_call_mute_new_participants(GroupCallId group_call_id, bool mute_new_participants,
@ -207,6 +210,8 @@ class GroupCallManager : public Actor {
static bool get_group_call_is_my_video_enabled(const GroupCall *group_call);
static bool get_group_call_is_my_presentation_paused(const GroupCall *group_call);
static bool get_group_call_mute_new_participants(const GroupCall *group_call);
static int32 get_group_call_record_start_date(const GroupCall *group_call);
@ -286,6 +291,12 @@ class GroupCallManager : public Actor {
void on_toggle_group_call_is_my_video_enabled(InputGroupCallId input_group_call_id, bool is_my_video_enabled,
Result<Unit> &&result);
void send_toggle_group_call_is_my_presentation_paused_query(InputGroupCallId input_group_call_id,
DialogId as_dialog_id, bool is_my_presentation_paused);
void on_toggle_group_call_is_my_presentation_paused(InputGroupCallId input_group_call_id,
bool is_my_presentation_paused, Result<Unit> &&result);
void send_toggle_group_call_mute_new_participants_query(InputGroupCallId input_group_call_id,
bool mute_new_participants);

View File

@ -6065,6 +6065,13 @@ void Td::on_request(uint64 id, td_api::startGroupCallScreenSharing &request) {
std::move(query_promise));
}
void Td::on_request(uint64 id, const td_api::setGroupCallScreenSharingIsPaused &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
group_call_manager_->toggle_group_call_is_my_presentation_paused(GroupCallId(request.group_call_id_),
request.is_paused_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::endGroupCallScreenSharing &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();

View File

@ -736,6 +736,8 @@ class Td final : public NetQueryCallback {
void on_request(uint64 id, td_api::startGroupCallRecording &request);
void on_request(uint64 id, const td_api::setGroupCallScreenSharingIsPaused &request);
void on_request(uint64 id, const td_api::endGroupCallRecording &request);
void on_request(uint64 id, const td_api::toggleGroupCallIsMyVideoPaused &request);