#pragma once #include #include #include namespace ts::server { class SpeakingClient; } namespace ts::rtc { typedef uint32_t RTCClientId; typedef uint32_t RTCChannelId; typedef uint32_t RTCStreamId; extern std::string_view version(); extern bool initialize(std::string& /* error */); enum struct ChannelAssignResult { Success, ClientUnknown, TargetChannelUnknown, UnknownError }; enum struct BroadcastStartResult { Success, InvalidClient, ClientHasNoChannel, InvalidBroadcastType, InvalidStreamId, UnknownError }; class NativeAudioSourceSupplier; class Server { public: Server(); ~Server(); RTCClientId create_rtp_client(const std::shared_ptr& /* client */); RTCClientId create_native_client(const std::shared_ptr& /* client */); void destroy_client(RTCClientId /* client id */); /* RTC client actions */ void reset_rtp_session(RTCClientId /* client */); bool apply_remote_description(std::string& /* error */, RTCClientId /* client id */, uint32_t /* mode */, const std::string_view& /* description */); bool generate_local_description(RTCClientId /* client id */, std::string& /* result */); bool add_ice_candidate(std::string& /* error */, RTCClientId /* client id */, uint32_t /* media line */, const std::string_view& /* description */); void ice_candidates_finished(RTCClientId /* client id */); /* Native client actions */ std::optional create_audio_source_supplier_sender(RTCClientId /* client id */); /* channel actions */ uint32_t create_channel(); ChannelAssignResult assign_channel(RTCClientId /* client id */, RTCChannelId /* channel id */); BroadcastStartResult start_broadcast(RTCClientId /* client id */, uint8_t /* broadcast type */, RTCStreamId /* stream id */); void destroy_channel(RTCChannelId /* channel id */); private: void* server_ptr{nullptr}; }; class NativeAudioSourceSupplier { public: explicit NativeAudioSourceSupplier() : sender_ptr{nullptr} {} explicit NativeAudioSourceSupplier(void*); virtual ~NativeAudioSourceSupplier() noexcept; NativeAudioSourceSupplier(const NativeAudioSourceSupplier&) = delete; NativeAudioSourceSupplier(NativeAudioSourceSupplier&& other) noexcept; inline void reset(NativeAudioSourceSupplier& other) { std::swap(other.sender_ptr, this->sender_ptr); } void send_audio(uint16_t /* seq no */, bool /* marked */, uint32_t /* timestamp */, uint8_t /* codec */, const std::string_view& /* data */); private: void* sender_ptr; }; }