int continue_on_timeout;
int ringback_ok;
int sending_ringback;
+ int bridge_early_media;
} originate_global_t;
if (switch_channel_test_flag(originate_status[i].peer_channel, CF_EARLY_MEDIA)) {
+ if (oglobals->ignore_early_media == 3 && oglobals->bridge_early_media == -1) {
+ oglobals->bridge_early_media = i;
+ oglobals->ringback_ok = 1;
+ }
+
if (oglobals->sending_ringback == 1) {
send_ringback++;
pindex = (uint32_t) i;
switch_codec_t *read_codec = NULL;
char *tmp_data = NULL;
- if (!ringback_data) {
- switch_goto_status(SWITCH_STATUS_GENERR, end);
- }
-
if (!switch_channel_test_flag(caller_channel, CF_ANSWERED)
&& !switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
if ((status = switch_channel_pre_answer(caller_channel)) != SWITCH_STATUS_SUCCESS) {
}
if (oglobals->session && (read_codec = switch_core_session_get_read_codec(oglobals->session))) {
- if (switch_is_file_path(ringback_data)) {
+ if (ringback_data && switch_is_file_path(ringback_data)) {
if (!(strrchr(ringback_data, '.') || strstr(ringback_data, SWITCH_URL_SEPARATOR))) {
ringback->asis++;
}
}
oglobals->gen_ringback = 1;
+
+ if (zstr(ringback_data)) {
+ switch_goto_status(SWITCH_STATUS_SUCCESS, end);
+ }
if (switch_is_file_path(ringback_data)) {
char *ext;
}
oglobals.ringback_ok = 1;
+ oglobals.bridge_early_media = -1;
if (session) {
const char *to_var;
ok = 1;
} else if (!strcasecmp((char *) hi->name, "ignore_early_media")) {
ok = 1;
+ } else if (!strcasecmp((char *) hi->name, "bridge_early_media")) {
+ ok = 1;
} else if (!strcasecmp((char *) hi->name, "originate_continue_on_timeout")) {
ok = 1;
} else if (!strcasecmp((char *) hi->name, "ignore_ring_ready")) {
*oglobals.file = '\0';
}
+ if ((var_val = switch_event_get_header(var_event, "bridge_early_media"))) {
+ if (switch_true(var_val)) {
+ oglobals.early_ok = 0;
+ oglobals.ignore_early_media = 3;
+ }
+ }
+
if ((var_val = switch_event_get_header(var_event, "ignore_early_media"))) {
if (switch_true(var_val)) {
oglobals.early_ok = 0;
} else {
read_frame = NULL;
}
-
- if (oglobals.ringback_ok && (oglobals.ring_ready || oglobals.instant_ringback || oglobals.sending_ringback > 1)) {
+
+ if (oglobals.ringback_ok && (oglobals.ring_ready || oglobals.instant_ringback ||
+ oglobals.sending_ringback > 1 || oglobals.bridge_early_media > -1)) {
if (oglobals.ringback_ok == 1) {
switch_status_t rst = setup_ringback(&oglobals, ringback_data, &ringback, &write_frame, &write_codec);
continue;
}
- if (ringback.fh) {
+ if (oglobals.bridge_early_media > -1) {
+ switch_channel_t *b_channel = originate_status[oglobals.bridge_early_media].peer_channel;
+ switch_core_session_t *b_session = originate_status[oglobals.bridge_early_media].peer_session;
+ switch_status_t b_status = SWITCH_STATUS_FALSE;
+ switch_frame_t *b_frame;
+
+ if (b_channel && b_session) {
+ b_status = switch_core_session_read_frame(b_session, &b_frame, SWITCH_IO_FLAG_NONE, 0);
+ }
+
+ if (!SWITCH_READ_ACCEPTABLE(status)) {
+ oglobals.bridge_early_media = -1;
+ } else {
+ if (switch_core_session_write_frame(oglobals.session, b_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
+ oglobals.bridge_early_media = -1;
+ }
+ continue;
+ }
+
+ } else if (ringback.fh) {
switch_size_t mlen, olen;
unsigned int pos = 0;