Files
freeswitch-modules/mod_audio_fork/mod_audio_fork.h
Dave Horton 3ce819b7c9 fixes for resampling and handling odd-number byte stream (#88)
* fixes for resampling and handling odd-number byte stream
2024-07-19 16:45:45 -04:00

73 lines
2.0 KiB
C

#ifndef __MOD_FORK_H__
#define __MOD_FORK_H__
#include <switch.h>
#include <libwebsockets.h>
#include <speex/speex_resampler.h>
#include <unistd.h>
#define MY_BUG_NAME "audio_fork"
#define MAX_BUG_LEN (64)
#define MAX_SESSION_ID (256)
#define MAX_WS_URL_LEN (512)
#define MAX_PATH_LEN (4096)
#define EVENT_TRANSCRIPTION "mod_audio_fork::transcription"
#define EVENT_TRANSFER "mod_audio_fork::transfer"
#define EVENT_PLAY_AUDIO "mod_audio_fork::play_audio"
#define EVENT_KILL_AUDIO "mod_audio_fork::kill_audio"
#define EVENT_DISCONNECT "mod_audio_fork::disconnect"
#define EVENT_ERROR "mod_audio_fork::error"
#define EVENT_CONNECT_SUCCESS "mod_audio_fork::connect"
#define EVENT_CONNECT_FAIL "mod_audio_fork::connect_failed"
#define EVENT_BUFFER_OVERRUN "mod_audio_fork::buffer_overrun"
#define EVENT_JSON "mod_audio_fork::json"
#define MAX_METADATA_LEN (8192)
struct playout {
char *file;
struct playout* next;
};
typedef void (*responseHandler_t)(switch_core_session_t* session, const char* eventName, char* json);
struct private_data {
switch_mutex_t *mutex;
char sessionId[MAX_SESSION_ID];
char bugname[MAX_BUG_LEN+1];
SpeexResamplerState *resampler;
responseHandler_t responseHandler;
void *pAudioPipe;
int ws_state;
char host[MAX_WS_URL_LEN];
unsigned int port;
char path[MAX_PATH_LEN];
int sampling;
struct playout* playout;
int channels;
unsigned int id;
int buffer_overrun_notified:1;
int audio_paused:1;
int graceful_shutdown:1;
char initialMetadata[8192];
// bidirectional audio
void *streamingPlayoutBuffer;
void *streamingPreBuffer;
int streamingPreBufSize;
uint8_t set_aside_byte;
int has_set_aside_byte;
int downscale_factor;
SpeexResamplerState *bidirectional_audio_resampler;
int bidirectional_audio_enable;
int bidirectional_audio_stream;
int bidirectional_audio_sample_rate;
int clear_bidirectional_audio_buffer;
};
typedef struct private_data private_t;
#endif