forked from Mirrors/freeswitch
FS-11896: [core] stop media bugs from being possible to add to channels with no media ready, stop transfer recordings upstream to not try to transfer recordings to channels without media ready
This commit is contained in:
parent
d61a20ce6a
commit
1dd4191601
|
@ -58,15 +58,21 @@ ESL_DECLARE(esl_status_t) esl_buffer_create(esl_buffer_t **buffer, esl_size_t bl
|
|||
if (new_buffer) {
|
||||
memset(new_buffer, 0, sizeof(*new_buffer));
|
||||
|
||||
if (start_len) {
|
||||
new_buffer->data = malloc(start_len);
|
||||
if (!new_buffer->data) {
|
||||
free(new_buffer);
|
||||
return ESL_FAIL;
|
||||
}
|
||||
memset(new_buffer->data, 0, start_len);
|
||||
if (!start_len) {
|
||||
start_len = 250;
|
||||
}
|
||||
|
||||
if (!block_size) {
|
||||
block_size = start_len;
|
||||
}
|
||||
|
||||
new_buffer->data = malloc(start_len);
|
||||
if (!new_buffer->data) {
|
||||
free(new_buffer);
|
||||
return ESL_FAIL;
|
||||
}
|
||||
memset(new_buffer->data, 0, start_len);
|
||||
|
||||
new_buffer->max_len = max_len;
|
||||
new_buffer->datalen = start_len;
|
||||
new_buffer->id = buffer_id++;
|
||||
|
|
|
@ -57,15 +57,21 @@ FT_DECLARE(ftdm_status_t) ftdm_buffer_create(ftdm_buffer_t **buffer, ftdm_size_t
|
|||
if (new_buffer) {
|
||||
memset(new_buffer, 0, sizeof(*new_buffer));
|
||||
|
||||
if (start_len) {
|
||||
new_buffer->data = ftdm_malloc(start_len);
|
||||
if (!new_buffer->data) {
|
||||
ftdm_safe_free(new_buffer);
|
||||
return FTDM_MEMERR;
|
||||
}
|
||||
memset(new_buffer->data, 0, start_len);
|
||||
if (!start_len) {
|
||||
start_len = 250;
|
||||
}
|
||||
|
||||
if (!block_size) {
|
||||
block_size = start_len;
|
||||
}
|
||||
|
||||
new_buffer->data = ftdm_malloc(start_len);
|
||||
if (!new_buffer->data) {
|
||||
ftdm_safe_free(new_buffer);
|
||||
return FTDM_MEMERR;
|
||||
}
|
||||
memset(new_buffer->data, 0, start_len);
|
||||
|
||||
new_buffer->max_len = max_len;
|
||||
new_buffer->datalen = start_len;
|
||||
new_buffer->id = buffer_id++;
|
||||
|
|
|
@ -118,15 +118,22 @@ SWITCH_DECLARE(switch_status_t) switch_buffer_create_dynamic(switch_buffer_t **b
|
|||
if ((new_buffer = malloc(sizeof(*new_buffer)))) {
|
||||
memset(new_buffer, 0, sizeof(*new_buffer));
|
||||
|
||||
if (start_len) {
|
||||
if (!(new_buffer->data = malloc(start_len))) {
|
||||
free(new_buffer);
|
||||
*buffer = NULL;
|
||||
return SWITCH_STATUS_MEMERR;
|
||||
}
|
||||
memset(new_buffer->data, 0, start_len);
|
||||
if (!start_len) {
|
||||
start_len = 250;
|
||||
}
|
||||
|
||||
if (!block_size) {
|
||||
block_size = start_len;
|
||||
}
|
||||
|
||||
if (!(new_buffer->data = malloc(start_len))) {
|
||||
free(new_buffer);
|
||||
*buffer = NULL;
|
||||
return SWITCH_STATUS_MEMERR;
|
||||
}
|
||||
|
||||
memset(new_buffer->data, 0, start_len);
|
||||
|
||||
new_buffer->max_len = max_len;
|
||||
new_buffer->datalen = start_len;
|
||||
new_buffer->id = buffer_id++;
|
||||
|
|
|
@ -828,7 +828,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t
|
|||
|
||||
|
||||
if (!switch_channel_media_ready(session->channel)) {
|
||||
if (switch_channel_pre_answer(session->channel) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_channel_direction(session->channel == SWITCH_CALL_DIRECTION_OUTBOUND) ||
|
||||
switch_channel_pre_answer(session->channel) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot establish media. Media bug add failed.\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -890,8 +892,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t
|
|||
}
|
||||
|
||||
bug->stop_time = stop_time;
|
||||
bytes = bug->read_impl.decoded_bytes_per_packet;
|
||||
|
||||
if (!(bytes = bug->read_impl.decoded_bytes_per_packet)) {
|
||||
bytes = 320;
|
||||
}
|
||||
|
||||
if (!bug->flags) {
|
||||
bug->flags = (SMBF_READ_STREAM | SMBF_WRITE_STREAM);
|
||||
}
|
||||
|
@ -1031,6 +1036,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_transfer_callback(switch_c
|
|||
switch_media_bug_t *new_bug = NULL, *cur = NULL, *bp = NULL, *last = NULL;
|
||||
int total = 0;
|
||||
|
||||
if (!switch_channel_media_ready(new_session->channel)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(orig_session), SWITCH_LOG_WARNING, "Cannot transfer media bugs to a channel with no media.\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
switch_thread_rwlock_wrlock(orig_session->bug_rwlock);
|
||||
bp = orig_session->bugs;
|
||||
while (bp) {
|
||||
|
|
Loading…
Reference in New Issue