<!-- Allow multiple registrations to the same account in the central registration table -->
<!-- <param name="multiple-registrations" value="true"/> -->
-
+
+ <!-- <param name="max-audio-channels" value="2"/> -->
+
</settings>
</configuration>
<!-- Allow multiple registrations to the same account in the central registration table -->
<!-- <param name="multiple-registrations" value="true"/> -->
+ <!-- <param name="max-audio-channels" value="2"/> -->
+
</settings>
</configuration>
int events_use_dispatch;
uint32_t port_alloc_flags;
char *event_channel_key_separator;
+ uint32_t max_audio_channels;
};
extern struct switch_runtime runtime;
SWITCH_DECLARE(switch_bool_t) switch_core_session_in_thread(switch_core_session_t *session);
SWITCH_DECLARE(uint32_t) switch_default_ptime(const char *name, uint32_t number);
SWITCH_DECLARE(uint32_t) switch_default_rate(const char *name, uint32_t number);
+SWITCH_DECLARE(uint32_t) switch_core_max_audio_channels(uint32_t limit);
/*!
\brief Add user registration
} else {
switch_clear_flag((&runtime), SCF_EVENT_CHANNEL_LOG_UNDELIVERABLE_JSON);
}
+ } else if (!strcasecmp(var, "max-audio-channels") && !zstr(val)) {
+ switch_core_max_audio_channels(atoi(val));
}
}
}
return runtime.sessions_peak_fivemin;
}
+SWITCH_DECLARE(uint32_t) switch_core_max_audio_channels(uint32_t limit)
+{
+ if (limit) {
+ runtime.max_audio_channels = limit;
+ }
+
+ return runtime.max_audio_channels;
+}
+
SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, void *val)
{
int *intval = (int *) val;
char *fp = NULL;
int to = 0;
int force_channels = 0;
+ uint32_t core_channel_limit;
if (switch_test_flag(fh, SWITCH_FILE_OPEN)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Handle already open\n");
goto fail;
}
+ if (fh->channels > 2) {
+ /* just show a warning for more than 2 channels, no matter if we allow them or not */
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "File [%s] has more than 2 channels: [%u]\n", file_path, fh->channels);
+ }
+
+ core_channel_limit = switch_core_max_audio_channels(0);
+ if (core_channel_limit && fh->channels > core_channel_limit) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "File [%s] has more channels (%u) than limit (%u). Closing.\n", file_path, fh->channels, core_channel_limit);
+ fh->file_interface->file_close(fh);
+ UNPROTECT_INTERFACE(fh->file_interface);
+ switch_goto_status(SWITCH_STATUS_FALSE, fail);
+ }
+
if (!force_channels && !fh->real_channels) {
fh->real_channels = fh->channels;
}
FST_TEST_END()
+ FST_TEST_BEGIN(test_switch_core_file_open_max_audio_channels)
+ {
+ switch_file_handle_t fh = { 0 };
+ switch_status_t status = SWITCH_STATUS_FALSE;
+ static char filename[] = "/tmp/fs_unit_test.wav";
+ static char hdr[] = /*simplest wav file, hardcoded 8 channels*/
+ "\x52\x49\x46\x46"
+ "\x24\x00\x00\x00"
+ "\x57\x41\x56\x45"
+ "\x66\x6d\x74\x20"
+ "\x10\x00\x00\x00"
+ "\x01\x00\x08\x00"
+ "\x44\xac\x00\x00"
+ "\x88\x58\x01\x00"
+ "\x02\x00\x10\x00"
+ "\x64\x61\x74\x61"
+ "\x00\x00";
+ FILE *f = NULL;
+
+ f = fopen(filename, "w");
+ fst_check(f != NULL);
+ fwrite(hdr, 1, sizeof(hdr) ,f);
+ fclose(f);
+
+ switch_core_max_audio_channels(6);
+ status = switch_core_file_open(&fh, filename, 1, 8000, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL);
+ fst_check(status == SWITCH_STATUS_FALSE);
+
+ switch_core_max_audio_channels(8);
+ status = switch_core_file_open(&fh, filename, 1, 8000, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL);
+ fst_check(status == SWITCH_STATUS_SUCCESS);
+
+ status = switch_core_file_close(&fh);
+ fst_check(status == SWITCH_STATUS_SUCCESS);
+
+ unlink(filename);
+ }
+ FST_TEST_END()
+
}
FST_SUITE_END()
}