Collaboration diagram for Media Bugs:
| #define switch_core_media_bug_remove_all | ( | _s | ) | switch_core_media_bug_remove_all_function(_s, NULL) |
Definition at line 258 of file switch_core.h.
Referenced by switch_core_session_hangup_state(), switch_core_session_perform_destroy(), and switch_core_session_thread().
| #define switch_core_session_get_name | ( | _s | ) | switch_channel_get_name(switch_core_session_get_channel(_s)) |
Definition at line 138 of file switch_core.h.
Referenced by check_channel_status(), jb_callback(), and switch_core_media_bug_transfer_recordings().
| uint32_t switch_core_cpu_count | ( | void | ) |
Definition at line 727 of file switch_core.c.
References switch_runtime::cpu_count, and runtime.
Referenced by switch_event_init().
| switch_status_t switch_core_media_bug_add | ( | _In_ switch_core_session_t * | session, | |
| _In_ const char * | function, | |||
| _In_ const char * | target, | |||
| _In_ switch_media_bug_callback_t | callback, | |||
| _In_opt_ void * | user_data, | |||
| _In_ time_t | stop_time, | |||
| _In_ switch_media_bug_flag_t | flags, | |||
| _Out_ switch_media_bug_t ** | new_bug | |||
| ) |
Add a media bug to the session.
| session | the session to add the bug to | |
| callback | a callback for events | |
| user_data | arbitrary user data | |
| stop_time | absolute time at which the bug is automatically removed (or 0) | |
| flags | flags to choose the stream | |
| new_bug | pointer to assign new bug to |
Referenced by switch_ivr_detect_speech(), switch_ivr_displace_session(), switch_ivr_eavesdrop_session(), switch_ivr_inband_dtmf_generate_session(), switch_ivr_inband_dtmf_session(), switch_ivr_record_session(), and switch_ivr_session_audio().
| uint32_t switch_core_media_bug_clear_flag | ( | _In_ switch_media_bug_t * | bug, | |
| _In_ uint32_t | flag | |||
| ) |
| switch_status_t switch_core_media_bug_close | ( | _Inout_ switch_media_bug_t ** | bug | ) |
Close and destroy a media bug.
| bug | bug to remove |
Referenced by switch_core_media_bug_prune(), switch_core_media_bug_remove(), and switch_core_media_bug_remove_callback().
| uint32_t switch_core_media_bug_count | ( | switch_core_session_t * | orig_session, | |
| const char * | function | |||
| ) |
Definition at line 603 of file switch_core_media_bug.c.
References switch_media_bug::function, switch_media_bug::next, SMBF_LOCK, SMBF_PRUNE, switch_test_flag, switch_thread_rwlock_rdlock(), and switch_thread_rwlock_unlock().
00604 { 00605 switch_media_bug_t *bp; 00606 uint32_t x = 0; 00607 00608 if (orig_session->bugs) { 00609 switch_thread_rwlock_rdlock(orig_session->bug_rwlock); 00610 for (bp = orig_session->bugs; bp; bp = bp->next) { 00611 if (!switch_test_flag(bp, SMBF_PRUNE) && !switch_test_flag(bp, SMBF_LOCK) && !strcmp(bp->function, function)) { 00612 x++; 00613 } 00614 } 00615 switch_thread_rwlock_unlock(orig_session->bug_rwlock); 00616 } 00617 00618 return x; 00619 }
| switch_status_t switch_core_media_bug_enumerate | ( | switch_core_session_t * | session, | |
| switch_stream_handle_t * | stream | |||
| ) |
Definition at line 643 of file switch_core_media_bug.c.
References switch_media_bug::function, switch_media_bug::next, SWITCH_STATUS_SUCCESS, switch_thread_rwlock_rdlock(), switch_thread_rwlock_unlock(), switch_thread_self(), switch_media_bug::target, and switch_media_bug::thread_id.
00644 { 00645 switch_media_bug_t *bp; 00646 00647 stream->write_function(stream, "<media-bugs>\n"); 00648 00649 if (session->bugs) { 00650 switch_thread_rwlock_rdlock(session->bug_rwlock); 00651 for (bp = session->bugs; bp; bp = bp->next) { 00652 int thread_locked = (bp->thread_id && bp->thread_id == switch_thread_self()); 00653 stream->write_function(stream, 00654 " <media-bug>\n" 00655 " <function>%s</function>\n" 00656 " <target>%s</target>\n" 00657 " <thread-locked>%d</thread-locked>\n" 00658 " </media-bug>\n", 00659 bp->function, bp->target, thread_locked); 00660 00661 } 00662 switch_thread_rwlock_unlock(session->bug_rwlock); 00663 } 00664 00665 stream->write_function(stream, "</media-bugs>\n"); 00666 00667 return SWITCH_STATUS_SUCCESS; 00668 }
| switch_status_t switch_core_media_bug_exec_all | ( | switch_core_session_t * | orig_session, | |
| const char * | function, | |||
| switch_media_bug_exec_cb_t | cb, | |||
| void * | user_data | |||
| ) |
Definition at line 621 of file switch_core_media_bug.c.
References switch_media_bug::function, switch_media_bug::next, SMBF_LOCK, SMBF_PRUNE, switch_assert, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_test_flag, switch_thread_rwlock_unlock(), and switch_thread_rwlock_wrlock().
Referenced by switch_ivr_eavesdrop_exec_all(), and switch_ivr_eavesdrop_update_display().
00623 { 00624 switch_media_bug_t *bp; 00625 int x = 0; 00626 00627 switch_assert(cb); 00628 00629 if (orig_session->bugs) { 00630 switch_thread_rwlock_wrlock(orig_session->bug_rwlock); 00631 for (bp = orig_session->bugs; bp; bp = bp->next) { 00632 if (!switch_test_flag(bp, SMBF_PRUNE) && !switch_test_flag(bp, SMBF_LOCK) && !strcmp(bp->function, function)) { 00633 cb(bp, user_data); 00634 x++; 00635 } 00636 } 00637 switch_thread_rwlock_unlock(orig_session->bug_rwlock); 00638 } 00639 00640 return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; 00641 }
| void switch_core_media_bug_flush | ( | _In_ switch_media_bug_t * | bug | ) |
Flush the read and write buffers for the bug.
| bug | the bug to flush the read and write buffers on |
Referenced by switch_core_media_bug_flush_all(), and switch_core_media_bug_read().
| switch_status_t switch_core_media_bug_flush_all | ( | _In_ switch_core_session_t * | session | ) |
Flush the read/write buffers for all media bugs on the session.
| session | the session to flush the read/write buffers for all media bugs on the session |
Referenced by switch_core_session_perform_receive_message(), and switch_core_session_write_frame().
| switch_frame_t* switch_core_media_bug_get_read_replace_frame | ( | _In_ switch_media_bug_t * | bug | ) |
Obtain a replace frame from a media bug.
| bug | the bug to get the data from |
Referenced by eavesdrop_callback(), inband_dtmf_callback(), inband_dtmf_generate_callback(), preprocess_callback(), read_displace_callback(), session_audio_callback(), tone_detect_callback(), and write_displace_callback().
| switch_core_session_t* switch_core_media_bug_get_session | ( | _In_ switch_media_bug_t * | bug | ) |
Obtain the session from a media bug.
| bug | the bug to get the data from |
Referenced by inband_dtmf_callback(), inband_dtmf_generate_callback(), preprocess_callback(), read_displace_callback(), record_callback(), speech_callback(), switch_core_media_bug_close(), switch_core_media_bug_read(), and write_displace_callback().
| void* switch_core_media_bug_get_user_data | ( | _In_ switch_media_bug_t * | bug | ) |
Obtain private data from a media bug.
| bug | the bug to get the data from |
Referenced by display_exec_cb(), exec_cb(), generate_on_dtmf(), switch_ivr_eavesdrop_pop_eavesdropper(), and switch_ivr_session_audio().
| switch_frame_t* switch_core_media_bug_get_write_replace_frame | ( | _In_ switch_media_bug_t * | bug | ) |
Obtain a replace frame from a media bug.
| bug | the bug to get the data from |
Referenced by eavesdrop_callback(), inband_dtmf_generate_callback(), preprocess_callback(), read_displace_callback(), session_audio_callback(), tone_detect_callback(), and write_displace_callback().
| void switch_core_media_bug_inuse | ( | switch_media_bug_t * | bug, | |
| switch_size_t * | readp, | |||
| switch_size_t * | writep | |||
| ) |
Definition at line 142 of file switch_core_media_bug.c.
References SMBF_READ_STREAM, SMBF_WRITE_STREAM, switch_buffer_inuse(), switch_mutex_lock(), switch_mutex_unlock(), and switch_test_flag.
00143 { 00144 if (switch_test_flag(bug, SMBF_READ_STREAM)) { 00145 switch_mutex_lock(bug->read_mutex); 00146 *readp = bug->raw_read_buffer ? switch_buffer_inuse(bug->raw_read_buffer) : 0; 00147 switch_mutex_unlock(bug->read_mutex); 00148 } else { 00149 *readp = 0; 00150 } 00151 00152 if (switch_test_flag(bug, SMBF_WRITE_STREAM)) { 00153 switch_mutex_lock(bug->write_mutex); 00154 *writep = bug->raw_write_buffer ? switch_buffer_inuse(bug->raw_write_buffer) : 0; 00155 switch_mutex_unlock(bug->write_mutex); 00156 } else { 00157 *writep = 0; 00158 } 00159 }
| void switch_core_media_bug_pause | ( | switch_core_session_t * | session | ) |
Pause a media bug on the session.
| session | the session to pause the bug on sets CF_PAUSE_BUGS flag |
Definition at line 58 of file switch_core_media_bug.c.
References CF_PAUSE_BUGS, and switch_channel_set_flag.
00059 { 00060 switch_channel_set_flag(session->channel, CF_PAUSE_BUGS); 00061 }
| switch_status_t switch_core_media_bug_pop | ( | switch_core_session_t * | orig_session, | |
| const char * | function, | |||
| switch_media_bug_t ** | pop | |||
| ) |
Definition at line 578 of file switch_core_media_bug.c.
References switch_media_bug::function, switch_media_bug::next, SMBF_LOCK, switch_set_flag, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_thread_rwlock_unlock(), and switch_thread_rwlock_wrlock().
Referenced by switch_ivr_eavesdrop_pop_eavesdropper().
00579 { 00580 switch_media_bug_t *bp; 00581 00582 if (orig_session->bugs) { 00583 switch_thread_rwlock_wrlock(orig_session->bug_rwlock); 00584 for (bp = orig_session->bugs; bp; bp = bp->next) { 00585 if (!strcmp(bp->function, function)) { 00586 switch_set_flag(bp, SMBF_LOCK); 00587 break; 00588 } 00589 } 00590 switch_thread_rwlock_unlock(orig_session->bug_rwlock); 00591 00592 if (bp) { 00593 *pop = bp; 00594 return SWITCH_STATUS_SUCCESS; 00595 } else { 00596 *pop = NULL; 00597 } 00598 } 00599 00600 return SWITCH_STATUS_FALSE; 00601 }
| uint32_t switch_core_media_bug_prune | ( | switch_core_session_t * | session | ) |
Definition at line 768 of file switch_core_media_bug.c.
References switch_media_bug::next, SMBF_LOCK, SMBF_PRUNE, switch_clear_flag, switch_core_codec_destroy(), switch_core_codec_ready(), switch_core_media_bug_close(), switch_core_media_bug_test_flag(), switch_thread_rwlock_unlock(), and switch_thread_rwlock_wrlock().
Referenced by switch_core_session_write_frame().
00769 { 00770 switch_media_bug_t *bp = NULL, *last = NULL; 00771 int ttl = 0; 00772 00773 00774 top: 00775 00776 switch_thread_rwlock_wrlock(session->bug_rwlock); 00777 if (session->bugs) { 00778 for (bp = session->bugs; bp; bp = bp->next) { 00779 if (switch_core_media_bug_test_flag(bp, SMBF_PRUNE)) { 00780 if (last) { 00781 last->next = bp->next; 00782 } else { 00783 session->bugs = bp->next; 00784 } 00785 break; 00786 } 00787 00788 last = bp; 00789 } 00790 } 00791 00792 if (!session->bugs && switch_core_codec_ready(&session->bug_codec)) { 00793 switch_core_codec_destroy(&session->bug_codec); 00794 } 00795 00796 switch_thread_rwlock_unlock(session->bug_rwlock); 00797 00798 if (bp) { 00799 switch_clear_flag(bp, SMBF_LOCK); 00800 bp->thread_id = 0; 00801 switch_core_media_bug_close(&bp); 00802 ttl++; 00803 goto top; 00804 } 00805 00806 return ttl; 00807 }
| switch_status_t switch_core_media_bug_read | ( | _In_ switch_media_bug_t * | bug, | |
| _In_ switch_frame_t * | frame, | |||
| switch_bool_t | fill | |||
| ) |
Read a frame from the bug.
| bug | the bug to read from | |
| frame | the frame to write the data to |
Referenced by eavesdrop_callback(), record_callback(), and speech_callback().
| switch_status_t switch_core_media_bug_remove | ( | _In_ switch_core_session_t * | session, | |
| _Inout_ switch_media_bug_t ** | bug | |||
| ) |
Remove a media bug from the session.
| session | the session to remove the bug from | |
| bug | bug to remove |
Referenced by switch_ivr_eavesdrop_session(), switch_ivr_stop_detect_speech(), switch_ivr_stop_displace_session(), switch_ivr_stop_inband_dtmf_generate_session(), switch_ivr_stop_inband_dtmf_session(), switch_ivr_stop_record_session(), switch_ivr_stop_session_audio(), and switch_ivr_stop_tone_detect_session().
| switch_status_t switch_core_media_bug_remove_all_function | ( | _In_ switch_core_session_t * | session, | |
| const char * | function | |||
| ) |
Remove all media bugs from the session.
| session | the session to remove the bugs from |
| switch_status_t switch_core_media_bug_remove_callback | ( | switch_core_session_t * | session, | |
| switch_media_bug_callback_t | callback | |||
| ) |
Remove media bug callback.
| bug | bug to remove | |
| callback | callback to remove |
Definition at line 810 of file switch_core_media_bug.c.
References switch_media_bug::callback, switch_media_bug::next, switch_media_bug::ready, switch_core_codec_destroy(), switch_core_codec_ready(), switch_core_media_bug_close(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_thread_rwlock_unlock(), switch_thread_rwlock_wrlock(), switch_thread_self(), and switch_media_bug::thread_id.
Referenced by switch_ivr_stop_record_session().
00811 { 00812 switch_media_bug_t *cur = NULL, *bp = NULL, *last = NULL; 00813 int total = 0; 00814 00815 switch_thread_rwlock_wrlock(session->bug_rwlock); 00816 if (session->bugs) { 00817 bp = session->bugs; 00818 while (bp) { 00819 cur = bp; 00820 bp = bp->next; 00821 00822 if ((!cur->thread_id || cur->thread_id == switch_thread_self()) && cur->ready && cur->callback == callback) { 00823 if (last) { 00824 last->next = cur->next; 00825 } else { 00826 session->bugs = cur->next; 00827 } 00828 if (switch_core_media_bug_close(&cur) == SWITCH_STATUS_SUCCESS) { 00829 total++; 00830 } 00831 } else { 00832 last = cur; 00833 } 00834 } 00835 } 00836 00837 if (!session->bugs && switch_core_codec_ready(&session->bug_codec)) { 00838 switch_core_codec_destroy(&session->bug_codec); 00839 } 00840 00841 switch_thread_rwlock_unlock(session->bug_rwlock); 00842 00843 00844 return total ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; 00845 }
| void switch_core_media_bug_resume | ( | switch_core_session_t * | session | ) |
Resume a media bug on the session.
| session | the session to resume the bug on, clears CF_PAUSE_BUGS flag |
Definition at line 63 of file switch_core_media_bug.c.
References CF_PAUSE_BUGS, and switch_channel_clear_flag().
00064 { 00065 switch_channel_clear_flag(session->channel, CF_PAUSE_BUGS); 00066 }
| uint32_t switch_core_media_bug_set_flag | ( | _In_ switch_media_bug_t * | bug, | |
| _In_ uint32_t | flag | |||
| ) |
Referenced by switch_ivr_eavesdrop_pop_eavesdropper(), and switch_ivr_session_audio().
| switch_status_t switch_core_media_bug_set_pre_buffer_framecount | ( | switch_media_bug_t * | bug, | |
| uint32_t | framecount | |||
| ) |
Definition at line 161 of file switch_core_media_bug.c.
References SWITCH_STATUS_SUCCESS.
Referenced by switch_ivr_record_session().
00162 { 00163 bug->record_pre_buffer_max = framecount; 00164 00165 return SWITCH_STATUS_SUCCESS; 00166 }
| void switch_core_media_bug_set_read_demux_frame | ( | _In_ switch_media_bug_t * | bug, | |
| _In_ switch_frame_t * | frame | |||
| ) |
Referenced by eavesdrop_callback().
| void switch_core_media_bug_set_read_replace_frame | ( | _In_ switch_media_bug_t * | bug, | |
| _In_ switch_frame_t * | frame | |||
| ) |
Set a return replace frame.
| bug | the bug to set the frame on | |
| frame | the frame to set |
Referenced by eavesdrop_callback(), inband_dtmf_callback(), inband_dtmf_generate_callback(), read_displace_callback(), session_audio_callback(), and write_displace_callback().
| void switch_core_media_bug_set_write_replace_frame | ( | _In_ switch_media_bug_t * | bug, | |
| _In_ switch_frame_t * | frame | |||
| ) |
Set a return replace frame.
| bug | the bug to set the frame on | |
| frame | the frame to set |
Referenced by eavesdrop_callback(), inband_dtmf_generate_callback(), read_displace_callback(), session_audio_callback(), and write_displace_callback().
| uint32_t switch_core_media_bug_test_flag | ( | _In_ switch_media_bug_t * | bug, | |
| _In_ uint32_t | flag | |||
| ) |
Test for the existance of a flag on an media bug.
| bug | the object to test | |
| flag | the or'd list of flags to test |
Referenced by switch_core_media_bug_prune(), switch_core_media_bug_remove(), and switch_core_session_write_frame().
| switch_status_t switch_core_media_bug_transfer_recordings | ( | switch_core_session_t * | orig_session, | |
| switch_core_session_t * | new_session | |||
| ) |
Definition at line 537 of file switch_core_media_bug.c.
References switch_media_bug::function, switch_media_bug::next, switch_media_bug::stop_time, switch_channel_get_variable, SWITCH_CHANNEL_SESSION_LOG, switch_channel_set_variable, switch_core_session_get_channel(), switch_core_session_get_name, switch_core_session_strdup, switch_epoch_time_now(), switch_ivr_record_session(), switch_ivr_stop_record_session(), SWITCH_LOG_CRIT, switch_log_printf(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_thread_rwlock_unlock(), switch_thread_rwlock_wrlock(), and switch_media_bug::target.
Referenced by switch_channel_mark_hold().
00538 { 00539 switch_media_bug_t *bp; 00540 char *list[100] = { 0 }; 00541 int stop_times[100] = { 0 }; 00542 int i = 0, x = 0; 00543 00544 if (orig_session->bugs) { 00545 switch_channel_t *new_channel = switch_core_session_get_channel(new_session); 00546 const char *save = switch_channel_get_variable(new_channel, "record_append"); 00547 00548 switch_thread_rwlock_wrlock(orig_session->bug_rwlock); 00549 00550 switch_channel_set_variable(new_channel, "record_append", "true"); 00551 00552 for (bp = orig_session->bugs; bp; bp = bp->next) { 00553 if (!strcmp(bp->function, "session_record")) { 00554 list[x] = switch_core_session_strdup(new_session, bp->target); 00555 if (bp->stop_time > 0) { 00556 stop_times[x] = (int)(bp->stop_time - switch_epoch_time_now(NULL)); 00557 } 00558 x++; 00559 } 00560 } 00561 00562 switch_thread_rwlock_unlock(orig_session->bug_rwlock); 00563 00564 for(i = 0; i < x; i++) { 00565 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(orig_session), SWITCH_LOG_CRIT, "Transfering %s from %s to %s\n", list[i], 00566 switch_core_session_get_name(orig_session), switch_core_session_get_name(new_session)); 00567 switch_ivr_stop_record_session(orig_session, list[i]); 00568 switch_ivr_record_session(new_session, list[i], stop_times[i], NULL); 00569 } 00570 00571 switch_channel_set_variable(new_channel, "record_append", save); 00572 00573 } 00574 00575 return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; 00576 }
| void switch_core_session_disable_heartbeat | ( | switch_core_session_t * | session | ) |
Definition at line 1383 of file switch_core_session.c.
References switch_assert, and switch_core_session_unsched_heartbeat().
01384 { 01385 switch_core_session_unsched_heartbeat(session); 01386 switch_assert(session != NULL); 01387 session->read_frame_count = 0; 01388 session->track_duration = 0; 01389 01390 }
| void switch_core_session_enable_heartbeat | ( | switch_core_session_t * | session, | |
| uint32_t | seconds | |||
| ) |
Definition at line 1357 of file switch_core_session.c.
References CF_PROXY_MODE, switch_assert, switch_channel_get_name(), SWITCH_CHANNEL_SESSION_LOG, switch_channel_test_flag(), switch_core_session_sched_heartbeat(), switch_core_session_unsched_heartbeat(), SWITCH_LOG_INFO, switch_log_printf(), and SWITCH_LOG_WARNING.
Referenced by switch_channel_perform_mark_answered().
01358 { 01359 switch_assert(session != NULL); 01360 01361 if (!seconds) { 01362 seconds = 60; 01363 } 01364 01365 session->track_duration = seconds; 01366 01367 if (switch_channel_test_flag(session->channel, CF_PROXY_MODE)) { 01368 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s using scheduler due to bypass_media mode\n", 01369 switch_channel_get_name(session->channel)); 01370 switch_core_session_sched_heartbeat(session, seconds); 01371 return; 01372 } 01373 01374 switch_core_session_unsched_heartbeat(session); 01375 01376 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "%s setting session heartbeat to %u second(s).\n", 01377 switch_channel_get_name(session->channel), seconds); 01378 01379 session->read_frame_count = 0; 01380 01381 }
| void switch_core_session_sched_heartbeat | ( | switch_core_session_t * | session, | |
| uint32_t | seconds | |||
| ) |
Definition at line 1349 of file switch_core_session.c.
References __SWITCH_FUNC__, SSHF_FREE_ARG, switch_core_session_get_uuid(), switch_core_session_unsched_heartbeat(), switch_epoch_time_now(), and switch_scheduler_add_task().
Referenced by switch_core_session_enable_heartbeat().
01350 { 01351 01352 switch_core_session_unsched_heartbeat(session); 01353 session->track_id = switch_scheduler_add_task(switch_epoch_time_now(NULL), sch_heartbeat_callback, (char *) __SWITCH_FUNC__, 01354 switch_core_session_get_uuid(session), 0, strdup(switch_core_session_get_uuid(session)), SSHF_FREE_ARG); 01355 }
| void switch_core_session_unsched_heartbeat | ( | switch_core_session_t * | session | ) |
Definition at line 1341 of file switch_core_session.c.
References switch_scheduler_del_task_id().
Referenced by switch_core_session_disable_heartbeat(), switch_core_session_enable_heartbeat(), and switch_core_session_sched_heartbeat().
01342 { 01343 if (session->track_id) { 01344 switch_scheduler_del_task_id(session->track_id); 01345 session->track_id = 0; 01346 } 01347 }
1.4.7