EchoLib
1.3.3
|
A class for creating an EchoLink connection. More...
#include <EchoLinkQso.h>
Classes | |
struct | RawPacket |
struct | VoicePacket |
Public Types | |
enum | State { STATE_DISCONNECTED, STATE_CONNECTING, STATE_BYE_RECEIVED, STATE_CONNECTED } |
The type of the connection state. More... | |
Public Member Functions | |
struct EchoLink::Qso::VoicePacket | __attribute__ ((packed)) |
Qso (const Async::IpAddress &ip, const std::string &callsign="", const std::string &name="", const std::string &info="") | |
Constructor. More... | |
~Qso (void) | |
Destructor. More... | |
bool | initOk (void) |
Check that the initialization went ok. More... | |
bool | setLocalCallsign (const std::string &callsign) |
Set the local callsign. More... | |
const std::string & | localCallsign (void) const |
Retrieve the local callsign. More... | |
bool | setLocalName (const std::string &name) |
Set the local name (name of station operator) More... | |
const std::string & | localName (void) const |
Retrieve the local name. More... | |
void | setLocalInfo (const std::string &info) |
Set the local info. More... | |
const std::string & | localInfo (void) const |
Retrieve the local station info. More... | |
bool | connect (void) |
Initiate a connection to the remote station. More... | |
bool | accept (void) |
Accept an incoming connection. More... | |
bool | disconnect (void) |
Initiate a disconnection from the remote station. More... | |
bool | sendInfoData (const std::string &info="") |
Send info data to the remote station. More... | |
bool | sendChatData (const std::string &msg) |
Send chat data to the remote station. More... | |
const Async::IpAddress & | remoteIp (void) const |
Get the IP address of the remote station. More... | |
bool | sendAudioRaw (RawPacket *raw_packet) |
Send a GSM/SPEEX audio packet to the remote station. More... | |
void | setRemoteParams (const std::string &priv) |
Set parameters of the remote station connection. More... | |
void | setRemoteName (const std::string &name) |
Set the name of the remote station. More... | |
const std::string & | remoteName (void) const |
Get the remote name. More... | |
void | setRemoteCallsign (const std::string &call) |
Set the callsign of the remote station. More... | |
const std::string & | remoteCallsign (void) const |
Get the remote callsign. More... | |
bool | isRemoteInitiated (void) const |
Find out if the connection is remotely initiated or locally initiated. More... | |
bool | receivingAudio (void) const |
Find out if there is audio coming in on this connection. More... | |
State | currentState (void) const |
Get the current state of the connection. More... | |
virtual int | writeSamples (const float *samples, int count) |
Write samples into this audio sink. More... | |
virtual void | flushSamples (void) |
Tell the sink to flush the previously written samples. More... | |
virtual void | resumeOutput (void) |
Resume audio output to the sink. More... | |
void | setUseGsmOnly (void) |
Setting GSM as only codec for echolink connections. More... | |
Public Attributes | |
struct EchoLink::Qso::RawPacket | __attribute__ |
sigc::signal< void, const std::string & > | infoMsgReceived |
A signal that is emitted when a station info message is received. More... | |
sigc::signal< void, const std::string & > | chatMsgReceived |
A signal that is emitted when a chat message is received. More... | |
sigc::signal< void, State > | stateChange |
A signal that is emitted when the connection state changes. More... | |
sigc::signal< void, bool > | isReceiving |
A signal that is emitted when the audio receive state changes. More... | |
sigc::signal< void, RawPacket * > | audioReceivedRaw |
A signal that is emitted when an audio datagram has been received. More... | |
Protected Member Functions | |
virtual void | allSamplesFlushed (void) |
The registered sink has flushed all samples. More... | |
A class for creating an EchoLink connection.
This class is used to create a connection to another EchoLink node. It only handles outgoing connections. To handle incoming connections, have a look at EchoLink::Dispatcher. However, when an incoming connection has been signalled by the dispatcher, a Qso object should be created to complete the connection. This logic should be glued together in the main program.
For an example usage, have a look at the code below. A connection is created to ourself. When the connection has been established the information message is automatically transmitted. Upon reception of the information message a disconnect is initiated. When the link has been disconnected the application exits.
Definition at line 145 of file EchoLinkQso.h.
enum EchoLink::Qso::State |
The type of the connection state.
Definition at line 171 of file EchoLinkQso.h.
EchoLink::Qso::Qso | ( | const Async::IpAddress & | ip, |
const std::string & | callsign = "" , |
||
const std::string & | name = "" , |
||
const std::string & | info = "" |
||
) |
Constructor.
ip | The IP-address of the remote station |
callsign | Callsign of local user (not remote callsign) |
name | Name of local user (not remote name) |
info | Local information to send upon connect |
EchoLink::Qso::~Qso | ( | void | ) |
Destructor.
struct EchoLink::Qso::VoicePacket EchoLink::Qso::__attribute__ | ( | (packed) | ) |
bool EchoLink::Qso::accept | ( | void | ) |
Accept an incoming connection.
Use this function to accept an incoming connection. Incoming connections are signalled through the EchoLink::Dispatcher. When an incoming connection has been received, a Qso object should be created and this function should be called to accept the connection. Be sure to check that a valid callsign has connected. At least if the EchoLink node is connected to a radio transmitter.
The difference between the connect and accept functions are that the accept function goes right into the connected state. The remote station is assumed to be present. This might not be true in some strange cases. In such a strange case, the connection will timeout after a while.
Referenced by localInfo().
|
protectedvirtual |
The registered sink has flushed all samples.
This function will be called when all samples have been flushed in the registered sink. If it is not reimplemented, a handler must be set that handle the function call. This function is normally only called from a connected sink object.
bool EchoLink::Qso::connect | ( | void | ) |
Initiate a connection to the remote station.
Use this function to connect to the remote station. The StateChange signal will be emitted to indicate that a connection is in progress. When the connection has been established, the stateChange signal will be emitted again. On failure to connect, the stateChange signal will be emitted to indicate that the disconnected state has been entered again.
Referenced by localInfo().
|
inline |
Get the current state of the connection.
Definition at line 370 of file EchoLinkQso.h.
bool EchoLink::Qso::disconnect | ( | void | ) |
Initiate a disconnection from the remote station.
Referenced by localInfo().
|
virtual |
Tell the sink to flush the previously written samples.
This function is used to tell the sink to flush previously written samples. When done flushing, the sink should call the sourceAllSamplesFlushed function. This function is normally only called from a connected source object.
|
inline |
Check that the initialization went ok.
This function should be called after creating a new Qso object to make sure everything went well.
Definition at line 202 of file EchoLinkQso.h.
References setLocalCallsign().
|
inline |
Find out if the connection is remotely initiated or locally initiated.
Definition at line 357 of file EchoLinkQso.h.
|
inline |
Retrieve the local callsign.
Definition at line 215 of file EchoLinkQso.h.
References setLocalName().
|
inline |
Retrieve the local station info.
Definition at line 241 of file EchoLinkQso.h.
References accept(), connect(), disconnect(), sendChatData(), and sendInfoData().
|
inline |
Retrieve the local name.
Definition at line 228 of file EchoLinkQso.h.
References setLocalInfo().
|
inline |
Find out if there is audio coming in on this connection.
Definition at line 364 of file EchoLinkQso.h.
|
inline |
Get the remote callsign.
Definition at line 348 of file EchoLinkQso.h.
|
inline |
Get the IP address of the remote station.
Definition at line 301 of file EchoLinkQso.h.
References sendAudioRaw(), and setRemoteParams().
|
inline |
Get the remote name.
Definition at line 335 of file EchoLinkQso.h.
|
virtual |
Resume audio output to the sink.
This function will be called when the registered audio sink is ready to accept more samples. This function is normally only called from a connected sink object.
bool EchoLink::Qso::sendAudioRaw | ( | RawPacket * | raw_packet | ) |
Send a GSM/SPEEX audio packet to the remote station.
raw_packet | The packet to send |
This function can be used to send a GSM/SPEEX packet to the remote station. Probably only useful if you received it from the audioReceivedRaw signal. The raw_packet contains both the network packet and the decoded samples, which is beneficial when the audio frame has to be transcoded (SPEEX -> GSM) prior re-transmission.
Referenced by remoteIp().
bool EchoLink::Qso::sendChatData | ( | const std::string & | msg | ) |
Send chat data to the remote station.
msg | The message to send |
Referenced by localInfo().
bool EchoLink::Qso::sendInfoData | ( | const std::string & | info = "" | ) |
Send info data to the remote station.
info | The info to send |
Referenced by localInfo().
bool EchoLink::Qso::setLocalCallsign | ( | const std::string & | callsign | ) |
Set the local callsign.
callsign | The callsign to set |
Referenced by initOk().
void EchoLink::Qso::setLocalInfo | ( | const std::string & | info | ) |
Set the local info.
info | The informational message that is sent to the remote station upon connection. |
Referenced by localName().
bool EchoLink::Qso::setLocalName | ( | const std::string & | name | ) |
Set the local name (name of station operator)
name | The name to set |
Referenced by localCallsign().
|
inline |
Set the callsign of the remote station.
call | The callsign to set |
Definition at line 341 of file EchoLinkQso.h.
|
inline |
Set the name of the remote station.
name | The name to set |
Definition at line 328 of file EchoLinkQso.h.
void EchoLink::Qso::setRemoteParams | ( | const std::string & | priv | ) |
Set parameters of the remote station connection.
priv | A private string for passing connection parameters |
Referenced by remoteIp().
void EchoLink::Qso::setUseGsmOnly | ( | void | ) |
Setting GSM as only codec for echolink connections.
This function can be called when SvxLink is installed and running on a system with smaller cpu to keep the load low.
|
virtual |
Write samples into this audio sink.
samples | The buffer containing the samples |
count | The number of samples in the buffer |
This function is used to write audio into this audio sink. If it returns 0, no more samples could be written. If the returned number of written samples is lower than the count parameter value, the sink is not ready to accept more samples. In this case, the audio source requires sample buffering to temporarily store samples that are not immediately accepted by the sink. The writeSamples function should be called on source buffer updates and after a source output request has been received through the requestSamples function. This function is normally only called from a connected source object.
struct EchoLink::Qso::RawPacket EchoLink::Qso::__attribute__ |
sigc::signal<void, RawPacket*> EchoLink::Qso::audioReceivedRaw |
A signal that is emitted when an audio datagram has been received.
data | A pointer to the buffer that contains the raw audio packet |
This signal is emitted whenever an audio packet has been received on the connection. It gives access to the GSM/SPEEX packet. This can be used if the encoded data is going to be retransmitted. In this case it is not good to decode and then encode the data again. It will sound awful.
Definition at line 407 of file EchoLinkQso.h.
sigc::signal<void, const std::string&> EchoLink::Qso::chatMsgReceived |
A signal that is emitted when a chat message is received.
msg | The received chat message |
Definition at line 382 of file EchoLinkQso.h.
sigc::signal<void, const std::string&> EchoLink::Qso::infoMsgReceived |
A signal that is emitted when a station info message is received.
msg | The received message |
Definition at line 376 of file EchoLinkQso.h.
sigc::signal<void, bool> EchoLink::Qso::isReceiving |
A signal that is emitted when the audio receive state changes.
is_receiving | Is true when audio is being received and false when not |
Definition at line 396 of file EchoLinkQso.h.
sigc::signal<void, State> EchoLink::Qso::stateChange |
A signal that is emitted when the connection state changes.
state | The new connection state |
Definition at line 388 of file EchoLinkQso.h.