Improve getGroupCallStreamSegment.
This commit is contained in:
parent
7e45fc3949
commit
ca6ece6707
@ -1166,8 +1166,7 @@ void GroupCallManager::finish_check_group_call_is_joined(InputGroupCallId input_
|
|||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
auto message = result.error().message();
|
auto message = result.error().message();
|
||||||
if (message == "GROUPCALL_JOIN_MISSING" || message == "GROUPCALL_FORBIDDEN" || message == "GROUPCALL_INVALID") {
|
if (message == "GROUPCALL_JOIN_MISSING" || message == "GROUPCALL_FORBIDDEN" || message == "GROUPCALL_INVALID") {
|
||||||
on_group_call_left(input_group_call_id, audio_source, true);
|
on_group_call_left(input_group_call_id, audio_source, message == "GROUPCALL_JOIN_MISSING");
|
||||||
result = Unit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1898,32 +1897,72 @@ int32 GroupCallManager::cancel_join_group_call_request(InputGroupCallId input_gr
|
|||||||
|
|
||||||
void GroupCallManager::get_group_call_stream_segment(GroupCallId group_call_id, int64 time_offset, int32 scale,
|
void GroupCallManager::get_group_call_stream_segment(GroupCallId group_call_id, int64 time_offset, int32 scale,
|
||||||
Promise<string> &&promise) {
|
Promise<string> &&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));
|
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);
|
auto *group_call = get_group_call(input_group_call_id);
|
||||||
CHECK(group_call != nullptr);
|
if (group_call == nullptr || !group_call->is_inited) {
|
||||||
|
reload_group_call(input_group_call_id,
|
||||||
if (!group_call->stream_dc_id.is_exact()) {
|
PromiseCreator::lambda(
|
||||||
|
[actor_id = actor_id(this), group_call_id, time_offset, scale, promise = std::move(promise)](
|
||||||
|
Result<td_api::object_ptr<td_api::groupCall>> &&result) mutable {
|
||||||
|
if (result.is_error()) {
|
||||||
|
promise.set_error(result.move_as_error());
|
||||||
|
} else {
|
||||||
|
send_closure(actor_id, &GroupCallManager::get_group_call_stream_segment, group_call_id,
|
||||||
|
time_offset, scale, std::move(promise));
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!group_call->is_active || !group_call->stream_dc_id.is_exact()) {
|
||||||
return promise.set_error(Status::Error(400, "Group call can't be streamed"));
|
return promise.set_error(Status::Error(400, "Group call can't be streamed"));
|
||||||
}
|
}
|
||||||
|
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, time_offset, scale,
|
||||||
|
promise = std::move(promise)](Result<Unit> &&result) mutable {
|
||||||
|
if (result.is_error()) {
|
||||||
|
promise.set_error(result.move_as_error());
|
||||||
|
} else {
|
||||||
|
send_closure(actor_id, &GroupCallManager::get_group_call_stream_segment, group_call_id, time_offset,
|
||||||
|
scale, std::move(promise));
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return promise.set_error(Status::Error(400, "GROUPCALL_JOIN_MISSING"));
|
||||||
|
}
|
||||||
|
|
||||||
auto query_promise = PromiseCreator::lambda(
|
auto query_promise =
|
||||||
[actor_id = actor_id(this), input_group_call_id, promise = std::move(promise)](Result<string> &&result) mutable {
|
PromiseCreator::lambda([actor_id = actor_id(this), input_group_call_id, audio_source = group_call->audio_source,
|
||||||
|
promise = std::move(promise)](Result<string> &&result) mutable {
|
||||||
send_closure(actor_id, &GroupCallManager::finish_get_group_call_stream_segment, input_group_call_id,
|
send_closure(actor_id, &GroupCallManager::finish_get_group_call_stream_segment, input_group_call_id,
|
||||||
std::move(result), std::move(promise));
|
audio_source, std::move(result), std::move(promise));
|
||||||
});
|
});
|
||||||
td_->create_handler<GetGroupCallStreamQuery>(std::move(query_promise))
|
td_->create_handler<GetGroupCallStreamQuery>(std::move(query_promise))
|
||||||
->send(input_group_call_id, group_call->stream_dc_id, time_offset, scale);
|
->send(input_group_call_id, group_call->stream_dc_id, time_offset, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupCallManager::finish_get_group_call_stream_segment(InputGroupCallId input_group_call_id,
|
void GroupCallManager::finish_get_group_call_stream_segment(InputGroupCallId input_group_call_id, int32 audio_source,
|
||||||
Result<string> &&result, Promise<string> &&promise) {
|
Result<string> &&result, Promise<string> &&promise) {
|
||||||
if (!G()->close_flag()) {
|
if (!G()->close_flag()) {
|
||||||
auto *group_call = get_group_call(input_group_call_id);
|
if (result.is_ok()) {
|
||||||
CHECK(group_call != nullptr);
|
auto *group_call = get_group_call(input_group_call_id);
|
||||||
if (group_call->is_inited && check_group_call_is_joined_timeout_.has_timeout(group_call->group_call_id.get())) {
|
CHECK(group_call != nullptr);
|
||||||
check_group_call_is_joined_timeout_.set_timeout_in(group_call->group_call_id.get(),
|
if (group_call->is_inited && check_group_call_is_joined_timeout_.has_timeout(group_call->group_call_id.get())) {
|
||||||
CHECK_GROUP_CALL_IS_JOINED_TIMEOUT);
|
check_group_call_is_joined_timeout_.set_timeout_in(group_call->group_call_id.get(),
|
||||||
|
CHECK_GROUP_CALL_IS_JOINED_TIMEOUT);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
auto message = result.error().message();
|
||||||
|
if (message == "GROUPCALL_JOIN_MISSING" || message == "GROUPCALL_FORBIDDEN" || message == "GROUPCALL_INVALID") {
|
||||||
|
on_group_call_left(input_group_call_id, audio_source, message == "GROUPCALL_JOIN_MISSING");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,8 +164,8 @@ class GroupCallManager : public Actor {
|
|||||||
void finish_get_group_call(InputGroupCallId input_group_call_id,
|
void finish_get_group_call(InputGroupCallId input_group_call_id,
|
||||||
Result<tl_object_ptr<telegram_api::phone_groupCall>> &&result);
|
Result<tl_object_ptr<telegram_api::phone_groupCall>> &&result);
|
||||||
|
|
||||||
void finish_get_group_call_stream_segment(InputGroupCallId input_group_call_id, Result<string> &&result,
|
void finish_get_group_call_stream_segment(InputGroupCallId input_group_call_id, int32 audio_source,
|
||||||
Promise<string> &&promise);
|
Result<string> &&result, Promise<string> &&promise);
|
||||||
|
|
||||||
void finish_check_group_call_is_joined(InputGroupCallId input_group_call_id, int32 audio_source,
|
void finish_check_group_call_is_joined(InputGroupCallId input_group_call_id, int32 audio_source,
|
||||||
Result<Unit> &&result);
|
Result<Unit> &&result);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user