Add td_api::sendCallSignalingData.

GitOrigin-RevId: d14899cd97fb46d472bcb48fd4b51f568e995608
This commit is contained in:
levlam 2020-08-10 11:34:28 +03:00
parent cdf6acac32
commit 301d0577ba
9 changed files with 78 additions and 36 deletions

View File

@ -4066,6 +4066,9 @@ createCall user_id:int32 protocol:callProtocol is_video:Bool = CallId;
//@description Accepts an incoming call @call_id Call identifier @protocol Description of the call protocols supported by the application
acceptCall call_id:int32 protocol:callProtocol = Ok;
//@description Sends call signaling data @call_id Call identifier @data The data
sendCallSignalingData call_id:int32 data:bytes = Ok;
//@description Discards a call @call_id Call identifier @is_disconnected True, if the user was disconnected @duration The call duration, in seconds @is_video True, if the call was a video call @connection_id Identifier of the connection used during the call
discardCall call_id:int32 is_disconnected:Bool duration:int32 is_video:Bool connection_id:int64 = Ok;

Binary file not shown.

View File

@ -131,6 +131,16 @@ void CallActor::create_call(UserId user_id, tl_object_ptr<telegram_api::InputUse
promise.set_value(CallId(local_call_id_));
}
void CallActor::accept_call(CallProtocol &&protocol, Promise<> promise) {
if (state_ != State::SendAcceptQuery) {
return promise.set_error(Status::Error(400, "Unexpected acceptCall"));
}
is_accepted_ = true;
call_state_.protocol = std::move(protocol);
promise.set_value(Unit());
loop();
}
void CallActor::update_call_signaling_data(string data) {
if (call_state_.type != CallState::Type::Ready) {
return;
@ -142,6 +152,24 @@ void CallActor::update_call_signaling_data(string data) {
send_closure(G()->td(), &Td::send_update, std::move(update));
}
void CallActor::send_call_signaling_data(string &&data, Promise<> promise) {
if (call_state_.type != CallState::Type::Ready) {
return promise.set_error(Status::Error(400, "Call is not active"));
}
auto query = G()->net_query_creator().create(
telegram_api::phone_sendSignalingData(get_input_phone_call("send_call_signaling_data"), BufferSlice(data)));
send_with_promise(std::move(query),
PromiseCreator::lambda([promise = std::move(promise)](NetQueryPtr net_query) mutable {
auto res = fetch_result<telegram_api::phone_sendSignalingData>(std::move(net_query));
if (res.is_error()) {
promise.set_error(res.move_as_error());
} else {
promise.set_value(Unit());
}
}));
}
void CallActor::discard_call(bool is_disconnected, int32 duration, bool is_video, int64 connection_id,
Promise<> promise) {
promise.set_value(Unit());
@ -187,16 +215,6 @@ void CallActor::discard_call(bool is_disconnected, int32 duration, bool is_video
loop();
}
void CallActor::accept_call(CallProtocol &&protocol, Promise<> promise) {
if (state_ != State::SendAcceptQuery) {
return promise.set_error(Status::Error(400, "Unexpected acceptCall"));
}
is_accepted_ = true;
call_state_.protocol = std::move(protocol);
promise.set_value(Unit());
loop();
}
void CallActor::rate_call(int32 rating, string comment, vector<td_api::object_ptr<td_api::CallProblem>> &&problems,
Promise<> promise) {
if (!call_state_.need_rating) {

View File

@ -87,9 +87,10 @@ class CallActor : public NetQueryCallback {
void create_call(UserId user_id, tl_object_ptr<telegram_api::InputUser> &&input_user, CallProtocol &&protocol,
bool is_video, Promise<CallId> &&promise);
void update_call_signaling_data(string data);
void discard_call(bool is_disconnected, int32 duration, bool is_video, int64 connection_id, Promise<> promise);
void accept_call(CallProtocol &&protocol, Promise<> promise);
void update_call_signaling_data(string data);
void send_call_signaling_data(string &&data, Promise<> promise);
void discard_call(bool is_disconnected, int32 duration, bool is_video, int64 connection_id, Promise<> promise);
void rate_call(int32 rating, string comment, vector<td_api::object_ptr<td_api::CallProblem>> &&problems,
Promise<> promise);
void send_call_debug_information(string data, Promise<> promise);

View File

@ -68,6 +68,22 @@ void CallManager::create_call(UserId user_id, tl_object_ptr<telegram_api::InputU
std::move(promise));
}
void CallManager::accept_call(CallId call_id, CallProtocol &&protocol, Promise<> promise) {
auto actor = get_call_actor(call_id);
if (actor.empty()) {
return promise.set_error(Status::Error(400, "Call not found"));
}
send_closure(actor, &CallActor::accept_call, std::move(protocol), std::move(promise));
}
void CallManager::send_call_signaling_data(CallId call_id, string &&data, Promise<> promise) {
auto actor = get_call_actor(call_id);
if (actor.empty()) {
return promise.set_error(Status::Error(400, "Call not found"));
}
send_closure(actor, &CallActor::send_call_signaling_data, std::move(data), std::move(promise));
}
void CallManager::discard_call(CallId call_id, bool is_disconnected, int32 duration, bool is_video, int64 connection_id,
Promise<> promise) {
auto actor = get_call_actor(call_id);
@ -77,14 +93,6 @@ void CallManager::discard_call(CallId call_id, bool is_disconnected, int32 durat
send_closure(actor, &CallActor::discard_call, is_disconnected, duration, is_video, connection_id, std::move(promise));
}
void CallManager::accept_call(CallId call_id, CallProtocol &&protocol, Promise<> promise) {
auto actor = get_call_actor(call_id);
if (actor.empty()) {
return promise.set_error(Status::Error(400, "Call not found"));
}
send_closure(actor, &CallActor::accept_call, std::move(protocol), std::move(promise));
}
void CallManager::rate_call(CallId call_id, int32 rating, string comment,
vector<td_api::object_ptr<td_api::CallProblem>> &&problems, Promise<> promise) {
auto actor = get_call_actor(call_id);

View File

@ -31,9 +31,10 @@ class CallManager : public Actor {
void create_call(UserId user_id, tl_object_ptr<telegram_api::InputUser> &&input_user, CallProtocol &&protocol,
bool is_video, Promise<CallId> promise);
void accept_call(CallId call_id, CallProtocol &&protocol, Promise<> promise);
void send_call_signaling_data(CallId call_id, string &&data, Promise<> promise);
void discard_call(CallId call_id, bool is_disconnected, int32 duration, bool is_video, int64 connection_id,
Promise<> promise);
void accept_call(CallId call_id, CallProtocol &&protocol, Promise<> promise);
void rate_call(CallId call_id, int32 rating, string comment,
vector<td_api::object_ptr<td_api::CallProblem>> &&problems, Promise<> promise);
void send_call_debug_information(CallId call_id, string data, Promise<> promise);

View File

@ -5817,7 +5817,7 @@ void Td::on_request(uint64 id, td_api::createNewSecretChat &request) {
CREATE_REQUEST(CreateNewSecretChatRequest, request.user_id_);
}
void Td::on_request(uint64 id, td_api::createCall &request) {
void Td::on_request(uint64 id, const td_api::createCall &request) {
CHECK_IS_USER();
CREATE_REQUEST_PROMISE();
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<CallId> result) mutable {
@ -5846,14 +5846,7 @@ void Td::on_request(uint64 id, td_api::createCall &request) {
CallProtocol(*request.protocol_), request.is_video_, std::move(query_promise));
}
void Td::on_request(uint64 id, td_api::discardCall &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
send_closure(G()->call_manager(), &CallManager::discard_call, CallId(request.call_id_), request.is_disconnected_,
request.duration_, request.is_video_, request.connection_id_, std::move(promise));
}
void Td::on_request(uint64 id, td_api::acceptCall &request) {
void Td::on_request(uint64 id, const td_api::acceptCall &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
if (!request.protocol_) {
@ -5863,6 +5856,20 @@ void Td::on_request(uint64 id, td_api::acceptCall &request) {
CallProtocol(*request.protocol_), std::move(promise));
}
void Td::on_request(uint64 id, td_api::sendCallSignalingData &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
send_closure(G()->call_manager(), &CallManager::send_call_signaling_data, CallId(request.call_id_),
std::move(request.data_), std::move(promise));
}
void Td::on_request(uint64 id, const td_api::discardCall &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
send_closure(G()->call_manager(), &CallManager::discard_call, CallId(request.call_id_), request.is_disconnected_,
request.duration_, request.is_video_, request.connection_id_, std::move(promise));
}
void Td::on_request(uint64 id, td_api::sendCallRating &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.comment_);

View File

@ -663,11 +663,13 @@ class Td final : public NetQueryCallback {
void on_request(uint64 id, td_api::createNewSecretChat &request);
void on_request(uint64 id, td_api::createCall &request);
void on_request(uint64 id, const td_api::createCall &request);
void on_request(uint64 id, td_api::discardCall &request);
void on_request(uint64 id, const td_api::acceptCall &request);
void on_request(uint64 id, td_api::acceptCall &request);
void on_request(uint64 id, td_api::sendCallSignalingData &request);
void on_request(uint64 id, const td_api::discardCall &request);
void on_request(uint64 id, td_api::sendCallRating &request);

View File

@ -2732,6 +2732,11 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::createCall>(
as_user_id(args), td_api::make_object<td_api::callProtocol>(true, true, 65, 65, vector<string>{"2.6"}),
Random::fast(0, 1) == 1));
} else if (op == "ac" || op == "AcceptCall") {
send_request(td_api::make_object<td_api::acceptCall>(
as_call_id(args), td_api::make_object<td_api::callProtocol>(true, true, 65, 65, vector<string>{"2.6"})));
} else if (op == "scsd") {
send_request(td_api::make_object<td_api::sendCallSignalingData>(as_call_id(args), "abacaba"));
} else if (op == "dc" || op == "DiscardCall") {
string call_id;
string is_disconnected;
@ -2739,9 +2744,6 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::discardCall>(as_call_id(call_id), as_bool(is_disconnected), 0,
Random::fast(0, 1) == 1, 0));
} else if (op == "ac" || op == "AcceptCall") {
send_request(td_api::make_object<td_api::acceptCall>(
as_call_id(args), td_api::make_object<td_api::callProtocol>(true, true, 65, 65, vector<string>{"2.6"})));
} else if (op == "scr" || op == "SendCallRating") {
string call_id;
string rating;