2018-12-31 20:04:05 +01:00
|
|
|
//
|
2022-01-01 01:35:39 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
|
2018-12-31 20:04:05 +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)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "td/telegram/CallActor.h"
|
|
|
|
#include "td/telegram/CallId.h"
|
2019-08-06 19:07:23 +02:00
|
|
|
#include "td/telegram/td_api.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/telegram_api.h"
|
|
|
|
|
|
|
|
#include "td/actor/actor.h"
|
|
|
|
#include "td/actor/PromiseFuture.h"
|
2022-02-07 22:04:34 +01:00
|
|
|
#include "td/utils/FlatHashMap.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/Status.h"
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class CallManager final : public Actor {
|
2018-12-31 20:04:05 +01:00
|
|
|
public:
|
|
|
|
using Update = telegram_api::object_ptr<telegram_api::updatePhoneCall>;
|
|
|
|
explicit CallManager(ActorShared<> parent);
|
|
|
|
void update_call(Update call);
|
2020-05-29 10:26:08 +02:00
|
|
|
void update_call_signaling_data(int64 call_id, string data);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void create_call(UserId user_id, tl_object_ptr<telegram_api::InputUser> &&input_user, CallProtocol &&protocol,
|
2019-06-08 11:26:35 +02:00
|
|
|
bool is_video, Promise<CallId> promise);
|
2022-04-22 14:16:09 +02:00
|
|
|
|
|
|
|
void accept_call(CallId call_id, CallProtocol &&protocol, Promise<Unit> promise);
|
|
|
|
|
|
|
|
void send_call_signaling_data(CallId call_id, string &&data, Promise<Unit> promise);
|
|
|
|
|
2019-06-08 11:26:35 +02:00
|
|
|
void discard_call(CallId call_id, bool is_disconnected, int32 duration, bool is_video, int64 connection_id,
|
2022-04-22 14:16:09 +02:00
|
|
|
Promise<Unit> promise);
|
|
|
|
|
2019-08-06 19:07:23 +02:00
|
|
|
void rate_call(CallId call_id, int32 rating, string comment,
|
2022-04-22 14:16:09 +02:00
|
|
|
vector<td_api::object_ptr<td_api::CallProblem>> &&problems, Promise<Unit> promise);
|
|
|
|
|
|
|
|
void send_call_debug_information(CallId call_id, string data, Promise<Unit> promise);
|
|
|
|
|
|
|
|
void send_call_log(CallId call_id, td_api::object_ptr<td_api::InputFile> log_file, Promise<Unit> promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool close_flag_ = false;
|
|
|
|
ActorShared<> parent_;
|
|
|
|
|
|
|
|
struct CallInfo {
|
|
|
|
CallId call_id{0};
|
|
|
|
std::vector<Update> updates;
|
|
|
|
};
|
|
|
|
std::map<int64, CallInfo> call_info_;
|
|
|
|
int32 next_call_id_{1};
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<CallId, ActorOwn<CallActor>, CallIdHash> id_to_actor_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
ActorId<CallActor> get_call_actor(CallId call_id);
|
|
|
|
CallId create_call_actor();
|
|
|
|
void set_call_id(CallId call_id, Result<int64> r_server_call_id);
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void hangup() final;
|
|
|
|
void hangup_shared() final;
|
2018-12-31 20:04:05 +01:00
|
|
|
};
|
|
|
|
} // namespace td
|