2021-01-12 15:05:25 +01:00
|
|
|
//
|
2022-12-31 22:28:08 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
2021-01-12 15:05:25 +01:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#include "td/telegram/GroupCallVideoPayload.h"
|
|
|
|
|
2021-05-03 15:30:14 +02:00
|
|
|
#include "td/utils/algorithm.h"
|
2021-01-12 15:05:25 +01:00
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2021-05-03 15:30:14 +02:00
|
|
|
bool operator==(const GroupCallVideoPayload &lhs, const GroupCallVideoPayload &rhs) {
|
2021-07-11 00:55:44 +02:00
|
|
|
if (lhs.source_groups_.size() != rhs.source_groups_.size() || lhs.endpoint_ != rhs.endpoint_ ||
|
|
|
|
lhs.is_paused_ != rhs.is_paused_) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for (size_t i = 0; i < lhs.source_groups_.size(); i++) {
|
|
|
|
if (lhs.source_groups_[i].semantics_ != rhs.source_groups_[i].semantics_ ||
|
|
|
|
lhs.source_groups_[i].source_ids_ != rhs.source_groups_[i].source_ids_) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2021-06-01 17:52:58 +02:00
|
|
|
}
|
|
|
|
|
2021-07-11 00:34:44 +02:00
|
|
|
bool GroupCallVideoPayload::is_empty() const {
|
2021-07-11 00:55:44 +02:00
|
|
|
return endpoint_.empty() || source_groups_.empty();
|
2021-07-11 00:34:44 +02:00
|
|
|
}
|
|
|
|
|
2021-07-11 00:45:30 +02:00
|
|
|
td_api::object_ptr<td_api::groupCallParticipantVideoInfo>
|
|
|
|
GroupCallVideoPayload::get_group_call_participant_video_info_object() const {
|
|
|
|
if (is_empty()) {
|
2021-05-03 15:30:14 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
2021-07-11 00:45:30 +02:00
|
|
|
|
|
|
|
auto get_group_call_video_source_group_object = [](const GroupCallVideoSourceGroup &group) {
|
2021-07-11 00:55:44 +02:00
|
|
|
return td_api::make_object<td_api::groupCallVideoSourceGroup>(group.semantics_, vector<int32>(group.source_ids_));
|
2021-07-11 00:45:30 +02:00
|
|
|
};
|
2021-06-01 17:52:58 +02:00
|
|
|
return td_api::make_object<td_api::groupCallParticipantVideoInfo>(
|
2021-07-11 00:55:44 +02:00
|
|
|
transform(source_groups_, get_group_call_video_source_group_object), endpoint_, is_paused_);
|
2021-05-03 15:30:14 +02:00
|
|
|
}
|
|
|
|
|
2021-07-11 00:45:30 +02:00
|
|
|
GroupCallVideoPayload::GroupCallVideoPayload(const telegram_api::groupCallParticipantVideo *video) {
|
|
|
|
if (video == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-11 00:55:44 +02:00
|
|
|
endpoint_ = video->endpoint_;
|
|
|
|
source_groups_ = transform(video->source_groups_, [](auto &&source_group) {
|
2021-06-01 17:52:58 +02:00
|
|
|
GroupCallVideoSourceGroup result;
|
2021-07-11 00:55:44 +02:00
|
|
|
result.semantics_ = source_group->semantics_;
|
|
|
|
result.source_ids_ = source_group->sources_;
|
2021-06-01 17:52:58 +02:00
|
|
|
return result;
|
|
|
|
});
|
2021-07-11 00:55:44 +02:00
|
|
|
if (!is_empty()) {
|
|
|
|
is_paused_ = video->paused_;
|
|
|
|
}
|
2021-01-12 15:05:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|