From 9ac71272a3711baff3e48cd5d5b6a8d8c9a4f3f7 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 12 Mar 2021 20:11:44 +0300 Subject: [PATCH] Support joining group call as a stream listener. --- td/generate/scheme/td_api.tl | 11 +++++++++-- td/telegram/GroupCallManager.cpp | 13 +++++++++---- td/telegram/GroupCallManager.h | 4 ++-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 83cb6c325..600efb51e 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2138,8 +2138,15 @@ groupCallPayload ufrag:string pwd:string fingerprints:vector = 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 = GroupCallJoinResponse; + +//@description Describes that group call needs to be joined as a stream +groupCallJoinResponseStream = GroupCallJoinResponse; + //@description Represents a group call participant //@participant Identifier of the group call participant diff --git a/td/telegram/GroupCallManager.cpp b/td/telegram/GroupCallManager.cpp index 35757b1ad..b23a3c626 100644 --- a/td/telegram/GroupCallManager.cpp +++ b/td/telegram/GroupCallManager.cpp @@ -680,7 +680,7 @@ struct GroupCallManager::PendingJoinRequest { NetQueryRef query_ref; uint64 generation = 0; int32 audio_source = 0; - Promise> promise; + Promise> promise; }; 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, td_api::object_ptr &&payload, int32 audio_source, bool is_muted, const string &invite_hash, - Promise> &&promise) { + Promise> &&promise) { 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); @@ -2017,7 +2017,7 @@ void GroupCallManager::process_join_group_call_response(InputGroupCallId input_g })); } -Result> GroupCallManager::get_group_call_join_response_object( +Result> GroupCallManager::get_group_call_join_response_object( string json_response) { auto r_value = json_decode(json_response); if (r_value.is_error()) { @@ -2030,6 +2030,11 @@ Result> GroupCallManager::get_ } 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(); + } + TRY_RESULT(transport, get_json_object_field(value_object, "transport", JsonValue::Type::Object, false)); CHECK(transport.type() == JsonValue::Type::Object); auto &transport_object = transport.get_object(); @@ -2078,7 +2083,7 @@ Result> GroupCallManager::get_ } auto payload = td_api::make_object(ufrag, pwd, std::move(fingerprints_object)); - return td_api::make_object(std::move(payload), std::move(candidates_object)); + return td_api::make_object(std::move(payload), std::move(candidates_object)); } bool GroupCallManager::on_join_group_call_response(InputGroupCallId input_group_call_id, string json_response) { diff --git a/td/telegram/GroupCallManager.h b/td/telegram/GroupCallManager.h index af4d6538a..27173523c 100644 --- a/td/telegram/GroupCallManager.h +++ b/td/telegram/GroupCallManager.h @@ -61,7 +61,7 @@ class GroupCallManager : public Actor { void join_group_call(GroupCallId group_call_id, DialogId as_dialog_id, td_api::object_ptr &&payload, int32 audio_source, bool is_muted, - const string &invite_hash, Promise> &&promise); + const string &invite_hash, Promise> &&promise); void set_group_call_title(GroupCallId group_call_id, string title, Promise &&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, bool is_speaking, int32 date); - static Result> get_group_call_join_response_object( + static Result> get_group_call_join_response_object( string json_response); void try_clear_group_call_participants(InputGroupCallId input_group_call_id);