123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #ifndef __AUDIOSTREAM_H__
- #define __AUDIOSTREAM_H__
- #pragma once
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include "audioframe.h"
- #define AMS2_OPT_AGC 0x04
- #define AMS2_OPT_NS 0x08
- #define AMS2_OPT_AEC 0x10
- /** stream direction flag */
- #define STREAM_DIR_NONE 0
- #define STREAM_DIR_READ 1
- #define STREAM_DIR_WRITE 2
- #define STREAM_DIR_BOTH 3
- #define EVT_STREAM_BASE 0x00000000
- #define STREAM_EVT_FILE_REPLAY (EVT_STREAM_BASE + 0) // file replay
- #define STREAM_EVT_FILE_IOERROR (EVT_STREAM_BASE + 1) // io error, param1: GetLastError()
- #define STREAM_EVT_RTP_DTMF (EVT_STREAM_BASE + 2) // receive dtmf, for AudioRtpStream
- #define STREAM_EVT_RTP_TIMEOUT (EVT_STREAM_BASE + 3) // not receive any peer packet in specified time, for AudioRtpStream
- #define STREAM_EVT_FAX_END (EVT_STREAM_BASE + 4) // for fax stream
- #define STREAM_EVT_REC_END (EVT_STREAM_BASE + 5) // for recply record
- #define STREAM_EVT_PLY_END (EVT_STREAM_BASE + 6) // for recply play
- #define STREAM_EVT_TFX_END (EVT_STREAM_BASE + 7) // for recply send fax
- #define STREAM_EVT_RFX_END (EVT_STREAM_BASE + 8) // for recply recv fax
- #define MAX_DTMF 72
- typedef struct audiostream_vtbl_t
- {
- apr_status_t (*read_frame)(void *self, audioframe_t *frame);
- apr_status_t (*write_frame)(void *self, const audioframe_t *frame);
- }audiostream_vtbl_t;
- typedef struct audiostream_t audiostream_t;
- typedef struct audiocontext_t audiocontext_t;
- typedef struct audioengine_t audioengine_t;
- struct audiostream_t {
- audiostream_vtbl_t *vtbl;
- int direction;
- void *user_data;
- #ifdef _WIN32
- int(__stdcall* event_handler)(audiostream_t* stream, void* user_data, int evt, int param1, int param2);
- #else
- int(__attribute__((__stdcall))* event_handler)(audiostream_t* stream, void* user_data, int evt, int param1, int param2);
- #endif // _WIN32
- audiostream_t *upstream;
- audiostream_t *downstream;
- audioengine_t *engine;
- audiocontext_t *ctx;
- };
- void audiostream_init(audioengine_t *engine, audiostream_vtbl_t *vtbl, audiostream_t *stream);
- static void audiostream_set_upstream(audiostream_t *stream, audiostream_t *upstream){stream->upstream = upstream;}
- static audiostream_t* audiostream_get_upstream(audiostream_t *stream) {return stream->upstream;}
- static void audiostream_set_downstream(audiostream_t *stream, audiostream_t *downstream) { stream->downstream = downstream;}
- static audiostream_t* audiostream_get_downstream(audiostream_t *stream){return stream->downstream;}
- static audiocontext_t* audiostream_get_context(audiostream_t *stream){return stream->ctx;}
- static void audiostream_set_direction(audiostream_t *stream, int dir){stream->direction =dir;}
- static int audiostream_get_direction(audiostream_t *stream) {return stream->direction;}
- void audiostream_raise_event(audiostream_t *stream, int evt, int param1, int param2);
- // stream utility
- /** must be end with NULL */
- audiostream_t* audiostream_connect_pipeline(int direction, ...);
- void audiostream_disconnect_pipeline(audiostream_t *stream);
- #ifdef __cplusplus
- } // extern "C" {
- #endif
- #endif //__AUDIOSTREAM_H__
|