40 #ifndef ECHOLINK_QSO_INCLUDED
41 #define ECHOLINK_QSO_INCLUDED
51 #include <sigc++/sigc++.h>
55 #include <speex/speex.h>
68 #include <AsyncTimer.h>
69 #include <AsyncIpAddress.h>
70 #include <AsyncAudioSink.h>
71 #include <AsyncAudioSource.h>
149 :
public SigC::Object,
public Async::AudioSink,
public Async::AudioSource
189 Qso(
const Async::IpAddress& ip,
const std::string& callsign=
"",
190 const std::string& name=
"",
const std::string& info=
"");
231 const std::string&
localName(
void)
const {
return name; }
244 const std::string&
localInfo(
void)
const {
return local_stn_info; }
338 const std::string&
remoteName(
void)
const {
return remote_name; }
430 virtual int writeSamples(
const float *samples,
int count);
465 static const int KEEP_ALIVE_TIME = 10000;
466 static const int MAX_CONNECT_RETRY_CNT = 5;
467 static const int CON_TIMEOUT_TIME = 50000;
468 static const int RX_INDICATOR_HANG_TIME = 200;
469 static const int FRAME_COUNT = 4;
470 static const int BUFFER_SIZE = FRAME_COUNT*160;
480 unsigned char sdes_packet[1500];
490 uint16_t next_audio_seq;
491 Async::Timer * keep_alive_timer;
492 int connect_retry_cnt;
493 Async::Timer * con_timeout_timer;
494 std::string callsign;
496 std::string local_stn_info;
497 short receive_buffer[BUFFER_SIZE];
498 short send_buffer[BUFFER_SIZE];
500 Async::IpAddress remote_ip;
501 Async::Timer * rx_indicator_timer;
502 struct timeval last_audio_packet_received;
503 std::string remote_name;
504 std::string remote_call;
506 bool is_remote_initiated;
507 bool receiving_audio;
510 Qso& operator=(
const Qso&);
511 void printData(
const unsigned char *buf,
int len);
512 void handleCtrlInput(
unsigned char *buf,
int len);
513 inline void handleByePacket(
unsigned char *buf,
int len);
514 inline void handleSdesPacket(
unsigned char *buf,
int len);
515 void handleAudioInput(
unsigned char *buf,
int len);
516 inline void handleNonAudioPacket(
unsigned char *buf,
int len);
517 inline void handleAudioPacket(
unsigned char *buf,
int len);
518 void micAudioRead(
void *buf,
size_t len);
519 bool sendSdesPacket(
void);
520 void sendKeepAlive(Async::Timer *timer);
521 void setState(
State state);
522 void connectionTimeout(Async::Timer *timer);
523 bool setupConnection(
void);
524 void cleanupConnection(
void);
525 bool sendVoicePacket(
void);
526 void checkRxActivity(Async::Timer *timer);
527 bool sendByePacket(
void);
bool sendAudioRaw(RawPacket *raw_packet)
Send a GSM/SPEEX audio packet to the remote station.
No connection to the remote station.
void setRemoteName(const std::string &name)
Set the name of the remote station.
bool sendChatData(const std::string &msg)
Send chat data to the remote station.
bool initOk(void)
Check that the initialization went ok.
const std::string & localName(void) const
Retrieve the local name.
struct EchoLink::Qso::RawPacket __attribute__
struct EchoLink::Qso::VoicePacket::@0 header
SigC::Signal1< void, bool > isReceiving
A signal that is emitted when the audio receive state changes.
virtual void resumeOutput(void)
Resume audio output to the sink.
Qso(const Async::IpAddress &ip, const std::string &callsign="", const std::string &name="", const std::string &info="")
Constructor.
VoicePacket * voice_packet
const Async::IpAddress & remoteIp(void) const
Get the IP address of the remote station.
void setLocalInfo(const std::string &info)
Set the local info.
SigC::Signal1< void, const std::string & > chatMsgReceived
A signal that is emitted when a chat message is received.
bool isRemoteInitiated(void) const
Find out if the connection is remotely initiated or locally initiated.
Received a disconnect request from remote station.
SigC::Signal1< void, RawPacket * > audioReceivedRaw
A signal that is emitted when an audio datagram has been received.
const std::string & localInfo(void) const
Retrieve the local station info.
Connecting to remote station (not established)
bool accept(void)
Accept an incoming connection.
Connected to remote station.
const std::string & remoteCallsign(void) const
Get the remote callsign.
bool connect(void)
Initiate a connection to the remote station.
const std::string & remoteName(void) const
Get the remote name.
virtual void allSamplesFlushed(void)
The registered sink has flushed all samples.
State currentState(void) const
Get the current state of the connection.
bool setLocalCallsign(const std::string &callsign)
Set the local callsign.
SigC::Signal1< void, const std::string & > infoMsgReceived
A signal that is emitted when a station info message is received.
void setRemoteParams(const std::string &priv)
Set parameters of the remote station connection.
bool receivingAudio(void) const
Find out if there is audio coming in on this connection.
SigC::Signal1< void, State > stateChange
A signal that is emitted when the connection state changes.
bool sendInfoData(const std::string &info="")
Send info data to the remote station.
const std::string & localCallsign(void) const
Retrieve the local callsign.
bool setLocalName(const std::string &name)
Set the local name (name of station operator)
virtual int writeSamples(const float *samples, int count)
Write samples into this audio sink.
virtual void flushSamples(void)
Tell the sink to flush the previously written samples.
bool disconnect(void)
Initiate a disconnection from the remote station.
State
The type of the connection state.
void setRemoteCallsign(const std::string &call)
Set the callsign of the remote station.
A class for creating an EchoLink connection.