RTS API Documentation  1.10.11
Macros | Functions
Media Bugs
+ Collaboration diagram for Media Bugs:

Macros

#define switch_core_session_get_name(_s)   switch_channel_get_name(switch_core_session_get_channel(_s))
 
#define switch_core_media_bug_remove_all(_s)   switch_core_media_bug_remove_all_function(_s, NULL)
 

Functions

void switch_core_screen_size (int *x, int *y)
 
void switch_core_session_sched_heartbeat (switch_core_session_t *session, uint32_t seconds)
 
void switch_core_session_unsched_heartbeat (switch_core_session_t *session)
 
void switch_core_session_enable_heartbeat (switch_core_session_t *session, uint32_t seconds)
 
void switch_core_session_disable_heartbeat (switch_core_session_t *session)
 
switch_status_t switch_core_media_bug_pop (switch_core_session_t *orig_session, const char *function, switch_media_bug_t **pop)
 
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)
 
uint32_t switch_core_media_bug_patch_video (switch_core_session_t *orig_session, switch_frame_t *frame)
 
uint32_t switch_core_media_bug_count (switch_core_session_t *orig_session, const char *function)
 
void switch_media_bug_set_spy_fmt (switch_media_bug_t *bug, switch_vid_spy_fmt_t spy_fmt)
 
switch_status_t switch_core_media_bug_push_spy_frame (switch_media_bug_t *bug, switch_frame_t *frame, switch_rw_t rw)
 
switch_status_t switch_core_media_bug_patch_spy_frame (switch_media_bug_t *bug, switch_image_t *img, switch_rw_t rw)
 
switch_vid_spy_fmt_t switch_media_bug_parse_spy_fmt (const char *name)
 
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. More...
 
void switch_core_media_bug_pause (switch_core_session_t *session)
 Pause a media bug on the session. More...
 
void switch_core_media_bug_resume (switch_core_session_t *session)
 Resume a media bug on the session. More...
 
void switch_core_media_bug_inuse (switch_media_bug_t *bug, switch_size_t *readp, switch_size_t *writep)
 
void * switch_core_media_bug_get_user_data (_In_ switch_media_bug_t *bug)
 Obtain private data from a media bug. More...
 
switch_frame_tswitch_core_media_bug_get_write_replace_frame (_In_ switch_media_bug_t *bug)
 Obtain a replace frame from a media bug. More...
 
switch_frame_tswitch_core_media_bug_get_native_read_frame (switch_media_bug_t *bug)
 
switch_frame_tswitch_core_media_bug_get_native_write_frame (switch_media_bug_t *bug)
 
switch_frame_tswitch_core_media_bug_get_video_ping_frame (switch_media_bug_t *bug)
 
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. More...
 
switch_frame_tswitch_core_media_bug_get_read_replace_frame (_In_ switch_media_bug_t *bug)
 Obtain a replace frame from a media bug. More...
 
void switch_core_media_bug_set_read_demux_frame (_In_ switch_media_bug_t *bug, _In_ switch_frame_t *frame)
 
switch_core_session_tswitch_core_media_bug_get_session (_In_ switch_media_bug_t *bug)
 Obtain the session from a media bug. More...
 
void switch_core_media_bug_set_media_params (switch_media_bug_t *bug, switch_mm_t *mm)
 
void switch_core_media_bug_get_media_params (switch_media_bug_t *bug, switch_mm_t *mm)
 
const char * switch_core_media_bug_get_text (switch_media_bug_t *bug)
 
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. More...
 
uint32_t switch_core_media_bug_set_flag (_In_ switch_media_bug_t *bug, _In_ uint32_t flag)
 
uint32_t switch_core_media_bug_clear_flag (_In_ switch_media_bug_t *bug, _In_ uint32_t flag)
 
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. More...
 
uint32_t switch_core_cpu_count (void)
 
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. More...
 
uint32_t switch_core_media_bug_prune (switch_core_session_t *session)
 
switch_status_t switch_core_media_bug_remove_callback (switch_core_session_t *session, switch_media_bug_callback_t callback)
 Remove media bug callback. More...
 
switch_status_t switch_core_media_bug_close (_Inout_ switch_media_bug_t **bug, switch_bool_t destroy)
 Close and destroy a media bug. More...
 
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. More...
 
switch_status_t switch_core_media_bug_enumerate (switch_core_session_t *session, switch_stream_handle_t *stream)
 
switch_status_t switch_core_media_bug_transfer_callback (switch_core_session_t *orig_session, switch_core_session_t *new_session, switch_media_bug_callback_t callback, void *(*user_data_dup_func)(switch_core_session_t *, void *))
 
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. More...
 
void switch_core_media_bug_flush (_In_ switch_media_bug_t *bug)
 Flush the read and write buffers for the bug. More...
 
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. More...
 
switch_status_t switch_core_media_bug_set_pre_buffer_framecount (switch_media_bug_t *bug, uint32_t framecount)
 

Detailed Description

Macro Definition Documentation

◆ switch_core_media_bug_remove_all

#define switch_core_media_bug_remove_all (   _s)    switch_core_media_bug_remove_all_function(_s, NULL)

◆ switch_core_session_get_name

#define switch_core_session_get_name (   _s)    switch_channel_get_name(switch_core_session_get_channel(_s))

Function Documentation

◆ switch_core_cpu_count()

uint32_t switch_core_cpu_count ( void  )

Definition at line 1055 of file switch_core.c.

References switch_runtime::cpu_count.

Referenced by switch_core_media_init(), switch_event_init(), and switch_parse_cpu_string().

1056 {
1057  return runtime.cpu_count;
1058 }
struct switch_runtime runtime
Definition: switch_core.c:86

◆ switch_core_media_bug_add()

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.

Parameters
sessionthe session to add the bug to
functionuser defined module/function/reason identifying this bug
targetuser defined identification of the target of the bug
callbacka callback for events
user_dataarbitrary user data
stop_timeabsolute time at which the bug is automatically removed (or 0)
flagsflags to choose the stream
new_bugpointer to assign new bug to
Returns
SWITCH_STATUS_SUCCESS if the operation was a success

Referenced by switch_ivr_capture_text(), switch_ivr_detect_speech_init(), switch_ivr_displace_session(), switch_ivr_eavesdrop_session(), switch_ivr_inband_dtmf_generate_session(), switch_ivr_inband_dtmf_session(), switch_ivr_preprocess_session(), switch_ivr_record_session_event(), switch_ivr_session_audio(), switch_ivr_tone_detect_session(), and switch_ivr_video_write_overlay_session().

◆ switch_core_media_bug_clear_flag()

uint32_t switch_core_media_bug_clear_flag ( _In_ switch_media_bug_t bug,
_In_ uint32_t  flag 
)

◆ switch_core_media_bug_close()

switch_status_t switch_core_media_bug_close ( _Inout_ switch_media_bug_t **  bug,
switch_bool_t  destroy 
)

Close and destroy a media bug.

Parameters
bugbug to remove
Returns
SWITCH_STATUS_SUCCESS if the operation was a success

◆ switch_core_media_bug_count()

uint32_t switch_core_media_bug_count ( switch_core_session_t orig_session,
const char *  function 
)

Definition at line 1135 of file switch_core_media_bug.c.

References switch_core_session::bug_rwlock, switch_core_session::bugs, switch_media_bug::function, switch_media_bug::next, SMBF_LOCK, SMBF_PRUNE, switch_test_flag, switch_thread_rwlock_rdlock(), and switch_thread_rwlock_unlock().

1136 {
1137  switch_media_bug_t *bp;
1138  uint32_t x = 0;
1139 
1140  if (orig_session->bugs) {
1141  switch_thread_rwlock_rdlock(orig_session->bug_rwlock);
1142  for (bp = orig_session->bugs; bp; bp = bp->next) {
1143  if (!switch_test_flag(bp, SMBF_PRUNE) && !switch_test_flag(bp, SMBF_LOCK) && !strcmp(bp->function, function)) {
1144  x++;
1145  }
1146  }
1147  switch_thread_rwlock_unlock(orig_session->bug_rwlock);
1148  }
1149 
1150  return x;
1151 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:286
switch_thread_rwlock_t * bug_rwlock
switch_status_t switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:250
switch_media_bug_t * bugs
struct switch_media_bug * next
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:693

◆ switch_core_media_bug_enumerate()

switch_status_t switch_core_media_bug_enumerate ( switch_core_session_t session,
switch_stream_handle_t stream 
)

Definition at line 1210 of file switch_core_media_bug.c.

References switch_core_session::bug_rwlock, switch_core_session::bugs, 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, switch_media_bug::thread_id, and switch_stream_handle::write_function.

1211 {
1212  switch_media_bug_t *bp;
1213 
1214  stream->write_function(stream, "<media-bugs>\n");
1215 
1216  if (session->bugs) {
1218  for (bp = session->bugs; bp; bp = bp->next) {
1219  int thread_locked = (bp->thread_id && bp->thread_id == switch_thread_self());
1220  stream->write_function(stream,
1221  " <media-bug>\n"
1222  " <function>%s</function>\n"
1223  " <target>%s</target>\n"
1224  " <thread-locked>%d</thread-locked>\n"
1225  " </media-bug>\n",
1226  bp->function, bp->target, thread_locked);
1227 
1228  }
1230  }
1231 
1232  stream->write_function(stream, "</media-bugs>\n");
1233 
1234  return SWITCH_STATUS_SUCCESS;
1235 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:286
switch_thread_rwlock_t * bug_rwlock
switch_thread_id_t thread_id
switch_status_t switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:250
switch_media_bug_t * bugs
struct switch_media_bug * next
switch_stream_handle_write_function_t write_function
switch_thread_id_t switch_thread_self(void)
Definition: switch_apr.c:102

◆ switch_core_media_bug_exec_all()

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 1188 of file switch_core_media_bug.c.

References switch_core_session::bug_rwlock, switch_core_session::bugs, 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().

1190 {
1191  switch_media_bug_t *bp;
1192  int x = 0;
1193 
1194  switch_assert(cb);
1195 
1196  if (orig_session->bugs) {
1197  switch_thread_rwlock_wrlock(orig_session->bug_rwlock);
1198  for (bp = orig_session->bugs; bp; bp = bp->next) {
1199  if (!switch_test_flag(bp, SMBF_PRUNE) && !switch_test_flag(bp, SMBF_LOCK) && !strcmp(bp->function, function)) {
1200  cb(bp, user_data);
1201  x++;
1202  }
1203  }
1204  switch_thread_rwlock_unlock(orig_session->bug_rwlock);
1205  }
1206 
1208 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:286
switch_thread_rwlock_t * bug_rwlock
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:260
switch_media_bug_t * bugs
struct switch_media_bug * next
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:693
#define switch_assert(expr)

◆ switch_core_media_bug_flush()

void switch_core_media_bug_flush ( _In_ switch_media_bug_t bug)

Flush the read and write buffers for the bug.

Parameters
bugthe bug to flush the read and write buffers on

◆ switch_core_media_bug_flush_all()

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.

Parameters
sessionthe 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_core_media_bug_get_media_params()

void switch_core_media_bug_get_media_params ( switch_media_bug_t bug,
switch_mm_t mm 
)

Definition at line 125 of file switch_core_media_bug.c.

References switch_media_bug::mm.

Referenced by video_bug_thread().

126 {
127  *mm = bug->mm;
128 }

◆ switch_core_media_bug_get_native_read_frame()

switch_frame_t* switch_core_media_bug_get_native_read_frame ( switch_media_bug_t bug)

Definition at line 160 of file switch_core_media_bug.c.

References switch_media_bug::native_read_frame.

Referenced by eavesdrop_callback(), and record_callback().

161 {
162  return bug->native_read_frame;
163 }
switch_frame_t * native_read_frame

◆ switch_core_media_bug_get_native_write_frame()

switch_frame_t* switch_core_media_bug_get_native_write_frame ( switch_media_bug_t bug)

Definition at line 165 of file switch_core_media_bug.c.

References switch_media_bug::native_write_frame.

Referenced by eavesdrop_callback(), and record_callback().

166 {
167  return bug->native_write_frame;
168 }
switch_frame_t * native_write_frame

◆ switch_core_media_bug_get_read_replace_frame()

switch_frame_t* switch_core_media_bug_get_read_replace_frame ( _In_ switch_media_bug_t bug)

◆ switch_core_media_bug_get_session()

switch_core_session_t* switch_core_media_bug_get_session ( _In_ switch_media_bug_t bug)

◆ switch_core_media_bug_get_text()

const char* switch_core_media_bug_get_text ( switch_media_bug_t bug)

Definition at line 135 of file switch_core_media_bug.c.

References switch_media_bug::text_framedata.

Referenced by text_callback().

136 {
137  return bug->text_framedata;
138 }

◆ switch_core_media_bug_get_user_data()

void* switch_core_media_bug_get_user_data ( _In_ switch_media_bug_t bug)

Obtain private data from a media bug.

Parameters
bugthe bug to get the data from
Returns
the private data

Referenced by display_exec_cb(), exec_cb(), generate_on_dtmf(), recording_thread(), switch_ivr_eavesdrop_pop_eavesdropper(), and switch_ivr_session_audio().

◆ switch_core_media_bug_get_video_ping_frame()

switch_frame_t* switch_core_media_bug_get_video_ping_frame ( switch_media_bug_t bug)

Definition at line 140 of file switch_core_media_bug.c.

References switch_media_bug::video_ping_frame.

Referenced by video_write_overlay_callback().

141 {
142  return bug->video_ping_frame;
143 }
switch_frame_t * video_ping_frame

◆ switch_core_media_bug_get_write_replace_frame()

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.

Parameters
bugthe 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().

◆ switch_core_media_bug_inuse()

void switch_core_media_bug_inuse ( switch_media_bug_t bug,
switch_size_t readp,
switch_size_t writep 
)

Definition at line 206 of file switch_core_media_bug.c.

References switch_media_bug::raw_read_buffer, switch_media_bug::raw_write_buffer, switch_media_bug::read_mutex, SMBF_READ_STREAM, SMBF_WRITE_STREAM, switch_buffer_inuse(), switch_mutex_lock(), switch_mutex_unlock(), switch_test_flag, and switch_media_bug::write_mutex.

207 {
210  *readp = bug->raw_read_buffer ? switch_buffer_inuse(bug->raw_read_buffer) : 0;
212  } else {
213  *readp = 0;
214  }
215 
218  *writep = bug->raw_write_buffer ? switch_buffer_inuse(bug->raw_write_buffer) : 0;
220  } else {
221  *writep = 0;
222  }
223 }
switch_buffer_t * raw_write_buffer
switch_mutex_t * read_mutex
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
Definition: switch_apr.c:313
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:308
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:693
switch_buffer_t * raw_read_buffer
switch_mutex_t * write_mutex
switch_size_t switch_buffer_inuse(_In_ switch_buffer_t *buffer)
Get the in use amount of a switch_buffer_t.

◆ switch_core_media_bug_patch_spy_frame()

switch_status_t switch_core_media_bug_patch_spy_frame ( switch_media_bug_t bug,
switch_image_t img,
switch_rw_t  rw 
)

Definition at line 465 of file switch_core_media_bug.c.

References vpx_image::d_h, vpx_image::d_w, POS_CENTER_MID, switch_media_bug::session, SPY_DUAL_CROP, switch_media_bug::spy_fmt, switch_media_bug::spy_img, SPY_LOWER_RIGHT_LARGE, SPY_LOWER_RIGHT_SMALL, switch_media_bug::spy_video_queue, switch_color_set_rgb(), SWITCH_CORE_QUEUE_LEN, switch_core_session_get_pool(), SWITCH_FIT_SIZE, switch_img_copy(), switch_img_copy_rect(), switch_img_fill(), switch_img_find_position(), switch_img_fit(), switch_img_free(), switch_img_patch(), switch_img_scale(), switch_queue_create(), switch_queue_size(), switch_queue_trypop(), SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.

Referenced by switch_core_session_read_video_frame(), and switch_core_session_write_video_frame().

466 {
467  switch_queue_t *spy_q = NULL;
468  int w = 0, h = 0;
469  void *pop;
470  int i;
471 
472  for (i = 0; i < 2; i++) {
473  if (!bug->spy_video_queue[i]) {
475  }
476  }
477 
478  spy_q = bug->spy_video_queue[rw];
479 
480  while(switch_queue_size(spy_q) > 0) {
481  if (switch_queue_trypop(spy_q, &pop) == SWITCH_STATUS_SUCCESS) {
482  switch_img_free(&bug->spy_img[rw]);
483  if (!(bug->spy_img[rw] = (switch_image_t *) pop)) {
484  break;
485  }
486  }
487  }
488 
489  w = img->d_w;
490  h = img->d_h;
491 
492  if (bug->spy_img[rw]) {
493 
494  switch (bug->spy_fmt) {
495  case SPY_DUAL_CROP:
496  {
497  switch_image_t *spy_tmp = NULL;
498  switch_image_t *img_tmp = NULL;
499  switch_image_t *img_dup = NULL;
500  int x = 0, y = 0;
501  float aspect169 = (float)1920 / 1080;
502  switch_rgb_color_t bgcolor = { 0 };
503 
504  if ((float)w/h == aspect169) {
505  if ((float)bug->spy_img[rw]->d_w / bug->spy_img[rw]->d_h == aspect169) {
506  spy_tmp = switch_img_copy_rect(bug->spy_img[rw], bug->spy_img[rw]->d_w / 4, 0, bug->spy_img[rw]->d_w / 2, bug->spy_img[rw]->d_h);
507 
508  } else {
509  switch_img_copy(bug->spy_img[rw], &spy_tmp);
510  }
511  } else {
512  if ((float)bug->spy_img[rw]->d_w / bug->spy_img[rw]->d_h == aspect169) {
513  spy_tmp = switch_img_copy_rect(bug->spy_img[rw], bug->spy_img[rw]->d_w / 6, 0, bug->spy_img[rw]->d_w / 4, bug->spy_img[rw]->d_h);
514  } else {
515  spy_tmp = switch_img_copy_rect(bug->spy_img[rw], bug->spy_img[rw]->d_w / 4, 0, bug->spy_img[rw]->d_w / 2, bug->spy_img[rw]->d_h);
516  }
517  }
518 
519  switch_img_copy(img, &img_dup);
520  img_tmp = switch_img_copy_rect(img_dup, w / 4, 0, w / 2, h);
521 
522  switch_img_fit(&spy_tmp, w / 2, h, SWITCH_FIT_SIZE);
523  switch_img_fit(&img_tmp, w / 2, h, SWITCH_FIT_SIZE);
524 
525  switch_color_set_rgb(&bgcolor, "#000000");
526  switch_img_fill(img, 0, 0, img->d_w, img->d_h, &bgcolor);
527 
528  switch_img_find_position(POS_CENTER_MID, w / 2, h, img_tmp->d_w, img_tmp->d_h, &x, &y);
529  switch_img_patch(img, img_tmp, x, y);
530 
531  switch_img_find_position(POS_CENTER_MID, w / 2, h, spy_tmp->d_w, spy_tmp->d_h, &x, &y);
532  switch_img_patch(img, spy_tmp, x + w / 2, y);
533 
534 
535  switch_img_free(&img_tmp);
536  switch_img_free(&img_dup);
537  switch_img_free(&spy_tmp);
538  }
539  break;
542  default:
543  {
544  float scaler = 0.125f;
545  int spyw, spyh;
546 
547  if (bug->spy_fmt == SPY_LOWER_RIGHT_LARGE) {
548  scaler = 0.25f;
549  }
550 
551  spyw = (int) (float)w * scaler;
552  spyh = (int) (float)h * scaler;
553 
554  if (bug->spy_img[rw]->d_w != spyw || bug->spy_img[rw]->d_h != spyh) {
555  switch_image_t *tmp_img = NULL;
556 
557  switch_img_scale(bug->spy_img[rw], &tmp_img, spyw, spyh);
558  switch_img_free(&bug->spy_img[rw]);
559  bug->spy_img[rw] = tmp_img;
560  }
561 
562  switch_img_patch(img, bug->spy_img[rw], w - spyw, h - spyh);
563  }
564  break;
565  }
566 
567  return SWITCH_STATUS_SUCCESS;
568  }
569 
570  return SWITCH_STATUS_FALSE;
571 }
unsigned int switch_queue_size(switch_queue_t *queue)
Definition: switch_apr.c:1238
Image Descriptor.
Definition: switch_image.h:88
void switch_img_patch(switch_image_t *IMG, switch_image_t *img, int x, int y)
patch a small img to a big IMG at position x,y
void switch_img_free(switch_image_t **img)
Close an image descriptor.
switch_status_t switch_queue_trypop(switch_queue_t *queue, void **data)
Definition: switch_apr.c:1264
switch_core_session_t * session
void switch_img_find_position(switch_img_position_t pos, int sw, int sh, int iw, int ih, int *xP, int *yP)
unsigned int d_w
Definition: switch_image.h:99
#define SWITCH_CORE_QUEUE_LEN
Definition: switch_types.h:593
switch_queue_t * spy_video_queue[2]
void switch_img_copy(switch_image_t *img, switch_image_t **new_img)
Copy image to a new image.
switch_status_t switch_img_fit(switch_image_t **srcP, int width, int height, switch_img_fit_t fit)
switch_image_t * spy_img[2]
switch_image_t * switch_img_copy_rect(switch_image_t *img, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
Copy part of an image to a new image.
switch_status_t switch_img_scale(switch_image_t *src, switch_image_t **destP, int width, int height)
void switch_color_set_rgb(switch_rgb_color_t *color, const char *color_str)
Set RGB color with a string.
void switch_img_fill(switch_image_t *img, int x, int y, int w, int h, switch_rgb_color_t *color)
Fill image with color.
switch_status_t switch_queue_create(switch_queue_t **queue, unsigned int queue_capacity, switch_memory_pool_t *pool)
Definition: switch_apr.c:1233
switch_vid_spy_fmt_t spy_fmt
unsigned int d_h
Definition: switch_image.h:100
switch_memory_pool_t * switch_core_session_get_pool(_In_ switch_core_session_t *session)
Retrieve the memory pool from a session.

◆ switch_core_media_bug_patch_video()

uint32_t switch_core_media_bug_patch_video ( switch_core_session_t orig_session,
switch_frame_t frame 
)

Definition at line 1153 of file switch_core_media_bug.c.

References switch_core_session::bug_rwlock, switch_core_session::bugs, switch_media_bug::callback, switch_media_bug::function, switch_frame::img, switch_media_bug::next, switch_media_bug::ready, SMBF_LOCK, SMBF_PRUNE, SMBF_VIDEO_PATCH, switch_media_bug::stop_time, SWITCH_ABC_TYPE_VIDEO_PATCH, switch_core_media_bug_prune(), switch_epoch_time_now(), SWITCH_FALSE, switch_set_flag, switch_test_flag, switch_thread_rwlock_rdlock(), switch_thread_rwlock_unlock(), SWITCH_TRUE, switch_media_bug::user_data, and switch_media_bug::video_ping_frame.

1154 {
1155  switch_media_bug_t *bp;
1156  uint32_t x = 0, ok = SWITCH_TRUE, prune = 0;
1157 
1158  if (orig_session->bugs) {
1159  switch_thread_rwlock_rdlock(orig_session->bug_rwlock);
1160  for (bp = orig_session->bugs; bp; bp = bp->next) {
1161  if (!switch_test_flag(bp, SMBF_PRUNE) && !switch_test_flag(bp, SMBF_LOCK) && !strcmp(bp->function, "patch:video")) {
1162  if (bp->ready && frame->img && switch_test_flag(bp, SMBF_VIDEO_PATCH)) {
1163  bp->video_ping_frame = frame;
1164  if (bp->callback) {
1166  || (bp->stop_time && bp->stop_time <= switch_epoch_time_now(NULL))) {
1167  ok = SWITCH_FALSE;
1168  }
1169  }
1170  bp->video_ping_frame = NULL;
1171  }
1172 
1173  if (ok == SWITCH_FALSE) {
1175  prune++;
1176  } else x++;
1177  }
1178  }
1179  switch_thread_rwlock_unlock(orig_session->bug_rwlock);
1180  if (prune) {
1181  switch_core_media_bug_prune(orig_session);
1182  }
1183  }
1184 
1185  return x;
1186 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:286
switch_thread_rwlock_t * bug_rwlock
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
Definition: switch_utils.h:700
switch_media_bug_callback_t callback
switch_status_t switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:250
uint32_t switch_core_media_bug_prune(switch_core_session_t *session)
switch_media_bug_t * bugs
switch_frame_t * video_ping_frame
struct switch_media_bug * next
switch_image_t * img
Definition: switch_frame.h:88
time_t switch_epoch_time_now(time_t *t)
Get the current epoch time.
Definition: switch_time.c:322
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:693

◆ switch_core_media_bug_pause()

void switch_core_media_bug_pause ( switch_core_session_t session)

Pause a media bug on the session.

Parameters
sessionthe session to pause the bug on sets CF_PAUSE_BUGS flag

Definition at line 92 of file switch_core_media_bug.c.

References CF_PAUSE_BUGS, switch_core_session::channel, and switch_channel_set_flag.

93 {
95 }
switch_channel_t * channel
#define switch_channel_set_flag(_c, _f)

◆ switch_core_media_bug_pop()

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 1109 of file switch_core_media_bug.c.

References switch_core_session::bug_rwlock, switch_core_session::bugs, 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().

1110 {
1111  switch_media_bug_t *bp;
1112 
1113  if (orig_session->bugs) {
1114  switch_thread_rwlock_wrlock(orig_session->bug_rwlock);
1115  for (bp = orig_session->bugs; bp; bp = bp->next) {
1116  if (!strcmp(bp->function, function)) {
1118  break;
1119  }
1120  }
1121  switch_thread_rwlock_unlock(orig_session->bug_rwlock);
1122 
1123  if (bp) {
1124  *pop = bp;
1125  return SWITCH_STATUS_SUCCESS;
1126  } else {
1127  *pop = NULL;
1128  }
1129  }
1130 
1131  return SWITCH_STATUS_FALSE;
1132 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:286
switch_thread_rwlock_t * bug_rwlock
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
Definition: switch_utils.h:700
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:260
switch_media_bug_t * bugs
struct switch_media_bug * next

◆ switch_core_media_bug_prune()

uint32_t switch_core_media_bug_prune ( switch_core_session_t session)

Definition at line 1393 of file switch_core_media_bug.c.

References switch_core_session::bug_codec, switch_core_session::bug_rwlock, switch_core_session::bugs, 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(), switch_thread_rwlock_wrlock(), SWITCH_TRUE, and switch_media_bug::thread_id.

Referenced by perform_write(), switch_core_media_bug_patch_video(), switch_core_session_read_frame(), switch_core_session_read_text_frame(), switch_core_session_read_video_frame(), switch_core_session_write_frame(), and switch_core_session_write_video_frame().

1394 {
1395  switch_media_bug_t *bp = NULL, *last = NULL;
1396  int ttl = 0;
1397 
1398 
1399  top:
1400 
1402  if (session->bugs) {
1403  for (bp = session->bugs; bp; bp = bp->next) {
1405  if (last) {
1406  last->next = bp->next;
1407  } else {
1408  session->bugs = bp->next;
1409  }
1410  break;
1411  }
1412 
1413  last = bp;
1414  }
1415  }
1416 
1417  if (!session->bugs && switch_core_codec_ready(&session->bug_codec)) {
1419  }
1420 
1422 
1423  if (bp) {
1425  bp->thread_id = 0;
1427  ttl++;
1428  goto top;
1429  }
1430 
1431  return ttl;
1432 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:286
switch_thread_rwlock_t * bug_rwlock
switch_thread_id_t thread_id
switch_status_t switch_core_codec_destroy(switch_codec_t *codec)
Destroy an initalized codec handle.
#define switch_clear_flag(obj, flag)
Clear a flag on an arbitrary object while locked.
Definition: switch_utils.h:724
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:260
switch_media_bug_t * bugs
struct switch_media_bug * next
uint32_t switch_core_media_bug_test_flag(switch_media_bug_t *bug, uint32_t flag)
switch_codec_t bug_codec
static switch_bool_t switch_core_codec_ready(switch_codec_t *codec)
switch_status_t switch_core_media_bug_close(switch_media_bug_t **bug, switch_bool_t destroy)

◆ switch_core_media_bug_push_spy_frame()

switch_status_t switch_core_media_bug_push_spy_frame ( switch_media_bug_t bug,
switch_frame_t frame,
switch_rw_t  rw 
)

Definition at line 773 of file switch_core_media_bug.c.

References switch_frame::img, switch_media_bug::spy_video_queue, switch_assert, switch_img_copy(), switch_queue_push(), SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.

Referenced by video_eavesdrop_callback().

774 {
775 
776  switch_assert(bug);
777  switch_assert(frame);
778 
779  if (bug->spy_video_queue[rw] && frame->img) {
780  switch_image_t *img = NULL;
781 
782  switch_img_copy(frame->img, &img);
783 
784  if (img) {
785  switch_queue_push(bug->spy_video_queue[rw], img);
786  return SWITCH_STATUS_SUCCESS;
787  }
788  }
789 
790  return SWITCH_STATUS_FALSE;
791 }
Image Descriptor.
Definition: switch_image.h:88
switch_queue_t * spy_video_queue[2]
void switch_img_copy(switch_image_t *img, switch_image_t **new_img)
Copy image to a new image.
switch_image_t * img
Definition: switch_frame.h:88
switch_status_t switch_queue_push(switch_queue_t *queue, void *data)
Definition: switch_apr.c:1253
#define switch_assert(expr)

◆ switch_core_media_bug_read()

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.

Parameters
bugthe bug to read from
framethe frame to write the data to
Returns
SWITCH_STATUS_SUCCESS if the operation was a success

Referenced by eavesdrop_callback(), record_callback(), and speech_callback().

◆ switch_core_media_bug_remove()

switch_status_t switch_core_media_bug_remove ( _In_ switch_core_session_t session,
_Inout_ switch_media_bug_t **  bug 
)

◆ switch_core_media_bug_remove_all_function()

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.

Parameters
sessionthe session to remove the bugs from
Returns
SWITCH_STATUS_SUCCESS if the operation was a success

◆ switch_core_media_bug_remove_callback()

switch_status_t switch_core_media_bug_remove_callback ( switch_core_session_t session,
switch_media_bug_callback_t  callback 
)

Remove media bug callback.

Parameters
bugbug to remove
callbackcallback to remove
Returns
SWITCH_STATUS_SUCCESS if the operation was a success

Definition at line 1435 of file switch_core_media_bug.c.

References switch_core_session::bug_codec, switch_core_session::bug_rwlock, switch_core_session::bugs, switch_media_bug::callback, cur, switch_media_bug::next, switch_media_bug::ready, switch_core_codec_destroy(), switch_core_codec_ready(), switch_core_media_bug_close(), switch_core_media_bug_destroy(), SWITCH_FALSE, 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().

1436 {
1437  switch_media_bug_t *cur = NULL, *bp = NULL, *last = NULL, *closed = NULL, *next = NULL;
1438  int total = 0;
1439 
1441  if (session->bugs) {
1442  bp = session->bugs;
1443  while (bp) {
1444  cur = bp;
1445  bp = bp->next;
1446 
1447  if ((!cur->thread_id || cur->thread_id == switch_thread_self()) && cur->ready && cur->callback == callback) {
1448  if (last) {
1449  last->next = cur->next;
1450  } else {
1451  session->bugs = cur->next;
1452  }
1454  total++;
1455  }
1456 
1457  cur->next = closed;
1458  closed = cur;
1459 
1460  } else {
1461  last = cur;
1462  }
1463  }
1464  }
1466 
1467  if (closed) {
1468  for (bp = closed; bp; bp = next) {
1469  next = bp->next;
1471  }
1472  }
1473 
1474  if (!session->bugs && switch_core_codec_ready(&session->bug_codec)) {
1476  }
1477 
1478  return total ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
1479 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:286
switch_thread_rwlock_t * bug_rwlock
switch_thread_id_t thread_id
static void switch_core_media_bug_destroy(switch_media_bug_t **bug)
switch_status_t switch_core_codec_destroy(switch_codec_t *codec)
Destroy an initalized codec handle.
pack cur
switch_media_bug_callback_t callback
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:260
switch_media_bug_t * bugs
struct switch_media_bug * next
switch_codec_t bug_codec
static switch_bool_t switch_core_codec_ready(switch_codec_t *codec)
switch_thread_id_t switch_thread_self(void)
Definition: switch_apr.c:102
switch_status_t switch_core_media_bug_close(switch_media_bug_t **bug, switch_bool_t destroy)

◆ switch_core_media_bug_resume()

void switch_core_media_bug_resume ( switch_core_session_t session)

Resume a media bug on the session.

Parameters
sessionthe session to resume the bug on, clears CF_PAUSE_BUGS flag

Definition at line 97 of file switch_core_media_bug.c.

References CF_PAUSE_BUGS, switch_core_session::channel, and switch_channel_clear_flag().

98 {
100 }
switch_channel_t * channel
void switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Clear given flag(s) from a channel.

◆ switch_core_media_bug_set_flag()

uint32_t switch_core_media_bug_set_flag ( _In_ switch_media_bug_t bug,
_In_ uint32_t  flag 
)

◆ switch_core_media_bug_set_media_params()

void switch_core_media_bug_set_media_params ( switch_media_bug_t bug,
switch_mm_t mm 
)

Definition at line 120 of file switch_core_media_bug.c.

References switch_media_bug::mm.

Referenced by record_callback().

121 {
122  bug->mm = *mm;
123 }

◆ switch_core_media_bug_set_pre_buffer_framecount()

switch_status_t switch_core_media_bug_set_pre_buffer_framecount ( switch_media_bug_t bug,
uint32_t  framecount 
)

Definition at line 225 of file switch_core_media_bug.c.

References switch_media_bug::record_pre_buffer_max, and SWITCH_STATUS_SUCCESS.

Referenced by switch_ivr_record_session_event().

226 {
227  bug->record_pre_buffer_max = framecount;
228 
229  return SWITCH_STATUS_SUCCESS;
230 }
uint32_t record_pre_buffer_max

◆ switch_core_media_bug_set_read_demux_frame()

void switch_core_media_bug_set_read_demux_frame ( _In_ switch_media_bug_t bug,
_In_ switch_frame_t frame 
)

Referenced by eavesdrop_callback().

◆ switch_core_media_bug_set_read_replace_frame()

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.

Parameters
bugthe bug to set the frame on
framethe frame to set

Referenced by eavesdrop_callback(), inband_dtmf_callback(), inband_dtmf_generate_callback(), read_displace_callback(), session_audio_callback(), and write_displace_callback().

◆ switch_core_media_bug_set_write_replace_frame()

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.

Parameters
bugthe bug to set the frame on
framethe frame to set

Referenced by eavesdrop_callback(), inband_dtmf_generate_callback(), read_displace_callback(), session_audio_callback(), and write_displace_callback().

◆ switch_core_media_bug_test_flag()

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.

Parameters
bugthe object to test
flagthe or'd list of flags to test
Returns
true value if the object has the flags defined

Referenced by eavesdrop_callback(), perform_write(), record_callback(), recording_thread(), switch_core_session_read_frame(), switch_core_session_read_text_frame(), switch_core_session_read_video_frame(), switch_core_session_write_frame(), switch_core_session_write_video_frame(), switch_ivr_eavesdrop_session(), and video_eavesdrop_callback().

◆ switch_core_media_bug_transfer_callback()

switch_status_t switch_core_media_bug_transfer_callback ( switch_core_session_t orig_session,
switch_core_session_t new_session,
switch_media_bug_callback_t  callback,
void *(*)(switch_core_session_t *, void *)  user_data_dup_func 
)

Definition at line 1044 of file switch_core_media_bug.c.

References switch_core_session::bug_codec, switch_core_session::bug_rwlock, switch_core_session::bugs, switch_core_session::channel, cur, switch_core_session::flags, switch_media_bug::next, switch_channel_media_ready, SWITCH_CHANNEL_SESSION_LOG, switch_core_codec_destroy(), switch_core_codec_ready(), switch_core_media_bug_add(), switch_core_media_bug_destroy(), switch_core_session_get_name, SWITCH_LOG_DEBUG, switch_log_printf(), SWITCH_LOG_WARNING, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_thread_rwlock_unlock(), and switch_thread_rwlock_wrlock().

Referenced by switch_ivr_transfer_recordings().

1046 {
1047  switch_media_bug_t *new_bug = NULL, *cur = NULL, *bp = NULL, *last = NULL, *old_last_next = NULL, *old_bugs = NULL;
1048  int total = 0;
1049 
1050  if (!switch_channel_media_ready(new_session->channel)) {
1051  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(orig_session), SWITCH_LOG_WARNING, "Cannot transfer media bugs to a channel with no media.\n");
1052  return SWITCH_STATUS_FALSE;
1053  }
1054 
1055  switch_thread_rwlock_wrlock(orig_session->bug_rwlock);
1056  bp = orig_session->bugs;
1057  while (bp) {
1058  cur = bp;
1059  bp = bp->next;
1060 
1061  if (cur->callback == callback) {
1062  if (last) {
1063  old_last_next = last->next;
1064  last->next = cur->next;
1065  } else {
1066  old_bugs = orig_session->bugs;
1067  orig_session->bugs = cur->next;
1068  }
1069 
1070  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(orig_session), SWITCH_LOG_DEBUG, "Transfering %s from %s to %s\n", cur->target,
1071  switch_core_session_get_name(orig_session), switch_core_session_get_name(new_session));
1072 
1073  if ((switch_core_media_bug_add(new_session, cur->function, cur->target, cur->callback,
1074  user_data_dup_func(new_session, cur->user_data),
1075  cur->stop_time, cur->flags, &new_bug) == SWITCH_STATUS_SUCCESS)) {
1077  total++;
1078  } else {
1079  /* Call the dup function again to revert to original session */
1080  user_data_dup_func(orig_session, cur->user_data);
1081  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(orig_session), SWITCH_LOG_DEBUG, "Adding a bug failed: abort transfering %s from %s to %s\n", cur->target,
1082  switch_core_session_get_name(orig_session), switch_core_session_get_name(new_session));
1083 
1084  /* Put the old bug back to the original session's list of bugs */
1085  if (last) {
1086  last->next = old_last_next;
1087  } else {
1088  orig_session->bugs = old_bugs;
1089  }
1090 
1091  last = cur;
1092  }
1093  } else {
1094  last = cur;
1095  }
1096  }
1097 
1098  if (!orig_session->bugs && switch_core_codec_ready(&orig_session->bug_codec)) {
1099  switch_core_codec_destroy(&orig_session->bug_codec);
1100  }
1101 
1102  switch_thread_rwlock_unlock(orig_session->bug_rwlock);
1103 
1104 
1105  return total ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
1106 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:286
#define SWITCH_CHANNEL_SESSION_LOG(x)
switch_thread_rwlock_t * bug_rwlock
switch_session_flag_t flags
static void switch_core_media_bug_destroy(switch_media_bug_t **bug)
#define switch_channel_media_ready(_channel)
switch_status_t switch_core_codec_destroy(switch_codec_t *codec)
Destroy an initalized codec handle.
#define switch_core_session_get_name(_s)
Definition: switch_core.h:265
pack cur
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:260
switch_channel_t * channel
switch_status_t switch_core_media_bug_add(switch_core_session_t *session, const char *function, const char *target, switch_media_bug_callback_t callback, void *user_data, time_t stop_time, switch_media_bug_flag_t flags, switch_media_bug_t **new_bug)
switch_media_bug_t * bugs
struct switch_media_bug * next
switch_codec_t bug_codec
static switch_bool_t switch_core_codec_ready(switch_codec_t *codec)
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.

◆ switch_core_screen_size()

void switch_core_screen_size ( int *  x,
int *  y 
)

Definition at line 261 of file switch_core.c.

Referenced by switch_core_init_and_modload(), and switch_must_realloc().

262 {
263 
264 #ifdef WIN32
265  CONSOLE_SCREEN_BUFFER_INFO csbi;
266  int ret;
267 
268  if ((ret = GetConsoleScreenBufferInfo(GetStdHandle( STD_OUTPUT_HANDLE ), &csbi))) {
269  if (x) *x = csbi.dwSize.X;
270  if (y) *y = csbi.dwSize.Y;
271  }
272 
273 #elif defined(TIOCGWINSZ)
274  struct winsize w;
275  ioctl(0, TIOCGWINSZ, &w);
276 
277  if (x) *x = w.ws_col;
278  if (y) *y = w.ws_row;
279 #else
280  if (x) *x = 80;
281  if (y) *y = 24;
282 #endif
283 
284 }

◆ switch_core_session_disable_heartbeat()

void switch_core_session_disable_heartbeat ( switch_core_session_t session)

Definition at line 1703 of file switch_core_session.c.

References switch_core_session::read_frame_count, switch_assert, switch_core_session_unsched_heartbeat(), and switch_core_session::track_duration.

Referenced by switch_must_realloc().

1704 {
1706  switch_assert(session != NULL);
1707  session->read_frame_count = 0;
1708  session->track_duration = 0;
1709 
1710 }
void switch_core_session_unsched_heartbeat(switch_core_session_t *session)
#define switch_assert(expr)

◆ switch_core_session_enable_heartbeat()

void switch_core_session_enable_heartbeat ( switch_core_session_t session,
uint32_t  seconds 
)

Definition at line 1670 of file switch_core_session.c.

References CF_PROXY_MODE, switch_core_session::channel, switch_core_session::read_frame_count, switch_core_session::read_impl, switch_codec_implementation::samples_per_packet, switch_codec_implementation::samples_per_second, switch_assert, switch_channel_get_name(), switch_channel_get_variable, switch_channel_get_variable_dup(), switch_channel_media_ready, SWITCH_CHANNEL_SESSION_LOG, switch_channel_test_flag(), switch_core_session_sched_heartbeat(), switch_core_session_unsched_heartbeat(), SWITCH_FALSE, SWITCH_LOG_INFO, switch_log_printf(), SWITCH_LOG_WARNING, switch_true(), and switch_core_session::track_duration.

Referenced by switch_channel_perform_mark_answered(), switch_core_media_receive_message(), and switch_must_realloc().

1671 {
1672  switch_assert(session != NULL);
1673 
1674  if (!seconds) {
1675  seconds = 60;
1676  }
1677 
1678  session->track_duration = seconds;
1679 
1681  switch_true(switch_channel_get_variable_dup(session->channel, "heartbeat_use_scheduler", SWITCH_FALSE, -1)) ||
1682  switch_true(switch_channel_get_variable_dup(session->channel, "bypass_media", SWITCH_FALSE, -1)) ||
1683  switch_true(switch_channel_get_variable_dup(session->channel, "bypass_media_after_bridge", SWITCH_FALSE, -1))) {
1684  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s using scheduler due to bypass media or media is not established.\n",
1685  switch_channel_get_name(session->channel));
1686  switch_core_session_sched_heartbeat(session, seconds);
1687  return;
1688  }
1689 
1690  if (switch_true(switch_channel_get_variable(session->channel, "heartbeat_fire_on_set"))) {
1691  session->read_frame_count = 0;
1692  } else {
1693  session->read_frame_count = (session->read_impl.samples_per_second / session->read_impl.samples_per_packet) * seconds;
1694  }
1695 
1697 
1698  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "%s setting session heartbeat to %u second(s).\n",
1699  switch_channel_get_name(session->channel), seconds);
1700 
1701 }
static switch_bool_t switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
Definition: switch_utils.h:519
#define SWITCH_CHANNEL_SESSION_LOG(x)
void switch_core_session_unsched_heartbeat(switch_core_session_t *session)
#define switch_channel_media_ready(_channel)
switch_codec_implementation_t read_impl
const char * switch_channel_get_variable_dup(switch_channel_t *channel, const char *varname, switch_bool_t dup, int idx)
Retrieve a variable from a given channel.
uint32_t switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Test for presence of given flag on a given channel.
switch_channel_t * channel
#define switch_channel_get_variable(_c, _v)
void switch_core_session_sched_heartbeat(switch_core_session_t *session, uint32_t seconds)
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.
#define switch_assert(expr)
char * switch_channel_get_name(switch_channel_t *channel)
Retrieve the name of a given channel.

◆ switch_core_session_sched_heartbeat()

void switch_core_session_sched_heartbeat ( switch_core_session_t session,
uint32_t  seconds 
)

Definition at line 1655 of file switch_core_session.c.

References __SWITCH_FUNC__, switch_core_session::channel, SSHF_FREE_ARG, switch_channel_get_variable, switch_core_session_get_uuid(), switch_core_session_unsched_heartbeat(), switch_epoch_time_now(), switch_scheduler_add_task(), switch_true(), switch_core_session::track_duration, and switch_core_session::track_id.

Referenced by switch_core_session_enable_heartbeat(), and switch_must_realloc().

1656 {
1657  time_t when;
1658 
1660  if (switch_true(switch_channel_get_variable(session->channel, "heartbeat_fire_on_set"))) {
1661  when = switch_epoch_time_now(NULL);
1662  } else {
1663  when = switch_epoch_time_now(NULL) + session->track_duration;
1664  }
1665 
1666  session->track_id = switch_scheduler_add_task(when, sch_heartbeat_callback, (char *) __SWITCH_FUNC__,
1668 }
#define __SWITCH_FUNC__
static switch_bool_t switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
Definition: switch_utils.h:519
void switch_core_session_unsched_heartbeat(switch_core_session_t *session)
uint32_t switch_scheduler_add_task(time_t task_runtime, switch_scheduler_func_t func, const char *desc, const char *group, uint32_t cmd_id, void *cmd_arg, switch_scheduler_flag_t flags)
Schedule a task in the future.
switch_channel_t * channel
#define switch_channel_get_variable(_c, _v)
time_t switch_epoch_time_now(time_t *t)
Get the current epoch time.
Definition: switch_time.c:322
char * switch_core_session_get_uuid(switch_core_session_t *session)

◆ switch_core_session_unsched_heartbeat()

void switch_core_session_unsched_heartbeat ( switch_core_session_t session)

Definition at line 1647 of file switch_core_session.c.

References switch_scheduler_del_task_id(), and switch_core_session::track_id.

Referenced by switch_core_session_disable_heartbeat(), switch_core_session_enable_heartbeat(), switch_core_session_sched_heartbeat(), and switch_must_realloc().

1648 {
1649  if (session->track_id) {
1651  session->track_id = 0;
1652  }
1653 }
uint32_t switch_scheduler_del_task_id(uint32_t task_id)
Delete a scheduled task.

◆ switch_media_bug_parse_spy_fmt()

switch_vid_spy_fmt_t switch_media_bug_parse_spy_fmt ( const char *  name)

Definition at line 443 of file switch_core_media_bug.c.

References SPY_DUAL_CROP, SPY_LOWER_RIGHT_LARGE, SPY_LOWER_RIGHT_SMALL, and zstr.

Referenced by switch_ivr_eavesdrop_session().

444 {
445  if (zstr(name)) goto end;
446 
447  if (!strcasecmp(name, "dual-crop")) {
448  return SPY_DUAL_CROP;
449  }
450 
451  if (!strcasecmp(name, "lower-right-large")) {
452  return SPY_LOWER_RIGHT_LARGE;
453  }
454 
455  end:
456 
457  return SPY_LOWER_RIGHT_SMALL;
458 }
#define zstr(x)
Definition: switch_utils.h:314
const char *const name
Definition: switch_cJSON.h:250

◆ switch_media_bug_set_spy_fmt()

void switch_media_bug_set_spy_fmt ( switch_media_bug_t bug,
switch_vid_spy_fmt_t  spy_fmt 
)

Definition at line 460 of file switch_core_media_bug.c.

References switch_media_bug::spy_fmt.

Referenced by switch_ivr_eavesdrop_session().

461 {
462  bug->spy_fmt = spy_fmt;
463 }
switch_vid_spy_fmt_t spy_fmt