Add class groupCallParticipantVideoInfo.

This commit is contained in:
levlam 2021-05-03 16:30:14 +03:00
parent 84b96be914
commit 529213030c
5 changed files with 101 additions and 20 deletions

View File

@ -2170,12 +2170,14 @@ groupCallRecentSpeaker participant_id:MessageSender is_speaking:Bool = GroupCall
//@duration Call duration; for ended calls only
groupCall id:int32 title:string scheduled_start_date:int32 enabled_start_notification:Bool is_active:Bool is_joined:Bool need_rejoin:Bool can_be_managed:Bool participant_count:int32 loaded_all_participants:Bool recent_speakers:vector<groupCallRecentSpeaker> is_my_video_enabled:Bool can_start_video:Bool mute_new_participants:Bool can_change_mute_new_participants:Bool record_duration:int32 duration:int32 = GroupCall;
//@description Contains informatioan about a group call participant's video @sources List of video synchronization sources @endpoint_id Video endpoint identifier
groupCallParticipantVideoInfo sources:vector<int32> endpoint_id:string = GroupCallParticipantVideoInfo;
//@description Represents a group call participant
//@participant_id Identifier of the group call participant
//@audio_source User's audio synchronization source
//@endpoint_id User's endpoint identifier
//@video_payload Description of user's video payload; may be empty if there is no video channel
//@video_info Information about user's video; may be null if there is no active video
//@screen_sharing_video_info Information about user's screen sharing video; may be null if there is no active screen sharing video
//@bio The participant user's bio or the participant chat's description
//@is_current_user True, if the participant is the current user
//@is_speaking True, if the participant is speaking as set by setGroupCallParticipantIsSpeaking
@ -2189,7 +2191,7 @@ groupCall id:int32 title:string scheduled_start_date:int32 enabled_start_notific
//@can_unmute_self True, if the participant is muted for all users, but can unmute themself
//@volume_level Participant's volume level; 1-20000 in hundreds of percents
//@order User's order in the group call participant list. Orders must be compared lexicographically. The bigger is order, the higher is user in the list. If order is empty, the user must be removed from the participant list
groupCallParticipant participant_id:MessageSender audio_source:int32 endpoint_id:string video_payload:string bio:string is_current_user:Bool is_speaking:Bool is_hand_raised:Bool can_be_muted_for_all_users:Bool can_be_unmuted_for_all_users:Bool can_be_muted_for_current_user:Bool can_be_unmuted_for_current_user:Bool is_muted_for_all_users:Bool is_muted_for_current_user:Bool can_unmute_self:Bool volume_level:int32 order:string = GroupCallParticipant;
groupCallParticipant participant_id:MessageSender audio_source:int32 video_info:groupCallParticipantVideoInfo screen_sharing_video_info:groupCallParticipantVideoInfo bio:string is_current_user:Bool is_speaking:Bool is_hand_raised:Bool can_be_muted_for_all_users:Bool can_be_unmuted_for_all_users:Bool can_be_muted_for_current_user:Bool can_be_unmuted_for_current_user:Bool is_muted_for_all_users:Bool is_muted_for_current_user:Bool can_unmute_self:Bool volume_level:int32 order:string = GroupCallParticipant;
//@class CallProblem @description Describes the exact type of a problem with a call

View File

@ -57,8 +57,10 @@ GroupCallParticipant::GroupCallParticipant(const tl_object_ptr<telegram_api::gro
version = call_version;
if (participant->video_ != nullptr) {
get_group_call_video_payload(participant->video_->data_, endpoint);
video_payload = std::move(participant->video_->data_);
video_payload = get_group_call_video_payload(participant->video_->data_);
}
if (participant->presentation_ != nullptr) {
presentation_payload = get_group_call_video_payload(participant->presentation_->data_);
}
}
@ -252,16 +254,19 @@ td_api::object_ptr<td_api::groupCallParticipant> GroupCallParticipant::get_group
}
return td_api::make_object<td_api::groupCallParticipant>(
td->messages_manager_->get_message_sender_object(dialog_id), audio_source, endpoint, video_payload, about,
is_self, is_speaking, get_is_hand_raised(), can_be_muted_for_all_users, can_be_unmuted_for_all_users,
can_be_muted_only_for_self, can_be_unmuted_only_for_self, get_is_muted_for_all_users(), get_is_muted_locally(),
get_is_muted_by_themselves(), get_volume_level(), order.get_group_call_participant_order_object());
td->messages_manager_->get_message_sender_object(dialog_id), audio_source,
get_group_call_participant_video_info_object(video_payload),
get_group_call_participant_video_info_object(presentation_payload), about, is_self, is_speaking,
get_is_hand_raised(), can_be_muted_for_all_users, can_be_unmuted_for_all_users, can_be_muted_only_for_self,
can_be_unmuted_only_for_self, get_is_muted_for_all_users(), get_is_muted_locally(), get_is_muted_by_themselves(),
get_volume_level(), order.get_group_call_participant_order_object());
}
bool operator==(const GroupCallParticipant &lhs, const GroupCallParticipant &rhs) {
return lhs.dialog_id == rhs.dialog_id && lhs.audio_source == rhs.audio_source && lhs.endpoint == rhs.endpoint &&
lhs.video_payload == rhs.video_payload && lhs.about == rhs.about && lhs.is_self == rhs.is_self &&
lhs.is_speaking == rhs.is_speaking && lhs.get_is_hand_raised() == rhs.get_is_hand_raised() &&
return lhs.dialog_id == rhs.dialog_id && lhs.audio_source == rhs.audio_source &&
lhs.video_payload == rhs.video_payload && lhs.presentation_payload == rhs.presentation_payload &&
lhs.about == rhs.about && lhs.is_self == rhs.is_self && lhs.is_speaking == rhs.is_speaking &&
lhs.get_is_hand_raised() == rhs.get_is_hand_raised() &&
lhs.can_be_muted_for_all_users == rhs.can_be_muted_for_all_users &&
lhs.can_be_unmuted_for_all_users == rhs.can_be_unmuted_for_all_users &&
lhs.can_be_muted_only_for_self == rhs.can_be_muted_only_for_self &&

View File

@ -22,8 +22,8 @@ class Td;
struct GroupCallParticipant {
DialogId dialog_id;
string about;
string video_payload;
string endpoint;
GroupCallVideoPayload video_payload;
GroupCallVideoPayload presentation_payload;
int32 audio_source = 0;
int32 joined_date = 0;
int32 active_date = 0;

View File

@ -6,26 +6,86 @@
//
#include "td/telegram/GroupCallVideoPayload.h"
#include "td/utils/algorithm.h"
#include "td/utils/JsonBuilder.h"
#include "td/utils/misc.h"
#include <algorithm>
namespace td {
void get_group_call_video_payload(string json, string &endpoint) {
auto r_value = json_decode(json);
bool operator==(const GroupCallVideoPayload &lhs, const GroupCallVideoPayload &rhs) {
return lhs.sources == rhs.sources && lhs.endpoint == rhs.endpoint;
}
td_api::object_ptr<td_api::groupCallParticipantVideoInfo> get_group_call_participant_video_info_object(
const GroupCallVideoPayload &payload) {
if (payload.endpoint.empty() || payload.sources.empty()) {
return nullptr;
}
return td_api::make_object<td_api::groupCallParticipantVideoInfo>(vector<int32>(payload.sources),
payload.endpoint);
}
static vector<int32> get_group_call_video_sources(JsonValue &&value) {
if (value.type() != JsonValue::Type::Object) {
return {};
}
vector<int32> result;
auto &value_object = value.get_object();
auto r_sources = get_json_object_field(value_object, "sources", JsonValue::Type::Array, false);
if (r_sources.is_error()) {
return {};
}
auto sources = r_sources.move_as_ok();
for (auto &source : sources.get_array()) {
Slice source_str;
if (source.type() == JsonValue::Type::String) {
source_str = source.get_string();
} else if (source.type() == JsonValue::Type::Number) {
source_str = source.get_number();
}
auto r_source_id = to_integer_safe<int64>(source_str);
if (r_source_id.is_ok()) {
result.push_back(static_cast<int32>(r_source_id.ok()));
}
}
return result;
}
GroupCallVideoPayload get_group_call_video_payload(string json) {
string json_copy = json;
auto r_value = json_decode(json_copy);
if (r_value.is_error()) {
return;
return {};
}
auto value = r_value.move_as_ok();
if (value.type() != JsonValue::Type::Object) {
return;
return {};
}
GroupCallVideoPayload result;
result.json_payload = std::move(json);
auto &value_object = value.get_object();
auto r_endpoint = get_json_object_string_field(value_object, "endpoint", true);
if (r_endpoint.is_ok()) {
endpoint = r_endpoint.move_as_ok();
result.endpoint = r_endpoint.move_as_ok();
}
auto r_source_groups = get_json_object_field(value_object, "ssrc-groups", JsonValue::Type::Array, false);
if (r_source_groups.is_ok()) {
auto source_groups = r_source_groups.move_as_ok();
for (auto &source_group_object : source_groups.get_array()) {
append(result.sources, get_group_call_video_sources(std::move(source_group_object)));
}
td::unique(result.sources);
}
return result;
}
} // namespace td

View File

@ -6,10 +6,24 @@
//
#pragma once
#include "td/telegram/td_api.h"
#include "td/utils/common.h"
#include "td/utils/Status.h"
namespace td {
void get_group_call_video_payload(string json, string &endpoint);
struct GroupCallVideoPayload {
vector<int32> sources;
string endpoint;
string json_payload;
};
bool operator==(const GroupCallVideoPayload &lhs, const GroupCallVideoPayload &rhs);
td_api::object_ptr<td_api::groupCallParticipantVideoInfo> get_group_call_participant_video_info_object(
const GroupCallVideoPayload &payload);
GroupCallVideoPayload get_group_call_video_payload(string json);
} // namespace td