mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-04-13 05:43:07 +00:00
added beginnings of portaudio based phone interface for testing
VoMP.
This commit is contained in:
parent
38941d92af
commit
44e9449988
@ -5,7 +5,7 @@ SRCS= dna.c server.c client.c peers.c ciphers.c responses.c packetformats.c data
|
||||
rhizome.c rhizome_http.c rhizome_bundle.c rhizome_database.c rhizome_crypto.c \
|
||||
rhizome_packetformats.c rhizome_fetch.c sqlite3.c encode.c sha2.c randombytes.c \
|
||||
overlay_broadcast.c dna_identity.c commandline.c serval_packetvisualise.c \
|
||||
trans_cache.c keyring.c vomp.c
|
||||
trans_cache.c keyring.c vomp.c pa_phone.c
|
||||
|
||||
OBJS= $(SRCS:.c=.o)
|
||||
|
||||
|
90
pa_phone.c
Normal file
90
pa_phone.c
Normal file
@ -0,0 +1,90 @@
|
||||
#ifdef WITH_PORTAUDIO
|
||||
#include "serval.h"
|
||||
#include <portaudio.h>
|
||||
|
||||
struct private_data {
|
||||
int foo;
|
||||
};
|
||||
|
||||
struct private_data pd;
|
||||
PaStream *stream=NULL;
|
||||
|
||||
/* This routine will be called by the PortAudio engine when audio is needed.
|
||||
It may called at interrupt level on some machines so don't do anything
|
||||
that could mess up the system like calling malloc() or free().
|
||||
*/
|
||||
static int paphoneCallback( const void *inputBuffer, void *outputBuffer,
|
||||
unsigned long framesPerBuffer,
|
||||
const PaStreamCallbackTimeInfo* timeInfo,
|
||||
PaStreamCallbackFlags statusFlags,
|
||||
void *userData )
|
||||
{
|
||||
/* Cast data passed through stream to our structure. */
|
||||
struct private_data *data = (struct private_data*)userData;
|
||||
uint16_t *out = (uint16_t*)outputBuffer;
|
||||
uint16_t *in = (uint16_t*)inputBuffer;
|
||||
unsigned int i;
|
||||
|
||||
/* Add recorded audio to ring buffer */
|
||||
/* Play audio from ring buffer.
|
||||
XXX - Special case for DTMF tones.
|
||||
DTMF is:
|
||||
1209 1336 1477 1633
|
||||
697 1 2 3 A
|
||||
770 4 5 6 B
|
||||
852 7 8 9 C
|
||||
941 * 0 # D
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int paphone_setup()
|
||||
{
|
||||
PaError err;
|
||||
err = Pa_Initialize();
|
||||
if( err != paNoError ) goto error;
|
||||
|
||||
|
||||
/* Open an audio I/O stream. */
|
||||
err = Pa_OpenDefaultStream( &stream,
|
||||
1, /* one input channel */
|
||||
1, /* one output channel */
|
||||
paInt16, /* sample format */
|
||||
8000,
|
||||
8000/40, /* frames per buffer, i.e. the number
|
||||
of sample frames that PortAudio will
|
||||
request from the callback. Many apps
|
||||
may want to use
|
||||
paFramesPerBufferUnspecified, which
|
||||
tells PortAudio to pick the best,
|
||||
possibly changing, buffer size.*/
|
||||
paphoneCallback, /* this is your callback function */
|
||||
&pd ); /*This is a pointer that will be passed to
|
||||
your callback*/
|
||||
if( err != paNoError ) goto error;
|
||||
|
||||
err = Pa_StartStream( stream );
|
||||
if( err != paNoError ) goto error;
|
||||
|
||||
return 0;
|
||||
error:
|
||||
return WHYF( "PortAudio error: %s\n", Pa_GetErrorText( err ) );
|
||||
}
|
||||
|
||||
int paphone_cleanup()
|
||||
{
|
||||
PaError err;
|
||||
err = Pa_StopStream( stream );
|
||||
if( err != paNoError ) goto error;
|
||||
err = Pa_CloseStream( stream );
|
||||
if( err != paNoError ) goto error;
|
||||
|
||||
error:
|
||||
err = Pa_Terminate();
|
||||
if( err != paNoError )
|
||||
return WHYF( "PortAudio error: %s\n", Pa_GetErrorText( err ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user