2020-11-07 13:17:51 +01:00
# pragma once
# include <memory>
# include <optional>
# include <string>
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 ( ) ;
2020-11-28 11:09:25 +01:00
RTCClientId create_client ( const std : : shared_ptr < server : : SpeakingClient > & /* client */ ) ;
bool initialize_rtc_connection ( std : : string & /* error */ , RTCClientId /* client id */ ) ;
bool initialize_native_connection ( std : : string & /* error */ , RTCClientId /* client id */ ) ;
2020-11-07 13:17:51 +01:00
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 */
2020-11-28 11:09:25 +01:00
std : : optional < NativeAudioSourceSupplier > create_audio_source_supplier_sender ( RTCClientId /* client id */ , uint32_t /* stream id */ ) ;
2020-11-07 13:17:51 +01:00
/* 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 */ ) ;
2020-11-28 11:09:25 +01:00
/* whisper actions */
bool configure_whisper_session ( std : : string & /* error */ , RTCClientId /* client id */ , uint32_t /* source stream id */ , RTCClientId * /* session members */ , size_t /* session member count */ ) ;
2020-11-28 11:27:31 +01:00
void reset_whisper_session ( RTCClientId /* client id */ ) ;
2020-11-07 13:17:51 +01:00
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 ;
} ;
}