2024-03-21 04:10:02 +04:00
|
|
|
#ifndef _AUDIO_H_
|
|
|
|
#define _AUDIO_H_
|
|
|
|
|
|
|
|
#include <opus/opus.h>
|
|
|
|
#include <portaudio.h>
|
|
|
|
|
2024-03-21 17:50:20 +04:00
|
|
|
#define AUDIO_SAMPLE_FORMAT paFloat32
|
|
|
|
typedef float audio_sample_t;
|
|
|
|
|
2024-03-21 04:10:02 +04:00
|
|
|
typedef struct audio_t {
|
2024-03-21 17:50:20 +04:00
|
|
|
PaStream *stream;
|
2024-03-22 03:30:12 +04:00
|
|
|
OpusEncoder *opus_enc;
|
|
|
|
OpusDecoder *opus_dec;
|
2024-03-21 04:10:02 +04:00
|
|
|
|
2024-03-21 17:50:20 +04:00
|
|
|
audio_sample_t *buffer;
|
2024-03-23 04:17:19 +04:00
|
|
|
int buffer_size;
|
2024-03-21 17:50:20 +04:00
|
|
|
} audio_t;
|
2024-03-21 04:10:02 +04:00
|
|
|
|
2024-03-22 03:30:12 +04:00
|
|
|
int audio_init(audio_t *aud, int channels, int sample_rate, int frame_size);
|
2024-03-21 04:10:02 +04:00
|
|
|
int audio_destroy(audio_t *aud);
|
|
|
|
|
2024-03-23 04:17:19 +04:00
|
|
|
int audio_read(audio_t *aud, unsigned char *output, int output_len);
|
|
|
|
int audio_write(audio_t *aud, const unsigned char *input, int input_len);
|
2024-03-21 17:50:20 +04:00
|
|
|
|
2024-03-21 04:10:02 +04:00
|
|
|
#endif /* _AUDIO_H_ */
|