FreeSWITCH API Documentation  1.7.0
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...
 
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)
 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_recordings (switch_core_session_t *orig_session, switch_core_session_t *new_session)
 
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

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

Function Documentation

uint32_t switch_core_cpu_count ( void  )

Definition at line 1042 of file switch_core.c.

References switch_runtime::cpu_count.

Referenced by switch_core_media_init(), and switch_event_init().

1043 {
1044  return runtime.cpu_count;
1045 }
struct switch_runtime runtime
Definition: switch_core.c:64
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
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_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(), switch_ivr_session_audio(), switch_ivr_tone_detect_session(), and switch_ivr_video_write_overlay_session().

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.

Parameters
bugbug to remove
Returns
SWITCH_STATUS_SUCCESS if the operation was a success
uint32_t switch_core_media_bug_count ( switch_core_session_t orig_session,
const char *  function 
)

Definition at line 994 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().

995 {
996  switch_media_bug_t *bp;
997  uint32_t x = 0;
998 
999  if (orig_session->bugs) {
1000  switch_thread_rwlock_rdlock(orig_session->bug_rwlock);
1001  for (bp = orig_session->bugs; bp; bp = bp->next) {
1002  if (!switch_test_flag(bp, SMBF_PRUNE) && !switch_test_flag(bp, SMBF_LOCK) && !strcmp(bp->function, function)) {
1003  x++;
1004  }
1005  }
1006  switch_thread_rwlock_unlock(orig_session->bug_rwlock);
1007  }
1008 
1009  return x;
1010 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:263
switch_thread_rwlock_t * bug_rwlock
switch_status_t switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:227
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:624
switch_status_t switch_core_media_bug_enumerate ( switch_core_session_t session,
switch_stream_handle_t stream 
)

Definition at line 1069 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.

1070 {
1071  switch_media_bug_t *bp;
1072 
1073  stream->write_function(stream, "<media-bugs>\n");
1074 
1075  if (session->bugs) {
1077  for (bp = session->bugs; bp; bp = bp->next) {
1078  int thread_locked = (bp->thread_id && bp->thread_id == switch_thread_self());
1079  stream->write_function(stream,
1080  " <media-bug>\n"
1081  " <function>%s</function>\n"
1082  " <target>%s</target>\n"
1083  " <thread-locked>%d</thread-locked>\n"
1084  " </media-bug>\n",
1085  bp->function, bp->target, thread_locked);
1086 
1087  }
1089  }
1090 
1091  stream->write_function(stream, "</media-bugs>\n");
1092 
1093  return SWITCH_STATUS_SUCCESS;
1094 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:263
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:227
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:79
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 1047 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().

1049 {
1050  switch_media_bug_t *bp;
1051  int x = 0;
1052 
1053  switch_assert(cb);
1054 
1055  if (orig_session->bugs) {
1056  switch_thread_rwlock_wrlock(orig_session->bug_rwlock);
1057  for (bp = orig_session->bugs; bp; bp = bp->next) {
1058  if (!switch_test_flag(bp, SMBF_PRUNE) && !switch_test_flag(bp, SMBF_LOCK) && !strcmp(bp->function, function)) {
1059  cb(bp, user_data);
1060  x++;
1061  }
1062  }
1063  switch_thread_rwlock_unlock(orig_session->bug_rwlock);
1064  }
1065 
1067 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:263
switch_thread_rwlock_t * bug_rwlock
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:237
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:624
#define switch_assert(expr)
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_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_frame_t* switch_core_media_bug_get_native_read_frame ( switch_media_bug_t bug)

Definition at line 111 of file switch_core_media_bug.c.

Referenced by record_callback().

112 {
113  return bug->native_read_frame;
114 }
switch_frame_t * native_read_frame
switch_frame_t* switch_core_media_bug_get_native_write_frame ( switch_media_bug_t bug)

Definition at line 116 of file switch_core_media_bug.c.

Referenced by record_callback().

117 {
118  return bug->native_write_frame;
119 }
switch_frame_t * native_write_frame
switch_frame_t* switch_core_media_bug_get_read_replace_frame ( _In_ switch_media_bug_t bug)
switch_core_session_t* switch_core_media_bug_get_session ( _In_ switch_media_bug_t bug)
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_frame_t* switch_core_media_bug_get_video_ping_frame ( switch_media_bug_t bug)

Definition at line 91 of file switch_core_media_bug.c.

Referenced by video_write_overlay_callback().

92 {
93  return bug->video_ping_frame;
94 }
switch_frame_t * video_ping_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().

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

Definition at line 157 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.

158 {
161  *readp = bug->raw_read_buffer ? switch_buffer_inuse(bug->raw_read_buffer) : 0;
163  } else {
164  *readp = 0;
165  }
166 
169  *writep = bug->raw_write_buffer ? switch_buffer_inuse(bug->raw_write_buffer) : 0;
171  } else {
172  *writep = 0;
173  }
174 }
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:290
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
Definition: switch_apr.c:285
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:624
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_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 416 of file switch_core_media_bug.c.

References vpx_image::d_h, vpx_image::d_w, POS_CENTER_MID, SPY_DUAL_CROP, SPY_LOWER_RIGHT_LARGE, SPY_LOWER_RIGHT_SMALL, 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().

417 {
418  switch_queue_t *spy_q = NULL;
419  int w = 0, h = 0;
420  switch_status_t status;
421  void *pop;
422  int i;
423 
424  for (i = 0; i < 2; i++) {
425  if (!bug->spy_video_queue[i]) {
427  }
428  }
429 
430  spy_q = bug->spy_video_queue[rw];
431 
432  while(switch_queue_size(spy_q) > 0) {
433  if ((status = switch_queue_trypop(spy_q, &pop)) == SWITCH_STATUS_SUCCESS) {
434  switch_img_free(&bug->spy_img[rw]);
435  if (!(bug->spy_img[rw] = (switch_image_t *) pop)) {
436  break;
437  }
438  }
439  }
440 
441  w = img->d_w;
442  h = img->d_h;
443 
444  if (bug->spy_img[rw]) {
445 
446  switch (bug->spy_fmt) {
447  case SPY_DUAL_CROP:
448  {
449  switch_image_t *spy_tmp = NULL;
450  switch_image_t *img_tmp = NULL;
451  switch_image_t *img_dup = NULL;
452  int x = 0, y = 0;
453  float aspect169 = (float)1920 / 1080;
454  switch_rgb_color_t bgcolor = { 0 };
455 
456  if ((float)w/h == aspect169) {
457  if ((float)bug->spy_img[rw]->d_w / bug->spy_img[rw]->d_h == aspect169) {
458  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);
459 
460  } else {
461  switch_img_copy(bug->spy_img[rw], &spy_tmp);
462  }
463  } else {
464  if ((float)bug->spy_img[rw]->d_w / bug->spy_img[rw]->d_h == aspect169) {
465  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);
466  } else {
467  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);
468  }
469  }
470 
471  switch_img_copy(img, &img_dup);
472  img_tmp = switch_img_copy_rect(img_dup, w / 4, 0, w / 2, h);
473 
474  switch_img_fit(&spy_tmp, w / 2, h, SWITCH_FIT_SIZE);
475  switch_img_fit(&img_tmp, w / 2, h, SWITCH_FIT_SIZE);
476 
477  switch_color_set_rgb(&bgcolor, "#000000");
478  switch_img_fill(img, 0, 0, img->d_w, img->d_h, &bgcolor);
479 
480  switch_img_find_position(POS_CENTER_MID, w / 2, h, img_tmp->d_w, img_tmp->d_h, &x, &y);
481  switch_img_patch(img, img_tmp, x, y);
482 
483  switch_img_find_position(POS_CENTER_MID, w / 2, h, spy_tmp->d_w, spy_tmp->d_h, &x, &y);
484  switch_img_patch(img, spy_tmp, x + w / 2, y);
485 
486 
487  switch_img_free(&img_tmp);
488  switch_img_free(&img_dup);
489  switch_img_free(&spy_tmp);
490  }
491  break;
494  default:
495  {
496  float scaler = 0.125f;
497  int spyw, spyh;
498 
499  if (bug->spy_fmt == SPY_LOWER_RIGHT_LARGE) {
500  scaler = 0.25f;
501  }
502 
503  spyw = (int) (float)w * scaler;
504  spyh = (int) (float)h * scaler;
505 
506  if (bug->spy_img[rw]->d_w != spyw || bug->spy_img[rw]->d_h != spyh) {
507  switch_image_t *tmp_img = NULL;
508 
509  switch_img_scale(bug->spy_img[rw], &tmp_img, spyw, spyh);
510  switch_img_free(&bug->spy_img[rw]);
511  bug->spy_img[rw] = tmp_img;
512  }
513 
514  switch_img_patch(img, bug->spy_img[rw], w - spyw, h - spyh);
515  }
516  break;
517  }
518 
519  return SWITCH_STATUS_SUCCESS;
520  }
521 
522  return SWITCH_STATUS_FALSE;
523 }
struct apr_queue_t switch_queue_t
Definition: switch_apr.h:590
unsigned int switch_queue_size(switch_queue_t *queue)
Definition: switch_apr.c:1114
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:1140
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:560
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.
switch_status_t
Common return values.
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:1109
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.
uint32_t switch_core_media_bug_patch_video ( switch_core_session_t orig_session,
switch_frame_t frame 
)

Definition at line 1012 of file switch_core_media_bug.c.

References switch_media_bug::callback, switch_media_bug::function, 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.

1013 {
1014  switch_media_bug_t *bp;
1015  uint32_t x = 0, ok = SWITCH_TRUE, prune = 0;
1016 
1017  if (orig_session->bugs) {
1018  switch_thread_rwlock_rdlock(orig_session->bug_rwlock);
1019  for (bp = orig_session->bugs; bp; bp = bp->next) {
1020  if (!switch_test_flag(bp, SMBF_PRUNE) && !switch_test_flag(bp, SMBF_LOCK) && !strcmp(bp->function, "patch:video")) {
1021  if (bp->ready && frame->img && switch_test_flag(bp, SMBF_VIDEO_PATCH)) {
1022  bp->video_ping_frame = frame;
1023  if (bp->callback) {
1025  || (bp->stop_time && bp->stop_time <= switch_epoch_time_now(NULL))) {
1026  ok = SWITCH_FALSE;
1027  }
1028  }
1029  bp->video_ping_frame = NULL;
1030  }
1031 
1032  if (ok == SWITCH_FALSE) {
1034  prune++;
1035  } else x++;
1036  }
1037  }
1038  switch_thread_rwlock_unlock(orig_session->bug_rwlock);
1039  if (prune) {
1040  switch_core_media_bug_prune(orig_session);
1041  }
1042  }
1043 
1044  return x;
1045 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:263
switch_thread_rwlock_t * bug_rwlock
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
Definition: switch_utils.h:631
switch_media_bug_callback_t callback
switch_status_t switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:227
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:77
time_t switch_epoch_time_now(time_t *t)
Get the current epoch time.
Definition: switch_time.c:321
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:624
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 58 of file switch_core_media_bug.c.

References CF_PAUSE_BUGS, and switch_channel_set_flag.

59 {
61 }
switch_channel_t * channel
#define switch_channel_set_flag(_c, _f)
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 968 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().

969 {
970  switch_media_bug_t *bp;
971 
972  if (orig_session->bugs) {
974  for (bp = orig_session->bugs; bp; bp = bp->next) {
975  if (!strcmp(bp->function, function)) {
977  break;
978  }
979  }
981 
982  if (bp) {
983  *pop = bp;
984  return SWITCH_STATUS_SUCCESS;
985  } else {
986  *pop = NULL;
987  }
988  }
989 
990  return SWITCH_STATUS_FALSE;
991 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:263
switch_thread_rwlock_t * bug_rwlock
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
Definition: switch_utils.h:631
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:237
switch_media_bug_t * bugs
struct switch_media_bug * next
uint32_t switch_core_media_bug_prune ( switch_core_session_t session)

Definition at line 1253 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(), switch_thread_rwlock_wrlock(), 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_video_frame(), switch_core_session_write_frame(), and switch_core_session_write_video_frame().

1254 {
1255  switch_media_bug_t *bp = NULL, *last = NULL;
1256  int ttl = 0;
1257 
1258 
1259  top:
1260 
1262  if (session->bugs) {
1263  for (bp = session->bugs; bp; bp = bp->next) {
1265  if (last) {
1266  last->next = bp->next;
1267  } else {
1268  session->bugs = bp->next;
1269  }
1270  break;
1271  }
1272 
1273  last = bp;
1274  }
1275  }
1276 
1277  if (!session->bugs && switch_core_codec_ready(&session->bug_codec)) {
1279  }
1280 
1282 
1283  if (bp) {
1285  bp->thread_id = 0;
1287  ttl++;
1288  goto top;
1289  }
1290 
1291  return ttl;
1292 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:263
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:655
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:237
switch_status_t switch_core_media_bug_close(switch_media_bug_t **bug)
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_push_spy_frame ( switch_media_bug_t bug,
switch_frame_t frame,
switch_rw_t  rw 
)

Definition at line 645 of file switch_core_media_bug.c.

References switch_assert, switch_img_copy(), switch_queue_push(), SWITCH_STATUS_FALSE, and SWITCH_STATUS_SUCCESS.

Referenced by video_eavesdrop_callback().

646 {
647 
648  switch_assert(bug);
649  switch_assert(frame);
650 
651  if (bug->spy_video_queue[rw] && frame->img) {
652  switch_image_t *img = NULL;
653 
654  switch_img_copy(frame->img, &img);
655 
656  if (img) {
657  switch_queue_push(bug->spy_video_queue[rw], img);
658  return SWITCH_STATUS_SUCCESS;
659  }
660  }
661 
662  return SWITCH_STATUS_FALSE;
663 }
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:77
switch_status_t switch_queue_push(switch_queue_t *queue, void *data)
Definition: switch_apr.c:1129
#define switch_assert(expr)
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
the amount of data

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 
)
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_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 1295 of file switch_core_media_bug.c.

References 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_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().

1296 {
1297  switch_media_bug_t *cur = NULL, *bp = NULL, *last = NULL;
1298  int total = 0;
1299 
1301  if (session->bugs) {
1302  bp = session->bugs;
1303  while (bp) {
1304  cur = bp;
1305  bp = bp->next;
1306 
1307  if ((!cur->thread_id || cur->thread_id == switch_thread_self()) && cur->ready && cur->callback == callback) {
1308  if (last) {
1309  last->next = cur->next;
1310  } else {
1311  session->bugs = cur->next;
1312  }
1314  total++;
1315  }
1316  } else {
1317  last = cur;
1318  }
1319  }
1320  }
1321 
1322  if (!session->bugs && switch_core_codec_ready(&session->bug_codec)) {
1324  }
1325 
1327 
1328 
1329  return total ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
1330 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:263
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.
pack cur
switch_media_bug_callback_t callback
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:237
switch_status_t switch_core_media_bug_close(switch_media_bug_t **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)
switch_thread_id_t switch_thread_self(void)
Definition: switch_apr.c:79
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 63 of file switch_core_media_bug.c.

References CF_PAUSE_BUGS, and switch_channel_clear_flag().

64 {
66 }
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.
uint32_t switch_core_media_bug_set_flag ( _In_ switch_media_bug_t bug,
_In_ uint32_t  flag 
)
switch_status_t switch_core_media_bug_set_pre_buffer_framecount ( switch_media_bug_t bug,
uint32_t  framecount 
)

Definition at line 176 of file switch_core_media_bug.c.

References SWITCH_STATUS_SUCCESS.

Referenced by switch_ivr_record_session().

177 {
178  bug->record_pre_buffer_max = framecount;
179 
180  return SWITCH_STATUS_SUCCESS;
181 }
uint32_t record_pre_buffer_max
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.

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

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

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_video_frame(), switch_core_session_write_frame(), switch_core_session_write_video_frame(), switch_ivr_eavesdrop_session(), and video_eavesdrop_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 925 of file switch_core_media_bug.c.

References cur, 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_STATUS_FALSE, SWITCH_STATUS_SUCCESS, switch_thread_rwlock_unlock(), and switch_thread_rwlock_wrlock().

Referenced by switch_ivr_transfer_recordings().

927 {
928  switch_media_bug_t *new_bug = NULL, *cur = NULL, *bp = NULL, *last = NULL;
929  int total = 0;
930 
932  bp = orig_session->bugs;
933  while (bp) {
934  cur = bp;
935  bp = bp->next;
936 
937  if (cur->callback == callback) {
938  if (last) {
939  last->next = cur->next;
940  } else {
941  orig_session->bugs = cur->next;
942  }
943 
944  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(orig_session), SWITCH_LOG_DEBUG, "Transfering %s from %s to %s\n", cur->target,
945  switch_core_session_get_name(orig_session), switch_core_session_get_name(new_session));
946 
947  switch_core_media_bug_add(new_session, cur->function, cur->target, cur->callback,
948  user_data_dup_func(new_session, cur->user_data),
949  cur->stop_time, cur->flags, &new_bug);
951  total++;
952  } else {
953  last = cur;
954  }
955  }
956 
957  if (!orig_session->bugs && switch_core_codec_ready(&orig_session->bug_codec)) {
958  switch_core_codec_destroy(&orig_session->bug_codec);
959  }
960 
962 
963 
965 }
static void switch_core_media_bug_destroy(switch_media_bug_t *bug)
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:263
#define SWITCH_CHANNEL_SESSION_LOG(x)
switch_thread_rwlock_t * bug_rwlock
switch_session_flag_t flags
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:271
pack cur
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:237
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_status_t switch_core_media_bug_transfer_recordings ( switch_core_session_t orig_session,
switch_core_session_t new_session 
)

Definition at line 877 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_DEBUG, 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(), and switch_ivr_originate().

878 {
879  switch_media_bug_t *bp;
880  char *list[100] = { 0 };
881  int stop_times[100] = { 0 };
882  int i = 0, x = 0;
883 
884  if (orig_session->bugs) {
885  switch_channel_t *new_channel = switch_core_session_get_channel(new_session);
886  switch_channel_t *orig_channel = switch_core_session_get_channel(orig_session);
887  const char *save_append = switch_channel_get_variable(new_channel, "record_append");
888  const char *save_stereo = switch_channel_get_variable(new_channel, "record_stereo");
889  const char *orig_stereo = switch_channel_get_variable(orig_channel, "record_stereo");
890  const char *new_stereo = orig_stereo;
891 
893  switch_channel_set_variable(new_channel, "RECORD_MIN_SEC", "0");
894  switch_channel_set_variable(new_channel, "record_append", "true");
895  switch_channel_set_variable(new_channel, "record_stereo", new_stereo);
896 
897  for (bp = orig_session->bugs; bp; bp = bp->next) {
898  if (!strcmp(bp->function, "session_record")) {
899  list[x] = switch_core_session_strdup(new_session, bp->target);
900  if (bp->stop_time > 0) {
901  stop_times[x] = (int)(bp->stop_time - switch_epoch_time_now(NULL));
902  }
903  x++;
904  }
905  }
906 
908 
909  for(i = 0; i < x; i++) {
910  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(orig_session), SWITCH_LOG_DEBUG, "Transfering %s from %s to %s\n", list[i],
911  switch_core_session_get_name(orig_session), switch_core_session_get_name(new_session));
912  switch_ivr_stop_record_session(orig_session, list[i]);
913  switch_ivr_record_session(new_session, list[i], stop_times[i], NULL);
914  }
915 
916  switch_channel_set_variable(new_channel, "record_append", save_append);
917  switch_channel_set_variable(new_channel, "record_stereo", save_stereo);
918 
919  }
920 
922 }
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:263
#define SWITCH_CHANNEL_SESSION_LOG(x)
switch_thread_rwlock_t * bug_rwlock
switch_status_t switch_ivr_stop_record_session(switch_core_session_t *session, const char *file)
Stop Recording a session.
#define switch_core_session_get_name(_s)
Definition: switch_core.h:271
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
Definition: switch_apr.c:237
#define switch_channel_get_variable(_c, _v)
switch_media_bug_t * bugs
struct switch_media_bug * next
switch_status_t switch_ivr_record_session(switch_core_session_t *session, char *file, uint32_t limit, switch_file_handle_t *fh)
Record a session to disk.
time_t switch_epoch_time_now(time_t *t)
Get the current epoch time.
Definition: switch_time.c:321
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_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
Definition: switch_core.h:717
#define switch_channel_set_variable(_channel, _var, _val)
void switch_core_screen_size ( int *  x,
int *  y 
)

Definition at line 238 of file switch_core.c.

Referenced by switch_core_init_and_modload().

239 {
240 
241 #ifdef WIN32
242  CONSOLE_SCREEN_BUFFER_INFO csbi;
243  int ret;
244 
245  if ((ret = GetConsoleScreenBufferInfo(GetStdHandle( STD_OUTPUT_HANDLE ), &csbi))) {
246  if (x) *x = csbi.dwSize.X;
247  if (y) *y = csbi.dwSize.Y;
248  }
249 
250 #elif defined(TIOCGWINSZ)
251  struct winsize w;
252  ioctl(0, TIOCGWINSZ, &w);
253 
254  if (x) *x = w.ws_col;
255  if (y) *y = w.ws_row;
256 #else
257  if (x) *x = 80;
258  if (y) *y = 24;
259 #endif
260 
261 }
void switch_core_session_disable_heartbeat ( switch_core_session_t session)

Definition at line 1605 of file switch_core_session.c.

References switch_assert, and switch_core_session_unsched_heartbeat().

1606 {
1608  switch_assert(session != NULL);
1609  session->read_frame_count = 0;
1610  session->track_duration = 0;
1611 
1612 }
void switch_core_session_unsched_heartbeat(switch_core_session_t *session)
#define switch_assert(expr)
void switch_core_session_enable_heartbeat ( switch_core_session_t session,
uint32_t  seconds 
)

Definition at line 1572 of file switch_core_session.c.

References CF_PROXY_MODE, 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, and switch_true().

Referenced by switch_channel_perform_mark_answered(), and switch_core_media_receive_message().

1573 {
1574  switch_assert(session != NULL);
1575 
1576  if (!seconds) {
1577  seconds = 60;
1578  }
1579 
1580  session->track_duration = seconds;
1581 
1583  switch_true(switch_channel_get_variable_dup(session->channel, "heartbeat_use_scheduler", SWITCH_FALSE, -1)) ||
1584  switch_true(switch_channel_get_variable_dup(session->channel, "bypass_media", SWITCH_FALSE, -1)) ||
1585  switch_true(switch_channel_get_variable_dup(session->channel, "bypass_media_after_bridge", SWITCH_FALSE, -1))) {
1586  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s using scheduler due to bypass media or media is not established.\n",
1587  switch_channel_get_name(session->channel));
1588  switch_core_session_sched_heartbeat(session, seconds);
1589  return;
1590  }
1591 
1592  if (switch_true(switch_channel_get_variable(session->channel, "heartbeat_fire_on_set"))) {
1593  session->read_frame_count = 0;
1594  } else {
1595  session->read_frame_count = (session->read_impl.samples_per_second / session->read_impl.samples_per_packet) * seconds;
1596  }
1597 
1599 
1600  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "%s setting session heartbeat to %u second(s).\n",
1601  switch_channel_get_name(session->channel), seconds);
1602 
1603 }
#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.
static int switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
Definition: switch_utils.h:450
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.
void switch_core_session_sched_heartbeat ( switch_core_session_t session,
uint32_t  seconds 
)

Definition at line 1557 of file switch_core_session.c.

References __SWITCH_FUNC__, 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(), and switch_true().

Referenced by switch_core_session_enable_heartbeat().

1558 {
1559  time_t when;
1560 
1562  if (switch_true(switch_channel_get_variable(session->channel, "heartbeat_fire_on_set"))) {
1563  when = switch_epoch_time_now(NULL);
1564  } else {
1565  when = switch_epoch_time_now(NULL) + session->track_duration;
1566  }
1567 
1568  session->track_id = switch_scheduler_add_task(when, sch_heartbeat_callback, (char *) __SWITCH_FUNC__,
1570 }
#define __SWITCH_FUNC__
void switch_core_session_unsched_heartbeat(switch_core_session_t *session)
static int switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
Definition: switch_utils.h:450
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:321
char * switch_core_session_get_uuid(switch_core_session_t *session)
void switch_core_session_unsched_heartbeat ( switch_core_session_t session)

Definition at line 1549 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().

1550 {
1551  if (session->track_id) {
1553  session->track_id = 0;
1554  }
1555 }
uint32_t switch_scheduler_del_task_id(uint32_t task_id)
Delete a scheduled task.
switch_vid_spy_fmt_t switch_media_bug_parse_spy_fmt ( const char *  name)

Definition at line 394 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().

395 {
396  if (zstr(name)) goto end;
397 
398  if (!strcasecmp(name, "dual-crop")) {
399  return SPY_DUAL_CROP;
400  }
401 
402  if (!strcasecmp(name, "lower-right-large")) {
403  return SPY_LOWER_RIGHT_LARGE;
404  }
405 
406  end:
407 
408  return SPY_LOWER_RIGHT_SMALL;
409 }
#define zstr(x)
Definition: switch_utils.h:281
void switch_media_bug_set_spy_fmt ( switch_media_bug_t bug,
switch_vid_spy_fmt_t  spy_fmt 
)

Definition at line 411 of file switch_core_media_bug.c.

Referenced by switch_ivr_eavesdrop_session().

412 {
413  bug->spy_fmt = spy_fmt;
414 }
switch_vid_spy_fmt_t spy_fmt