Helmut Pozimski c4623055ac add README.md | 4 years ago | |
---|---|---|
LICENSES | 5 years ago | |
src | 5 years ago | |
.gitignore | 5 years ago | |
Makefile | 5 years ago | |
README.md | 4 years ago |
This repository contains a small daemon implemented in C that receives raw PCM audio data and saves it to a directory on a file system as a RIFF-Wave file. It is meant to be used together with esp32-transmit-i2s. If another software was to be used on the sender side, it would need to implement the same protocol.
Tpr takes three command line arguments that specify the directory to write files to and the IP address and port it should listen to. An example call would be:
tpr -i 10.0.0.1 -p 8000 -d /var/tpr
Once the program is running, it will wait for a handshake from a compatible client and once that occurs, create a new file with time and date in the file name and acknowledge the request. All data received from the client is then written into the file until either the connection is interrupted for at least three seconds or tpr is terminated. In both cases the file currently opened the file is finished and closed.
To compile this program you will need a compiler and C library that conform to the C99 and POSIX standards as well as GNU make.
The daemon needs a directory to store saved data so unless an existing temporary directory like /tmp is to be used, it should be created before launching it. You can execute it as any user but an unprivileged one is recommended of course. Make sure the user has write access to the target directory specified on the command line.
The program can be compiled using the make
command and be installed using the install
target so it typically would look like this:
make
make install
The make file respects the environment variables CC
, LDFLAGS
and PREFIX
so you can use this to alter the behaviour of the building process. By default it will use gcc with the default CFLAGS and install the binary tpr
into /usr/local/bin. If you do not want to install it, you can also execute the binary directly from the build
directory.
The protocol between tpr and the client is relatively simple. After establishing a TCP session it starts with a request from the client to open a new file which contains just the sample rate used and the number of bits of a single sample value. Both values are to be sent as 32 bit unsigned integers. The server then responds with the ASCII value "ACK" added before the values it just received in the reply packet when it has opened a file and is ready to receive data.
All data that is received from the client after the handshake is written into the data part of the file. There's no way to orderly terminate a connection from the client side. When the server does not receive any data for three seconds, it will terminate the connection on its side, finish and close the file and will be ready to accept a new connection and open a new file.
This project is licensed under the GNU General Public License, Version 2.