2021-01-12 15:05:25 +01:00
|
|
|
//
|
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021
|
|
|
|
//
|
|
|
|
// 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-06-01 17:52:58 +02:00
|
|
|
static bool operator==(const GroupCallVideoSourceGroup &lhs, const GroupCallVideoSourceGroup &rhs) {
|
|
|
|
return lhs.semantics == rhs.semantics && lhs.source_ids == rhs.source_ids;
|
|
|
|
}
|
|
|
|
|
2021-05-03 15:30:14 +02:00
|
|
|
bool operator==(const GroupCallVideoPayload &lhs, const GroupCallVideoPayload &rhs) {
|
2021-06-01 21:34:50 +02:00
|
|
|
return lhs.source_groups == rhs.source_groups && lhs.endpoint == rhs.endpoint && lhs.is_paused == rhs.is_paused;
|
2021-06-01 17:52:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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));
|
2021-05-03 15:30:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::groupCallParticipantVideoInfo> get_group_call_participant_video_info_object(
|
|
|
|
const GroupCallVideoPayload &payload) {
|
2021-06-01 17:52:58 +02:00
|
|
|
if (payload.endpoint.empty() || payload.source_groups.empty()) {
|
2021-05-03 15:30:14 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
2021-06-01 17:52:58 +02:00
|
|
|
return td_api::make_object<td_api::groupCallParticipantVideoInfo>(
|
2021-06-01 21:34:50 +02:00
|
|
|
transform(payload.source_groups, get_group_call_video_source_group_object), payload.endpoint, payload.is_paused);
|
2021-05-03 15:30:14 +02:00
|
|
|
}
|
|
|
|
|
2021-06-01 17:52:58 +02:00
|
|
|
GroupCallVideoPayload get_group_call_video_payload(const telegram_api::groupCallParticipantVideo *video) {
|
2021-05-03 15:30:14 +02:00
|
|
|
GroupCallVideoPayload result;
|
2021-06-01 17:52:58 +02:00
|
|
|
result.endpoint = video->endpoint_;
|
|
|
|
result.source_groups = transform(video->source_groups_, [](auto &&source_group) {
|
|
|
|
GroupCallVideoSourceGroup result;
|
|
|
|
result.semantics = source_group->semantics_;
|
|
|
|
result.source_ids = source_group->sources_;
|
|
|
|
return result;
|
|
|
|
});
|
2021-06-01 21:34:50 +02:00
|
|
|
result.is_paused = video->paused_;
|
2021-05-03 15:30:14 +02:00
|
|
|
return result;
|
2021-01-12 15:05:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|