Support joining group call as a stream listener.

This commit is contained in:
levlam 2021-03-12 20:11:44 +03:00
parent a833d5e292
commit 9ac71272a3
3 changed files with 20 additions and 8 deletions

View File

@ -2138,8 +2138,15 @@ groupCallPayload ufrag:string pwd:string fingerprints:vector<groupCallPayloadFin
//@ip Value of the field ip @type Value of the field type @tcp_type Value of the field tcp_type @rel_addr Value of the field rel_addr @rel_port Value of the field rel_port //@ip Value of the field ip @type Value of the field type @tcp_type Value of the field tcp_type @rel_addr Value of the field rel_addr @rel_port Value of the field rel_port
groupCallJoinResponseCandidate port:string protocol:string network:string generation:string id:string component:string foundation:string priority:string ip:string type:string tcp_type:string rel_addr:string rel_port:string = GroupCallJoinResponseCandidate; groupCallJoinResponseCandidate port:string protocol:string network:string generation:string id:string component:string foundation:string priority:string ip:string type:string tcp_type:string rel_addr:string rel_port:string = GroupCallJoinResponseCandidate;
//@description Describes a join response for interaction with tgcalls @payload Join response payload to pass to tgcalls @candidates Join response candidates to pass to tgcalls
groupCallJoinResponse payload:groupCallPayload candidates:vector<groupCallJoinResponseCandidate> = GroupCallJoinResponse; //@class GroupCallJoinResponse @description Describes a group call join response
//@description Contains data needed to join the group call with WebRTC @payload Group call payload to pass to tgcalls @candidates Join response candidates to pass to tgcalls
groupCallJoinResponseWebrtc payload:groupCallPayload candidates:vector<groupCallJoinResponseCandidate> = GroupCallJoinResponse;
//@description Describes that group call needs to be joined as a stream
groupCallJoinResponseStream = GroupCallJoinResponse;
//@description Represents a group call participant //@description Represents a group call participant
//@participant Identifier of the group call participant //@participant Identifier of the group call participant

View File

@ -680,7 +680,7 @@ struct GroupCallManager::PendingJoinRequest {
NetQueryRef query_ref; NetQueryRef query_ref;
uint64 generation = 0; uint64 generation = 0;
int32 audio_source = 0; int32 audio_source = 0;
Promise<td_api::object_ptr<td_api::groupCallJoinResponse>> promise; Promise<td_api::object_ptr<td_api::GroupCallJoinResponse>> promise;
}; };
GroupCallManager::GroupCallManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) { GroupCallManager::GroupCallManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
@ -1801,7 +1801,7 @@ void GroupCallManager::get_group_call_stream_segment(GroupCallId group_call_id,
void GroupCallManager::join_group_call(GroupCallId group_call_id, DialogId as_dialog_id, void GroupCallManager::join_group_call(GroupCallId group_call_id, DialogId as_dialog_id,
td_api::object_ptr<td_api::groupCallPayload> &&payload, int32 audio_source, td_api::object_ptr<td_api::groupCallPayload> &&payload, int32 audio_source,
bool is_muted, const string &invite_hash, bool is_muted, const string &invite_hash,
Promise<td_api::object_ptr<td_api::groupCallJoinResponse>> &&promise) { Promise<td_api::object_ptr<td_api::GroupCallJoinResponse>> &&promise) {
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);
@ -2017,7 +2017,7 @@ void GroupCallManager::process_join_group_call_response(InputGroupCallId input_g
})); }));
} }
Result<td_api::object_ptr<td_api::groupCallJoinResponse>> GroupCallManager::get_group_call_join_response_object( Result<td_api::object_ptr<td_api::GroupCallJoinResponse>> GroupCallManager::get_group_call_join_response_object(
string json_response) { string json_response) {
auto r_value = json_decode(json_response); auto r_value = json_decode(json_response);
if (r_value.is_error()) { if (r_value.is_error()) {
@ -2030,6 +2030,11 @@ Result<td_api::object_ptr<td_api::groupCallJoinResponse>> GroupCallManager::get_
} }
auto &value_object = value.get_object(); auto &value_object = value.get_object();
auto r_stream = get_json_object_bool_field(value_object, "stream");
if (r_stream.is_ok() && r_stream.ok() == true) {
return td_api::make_object<td_api::groupCallJoinResponseStream>();
}
TRY_RESULT(transport, get_json_object_field(value_object, "transport", JsonValue::Type::Object, false)); TRY_RESULT(transport, get_json_object_field(value_object, "transport", JsonValue::Type::Object, false));
CHECK(transport.type() == JsonValue::Type::Object); CHECK(transport.type() == JsonValue::Type::Object);
auto &transport_object = transport.get_object(); auto &transport_object = transport.get_object();
@ -2078,7 +2083,7 @@ Result<td_api::object_ptr<td_api::groupCallJoinResponse>> GroupCallManager::get_
} }
auto payload = td_api::make_object<td_api::groupCallPayload>(ufrag, pwd, std::move(fingerprints_object)); auto payload = td_api::make_object<td_api::groupCallPayload>(ufrag, pwd, std::move(fingerprints_object));
return td_api::make_object<td_api::groupCallJoinResponse>(std::move(payload), std::move(candidates_object)); return td_api::make_object<td_api::groupCallJoinResponseWebrtc>(std::move(payload), std::move(candidates_object));
} }
bool GroupCallManager::on_join_group_call_response(InputGroupCallId input_group_call_id, string json_response) { bool GroupCallManager::on_join_group_call_response(InputGroupCallId input_group_call_id, string json_response) {

View File

@ -61,7 +61,7 @@ class GroupCallManager : public Actor {
void join_group_call(GroupCallId group_call_id, DialogId as_dialog_id, void join_group_call(GroupCallId group_call_id, DialogId as_dialog_id,
td_api::object_ptr<td_api::groupCallPayload> &&payload, int32 audio_source, bool is_muted, td_api::object_ptr<td_api::groupCallPayload> &&payload, int32 audio_source, bool is_muted,
const string &invite_hash, Promise<td_api::object_ptr<td_api::groupCallJoinResponse>> &&promise); const string &invite_hash, Promise<td_api::object_ptr<td_api::GroupCallJoinResponse>> &&promise);
void set_group_call_title(GroupCallId group_call_id, string title, Promise<Unit> &&promise); void set_group_call_title(GroupCallId group_call_id, string title, Promise<Unit> &&promise);
@ -252,7 +252,7 @@ class GroupCallManager : public Actor {
DialogId set_group_call_participant_is_speaking_by_source(InputGroupCallId input_group_call_id, int32 audio_source, DialogId set_group_call_participant_is_speaking_by_source(InputGroupCallId input_group_call_id, int32 audio_source,
bool is_speaking, int32 date); bool is_speaking, int32 date);
static Result<td_api::object_ptr<td_api::groupCallJoinResponse>> get_group_call_join_response_object( static Result<td_api::object_ptr<td_api::GroupCallJoinResponse>> get_group_call_join_response_object(
string json_response); string json_response);
void try_clear_group_call_participants(InputGroupCallId input_group_call_id); void try_clear_group_call_participants(InputGroupCallId input_group_call_id);