Skip to content

Commit

Permalink
New configuration variable RAW_AUDIO_UDP_DEST
Browse files Browse the repository at this point in the history
A new configuration variable for local receivers have been added,
RAW_AUDIO_UDP_DEST, which makes it possible to stream the raw audio read
by SvxLink from the audio device to a UDP port. This feature was mainly
added for debugging but may be usable for other things as well.
  • Loading branch information
sm0svx committed Aug 5, 2014
1 parent ef9169a commit 4fd754c
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/doc/man/svxlink.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,15 @@ you define ZVEI1 for SvxLink and a (e.g.) ZVEI3 sequence is received.
At the moment only SEL5_DEC_TYPE=INTERNAL is valid. Maybe we have support for
some external tone detectors later. To disable SEL5 tone decoding, specify
NONE or just comment the configuration variable out.
.TP
.B RAW_AUDIO_UDP_DEST
Setting this configuration variable makes it possible to stream the raw audio
from the sound device to an UDP socket. The sample format is the one used
internally in SvxLink, that is each sample is represented by a 32 bit float.
The sample rate is the same as the one chosen for the audio device.
The destination is specified as ip-address:port.

Example: RAW_AUDIO_UDP_DEST=127.0.0.1:10000
.
.SS Ddr Receiver Section
.
Expand Down
5 changes: 5 additions & 0 deletions src/svxlink/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
with local coverage for a SvxLink based repeater, as long as there is a
network connection to the repeater.

* New configuration variable for local receivers, RAW_AUDIO_UDP_DEST, which
makes it possible to stream the raw audio read by SvxLink from the audio
device to a UDP port. This feature was mainly added for debugging but may
be usable for other things as well.



1.4.0 -- 02 aug 2014
Expand Down
70 changes: 70 additions & 0 deletions src/svxlink/trx/LocalRxBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include <AsyncAudioCompressor.h>
#include <AsyncAudioFifo.h>
#include <AsyncAudioStreamStateDetector.h>
#include <AsyncUdpSocket.h>
#include <common.h>


/****************************************************************************
Expand Down Expand Up @@ -144,6 +146,55 @@ class PeakMeter : public AudioPassthrough
};


class AudioUdpSink : public UdpSocket, public AudioSink
{
public:
AudioUdpSink(const IpAddress &remote_ip, uint16_t remote_port,
uint16_t local_port=0, const IpAddress &bind_ip=IpAddress())
: UdpSocket(local_port, bind_ip), remote_ip(remote_ip),
remote_port(remote_port)
{
}

/**
* @brief Write samples into this audio sink
* @param samples The buffer containing the samples
* @param count The number of samples in the buffer
* @return Returns the number of samples that has been taken care of
*
* This function is used to write audio into this audio sink. If it
* returns 0, no more samples should be written until the resumeOutput
* function in the source have been called.
* This function is normally only called from a connected source object.
*/
virtual int writeSamples(const float *samples, int count)
{
const char *buf = reinterpret_cast<const char *>(samples);
size_t len = count * sizeof(*samples);
UdpSocket::write(remote_ip, remote_port, buf, len);
return count;
}

/**
* @brief 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.
*/
virtual void flushSamples(void)
{
UdpSocket::write(remote_ip, remote_port, NULL, 0);
}

private:
Async::IpAddress remote_ip;
uint16_t remote_port;

};


/****************************************************************************
*
* Prototypes
Expand Down Expand Up @@ -242,6 +293,25 @@ bool LocalRxBase::initialize(void)
// input_fifo->setOverwrite(true);
prev_src->registerSink(input_fifo);
prev_src = input_fifo;

SvxLink::SepPair<string, uint16_t> raw_audio_fwd_dest;
if (cfg.getValue(name(), "RAW_AUDIO_UDP_DEST", raw_audio_fwd_dest))
{
AudioSplitter *raw_audio_splitter = new AudioSplitter;
prev_src->registerSink(raw_audio_splitter, true);
AudioPassthrough *pass = new AudioPassthrough;
raw_audio_splitter->addSink(pass, true);
prev_src = pass;
AudioUdpSink *udp = new AudioUdpSink(IpAddress(raw_audio_fwd_dest.first),
raw_audio_fwd_dest.second);
if (!udp->initOk())
{
cerr << "*** ERROR: Could not open UDP socket for raw audio output\n";
return false;

}
raw_audio_splitter->addSink(udp, true);
}

// If a preamp was configured, create it
if (preamp_gain != 0)
Expand Down

0 comments on commit 4fd754c

Please sign in to comment.