67 const char *file_path,
72 char stream_name[128] =
"";
74 const char *spool_path = NULL;
78 int force_channels = 0;
79 uint32_t core_channel_limit;
101 if (
zstr(file_path)) {
128 if (*file_path ==
'{') {
150 if ((to = atoi(timeout)) < 1) {
168 if (tmp >= 0 && tmp < 3) {
169 force_channels = tmp;
188 if (strrchr(val,
'k')) {
190 }
else if (strrchr(val,
'm')) {
224 float ftmp = atof(val);
233 if (strrchr(val,
'k')) {
235 }
else if (strrchr(val,
'm')) {
239 if (tmp > 0 && tmp < 104857600 ) {
247 if (!strcasecmp(val,
"slow")) {
249 }
else if (!strcasecmp(val,
"medium")) {
251 }
else if (!strcasecmp(val,
"fast")) {
259 if (!strcasecmp(val,
"baseline")) {
261 }
else if (!strcasecmp(val,
"main")) {
263 }
else if (!strcasecmp(val,
"high")) {
278 char *youtube_root = NULL;
281 char *resolve_url, *encoded, *url_buf;
284 const char *video = NULL, *
format =
"best";
286 url_buflen = strlen(file_path) * 4;
291 format =
"bestaudio";
301 if (stream.
data && !strncasecmp(
"https://", (
char *)stream.
data, 8)) {
302 char *url = (
char *) stream.
data;
324 if ((flags & SWITCH_FILE_FLAG_WRITE)) {
335 if ((ext = strrchr(file_path,
'.')) == 0) {
375 if (force_channels == channels) {
379 if (force_channels && force_channels > 0 && force_channels < 3) {
410 if (core_channel_limit && fh->
channels > core_channel_limit) {
445 if ((flags & SWITCH_FILE_FLAG_READ)) {
548 *len = asis ? rlen : rlen / 2 / fh->
channels;
654 memcpy(fh->
muxbuf, data, *len * 2);
712 if (rlen >= datalen_adj) {
809 unsigned int cur = 0;
986 uint8_t destroy_pool = 0;
1005 if (!destroy_pool) {
1016 #define DUP_CHECK(dup) if (oldfh->dup && !(fh->dup = switch_core_strdup(pool, oldfh->dup))) {switch_goto_status(SWITCH_STATUS_MEMERR, err);} 1030 if (pre_buffer_data_size) {
1095 if (system(command) == -1) {
switch_status_t switch_core_file_set_string(switch_file_handle_t *fh, switch_audio_col_t col, const char *string)
unsigned char * pre_buffer_data
#define switch_core_new_memory_pool(p)
Create a new sub memory pool from the core's master pool.
switch_status_t switch_directory_exists(const char *dirname, switch_memory_pool_t *pool)
static switch_bool_t switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
#define SWITCH_CHANNEL_LOG
switch_size_t switch_buffer_read(_In_ switch_buffer_t *buffer, _In_ void *data, _In_ switch_size_t datalen)
Read data from a switch_buffer_t up to the ammount of datalen if it is available. Remove read data fr...
switch_status_t(* file_write)(switch_file_handle_t *, void *data, switch_size_t *len)
switch_status_t(* file_write_video)(switch_file_handle_t *, switch_frame_t *frame)
switch_status_t(* file_truncate)(switch_file_handle_t *, int64_t offset)
switch_status_t switch_buffer_create_dynamic(_Out_ switch_buffer_t **buffer, _In_ switch_size_t blocksize, _In_ switch_size_t start_len, _In_ switch_size_t max_len)
Allocate a new dynamic switch_buffer.
switch_file_interface_t * file_interface
#define SWITCH_FOPEN_READ
char * switch_core_get_variable_pdup(_In_z_ const char *varname, switch_memory_pool_t *pool)
switch_status_t switch_event_create_brackets(char *data, char a, char b, char c, switch_event_t **event, char **new_data, switch_bool_t dup)
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
#define SWITCH_URL_SEPARATOR
switch_status_t switch_api_execute(const char *cmd, const char *arg, switch_core_session_t *session, switch_stream_handle_t *stream)
Execute a registered API command.
#define switch_core_destroy_memory_pool(p)
Returns a subpool back to the main pool.
switch_memory_pool_t * pool
switch_status_t(* file_read)(switch_file_handle_t *, void *data, switch_size_t *len)
#define SWITCH_AUDIO_SPOOL_PATH_VARIABLE
uint8_t try_hardware_encoder
#define SWITCH_FPROT_OS_DEFAULT
#define SWITCH_RESAMPLE_QUALITY
char const int const cJSON_bool format
char * switch_url_encode(const char *url, char *buf, size_t len)
switch_status_t(* file_read_video)(switch_file_handle_t *, switch_frame_t *frame, switch_video_read_flag_t flags)
void switch_resample_destroy(switch_audio_resampler_t **resampler)
Destroy an existing resampler handle.
switch_video_profile_t vprofile
switch_size_t switch_buffer_write(_In_ switch_buffer_t *buffer, _In_bytecount_(datalen) const void *data, _In_ switch_size_t datalen)
Write data into a switch_buffer_t up to the length of datalen.
switch_audio_resampler_t * resampler
switch_memory_pool_t * memory_pool
switch_status_t(* file_command)(switch_file_handle_t *fh, switch_file_command_t command)
switch_status_t(* file_get_string)(switch_file_handle_t *fh, switch_audio_col_t col, const char **string)
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
switch_status_t switch_core_file_seek(switch_file_handle_t *fh, unsigned int *cur_pos, int64_t samples, int whence)
#define UNPROTECT_INTERFACE(_it)
#define switch_clear_flag(obj, flag)
Clear a flag on an arbitrary object while locked.
switch_status_t(* file_seek)(switch_file_handle_t *, unsigned int *cur_pos, int64_t samples, int whence)
#define SWITCH_MUTEX_NESTED
#define SWITCH_PATH_SEPARATOR
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
#define switch_core_alloc(_pool, _mem)
Allocate memory directly from a memory pool.
switch_file_interface_t * switch_loadable_module_get_file_interface(const char *name, const char *modname)
Retrieve the file format interface by it's registered name.
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
switch_buffer_t * pre_buffer
switch_status_t switch_mutex_init(switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool)
void switch_buffer_zero(_In_ switch_buffer_t *buffer)
Remove all data from the buffer.
uint32_t switch_core_max_audio_channels(uint32_t limit)
An abstraction of a data frame.
#define switch_set_flag_locked(obj, flag)
Set a flag on an arbitrary object while locked.
switch_status_t(* file_set_string)(switch_file_handle_t *fh, switch_audio_col_t col, const char *string)
void switch_cond_next(void)
#define SWITCH_STANDARD_STREAM(s)
char * switch_copy_string(_Out_z_cap_(dst_size) char *dst, _In_z_ const char *src, _In_ switch_size_t dst_size)
switch_status_t(* file_close)(switch_file_handle_t *)
switch_video_encode_speed_t vencspd
void switch_mux_channels(int16_t *data, switch_size_t samples, uint32_t orig_channels, uint32_t channels)
switch_status_t switch_file_exists(const char *filename, switch_memory_pool_t *pool)
void switch_uuid_format(char *buffer, const switch_uuid_t *uuid)
switch_status_t switch_core_file_close(switch_file_handle_t *fh)
#define switch_clear_flag_locked(obj, flag)
Clear a flag on an arbitrary object.
switch_status_t
Common return values.
switch_status_t(* file_pre_close)(switch_file_handle_t *fh)
#define switch_goto_status(_status, _label)
void switch_uuid_get(switch_uuid_t *uuid)
switch_status_t switch_core_file_get_string(switch_file_handle_t *fh, switch_audio_col_t col, const char **string)
switch_status_t switch_core_perform_file_open(const char *file, const char *func, int line, switch_file_handle_t *fh, const char *file_path, uint32_t channels, uint32_t rate, unsigned int flags, switch_memory_pool_t *pool)
#define switch_event_get_header(_e, _h)
struct fspr_file_t switch_file_t
switch_status_t switch_core_file_write_video(switch_file_handle_t *fh, switch_frame_t *frame)
switch_size_t samples_out
switch_status_t switch_core_file_read(switch_file_handle_t *fh, void *data, switch_size_t *len)
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
const char * switch_stristr(const char *instr, const char *str)
switch_status_t switch_core_file_pre_close(switch_file_handle_t *fh)
static int switch_false(const char *expr)
Evaluate the falsefullness of a string expression.
switch_status_t switch_core_file_write(switch_file_handle_t *fh, void *data, switch_size_t *len)
while(unpack->bits_cur<=SWITCH_BITS_PER_BYTE)
struct fspr_pool_t switch_memory_pool_t
switch_status_t(* file_open)(switch_file_handle_t *, const char *file_path)
switch_status_t switch_file_open(switch_file_t **newf, const char *fname, int32_t flag, switch_fileperms_t perm, switch_memory_pool_t *pool)
void switch_event_destroy(switch_event_t **event)
Destroy an event.
switch_status_t switch_file_close(switch_file_t *thefile)
char * switch_core_sprintf(_In_ switch_memory_pool_t *pool, _In_z_ _Printf_format_string_ const char *fmt,...)
printf-style style printing routine. The data is output to a string allocated from the pool ...
static switch_status_t get_file_size(switch_file_handle_t *fh, const char **string)
switch_size_t pre_buffer_datalen
switch_size_t switch_buffer_inuse(_In_ switch_buffer_t *buffer)
Get the in use amount of a switch_buffer_t.
void switch_buffer_destroy(switch_buffer_t **buffer)
Destroy the buffer.
SWITCH_BEGIN_EXTERN_C char * switch_mprintf(const char *zFormat,...)
#define switch_resample_create(_n, _fr, _tr, _ts, _q, _c)
#define SWITCH_UUID_FORMATTED_LENGTH
uint32_t switch_resample_process(switch_audio_resampler_t *resampler, int16_t *src, uint32_t srclen)
Resample one float buffer into another using specifications of a given handle.
switch_size_t switch_file_get_size(switch_file_t *thefile)
switch_mutex_t * flag_mutex