tdlight/td/telegram/CallManager.h

69 lines
2.2 KiB
C
Raw Normal View History

//
2022-01-01 01:35:39 +01:00
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
//
// 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"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/actor/actor.h"
#include "td/actor/PromiseFuture.h"
2022-06-02 15:19:16 +02:00
#include "td/utils/common.h"
2022-02-07 22:04:34 +01:00
#include "td/utils/FlatHashMap.h"
#include "td/utils/Status.h"
#include <map>
namespace td {
class CallManager final : public Actor {
public:
using Update = telegram_api::object_ptr<telegram_api::updatePhoneCall>;
explicit CallManager(ActorShared<> parent);
void update_call(Update call);
void update_call_signaling_data(int64 call_id, string data);
void create_call(UserId user_id, tl_object_ptr<telegram_api::InputUser> &&input_user, CallProtocol &&protocol,
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);
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);
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);
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};
FlatHashMap<CallId, ActorOwn<CallActor>, CallIdHash> id_to_actor_;
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;
};
} // namespace td