Babel
Epitech's C++ VoIP project
Public Member Functions | Private Attributes | List of all members
Babel::UDPSocket Class Reference

wrapper around Qt UDP socket, ICodec and Portaudio More...

#include <UDPSocket.hpp>

Inheritance diagram for Babel::UDPSocket:
Collaboration diagram for Babel::UDPSocket:

Public Member Functions

 UDPSocket (std::int16_t port, std::shared_ptr< Babel::IAudioManager > &, std::shared_ptr< Babel::ICodec > &)
 ctor More...
 
 ~UDPSocket () override
 dtor More...
 
std::int64_t write (std::array< unsigned char, 4000 > &data, std::int32_t size, const std::string &address, int port)
 writes data to socket More...
 
void close ()
 closes the socket More...
 
void readPending ()
 reads the incoming datagrams when they arrive More...
 
uint16_t getLocalPort () const
 get the port that the UDPSocket is listening More...
 

Private Attributes

std::mutex _mutex
 mutex for closing the socket More...
 
std::unique_ptr< QUdpSocket > _socket
 Qt's UDP socket. More...
 
std::shared_ptr< Babel::IAudioManager_audio
 audio interface to play sound More...
 
std::shared_ptr< Babel::ICodec_codec
 codec interface to encode and decode sound More...
 

Detailed Description

wrapper around Qt UDP socket, ICodec and Portaudio

Constructor & Destructor Documentation

◆ UDPSocket()

Babel::UDPSocket::UDPSocket ( std::int16_t  port,
std::shared_ptr< Babel::IAudioManager > &  audio,
std::shared_ptr< Babel::ICodec > &  opus 
)

ctor

◆ ~UDPSocket()

Babel::UDPSocket::~UDPSocket ( )
override

dtor

Member Function Documentation

◆ close()

void Babel::UDPSocket::close ( )

closes the socket

◆ getLocalPort()

uint16_t Babel::UDPSocket::getLocalPort ( ) const

get the port that the UDPSocket is listening

◆ readPending()

void Babel::UDPSocket::readPending ( )

reads the incoming datagrams when they arrive

◆ write()

std::int64_t Babel::UDPSocket::write ( std::array< unsigned char, 4000 > &  data,
std::int32_t  size,
const std::string &  address,
int  port 
)

writes data to socket

Member Data Documentation

◆ _audio

std::shared_ptr<Babel::IAudioManager> Babel::UDPSocket::_audio
private

audio interface to play sound

◆ _codec

std::shared_ptr<Babel::ICodec> Babel::UDPSocket::_codec
private

codec interface to encode and decode sound

◆ _mutex

std::mutex Babel::UDPSocket::_mutex
private

mutex for closing the socket

◆ _socket

std::unique_ptr<QUdpSocket> Babel::UDPSocket::_socket
private

Qt's UDP socket.


The documentation for this class was generated from the following files: