Move GroupCallVideoPayload methods inside class.

This commit is contained in:
levlam 2021-07-11 01:45:30 +03:00
parent 039509afe7
commit f7ed3d6b99
3 changed files with 25 additions and 24 deletions

View File

@ -57,13 +57,13 @@ GroupCallParticipant::GroupCallParticipant(const tl_object_ptr<telegram_api::gro
version = call_version;
if (participant->video_ != nullptr) {
video_payload = get_group_call_video_payload(participant->video_.get());
video_payload = GroupCallVideoPayload(participant->video_.get());
}
if (participant->presentation_ != nullptr) {
if (participant->presentation_->flags_ & telegram_api::groupCallParticipantVideo::AUDIO_SOURCE_MASK) {
presentation_audio_source = participant->presentation_->audio_source_;
}
presentation_payload = get_group_call_video_payload(participant->presentation_.get());
presentation_payload = GroupCallVideoPayload(participant->presentation_.get());
}
}
@ -259,8 +259,8 @@ 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, presentation_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,
video_payload.get_group_call_participant_video_info_object(),
presentation_payload.get_group_call_participant_video_info_object(), 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());

View File

@ -18,35 +18,36 @@ bool operator==(const GroupCallVideoPayload &lhs, const GroupCallVideoPayload &r
return lhs.source_groups == rhs.source_groups && lhs.endpoint == rhs.endpoint && lhs.is_paused == rhs.is_paused;
}
static td_api::object_ptr<td_api::groupCallVideoSourceGroup> get_group_call_video_source_group_object(
const GroupCallVideoSourceGroup &group) {
return td_api::make_object<td_api::groupCallVideoSourceGroup>(group.semantics, vector<int32>(group.source_ids));
}
bool GroupCallVideoPayload::is_empty() const {
return endpoint.empty() || source_groups.empty();
}
td_api::object_ptr<td_api::groupCallParticipantVideoInfo> get_group_call_participant_video_info_object(
const GroupCallVideoPayload &payload) {
if (payload.is_empty()) {
td_api::object_ptr<td_api::groupCallParticipantVideoInfo>
GroupCallVideoPayload::get_group_call_participant_video_info_object() const {
if (is_empty()) {
return nullptr;
}
auto get_group_call_video_source_group_object = [](const GroupCallVideoSourceGroup &group) {
return td_api::make_object<td_api::groupCallVideoSourceGroup>(group.semantics, vector<int32>(group.source_ids));
};
return td_api::make_object<td_api::groupCallParticipantVideoInfo>(
transform(payload.source_groups, get_group_call_video_source_group_object), payload.endpoint, payload.is_paused);
transform(source_groups, get_group_call_video_source_group_object), endpoint, is_paused);
}
GroupCallVideoPayload get_group_call_video_payload(const telegram_api::groupCallParticipantVideo *video) {
GroupCallVideoPayload result;
result.endpoint = video->endpoint_;
result.source_groups = transform(video->source_groups_, [](auto &&source_group) {
GroupCallVideoPayload::GroupCallVideoPayload(const telegram_api::groupCallParticipantVideo *video) {
if (video == nullptr) {
return;
}
endpoint = video->endpoint_;
source_groups = transform(video->source_groups_, [](auto &&source_group) {
GroupCallVideoSourceGroup result;
result.semantics = source_group->semantics_;
result.source_ids = source_group->sources_;
return result;
});
result.is_paused = video->paused_;
return result;
is_paused = video->paused_;
}
} // namespace td

View File

@ -23,14 +23,14 @@ struct GroupCallVideoPayload {
string endpoint;
bool is_paused = false;
GroupCallVideoPayload() = default;
explicit GroupCallVideoPayload(const telegram_api::groupCallParticipantVideo *video);
bool is_empty() const;
td_api::object_ptr<td_api::groupCallParticipantVideoInfo> get_group_call_participant_video_info_object() const;
};
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(const telegram_api::groupCallParticipantVideo *video);
} // namespace td