forked from Mirrors/freeswitch
standardize to some more specific int types for frame size and rate variables.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1095 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
04395dabee
commit
9db533862d
@ -30,9 +30,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/*! \file switch_core.h
|
/*! \file switch_core.h
|
||||||
\brief Core Library
|
\brief Core Library
|
||||||
|
|
||||||
This module is the main core library and is the intended location of all fundamental operations.
|
This module is the main core library and is the intended location of all fundamental operations.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SWITCH_CORE_H
|
#ifndef SWITCH_CORE_H
|
||||||
@ -41,6 +41,9 @@
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef _FORMATBUG
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
@ -306,7 +309,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_set_private(switch_core_sessio
|
|||||||
\param session the session to add the stream to
|
\param session the session to add the stream to
|
||||||
\param private_info an optional pointer to private data for the new stream
|
\param private_info an optional pointer to private data for the new stream
|
||||||
\return the stream id of the new stream
|
\return the stream id of the new stream
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(int) switch_core_session_add_stream(switch_core_session *session, void *private_info);
|
SWITCH_DECLARE(int) switch_core_session_add_stream(switch_core_session *session, void *private_info);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -314,14 +317,14 @@ SWITCH_DECLARE(int) switch_core_session_add_stream(switch_core_session *session,
|
|||||||
\param session the session to add the stream to
|
\param session the session to add the stream to
|
||||||
\param index the index to retrieve
|
\param index the index to retrieve
|
||||||
\return the stream
|
\return the stream
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(void *) switch_core_session_get_stream(switch_core_session *session, int index);
|
SWITCH_DECLARE(void *) switch_core_session_get_stream(switch_core_session *session, int index);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Determine the number of logical streams a session has
|
\brief Determine the number of logical streams a session has
|
||||||
\param session the session to query
|
\param session the session to query
|
||||||
\return the total number of logical streams
|
\return the total number of logical streams
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(int) switch_core_session_get_stream_count(switch_core_session *session);
|
SWITCH_DECLARE(int) switch_core_session_get_stream_count(switch_core_session *session);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -607,7 +610,7 @@ SWITCH_DECLARE(switch_status) switch_core_timer_destroy(switch_timer *timer);
|
|||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec,
|
SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec,
|
||||||
char *codec_name,
|
char *codec_name,
|
||||||
int rate,
|
uint32_t rate,
|
||||||
int ms,
|
int ms,
|
||||||
int channels,
|
int channels,
|
||||||
uint32_t flags,
|
uint32_t flags,
|
||||||
@ -629,14 +632,14 @@ SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec,
|
|||||||
\note encoded_data_len will be rewritten to the in-use size of encoded_data
|
\note encoded_data_len will be rewritten to the in-use size of encoded_data
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(switch_status) switch_core_codec_encode(switch_codec *codec,
|
SWITCH_DECLARE(switch_status) switch_core_codec_encode(switch_codec *codec,
|
||||||
switch_codec *other_codec,
|
switch_codec *other_codec,
|
||||||
void *decoded_data,
|
void *decoded_data,
|
||||||
switch_size_t decoded_data_len,
|
uint32_t decoded_data_len,
|
||||||
int decoded_rate,
|
uint32_t decoded_rate,
|
||||||
void *encoded_data,
|
void *encoded_data,
|
||||||
switch_size_t *encoded_data_len,
|
uint32_t *encoded_data_len,
|
||||||
int *encoded_rate,
|
uint32_t *encoded_rate,
|
||||||
unsigned int *flag);
|
unsigned int *flag);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Decode data using a codec handle
|
\brief Decode data using a codec handle
|
||||||
@ -653,14 +656,14 @@ SWITCH_DECLARE(switch_status) switch_core_codec_encode(switch_codec *codec,
|
|||||||
\note decoded_data_len will be rewritten to the in-use size of decoded_data
|
\note decoded_data_len will be rewritten to the in-use size of decoded_data
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(switch_status) switch_core_codec_decode(switch_codec *codec,
|
SWITCH_DECLARE(switch_status) switch_core_codec_decode(switch_codec *codec,
|
||||||
switch_codec *other_codec,
|
switch_codec *other_codec,
|
||||||
void *encoded_data,
|
void *encoded_data,
|
||||||
switch_size_t encoded_data_len,
|
uint32_t encoded_data_len,
|
||||||
int encoded_rate,
|
uint32_t encoded_rate,
|
||||||
void *decoded_data,
|
void *decoded_data,
|
||||||
switch_size_t *decoded_data_len,
|
uint32_t *decoded_data_len,
|
||||||
int *decoded_rate,
|
uint32_t *decoded_rate,
|
||||||
unsigned int *flag);
|
unsigned int *flag);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Destroy an initalized codec handle
|
\brief Destroy an initalized codec handle
|
||||||
@ -827,10 +830,10 @@ SWITCH_DECLARE(switch_status) switch_core_speech_feed_tts(switch_speech_handle *
|
|||||||
\param flags flags in/out for fine tuning
|
\param flags flags in/out for fine tuning
|
||||||
\return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful
|
\return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(switch_status) switch_core_speech_read_tts(switch_speech_handle *sh,
|
SWITCH_DECLARE(switch_status) switch_core_speech_read_tts(switch_speech_handle *sh,
|
||||||
void *data,
|
void *data,
|
||||||
switch_size_t *datalen,
|
switch_size_t *datalen,
|
||||||
switch_size_t *rate,
|
uint32_t *rate,
|
||||||
switch_speech_flag *flags);
|
switch_speech_flag *flags);
|
||||||
/*!
|
/*!
|
||||||
\brief Close an open speech handle
|
\brief Close an open speech handle
|
||||||
|
@ -49,13 +49,13 @@ struct switch_frame {
|
|||||||
/*! the frame data */
|
/*! the frame data */
|
||||||
void *data;
|
void *data;
|
||||||
/*! the size of the buffer that is in use */
|
/*! the size of the buffer that is in use */
|
||||||
switch_size_t datalen;
|
uint32_t datalen;
|
||||||
/*! the entire size of the buffer */
|
/*! the entire size of the buffer */
|
||||||
switch_size_t buflen;
|
uint32_t buflen;
|
||||||
/*! the number of audio samples present (audio only) */
|
/*! the number of audio samples present (audio only) */
|
||||||
switch_size_t samples;
|
uint32_t samples;
|
||||||
/*! the rate of the frame */
|
/*! the rate of the frame */
|
||||||
int rate;
|
uint32_t rate;
|
||||||
/*! frame flags */
|
/*! frame flags */
|
||||||
switch_frame_flag flags;
|
switch_frame_flag flags;
|
||||||
};
|
};
|
||||||
|
@ -144,7 +144,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_speak_text(switch_core_session *session
|
|||||||
char *tts_name,
|
char *tts_name,
|
||||||
char *voice_name,
|
char *voice_name,
|
||||||
char *timer_name,
|
char *timer_name,
|
||||||
switch_size_t rate,
|
uint32_t rate,
|
||||||
switch_dtmf_callback_function dtmf_callback,
|
switch_dtmf_callback_function dtmf_callback,
|
||||||
char *text,
|
char *text,
|
||||||
void *buf,
|
void *buf,
|
||||||
|
@ -262,9 +262,9 @@ struct switch_file_handle {
|
|||||||
/*! samples position of the handle */
|
/*! samples position of the handle */
|
||||||
unsigned int samples;
|
unsigned int samples;
|
||||||
/*! the current samplerate */
|
/*! the current samplerate */
|
||||||
unsigned int samplerate;
|
uint32_t samplerate;
|
||||||
/*! the number of channels */
|
/*! the number of channels */
|
||||||
unsigned int channels;
|
uint8_t channels;
|
||||||
/*! integer representation of the format */
|
/*! integer representation of the format */
|
||||||
unsigned int format;
|
unsigned int format;
|
||||||
/*! integer representation of the sections */
|
/*! integer representation of the sections */
|
||||||
@ -305,7 +305,7 @@ struct switch_speech_interface {
|
|||||||
switch_status (*speech_read_tts)(switch_speech_handle *sh,
|
switch_status (*speech_read_tts)(switch_speech_handle *sh,
|
||||||
void *data,
|
void *data,
|
||||||
switch_size_t *datalen,
|
switch_size_t *datalen,
|
||||||
switch_size_t *rate,
|
uint32_t *rate,
|
||||||
switch_speech_flag *flags);
|
switch_speech_flag *flags);
|
||||||
|
|
||||||
const struct switch_speech_interface *next;
|
const struct switch_speech_interface *next;
|
||||||
@ -415,19 +415,19 @@ struct switch_codec {
|
|||||||
/*! \brief A table of settings and callbacks that define a paticular implementation of a codec */
|
/*! \brief A table of settings and callbacks that define a paticular implementation of a codec */
|
||||||
struct switch_codec_implementation {
|
struct switch_codec_implementation {
|
||||||
/*! samples transferred per second */
|
/*! samples transferred per second */
|
||||||
int samples_per_second;
|
uint32_t samples_per_second;
|
||||||
/*! bits transferred per second */
|
/*! bits transferred per second */
|
||||||
int bits_per_second;
|
int bits_per_second;
|
||||||
/*! number of microseconds that denote one frame */
|
/*! number of microseconds that denote one frame */
|
||||||
int microseconds_per_frame;
|
int microseconds_per_frame;
|
||||||
/*! number of samples that denote one frame */
|
/*! number of samples that denote one frame */
|
||||||
int samples_per_frame;
|
uint32_t samples_per_frame;
|
||||||
/*! number of bytes that denote one frame decompressed */
|
/*! number of bytes that denote one frame decompressed */
|
||||||
switch_size_t bytes_per_frame;
|
uint32_t bytes_per_frame;
|
||||||
/*! number of bytes that denote one frame compressed */
|
/*! number of bytes that denote one frame compressed */
|
||||||
int encoded_bytes_per_frame;
|
uint32_t encoded_bytes_per_frame;
|
||||||
/*! number of channels represented */
|
/*! number of channels represented */
|
||||||
int number_of_channels;
|
uint8_t number_of_channels;
|
||||||
/*! number of frames to send in one netowrk packet */
|
/*! number of frames to send in one netowrk packet */
|
||||||
int pref_frames_per_packet;
|
int pref_frames_per_packet;
|
||||||
/*! max number of frames to send in one network packet */
|
/*! max number of frames to send in one network packet */
|
||||||
@ -438,21 +438,21 @@ struct switch_codec_implementation {
|
|||||||
switch_status (*encode)(switch_codec *codec,
|
switch_status (*encode)(switch_codec *codec,
|
||||||
switch_codec *other_codec,
|
switch_codec *other_codec,
|
||||||
void *decoded_data,
|
void *decoded_data,
|
||||||
switch_size_t decoded_data_len,
|
uint32_t decoded_data_len,
|
||||||
int decoded_rate,
|
uint32_t decoded_rate,
|
||||||
void *encoded_data,
|
void *encoded_data,
|
||||||
switch_size_t *encoded_data_len,
|
uint32_t *encoded_data_len,
|
||||||
int *encoded_rate,
|
uint32_t *encoded_rate,
|
||||||
unsigned int *flag);
|
unsigned int *flag);
|
||||||
/*! function to decode encoded data into raw data */
|
/*! function to decode encoded data into raw data */
|
||||||
switch_status (*decode)(switch_codec *codec,
|
switch_status (*decode)(switch_codec *codec,
|
||||||
switch_codec *other_codec,
|
switch_codec *other_codec,
|
||||||
void *encoded_data,
|
void *encoded_data,
|
||||||
switch_size_t encoded_data_len,
|
uint32_t encoded_data_len,
|
||||||
int encoded_rate,
|
uint32_t encoded_rate,
|
||||||
void *decoded_data,
|
void *decoded_data,
|
||||||
switch_size_t *decoded_data_len,
|
uint32_t *decoded_data_len,
|
||||||
int *decoded_rate,
|
uint32_t *decoded_rate,
|
||||||
unsigned int *flag);
|
unsigned int *flag);
|
||||||
/*! deinitalize a codec handle using this implementation */
|
/*! deinitalize a codec handle using this implementation */
|
||||||
switch_status (*destroy)(switch_codec *);
|
switch_status (*destroy)(switch_codec *);
|
||||||
@ -466,7 +466,7 @@ struct switch_codec_interface {
|
|||||||
/*! enumeration defining the type of the codec */
|
/*! enumeration defining the type of the codec */
|
||||||
const switch_codec_type codec_type;
|
const switch_codec_type codec_type;
|
||||||
/*! the IANA code number */
|
/*! the IANA code number */
|
||||||
unsigned int ianacode;
|
uint8_t ianacode;
|
||||||
/*! the IANA code name */
|
/*! the IANA code name */
|
||||||
char *iananame;
|
char *iananame;
|
||||||
/*! a list of codec implementations related to the codec */
|
/*! a list of codec implementations related to the codec */
|
||||||
|
@ -67,9 +67,9 @@ struct switch_audio_resampler {
|
|||||||
/*! a pointer to store a float buffer for resampled data */
|
/*! a pointer to store a float buffer for resampled data */
|
||||||
float *to;
|
float *to;
|
||||||
/*! the size of the to buffer used */
|
/*! the size of the to buffer used */
|
||||||
int to_len;
|
uint32_t to_len;
|
||||||
/*! the total size of the to buffer */
|
/*! the total size of the to buffer */
|
||||||
switch_size_t to_size;
|
uint32_t to_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -86,7 +86,7 @@ SWITCH_DECLARE(switch_status) switch_resample_create(switch_audio_resampler **ne
|
|||||||
int from_rate,
|
int from_rate,
|
||||||
switch_size_t from_size,
|
switch_size_t from_size,
|
||||||
int to_rate,
|
int to_rate,
|
||||||
switch_size_t to_size,
|
uint32_t to_size,
|
||||||
switch_memory_pool *pool);
|
switch_memory_pool *pool);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -105,7 +105,7 @@ SWITCH_DECLARE(void) switch_resample_destroy(switch_audio_resampler *resampler);
|
|||||||
\param last parameter denoting the last sample is being resampled
|
\param last parameter denoting the last sample is being resampled
|
||||||
\return the used size of dst
|
\return the used size of dst
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(int) switch_resample_process(switch_audio_resampler *resampler, float *src, int srclen, float *dst, int dstlen, int last);
|
SWITCH_DECLARE(uint32_t) switch_resample_process(switch_audio_resampler *resampler, float *src, int srclen, float *dst, uint32_t dstlen, int last);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Convert an array of floats to an array of shorts
|
\brief Convert an array of floats to an array of shorts
|
||||||
|
@ -81,8 +81,8 @@ SWITCH_DECLARE(switch_port_t) switch_rtp_request_port(void);
|
|||||||
\return the new RTP session or NULL on failure
|
\return the new RTP session or NULL on failure
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(switch_status)switch_rtp_create(switch_rtp **new_rtp_session,
|
SWITCH_DECLARE(switch_status)switch_rtp_create(switch_rtp **new_rtp_session,
|
||||||
int payload,
|
uint8_t payload,
|
||||||
switch_size_t packet_size,
|
uint32_t packet_size,
|
||||||
uint32_t ms_per_packet,
|
uint32_t ms_per_packet,
|
||||||
switch_rtp_flag_t flags,
|
switch_rtp_flag_t flags,
|
||||||
const char **err,
|
const char **err,
|
||||||
@ -107,8 +107,8 @@ SWITCH_DECLARE(switch_rtp *)switch_rtp_new(char *rx_host,
|
|||||||
switch_port_t rx_port,
|
switch_port_t rx_port,
|
||||||
char *tx_host,
|
char *tx_host,
|
||||||
switch_port_t tx_port,
|
switch_port_t tx_port,
|
||||||
int payload,
|
uint8_t payload,
|
||||||
switch_size_t packet_size,
|
uint32_t packet_size,
|
||||||
uint32_t ms_per_packet,
|
uint32_t ms_per_packet,
|
||||||
switch_rtp_flag_t flags,
|
switch_rtp_flag_t flags,
|
||||||
const char **err,
|
const char **err,
|
||||||
@ -164,7 +164,7 @@ SWITCH_DECLARE(switch_socket_t *)switch_rtp_get_rtp_socket(switch_rtp *rtp_sessi
|
|||||||
\param rtp_session the RTP session to set the packet size on
|
\param rtp_session the RTP session to set the packet size on
|
||||||
\param packet_size the new default packet size
|
\param packet_size the new default packet size
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(void) switch_rtp_set_default_packet_size(switch_rtp *rtp_session, uint32_t packet_size);
|
SWITCH_DECLARE(void) switch_rtp_set_default_packet_size(switch_rtp *rtp_session, uint16_t packet_size);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Get the default packet size for a given RTP session
|
\brief Get the default packet size for a given RTP session
|
||||||
@ -178,7 +178,7 @@ SWITCH_DECLARE(uint32_t) switch_rtp_get_default_packet_size(switch_rtp *rtp_sess
|
|||||||
\param rtp_session the RTP session to set the payload number on
|
\param rtp_session the RTP session to set the payload number on
|
||||||
\param payload the new default payload number
|
\param payload the new default payload number
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(void) switch_rtp_set_default_payload(switch_rtp *rtp_session, uint32_t payload);
|
SWITCH_DECLARE(void) switch_rtp_set_default_payload(switch_rtp *rtp_session, uint8_t payload);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Get the default payload number for a given RTP session
|
\brief Get the default payload number for a given RTP session
|
||||||
@ -225,7 +225,7 @@ SWITCH_DECLARE(int) switch_rtp_zerocopy_read(switch_rtp *rtp_session, void **dat
|
|||||||
\param ts then number of bytes to increment the timestamp by
|
\param ts then number of bytes to increment the timestamp by
|
||||||
\return the number of bytes written
|
\return the number of bytes written
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(int) switch_rtp_write(switch_rtp *rtp_session, void *data, int datalen, uint32_t ts);
|
SWITCH_DECLARE(int) switch_rtp_write(switch_rtp *rtp_session, void *data, uint32_t datalen, uint32_t ts);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Write data with a specified payload and sequence number to a given RTP session
|
\brief Write data with a specified payload and sequence number to a given RTP session
|
||||||
@ -237,7 +237,7 @@ SWITCH_DECLARE(int) switch_rtp_write(switch_rtp *rtp_session, void *data, int da
|
|||||||
\param mseq the specific sequence number to use
|
\param mseq the specific sequence number to use
|
||||||
\return the number of bytes written
|
\return the number of bytes written
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(int) switch_rtp_write_payload(switch_rtp *rtp_session, void *data, int datalen, uint8_t payload, uint32_t ts, uint16_t mseq);
|
SWITCH_DECLARE(int) switch_rtp_write_payload(switch_rtp *rtp_session, void *data, uint16_t datalen, uint8_t payload, uint32_t ts, uint16_t mseq);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Retrieve the SSRC from a given RTP session
|
\brief Retrieve the SSRC from a given RTP session
|
||||||
|
@ -460,7 +460,6 @@ typedef enum {
|
|||||||
SWITCH_EVENT_ALL
|
SWITCH_EVENT_ALL
|
||||||
} switch_event_t;
|
} switch_event_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct switch_rtp switch_rtp;
|
typedef struct switch_rtp switch_rtp;
|
||||||
typedef struct switch_core_session_message switch_core_session_message;
|
typedef struct switch_core_session_message switch_core_session_message;
|
||||||
typedef struct switch_audio_resampler switch_audio_resampler;
|
typedef struct switch_audio_resampler switch_audio_resampler;
|
||||||
|
@ -55,14 +55,14 @@ static switch_status switch_g711u_init(switch_codec *codec, switch_codec_flag fl
|
|||||||
static switch_status switch_g711u_encode(switch_codec *codec,
|
static switch_status switch_g711u_encode(switch_codec *codec,
|
||||||
switch_codec *other_codec,
|
switch_codec *other_codec,
|
||||||
void *decoded_data,
|
void *decoded_data,
|
||||||
size_t decoded_data_len,
|
uint32_t decoded_data_len,
|
||||||
int decoded_rate,
|
uint32_t decoded_rate,
|
||||||
void *encoded_data,
|
void *encoded_data,
|
||||||
size_t *encoded_data_len, int *encoded_rate, unsigned int *flag)
|
uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
|
||||||
{
|
{
|
||||||
short *dbuf;
|
short *dbuf;
|
||||||
unsigned char *ebuf;
|
unsigned char *ebuf;
|
||||||
size_t i;
|
uint32_t i;
|
||||||
|
|
||||||
dbuf = decoded_data;
|
dbuf = decoded_data;
|
||||||
ebuf = encoded_data;
|
ebuf = encoded_data;
|
||||||
@ -79,14 +79,14 @@ static switch_status switch_g711u_encode(switch_codec *codec,
|
|||||||
static switch_status switch_g711u_decode(switch_codec *codec,
|
static switch_status switch_g711u_decode(switch_codec *codec,
|
||||||
switch_codec *other_codec,
|
switch_codec *other_codec,
|
||||||
void *encoded_data,
|
void *encoded_data,
|
||||||
size_t encoded_data_len,
|
uint32_t encoded_data_len,
|
||||||
int encoded_rate,
|
uint32_t encoded_rate,
|
||||||
void *decoded_data,
|
void *decoded_data,
|
||||||
size_t *decoded_data_len, int *decoded_rate, unsigned int *flag)
|
uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
|
||||||
{
|
{
|
||||||
short *dbuf;
|
short *dbuf;
|
||||||
unsigned char *ebuf;
|
unsigned char *ebuf;
|
||||||
size_t i;
|
uint32_t i;
|
||||||
|
|
||||||
dbuf = decoded_data;
|
dbuf = decoded_data;
|
||||||
ebuf = encoded_data;
|
ebuf = encoded_data;
|
||||||
@ -130,14 +130,14 @@ static switch_status switch_g711a_init(switch_codec *codec, switch_codec_flag fl
|
|||||||
static switch_status switch_g711a_encode(switch_codec *codec,
|
static switch_status switch_g711a_encode(switch_codec *codec,
|
||||||
switch_codec *other_codec,
|
switch_codec *other_codec,
|
||||||
void *decoded_data,
|
void *decoded_data,
|
||||||
size_t decoded_data_len,
|
uint32_t decoded_data_len,
|
||||||
int decoded_rate,
|
uint32_t decoded_rate,
|
||||||
void *encoded_data,
|
void *encoded_data,
|
||||||
size_t *encoded_data_len, int *encoded_rate, unsigned int *flag)
|
uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
|
||||||
{
|
{
|
||||||
short *dbuf;
|
short *dbuf;
|
||||||
unsigned char *ebuf;
|
unsigned char *ebuf;
|
||||||
size_t i;
|
uint32_t i;
|
||||||
|
|
||||||
dbuf = decoded_data;
|
dbuf = decoded_data;
|
||||||
ebuf = encoded_data;
|
ebuf = encoded_data;
|
||||||
@ -154,14 +154,14 @@ static switch_status switch_g711a_encode(switch_codec *codec,
|
|||||||
static switch_status switch_g711a_decode(switch_codec *codec,
|
static switch_status switch_g711a_decode(switch_codec *codec,
|
||||||
switch_codec *other_codec,
|
switch_codec *other_codec,
|
||||||
void *encoded_data,
|
void *encoded_data,
|
||||||
size_t encoded_data_len,
|
uint32_t encoded_data_len,
|
||||||
int encoded_rate,
|
uint32_t encoded_rate,
|
||||||
void *decoded_data,
|
void *decoded_data,
|
||||||
size_t *decoded_data_len, int *decoded_rate, unsigned int *flag)
|
uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
|
||||||
{
|
{
|
||||||
short *dbuf;
|
short *dbuf;
|
||||||
unsigned char *ebuf;
|
unsigned char *ebuf;
|
||||||
size_t i;
|
uint32_t i;
|
||||||
|
|
||||||
dbuf = decoded_data;
|
dbuf = decoded_data;
|
||||||
ebuf = encoded_data;
|
ebuf = encoded_data;
|
||||||
|
@ -84,12 +84,12 @@ static switch_status switch_g729_encode(switch_codec *codec,
|
|||||||
switch_codec *other_codec,
|
switch_codec *other_codec,
|
||||||
void *decoded_data,
|
void *decoded_data,
|
||||||
|
|
||||||
size_t decoded_data_len,
|
uint32_t decoded_data_len,
|
||||||
int decoded_rate,
|
uint32_t decoded_rate,
|
||||||
void *encoded_data,
|
void *encoded_data,
|
||||||
|
|
||||||
size_t *encoded_data_len,
|
uint32_t *encoded_data_len,
|
||||||
int *encoded_rate,
|
uint32_t *encoded_rate,
|
||||||
unsigned int *flag)
|
unsigned int *flag)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ static switch_status switch_g729_encode(switch_codec *codec,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (decoded_data_len % 160 == 0) {
|
if (decoded_data_len % 160 == 0) {
|
||||||
unsigned int new_len = 0;
|
uint32_t new_len = 0;
|
||||||
INT16 * ddp = decoded_data;
|
INT16 * ddp = decoded_data;
|
||||||
char *edp = encoded_data;
|
char *edp = encoded_data;
|
||||||
int x;
|
int x;
|
||||||
@ -131,12 +131,12 @@ static switch_status switch_g729_decode(switch_codec *codec,
|
|||||||
switch_codec *other_codec,
|
switch_codec *other_codec,
|
||||||
void *encoded_data,
|
void *encoded_data,
|
||||||
|
|
||||||
size_t encoded_data_len,
|
uint32_t encoded_data_len,
|
||||||
int encoded_rate,
|
uint32_t encoded_rate,
|
||||||
void *decoded_data,
|
void *decoded_data,
|
||||||
|
|
||||||
size_t *decoded_data_len,
|
uint32_t *decoded_data_len,
|
||||||
int *decoded_rate,
|
uint32_t *decoded_rate,
|
||||||
unsigned int *flag)
|
unsigned int *flag)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ static switch_status switch_g729_decode(switch_codec *codec,
|
|||||||
|
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
unsigned int new_len = 0;
|
uint32_t new_len = 0;
|
||||||
|
|
||||||
test = (uint8_t *) encoded_data;
|
test = (uint8_t *) encoded_data;
|
||||||
if (*test == 0 && *(test+1) == 0) {
|
if (*test == 0 && *(test+1) == 0) {
|
||||||
|
@ -68,15 +68,15 @@ static switch_status switch_gsm_destroy(switch_codec *codec)
|
|||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
static switch_status switch_gsm_encode(switch_codec *codec, switch_codec *other_codec, void *decoded_data,
|
static switch_status switch_gsm_encode(switch_codec *codec, switch_codec *other_codec, void *decoded_data,
|
||||||
size_t decoded_data_len, int decoded_rate, void *encoded_data,
|
uint32_t decoded_data_len, uint32_t decoded_rate, void *encoded_data,
|
||||||
size_t *encoded_data_len, int *encoded_rate, unsigned int *flag)
|
uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
|
||||||
{
|
{
|
||||||
struct gsm_context *context = codec->private_info;
|
struct gsm_context *context = codec->private_info;
|
||||||
if (!context) {
|
if (!context) {
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
if (decoded_data_len % 320 == 0) {
|
if (decoded_data_len % 320 == 0) {
|
||||||
unsigned int new_len = 0;
|
uint32_t new_len = 0;
|
||||||
gsm_signal * ddp = decoded_data;
|
gsm_signal * ddp = decoded_data;
|
||||||
gsm_byte * edp = encoded_data;
|
gsm_byte * edp = encoded_data;
|
||||||
int x;
|
int x;
|
||||||
@ -97,8 +97,8 @@ static switch_status switch_gsm_encode(switch_codec *codec, switch_codec *other_
|
|||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
static switch_status switch_gsm_decode(switch_codec *codec, switch_codec *other_codec, void *encoded_data,
|
static switch_status switch_gsm_decode(switch_codec *codec, switch_codec *other_codec, void *encoded_data,
|
||||||
size_t encoded_data_len, int encoded_rate, void *decoded_data,
|
uint32_t encoded_data_len, uint32_t encoded_rate, void *decoded_data,
|
||||||
size_t *decoded_data_len, int *decoded_rate, unsigned int *flag)
|
uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
|
||||||
{
|
{
|
||||||
struct gsm_context *context = codec->private_info;
|
struct gsm_context *context = codec->private_info;
|
||||||
if (!context) {
|
if (!context) {
|
||||||
@ -110,7 +110,7 @@ static switch_status switch_gsm_decode(switch_codec *codec, switch_codec *other_
|
|||||||
gsm_byte * edp = encoded_data;
|
gsm_byte * edp = encoded_data;
|
||||||
gsm_signal * ddp = decoded_data;
|
gsm_signal * ddp = decoded_data;
|
||||||
int x;
|
int x;
|
||||||
unsigned int new_len = 0;
|
uint32_t new_len = 0;
|
||||||
|
|
||||||
for (x = 0; x < loops && new_len < *decoded_data_len; x++) {
|
for (x = 0; x < loops && new_len < *decoded_data_len; x++) {
|
||||||
gsm_decode(context->decoder, edp, ddp);
|
gsm_decode(context->decoder, edp, ddp);
|
||||||
|
@ -52,10 +52,10 @@ static switch_status switch_raw_init(switch_codec *codec, switch_codec_flag flag
|
|||||||
static switch_status switch_raw_encode(switch_codec *codec,
|
static switch_status switch_raw_encode(switch_codec *codec,
|
||||||
switch_codec *other_codec,
|
switch_codec *other_codec,
|
||||||
void *decoded_data,
|
void *decoded_data,
|
||||||
size_t decoded_data_len,
|
uint32_t decoded_data_len,
|
||||||
int decoded_rate,
|
uint32_t decoded_rate,
|
||||||
void *encoded_data,
|
void *encoded_data,
|
||||||
size_t *encoded_data_len, int *encoded_rate, unsigned int *flag)
|
uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* NOOP indicates that the audio in is already the same as the audio out, so no conversion was necessary. */
|
/* NOOP indicates that the audio in is already the same as the audio out, so no conversion was necessary. */
|
||||||
@ -70,10 +70,10 @@ static switch_status switch_raw_encode(switch_codec *codec,
|
|||||||
static switch_status switch_raw_decode(switch_codec *codec,
|
static switch_status switch_raw_decode(switch_codec *codec,
|
||||||
switch_codec *other_codec,
|
switch_codec *other_codec,
|
||||||
void *encoded_data,
|
void *encoded_data,
|
||||||
size_t encoded_data_len,
|
uint32_t encoded_data_len,
|
||||||
int encoded_rate,
|
uint32_t encoded_rate,
|
||||||
void *decoded_data,
|
void *decoded_data,
|
||||||
size_t *decoded_data_len, int *decoded_rate, unsigned int *flag)
|
uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
|
||||||
{
|
{
|
||||||
if (codec && other_codec && codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
|
if (codec && other_codec && codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
|
||||||
memcpy(decoded_data, encoded_data, encoded_data_len);
|
memcpy(decoded_data, encoded_data, encoded_data_len);
|
||||||
|
@ -160,10 +160,10 @@ static switch_status switch_speex_init(switch_codec *codec, switch_codec_flag fl
|
|||||||
static switch_status switch_speex_encode(switch_codec *codec,
|
static switch_status switch_speex_encode(switch_codec *codec,
|
||||||
switch_codec *other_codec,
|
switch_codec *other_codec,
|
||||||
void *decoded_data,
|
void *decoded_data,
|
||||||
size_t decoded_data_len,
|
uint32_t decoded_data_len,
|
||||||
int decoded_rate,
|
uint32_t decoded_rate,
|
||||||
void *encoded_data,
|
void *encoded_data,
|
||||||
size_t *encoded_data_len, int *encoded_rate, unsigned int *flag)
|
uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
|
||||||
{
|
{
|
||||||
struct speex_context *context = codec->private_info;
|
struct speex_context *context = codec->private_info;
|
||||||
short *buf;
|
short *buf;
|
||||||
@ -215,10 +215,10 @@ static switch_status switch_speex_encode(switch_codec *codec,
|
|||||||
static switch_status switch_speex_decode(switch_codec *codec,
|
static switch_status switch_speex_decode(switch_codec *codec,
|
||||||
switch_codec *other_codec,
|
switch_codec *other_codec,
|
||||||
void *encoded_data,
|
void *encoded_data,
|
||||||
size_t encoded_data_len,
|
uint32_t encoded_data_len,
|
||||||
int encoded_rate,
|
uint32_t encoded_rate,
|
||||||
void *decoded_data,
|
void *decoded_data,
|
||||||
size_t *decoded_data_len, int *decoded_rate, unsigned int *flag)
|
uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
|
||||||
{
|
{
|
||||||
struct speex_context *context = codec->private_info;
|
struct speex_context *context = codec->private_info;
|
||||||
short *buf;
|
short *buf;
|
||||||
|
@ -117,7 +117,7 @@ struct private_object {
|
|||||||
int32_t timestamp_recv;
|
int32_t timestamp_recv;
|
||||||
int32_t timestamp_dtmf;
|
int32_t timestamp_dtmf;
|
||||||
char *codec_name;
|
char *codec_name;
|
||||||
int codec_num;
|
uint8_t codec_num;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct rfc2833_digit {
|
struct rfc2833_digit {
|
||||||
@ -545,7 +545,8 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra
|
|||||||
switch_io_flag flags, int stream_id)
|
switch_io_flag flags, int stream_id)
|
||||||
{
|
{
|
||||||
struct private_object *tech_pvt = NULL;
|
struct private_object *tech_pvt = NULL;
|
||||||
size_t bytes = 0, samples = 0, frames = 0, ms = 0;
|
uint32_t bytes = 0;
|
||||||
|
switch_size_t samples = 0, frames = 0, ms = 0;
|
||||||
switch_channel *channel = NULL;
|
switch_channel *channel = NULL;
|
||||||
int payload = 0;
|
int payload = 0;
|
||||||
|
|
||||||
@ -728,7 +729,7 @@ static switch_status channel_write_frame(switch_core_session *session, switch_fr
|
|||||||
//printf("%s send %d bytes %d samples in %d frames ts=%d\n", switch_channel_get_name(channel), frame->datalen, samples, frames, tech_pvt->timestamp_send);
|
//printf("%s send %d bytes %d samples in %d frames ts=%d\n", switch_channel_get_name(channel), frame->datalen, samples, frames, tech_pvt->timestamp_send);
|
||||||
|
|
||||||
|
|
||||||
switch_rtp_write(tech_pvt->rtp_session, frame->data, (int) frame->datalen, samples);
|
switch_rtp_write(tech_pvt->rtp_session, frame->data, frame->datalen, samples);
|
||||||
tech_pvt->timestamp_send += (int) samples;
|
tech_pvt->timestamp_send += (int) samples;
|
||||||
|
|
||||||
switch_clear_flag(tech_pvt, TFLAG_WRITING);
|
switch_clear_flag(tech_pvt, TFLAG_WRITING);
|
||||||
|
@ -134,7 +134,7 @@ static switch_status sndfile_file_open(switch_file_handle *handle, char *path)
|
|||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Opening File [%s] %dhz\n", path, context->sfinfo.samplerate);
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Opening File [%s] %dhz\n", path, context->sfinfo.samplerate);
|
||||||
handle->samples = (unsigned int) context->sfinfo.frames;
|
handle->samples = (unsigned int) context->sfinfo.frames;
|
||||||
handle->samplerate = context->sfinfo.samplerate;
|
handle->samplerate = context->sfinfo.samplerate;
|
||||||
handle->channels = context->sfinfo.channels;
|
handle->channels = (uint8_t)context->sfinfo.channels;
|
||||||
handle->format = context->sfinfo.format;
|
handle->format = context->sfinfo.format;
|
||||||
handle->sections = context->sfinfo.sections;
|
handle->sections = context->sfinfo.sections;
|
||||||
handle->seekable = context->sfinfo.seekable;
|
handle->seekable = context->sfinfo.seekable;
|
||||||
|
@ -1665,7 +1665,7 @@ static JSBool teletone_generate(JSContext *cx, JSObject *obj, uintN argc, jsval
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((write_frame.datalen = switch_buffer_read(tto->audio_buffer, fdata, write_frame.codec->implementation->bytes_per_frame)) <= 0) {
|
if ((write_frame.datalen = (uint32_t)switch_buffer_read(tto->audio_buffer, fdata, write_frame.codec->implementation->bytes_per_frame)) <= 0) {
|
||||||
if (loops > 0) {
|
if (loops > 0) {
|
||||||
switch_buffer *tmp;
|
switch_buffer *tmp;
|
||||||
|
|
||||||
@ -1675,7 +1675,7 @@ static JSBool teletone_generate(JSContext *cx, JSObject *obj, uintN argc, jsval
|
|||||||
tto->loop_buffer = tmp;
|
tto->loop_buffer = tmp;
|
||||||
loops--;
|
loops--;
|
||||||
/* try again */
|
/* try again */
|
||||||
if ((write_frame.datalen = switch_buffer_read(tto->audio_buffer, fdata, write_frame.codec->implementation->bytes_per_frame)) <= 0) {
|
if ((write_frame.datalen = (uint32_t)switch_buffer_read(tto->audio_buffer, fdata, write_frame.codec->implementation->bytes_per_frame)) <= 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -265,7 +265,7 @@ SWITCH_DECLARE(switch_codec *) switch_core_session_get_write_codec(switch_core_s
|
|||||||
return session->write_codec;
|
return session->write_codec;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec, char *codec_name, int rate, int ms,
|
SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec, char *codec_name, uint32_t rate, int ms,
|
||||||
int channels, uint32_t flags,
|
int channels, uint32_t flags,
|
||||||
const switch_codec_settings *codec_settings,
|
const switch_codec_settings *codec_settings,
|
||||||
switch_memory_pool *pool)
|
switch_memory_pool *pool)
|
||||||
@ -321,10 +321,10 @@ SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec, char *
|
|||||||
SWITCH_DECLARE(switch_status) switch_core_codec_encode(switch_codec *codec,
|
SWITCH_DECLARE(switch_status) switch_core_codec_encode(switch_codec *codec,
|
||||||
switch_codec *other_codec,
|
switch_codec *other_codec,
|
||||||
void *decoded_data,
|
void *decoded_data,
|
||||||
switch_size_t decoded_data_len,
|
uint32_t decoded_data_len,
|
||||||
int decoded_rate,
|
uint32_t decoded_rate,
|
||||||
void *encoded_data,
|
void *encoded_data,
|
||||||
switch_size_t *encoded_data_len, int *encoded_rate, unsigned int *flag)
|
uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
|
||||||
{
|
{
|
||||||
assert(codec != NULL);
|
assert(codec != NULL);
|
||||||
assert(encoded_data != NULL);
|
assert(encoded_data != NULL);
|
||||||
@ -352,10 +352,10 @@ SWITCH_DECLARE(switch_status) switch_core_codec_encode(switch_codec *codec,
|
|||||||
SWITCH_DECLARE(switch_status) switch_core_codec_decode(switch_codec *codec,
|
SWITCH_DECLARE(switch_status) switch_core_codec_decode(switch_codec *codec,
|
||||||
switch_codec *other_codec,
|
switch_codec *other_codec,
|
||||||
void *encoded_data,
|
void *encoded_data,
|
||||||
switch_size_t encoded_data_len,
|
uint32_t encoded_data_len,
|
||||||
int encoded_rate,
|
uint32_t encoded_rate,
|
||||||
void *decoded_data,
|
void *decoded_data,
|
||||||
switch_size_t *decoded_data_len, int *decoded_rate, unsigned int *flag)
|
uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
|
||||||
{
|
{
|
||||||
|
|
||||||
assert(codec != NULL);
|
assert(codec != NULL);
|
||||||
@ -553,7 +553,7 @@ SWITCH_DECLARE(switch_status) switch_core_speech_feed_tts(switch_speech_handle *
|
|||||||
SWITCH_DECLARE(switch_status) switch_core_speech_read_tts(switch_speech_handle *sh,
|
SWITCH_DECLARE(switch_status) switch_core_speech_read_tts(switch_speech_handle *sh,
|
||||||
void *data,
|
void *data,
|
||||||
switch_size_t *datalen,
|
switch_size_t *datalen,
|
||||||
switch_size_t *rate,
|
uint32_t *rate,
|
||||||
switch_speech_flag *flags)
|
switch_speech_flag *flags)
|
||||||
{
|
{
|
||||||
assert(sh != NULL);
|
assert(sh != NULL);
|
||||||
@ -985,7 +985,9 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
|||||||
read_frame->datalen,
|
read_frame->datalen,
|
||||||
session->read_codec->implementation->samples_per_second,
|
session->read_codec->implementation->samples_per_second,
|
||||||
session->raw_read_frame.data,
|
session->raw_read_frame.data,
|
||||||
&session->raw_read_frame.datalen, &session->raw_read_frame.rate, &flag);
|
&session->raw_read_frame.datalen,
|
||||||
|
&session->raw_read_frame.rate,
|
||||||
|
&flag);
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case SWITCH_STATUS_RESAMPLE:
|
case SWITCH_STATUS_RESAMPLE:
|
||||||
@ -1017,7 +1019,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
|||||||
session->read_resampler->to_len =
|
session->read_resampler->to_len =
|
||||||
switch_resample_process(session->read_resampler, session->read_resampler->from,
|
switch_resample_process(session->read_resampler, session->read_resampler->from,
|
||||||
session->read_resampler->from_len, session->read_resampler->to,
|
session->read_resampler->from_len, session->read_resampler->to,
|
||||||
(int) session->read_resampler->to_size, 0);
|
session->read_resampler->to_size, 0);
|
||||||
switch_float_to_short(session->read_resampler->to, data, read_frame->datalen);
|
switch_float_to_short(session->read_resampler->to, data, read_frame->datalen);
|
||||||
read_frame->samples = session->read_resampler->to_len;
|
read_frame->samples = session->read_resampler->to_len;
|
||||||
read_frame->datalen = session->read_resampler->to_len * 2;
|
read_frame->datalen = session->read_resampler->to_len * 2;
|
||||||
@ -1045,7 +1047,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
|||||||
enc_frame = *frame;
|
enc_frame = *frame;
|
||||||
session->raw_read_frame.rate = (*frame)->rate;
|
session->raw_read_frame.rate = (*frame)->rate;
|
||||||
} else {
|
} else {
|
||||||
session->raw_read_frame.datalen = switch_buffer_read(session->raw_read_buffer,
|
session->raw_read_frame.datalen = (uint32_t)switch_buffer_read(session->raw_read_buffer,
|
||||||
session->raw_read_frame.data,
|
session->raw_read_frame.data,
|
||||||
session->read_codec->implementation->
|
session->read_codec->implementation->
|
||||||
bytes_per_frame);
|
bytes_per_frame);
|
||||||
@ -1187,10 +1189,10 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
|||||||
|
|
||||||
session->write_resampler->from_len =
|
session->write_resampler->from_len =
|
||||||
switch_short_to_float(data, session->write_resampler->from, (int) write_frame->datalen / 2);
|
switch_short_to_float(data, session->write_resampler->from, (int) write_frame->datalen / 2);
|
||||||
session->write_resampler->to_len =
|
session->write_resampler->to_len = (uint32_t)
|
||||||
switch_resample_process(session->write_resampler, session->write_resampler->from,
|
switch_resample_process(session->write_resampler, session->write_resampler->from,
|
||||||
session->write_resampler->from_len, session->write_resampler->to,
|
session->write_resampler->from_len, session->write_resampler->to,
|
||||||
(int) session->write_resampler->to_size, 0);
|
session->write_resampler->to_size, 0);
|
||||||
switch_float_to_short(session->write_resampler->to, data, write_frame->datalen * 2);
|
switch_float_to_short(session->write_resampler->to, data, write_frame->datalen * 2);
|
||||||
write_frame->samples = session->write_resampler->to_len;
|
write_frame->samples = session->write_resampler->to_len;
|
||||||
write_frame->datalen = session->write_resampler->to_len * 2;
|
write_frame->datalen = session->write_resampler->to_len * 2;
|
||||||
@ -1256,19 +1258,14 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
|||||||
return status;
|
return status;
|
||||||
} else {
|
} else {
|
||||||
switch_size_t used = switch_buffer_inuse(session->raw_write_buffer);
|
switch_size_t used = switch_buffer_inuse(session->raw_write_buffer);
|
||||||
switch_size_t bytes = session->write_codec->implementation->bytes_per_frame;
|
uint32_t bytes = session->write_codec->implementation->bytes_per_frame;
|
||||||
switch_size_t frames = (used / bytes);
|
switch_size_t frames = (used / bytes);
|
||||||
|
|
||||||
|
status = SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
status = SWITCH_STATUS_SUCCESS;
|
|
||||||
if (frames) {
|
if (frames) {
|
||||||
switch_size_t x;
|
switch_size_t x;
|
||||||
for (x = 0; x < frames; x++) {
|
for (x = 0; x < frames; x++) {
|
||||||
if ((session->raw_write_frame.datalen =
|
if ((session->raw_write_frame.datalen = (uint32_t)
|
||||||
switch_buffer_read(session->raw_write_buffer, session->raw_write_frame.data, bytes)) != 0) {
|
switch_buffer_read(session->raw_write_buffer, session->raw_write_frame.data, bytes)) != 0) {
|
||||||
|
|
||||||
enc_frame = &session->raw_write_frame;
|
enc_frame = &session->raw_write_frame;
|
||||||
@ -1320,11 +1317,11 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
|||||||
session->read_resampler->from,
|
session->read_resampler->from,
|
||||||
(int) write_frame->datalen /
|
(int) write_frame->datalen /
|
||||||
2);
|
2);
|
||||||
session->read_resampler->to_len =
|
session->read_resampler->to_len = (uint32_t)
|
||||||
switch_resample_process(session->read_resampler, session->read_resampler->from,
|
switch_resample_process(session->read_resampler, session->read_resampler->from,
|
||||||
session->read_resampler->from_len,
|
session->read_resampler->from_len,
|
||||||
session->read_resampler->to,
|
session->read_resampler->to,
|
||||||
(int) session->read_resampler->to_size, 0);
|
session->read_resampler->to_size, 0);
|
||||||
switch_float_to_short(session->read_resampler->to, data, write_frame->datalen * 2);
|
switch_float_to_short(session->read_resampler->to, data, write_frame->datalen * 2);
|
||||||
write_frame->samples = session->read_resampler->to_len;
|
write_frame->samples = session->read_resampler->to_len;
|
||||||
write_frame->datalen = session->read_resampler->to_len * 2;
|
write_frame->datalen = session->read_resampler->to_len * 2;
|
||||||
|
@ -256,8 +256,9 @@ SWITCH_DECLARE(switch_status) switch_ivr_play_file(switch_core_session *session,
|
|||||||
switch_channel *channel;
|
switch_channel *channel;
|
||||||
short abuf[960];
|
short abuf[960];
|
||||||
char dtmf[128];
|
char dtmf[128];
|
||||||
int interval = 0, samples = 0;
|
uint32_t interval = 0, samples = 0;
|
||||||
switch_size_t len = 0, ilen = 0, olen = 0;
|
uint32_t len = 0, ilen = 0;
|
||||||
|
switch_size_t olen = 0;
|
||||||
switch_frame write_frame;
|
switch_frame write_frame;
|
||||||
switch_timer timer;
|
switch_timer timer;
|
||||||
switch_core_thread_session thread_session;
|
switch_core_thread_session thread_session;
|
||||||
@ -292,7 +293,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_play_file(switch_core_session *session,
|
|||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "OPEN FILE %s %uhz %u channels\n", file, fh->samplerate, fh->channels);
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "OPEN FILE %s %uhz %u channels\n", file, fh->samplerate, fh->channels);
|
||||||
|
|
||||||
interval = 20;
|
interval = 20;
|
||||||
samples = (fh->samplerate / 50) * fh->channels;
|
samples = ((fh->samplerate / 50) * fh->channels);
|
||||||
len = samples * 2;
|
len = samples * 2;
|
||||||
|
|
||||||
codec_name = "L16";
|
codec_name = "L16";
|
||||||
@ -362,7 +363,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_play_file(switch_core_session *session,
|
|||||||
memset(abuf, 0, ilen * 2);
|
memset(abuf, 0, ilen * 2);
|
||||||
olen = ilen;
|
olen = ilen;
|
||||||
do_speed = 0;
|
do_speed = 0;
|
||||||
} else if (fh->audio_buffer && (switch_buffer_inuse(fh->audio_buffer) > (ilen * 2))) {
|
} else if (fh->audio_buffer && (switch_buffer_inuse(fh->audio_buffer) > (switch_size_t)(ilen * 2))) {
|
||||||
switch_buffer_read(fh->audio_buffer, abuf, ilen * 2);
|
switch_buffer_read(fh->audio_buffer, abuf, ilen * 2);
|
||||||
olen = ilen;
|
olen = ilen;
|
||||||
do_speed = 0;
|
do_speed = 0;
|
||||||
@ -425,8 +426,8 @@ SWITCH_DECLARE(switch_status) switch_ivr_play_file(switch_core_session *session,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
write_frame.datalen = olen * 2;
|
write_frame.datalen = (uint32_t)(olen * 2);
|
||||||
write_frame.samples = (int) olen;
|
write_frame.samples = (uint32_t)olen;
|
||||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||||
switch_swap_linear(write_frame.data, (int) write_frame.datalen / 2);
|
switch_swap_linear(write_frame.data, (int) write_frame.datalen / 2);
|
||||||
#endif
|
#endif
|
||||||
@ -474,7 +475,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_speak_text(switch_core_session *session
|
|||||||
char *tts_name,
|
char *tts_name,
|
||||||
char *voice_name,
|
char *voice_name,
|
||||||
char *timer_name,
|
char *timer_name,
|
||||||
switch_size_t rate,
|
uint32_t rate,
|
||||||
switch_dtmf_callback_function dtmf_callback,
|
switch_dtmf_callback_function dtmf_callback,
|
||||||
char *text,
|
char *text,
|
||||||
void *buf,
|
void *buf,
|
||||||
@ -484,8 +485,8 @@ SWITCH_DECLARE(switch_status) switch_ivr_speak_text(switch_core_session *session
|
|||||||
short abuf[960];
|
short abuf[960];
|
||||||
char dtmf[128];
|
char dtmf[128];
|
||||||
int interval = 0;
|
int interval = 0;
|
||||||
switch_size_t samples = 0;
|
uint32_t samples = 0;
|
||||||
switch_size_t len = 0;
|
uint32_t len = 0;
|
||||||
switch_size_t ilen = 0;
|
switch_size_t ilen = 0;
|
||||||
switch_frame write_frame;
|
switch_frame write_frame;
|
||||||
switch_timer timer;
|
switch_timer timer;
|
||||||
@ -527,7 +528,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_speak_text(switch_core_session *session
|
|||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "OPEN TTS %s\n", tts_name);
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "OPEN TTS %s\n", tts_name);
|
||||||
|
|
||||||
interval = 20;
|
interval = 20;
|
||||||
samples = (rate / 50);
|
samples = (uint32_t)(rate / 50);
|
||||||
len = samples * 2;
|
len = samples * 2;
|
||||||
|
|
||||||
codec_name = "L16";
|
codec_name = "L16";
|
||||||
@ -562,7 +563,7 @@ SWITCH_DECLARE(switch_status) switch_ivr_speak_text(switch_core_session *session
|
|||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
switch_core_speech_feed_tts(&sh, text, &flags);
|
switch_core_speech_feed_tts(&sh, text, &flags);
|
||||||
write_frame.rate = (int)rate;
|
write_frame.rate = rate;
|
||||||
|
|
||||||
memset(write_frame.data, 0, len);
|
memset(write_frame.data, 0, len);
|
||||||
write_frame.datalen = len;
|
write_frame.datalen = len;
|
||||||
@ -634,8 +635,8 @@ SWITCH_DECLARE(switch_status) switch_ivr_speak_text(switch_core_session *session
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
write_frame.datalen = ilen;
|
write_frame.datalen = (uint32_t)ilen;
|
||||||
write_frame.samples = (int) ilen / 2;
|
write_frame.samples = (uint32_t)(ilen / 2);
|
||||||
|
|
||||||
for (stream_id = 0; stream_id < switch_core_session_get_stream_count(session); stream_id++) {
|
for (stream_id = 0; stream_id < switch_core_session_get_stream_count(session); stream_id++) {
|
||||||
if (switch_core_session_write_frame(session, &write_frame, -1, stream_id) != SWITCH_STATUS_SUCCESS) {
|
if (switch_core_session_write_frame(session, &write_frame, -1, stream_id) != SWITCH_STATUS_SUCCESS) {
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
SWITCH_DECLARE(switch_status) switch_resample_create(switch_audio_resampler **new_resampler,
|
SWITCH_DECLARE(switch_status) switch_resample_create(switch_audio_resampler **new_resampler,
|
||||||
int from_rate,
|
int from_rate,
|
||||||
switch_size_t from_size,
|
switch_size_t from_size,
|
||||||
int to_rate, switch_size_t to_size, switch_memory_pool *pool)
|
int to_rate, uint32_t to_size, switch_memory_pool *pool)
|
||||||
{
|
{
|
||||||
switch_audio_resampler *resampler;
|
switch_audio_resampler *resampler;
|
||||||
double lto_rate, lfrom_rate;
|
double lto_rate, lfrom_rate;
|
||||||
@ -77,8 +77,8 @@ SWITCH_DECLARE(switch_status) switch_resample_create(switch_audio_resampler **ne
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SWITCH_DECLARE(int) switch_resample_process(switch_audio_resampler *resampler, float *src, int srclen, float *dst,
|
SWITCH_DECLARE(uint32_t) switch_resample_process(switch_audio_resampler *resampler, float *src, int srclen, float *dst,
|
||||||
int dstlen, int last)
|
uint32_t dstlen, int last)
|
||||||
{
|
{
|
||||||
int o = 0, srcused = 0, srcpos = 0, out = 0;
|
int o = 0, srcused = 0, srcpos = 0, out = 0;
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ struct switch_rtp {
|
|||||||
srtp_ctx_t *recv_ctx;
|
srtp_ctx_t *recv_ctx;
|
||||||
|
|
||||||
uint16_t seq;
|
uint16_t seq;
|
||||||
uint32_t payload;
|
uint8_t payload;
|
||||||
|
|
||||||
switch_rtp_invalid_handler invalid_handler;
|
switch_rtp_invalid_handler invalid_handler;
|
||||||
void *private_data;
|
void *private_data;
|
||||||
@ -80,7 +80,7 @@ struct switch_rtp {
|
|||||||
char *ice_user;
|
char *ice_user;
|
||||||
char *user_ice;
|
char *user_ice;
|
||||||
switch_time_t last_stun;
|
switch_time_t last_stun;
|
||||||
switch_size_t packet_size;
|
uint32_t packet_size;
|
||||||
switch_time_t last_read;
|
switch_time_t last_read;
|
||||||
switch_time_t next_read;
|
switch_time_t next_read;
|
||||||
uint32_t ms_per_packet;
|
uint32_t ms_per_packet;
|
||||||
@ -240,8 +240,8 @@ SWITCH_DECLARE(switch_status) switch_rtp_set_remote_address(switch_rtp *rtp_sess
|
|||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status) switch_rtp_create(switch_rtp **new_rtp_session,
|
SWITCH_DECLARE(switch_status) switch_rtp_create(switch_rtp **new_rtp_session,
|
||||||
int payload,
|
uint8_t payload,
|
||||||
switch_size_t packet_size,
|
uint32_t packet_size,
|
||||||
uint32_t ms_per_packet,
|
uint32_t ms_per_packet,
|
||||||
switch_rtp_flag_t flags,
|
switch_rtp_flag_t flags,
|
||||||
const char **err,
|
const char **err,
|
||||||
@ -327,8 +327,8 @@ SWITCH_DECLARE(switch_rtp *)switch_rtp_new(char *rx_host,
|
|||||||
switch_port_t rx_port,
|
switch_port_t rx_port,
|
||||||
char *tx_host,
|
char *tx_host,
|
||||||
switch_port_t tx_port,
|
switch_port_t tx_port,
|
||||||
int payload,
|
uint8_t payload,
|
||||||
switch_size_t packet_size,
|
uint32_t packet_size,
|
||||||
uint32_t ms_per_packet,
|
uint32_t ms_per_packet,
|
||||||
switch_rtp_flag_t flags,
|
switch_rtp_flag_t flags,
|
||||||
const char **err,
|
const char **err,
|
||||||
@ -391,7 +391,7 @@ SWITCH_DECLARE(switch_socket_t *)switch_rtp_get_rtp_socket(switch_rtp *rtp_sessi
|
|||||||
return rtp_session->sock;
|
return rtp_session->sock;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_rtp_set_default_packet_size(switch_rtp *rtp_session, uint32_t packet_size)
|
SWITCH_DECLARE(void) switch_rtp_set_default_packet_size(switch_rtp *rtp_session, uint16_t packet_size)
|
||||||
{
|
{
|
||||||
rtp_session->packet_size = packet_size;
|
rtp_session->packet_size = packet_size;
|
||||||
}
|
}
|
||||||
@ -401,7 +401,7 @@ SWITCH_DECLARE(uint32_t) switch_rtp_get_default_packet_size(switch_rtp *rtp_sess
|
|||||||
return rtp_session->packet_size;
|
return rtp_session->packet_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_rtp_set_default_payload(switch_rtp *rtp_session, uint32_t payload)
|
SWITCH_DECLARE(void) switch_rtp_set_default_payload(switch_rtp *rtp_session, uint8_t payload)
|
||||||
{
|
{
|
||||||
rtp_session->payload = payload;
|
rtp_session->payload = payload;
|
||||||
}
|
}
|
||||||
@ -501,7 +501,7 @@ SWITCH_DECLARE(int) switch_rtp_zerocopy_read(switch_rtp *rtp_session, void **dat
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rtp_common_write(switch_rtp *rtp_session, void *data, int datalen, int payload)
|
static int rtp_common_write(switch_rtp *rtp_session, void *data, uint32_t datalen, uint8_t payload)
|
||||||
{
|
{
|
||||||
switch_size_t bytes;
|
switch_size_t bytes;
|
||||||
|
|
||||||
@ -536,7 +536,7 @@ static int rtp_common_write(switch_rtp *rtp_session, void *data, int datalen, in
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(int) switch_rtp_write(switch_rtp *rtp_session, void *data, int datalen, uint32_t ts)
|
SWITCH_DECLARE(int) switch_rtp_write(switch_rtp *rtp_session, void *data, uint32_t datalen, uint32_t ts)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO) || !rtp_session->remote_addr) {
|
if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO) || !rtp_session->remote_addr) {
|
||||||
@ -548,13 +548,13 @@ SWITCH_DECLARE(int) switch_rtp_write(switch_rtp *rtp_session, void *data, int da
|
|||||||
rtp_session->seq = htons(rtp_session->seq);
|
rtp_session->seq = htons(rtp_session->seq);
|
||||||
rtp_session->send_msg.header.seq = rtp_session->seq;
|
rtp_session->send_msg.header.seq = rtp_session->seq;
|
||||||
rtp_session->send_msg.header.ts = htonl(rtp_session->ts);
|
rtp_session->send_msg.header.ts = htonl(rtp_session->ts);
|
||||||
rtp_session->payload = htonl(rtp_session->payload);
|
rtp_session->payload = (uint8_t)htonl(rtp_session->payload);
|
||||||
|
|
||||||
return rtp_common_write(rtp_session, data, datalen, rtp_session->payload);
|
return rtp_common_write(rtp_session, data, datalen, rtp_session->payload);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(int) switch_rtp_write_payload(switch_rtp *rtp_session, void *data, int datalen, uint8_t payload, uint32_t ts, uint16_t mseq)
|
SWITCH_DECLARE(int) switch_rtp_write_payload(switch_rtp *rtp_session, void *data, uint16_t datalen, uint8_t payload, uint32_t ts, uint16_t mseq)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO) || !rtp_session->remote_addr) {
|
if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO) || !rtp_session->remote_addr) {
|
||||||
|
Loading…
Reference in New Issue
Block a user