Update layer to 117. Support WebRTC call servers.

GitOrigin-RevId: 0db2aa89165760b8588a4ebd1c7cb77451e7c6d6
This commit is contained in:
levlam 2020-08-10 18:37:03 +03:00
parent 2277557f52
commit 62b0582bec
8 changed files with 73 additions and 24 deletions

View File

@ -1918,8 +1918,18 @@ callDiscardReasonHungUp = CallDiscardReason;
//@library_versions List of supported libtgvoip versions
callProtocol udp_p2p:Bool udp_reflector:Bool min_layer:int32 max_layer:int32 library_versions:vector<string> = CallProtocol;
//@description Describes the address of UDP reflectors @id Reflector identifier @ip IPv4 reflector address @ipv6 IPv6 reflector address @port Reflector port number @peer_tag Connection peer tag
callConnection id:int64 ip:string ipv6:string port:int32 peer_tag:bytes = CallConnection;
//@class CallServerType @description Describes the type of a call server
//@description A Telegram call reflector @peer_tag A peer tag to be used with the reflector
callServerTypeTelegramReflector peer_tag:bytes = CallServerType;
//@description A WebRTC server @username Username to be used for authentification @password Authentication password @supports_turn True, if the server supports TURN @supports_stun True, if the server supports STUN
callServerTypeWebrtc username:string password:string supports_turn:Bool supports_stun:Bool = CallServerType;
//@description Describes a server for relaying call data @id Server identifier @ip_address Server IPv4 address @ipv6_address Server IPv6 address @port Server port number @type Server type
callServer id:int64 ip_address:string ipv6_address:string port:int32 type:CallServerType = CallServer;
//@description Contains the call identifier @id Call identifier
@ -1934,8 +1944,8 @@ callStatePending is_created:Bool is_received:Bool = CallState;
//@description The call has been answered and encryption keys are being exchanged
callStateExchangingKeys = CallState;
//@description The call is ready to use @protocol Call protocols supported by the peer @connections Available UDP reflectors @config A JSON-encoded call config @encryption_key Call encryption key @emojis Encryption key emojis fingerprint @allow_p2p True, if peer-to-peer connection is allowed by users privacy settings
callStateReady protocol:callProtocol connections:vector<callConnection> config:string encryption_key:bytes emojis:vector<string> allow_p2p:Bool = CallState;
//@description The call is ready to use @protocol Call protocols supported by the peer @servers List of available call servers @config A JSON-encoded call config @encryption_key Call encryption key @emojis Encryption key emojis fingerprint @allow_p2p True, if peer-to-peer connection is allowed by users privacy settings
callStateReady protocol:callProtocol servers:vector<callServer> config:string encryption_key:bytes emojis:vector<string> allow_p2p:Bool = CallState;
//@description The call is hanging up after discardCall has been called
callStateHangingUp = CallState;

Binary file not shown.

View File

@ -812,6 +812,7 @@ phoneCall#8742ae7f flags:# p2p_allowed:flags.5?true video:flags.6?true id:long a
phoneCallDiscarded#50ca4de1 flags:# need_rating:flags.2?true need_debug:flags.3?true video:flags.6?true id:long reason:flags.0?PhoneCallDiscardReason duration:flags.1?int = PhoneCall;
phoneConnection#9d4c17c0 id:long ip:string ipv6:string port:int peer_tag:bytes = PhoneConnection;
phoneConnectionWebrtc#635fe375 flags:# turn:flags.0?true stun:flags.1?true id:long ip:string ipv6:string port:int username:string password:string = PhoneConnection;
phoneCallProtocol#fc878fc8 flags:# udp_p2p:flags.0?true udp_reflector:flags.1?true min_layer:int max_layer:int library_versions:Vector<string> = PhoneCallProtocol;

Binary file not shown.

View File

@ -64,12 +64,34 @@ CallProtocol::CallProtocol(const td_api::callProtocol &protocol)
, library_versions(protocol.library_versions_) {
}
CallConnection::CallConnection(const telegram_api::phoneConnection &connection)
: id(connection.id_)
, ip(connection.ip_)
, ipv6(connection.ipv6_)
, port(connection.port_)
, peer_tag(connection.peer_tag_.as_slice().str()) {
CallConnection::CallConnection(const telegram_api::PhoneConnection &connection) {
switch (connection.get_id()) {
case telegram_api::phoneConnection::ID: {
auto &conn = static_cast<const telegram_api::phoneConnection &>(connection);
type = Type::Telegram;
id = conn.id_;
ip = conn.ip_;
ipv6 = conn.ipv6_;
port = conn.port_;
peer_tag = conn.peer_tag_.as_slice().str();
break;
}
case telegram_api::phoneConnectionWebrtc::ID: {
auto &conn = static_cast<const telegram_api::phoneConnectionWebrtc &>(connection);
type = Type::Webrtc;
id = conn.id_;
ip = conn.ip_;
ipv6 = conn.ipv6_;
port = conn.port_;
username = conn.username_;
password = conn.password_;
supports_turn = conn.turn_;
supports_stun = conn.stun_;
break;
}
default:
UNREACHABLE();
}
}
tl_object_ptr<td_api::callProtocol> CallProtocol::get_call_protocol_object() const {
@ -77,12 +99,19 @@ tl_object_ptr<td_api::callProtocol> CallProtocol::get_call_protocol_object() con
vector<string>(library_versions));
}
tl_object_ptr<telegram_api::phoneConnection> CallConnection::get_input_phone_connection() const {
return make_tl_object<telegram_api::phoneConnection>(id, ip, ipv6, port, BufferSlice(peer_tag));
}
tl_object_ptr<td_api::callConnection> CallConnection::get_call_connection_object() const {
return make_tl_object<td_api::callConnection>(id, ip, ipv6, port, peer_tag);
tl_object_ptr<td_api::callServer> CallConnection::get_call_server_object() const {
auto server_type = [&]() -> tl_object_ptr<td_api::CallServerType> {
switch (type) {
case Type::Telegram:
return make_tl_object<td_api::callServerTypeTelegramReflector>(peer_tag);
case Type::Webrtc:
return make_tl_object<td_api::callServerTypeWebrtc>(username, password, supports_turn, supports_stun);
default:
UNREACHABLE();
return nullptr;
}
}();
return make_tl_object<td_api::callServer>(id, ip, ipv6, port, std::move(server_type));
}
tl_object_ptr<td_api::CallState> CallState::get_call_state_object() const {
@ -92,7 +121,7 @@ tl_object_ptr<td_api::CallState> CallState::get_call_state_object() const {
case Type::ExchangingKey:
return make_tl_object<td_api::callStateExchangingKeys>();
case Type::Ready: {
auto call_connections = transform(connections, [](auto &c) { return c.get_call_connection_object(); });
auto call_connections = transform(connections, [](auto &c) { return c.get_call_server_object(); });
return make_tl_object<td_api::callStateReady>(protocol.get_call_protocol_object(), std::move(call_connections),
config, key, vector<string>(emojis_fingerprint), allow_p2p);
}

View File

@ -46,17 +46,25 @@ struct CallProtocol {
};
struct CallConnection {
enum class Type : int32 { Telegram, Webrtc };
Type type;
int64 id;
string ip;
string ipv6;
int32 port;
// Telegram
string peer_tag;
explicit CallConnection(const telegram_api::phoneConnection &connection);
// WebRTC
string username;
string password;
bool supports_turn = false;
bool supports_stun = false;
tl_object_ptr<telegram_api::phoneConnection> get_input_phone_connection() const;
explicit CallConnection(const telegram_api::PhoneConnection &connection);
tl_object_ptr<td_api::callConnection> get_call_connection_object() const;
tl_object_ptr<td_api::callServer> get_call_server_object() const;
};
struct CallState {

View File

@ -8,7 +8,7 @@
namespace td {
constexpr int32 MTPROTO_LAYER = 116;
constexpr int32 MTPROTO_LAYER = 117;
enum class Version : int32 {
Initial, // 0
@ -31,7 +31,7 @@ enum class Version : int32 {
AddMessageUnsupportedVersion,
SupportInstantView2_0,
AddNotificationGroupInfoMaxRemovedMessageId,
SupportMinithumbnails, // 20
SupportMinithumbnails, // 20
AddVideoCallsSupport,
AddPhotoSizeSource,
AddFolders,

View File

@ -2730,11 +2730,12 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::closeSecretChat>(as_secret_chat_id(args)));
} else if (op == "cc" || op == "CreateCall") {
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"}),
as_user_id(args), td_api::make_object<td_api::callProtocol>(true, true, 65, 65, vector<string>{"2.6", "3.0"}),
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"})));
as_call_id(args),
td_api::make_object<td_api::callProtocol>(true, true, 65, 65, vector<string>{"2.6", "3.0"})));
} else if (op == "scsd") {
send_request(td_api::make_object<td_api::sendCallSignalingData>(as_call_id(args), "abacaba"));
} else if (op == "dc" || op == "DiscardCall") {