57 for (i = 0; i < 2; i++) {
242 switch_size_t do_read = 0, do_write = 0, has_read = 0, has_write = 0, fill_read = 0, fill_write = 0;
248 if (frame->
buflen < bytes) {
256 "%s Buffer Error (raw_read_buffer=%p, raw_write_buffer=%p, read=%s, write=%s)\n",
303 if ((has_read && !do_read)) {
307 if ((has_write && !do_write)) {
313 if ((do_read && do_read < bug->record_frame_size) || (do_write && do_write < bug->record_frame_size)) {
326 if ((fill_read && fill_write) || (fill && (fill_read || fill_write))) {
341 if (frame->
datalen != do_read) {
348 }
else if (fill_read) {
349 frame->
datalen = (uint32_t)bytes;
357 if (datalen != do_write) {
364 }
else if (fill_write) {
370 dp = (int16_t *) bug->
data;
371 fp = (int16_t *) frame->
data;
374 blen = (uint32_t)(bytes / 2);
377 int16_t *left, *right;
378 size_t left_len, right_len;
390 for (x = 0; x < blen; x++) {
392 *(tp++) = *(left + x);
397 *(tp++) = *(right + x);
402 memcpy(frame->
data, bug->
tmp, bytes * 2);
404 for (x = 0; x < blen; x++) {
405 int32_t w = 0, r = 0, z = 0;
408 r = (int32_t) * (fp + x);
412 w = (int32_t) * (dp + x);
424 *(fp + x) = (int16_t) z;
428 frame->
datalen = (uint32_t)bytes;
445 if (
zstr(name))
goto end;
447 if (!strcasecmp(name,
"dual-crop")) {
451 if (!strcasecmp(name,
"lower-right-large")) {
472 for (i = 0; i < 2; i++) {
501 float aspect169 = (float)1920 / 1080;
504 if ((
float)w/h == aspect169) {
544 float scaler = 0.125f;
551 spyw = (int) (
float)w * scaler;
552 spyh = (int) (
float)h * scaler;
595 void *pop, *other_pop;
603 int last_w = 0, last_h = 0, other_last_w = 0, other_last_h = 0;
611 frame.
data = buf + 12;
613 frame.
buflen = buflen - 12;
630 if (mm.
vw) vw = mm.
vw;
631 if (mm.
vh) vh = mm.
vh;
643 int w = 0, h = 0, ok = 1, new_main = 0, new_other = 0, new_canvas = 0;
668 if (IMG && !(last_w == img->d_w && last_h == img->d_h)) {
683 if (IMG && !(other_last_w == other_img->d_w && other_last_h == other_img->d_h)) {
687 other_last_w = other_img->d_w;
688 other_last_h = other_img->d_h;
693 if (img && new_main) {
697 if (other_img && new_other) {
712 if (img && (new_canvas || new_main)) {
719 if (other_img && (new_canvas || new_other)) {
729 frame.
img = other_q ? IMG : img;
793 #define MAX_BUG_BUFFER 1024 * 512 795 const char *
function,
798 void *user_data, time_t stop_time,
805 int tap_only = 1, punt = 0, added = 0;
809 if (!
zstr(
function)) {
812 for (bp = session->
bugs; bp; bp = bp->
next) {
846 for (bp = session->
bugs; bp; bp = bp->
next) {
858 for (bp = session->
bugs; bp; bp = bp->
next) {
979 if (!session->
bugs) {
990 for(bp = session->
bugs; bp; bp = bp->
next) {
995 if (!added && !bp->
next) {
1031 if (session->
bugs) {
1033 for (bp = session->
bugs; bp; bp = bp->
next) {
1047 switch_media_bug_t *new_bug = NULL, *
cur = NULL, *bp = NULL, *last = NULL, *old_last_next = NULL, *old_bugs = NULL;
1056 bp = orig_session->
bugs;
1061 if (cur->callback == callback) {
1063 old_last_next = last->
next;
1066 old_bugs = orig_session->
bugs;
1074 user_data_dup_func(new_session, cur->user_data),
1080 user_data_dup_func(orig_session, cur->user_data);
1086 last->next = old_last_next;
1088 orig_session->
bugs = old_bugs;
1113 if (orig_session->
bugs) {
1115 for (bp = orig_session->
bugs; bp; bp = bp->
next) {
1116 if (!strcmp(bp->
function,
function)) {
1140 if (orig_session->
bugs) {
1142 for (bp = orig_session->
bugs; bp; bp = bp->
next) {
1158 if (orig_session->
bugs) {
1160 for (bp = orig_session->
bugs; bp; bp = bp->
next) {
1196 if (orig_session->
bugs) {
1198 for (bp = orig_session->
bugs; bp; bp = bp->
next) {
1216 if (session->
bugs) {
1218 for (bp = session->
bugs; bp; bp = bp->
next) {
1222 " <function>%s</function>\n" 1223 " <target>%s</target>\n" 1224 " <thread-locked>%d</thread-locked>\n" 1244 if (session->
bugs) {
1245 for (bp = session->
bugs; bp; bp = next) {
1255 if (!
zstr(
function) && strcmp(bp->
function,
function)) {
1277 for (bp = closed; bp; bp = next) {
1350 if (session->
bugs) {
1351 for (bp = session->
bugs; bp; bp = bp->
next) {
1354 last->next = bp->
next;
1369 if (session->
bugs) {
1370 for(bp2 = session->
bugs; bp2; bp2 = bp2->
next) {
1402 if (session->
bugs) {
1403 for (bp = session->
bugs; bp; bp = bp->
next) {
1406 last->next = bp->
next;
1441 if (session->
bugs) {
1468 for (bp = closed; bp; bp = next) {
switch_frame_t * switch_core_media_bug_get_video_ping_frame(switch_media_bug_t *bug)
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
unsigned int switch_queue_size(switch_queue_t *queue)
void switch_channel_set_flag_recursive(switch_channel_t *channel, switch_channel_flag_t flag)
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
#define SWITCH_BUFFER_START_FRAMES
static switch_bool_t switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
#define SWITCH_CHANNEL_SESSION_LOG(x)
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
switch_thread_rwlock_t * bug_rwlock
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
switch_status_t switch_core_timer_init(switch_timer_t *timer, const char *timer_name, int interval, int samples, switch_memory_pool_t *pool)
Request a timer handle using given time module.
switch_size_t switch_buffer_read(_In_ switch_buffer_t *buffer, _In_ void *data, _In_ switch_size_t datalen)
Read data from a switch_buffer_t up to the ammount of datalen if it is available. Remove read data fr...
void switch_img_free(switch_image_t **img)
Close an image descriptor.
switch_session_flag_t flags
switch_status_t switch_buffer_create_dynamic(_Out_ switch_buffer_t **buffer, _In_ switch_size_t blocksize, _In_ switch_size_t start_len, _In_ switch_size_t max_len)
Allocate a new dynamic switch_buffer.
switch_frame_t * switch_core_media_bug_get_native_read_frame(switch_media_bug_t *bug)
#define SWITCH_RECOMMENDED_BUFFER_SIZE
void switch_channel_event_set_data(_In_ switch_channel_t *channel, _In_ switch_event_t *event)
Add information about a given channel to an event object.
switch_bool_t(* switch_media_bug_callback_t)(switch_media_bug_t *, void *, switch_abc_type_t)
void switch_core_media_bug_set_media_params(switch_media_bug_t *bug, switch_mm_t *mm)
switch_codec_t * video_read_codec
switch_status_t switch_threadattr_stacksize_set(switch_threadattr_t *attr, switch_size_t stacksize)
uint32_t decoded_bytes_per_packet
switch_memory_pool_t * pool
void switch_core_media_bug_inuse(switch_media_bug_t *bug, switch_size_t *readp, switch_size_t *writep)
switch_status_t switch_event_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *fmt,...) PRINTF_FUNCTION(4
Add a header to an event.
Representation of an event.
switch_status_t switch_core_media_bug_set_pre_buffer_framecount(switch_media_bug_t *bug, uint32_t framecount)
void switch_media_bug_set_spy_fmt(switch_media_bug_t *bug, switch_vid_spy_fmt_t spy_fmt)
#define SWITCH_RTP_MAX_BUF_LEN
switch_status_t switch_queue_trypop(switch_queue_t *queue, void **data)
uint32_t switch_core_media_bug_count(switch_core_session_t *orig_session, const char *function)
#define switch_channel_media_ready(_channel)
void switch_core_media_bug_pause(switch_core_session_t *session)
Pause a media bug on the session.
switch_status_t switch_core_codec_destroy(switch_codec_t *codec)
Destroy an initalized codec handle.
#define switch_calc_video_fps(fpsP, fps)
#define switch_core_session_get_name(_s)
switch_status_t switch_core_media_bug_patch_spy_frame(switch_media_bug_t *bug, switch_image_t *img, switch_rw_t rw)
Abstract handler to a timer module.
static switch_thread_t * thread
switch_status_t switch_core_media_bug_enumerate(switch_core_session_t *session, switch_stream_handle_t *stream)
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.
void switch_img_find_position(switch_img_position_t pos, int sw, int sh, int iw, int ih, int *xP, int *yP)
switch_image_t * switch_img_alloc(switch_image_t *img, switch_img_fmt_t fmt, unsigned int d_w, unsigned int d_h, unsigned int align)
Open a descriptor, allocating storage for the underlying image.
const char * switch_core_media_bug_get_text(switch_media_bug_t *bug)
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
switch_status_t switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock)
switch_status_t switch_core_session_get_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
#define switch_clear_flag(obj, flag)
Clear a flag on an arbitrary object while locked.
#define SWITCH_MUTEX_NESTED
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
switch_status_t switch_core_media_bug_pop(switch_core_session_t *orig_session, const char *function, switch_media_bug_t **pop)
switch_size_t switch_buffer_toss(_In_ switch_buffer_t *buffer, _In_ switch_size_t datalen)
Remove data from the buffer.
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_byte_t switch_byte_t * buf
uint32_t switch_core_media_bug_prune(switch_core_session_t *session)
switch_channel_t * channel
#define SWITCH_CORE_QUEUE_LEN
switch_frame_flag_t flags
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
uint32_t actual_samples_per_second
switch_status_t switch_core_media_bug_push_spy_frame(switch_media_bug_t *bug, switch_frame_t *frame, switch_rw_t rw)
#define switch_channel_get_variable(_c, _v)
#define SWITCH_THREAD_STACKSIZE
switch_status_t switch_core_media_bug_remove_callback(switch_core_session_t *session, switch_media_bug_callback_t callback)
Remove media bug callback.
#define switch_zmalloc(ptr, len)
void switch_img_copy(switch_image_t *img, switch_image_t **new_img)
Copy image to a new image.
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
switch_status_t switch_img_fit(switch_image_t **srcP, int width, int height, switch_img_fit_t fit)
switch_status_t switch_mutex_init(switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool)
switch_status_t switch_thread_join(switch_status_t *retval, switch_thread_t *thd)
switch_media_bug_t * bugs
void switch_buffer_zero(_In_ switch_buffer_t *buffer)
Remove all data from the buffer.
An abstraction of a data frame.
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_vid_spy_fmt_t switch_media_bug_parse_spy_fmt(const char *name)
switch_byte_t switch_byte_t uint32_t buflen
switch_status_t switch_img_scale(switch_image_t *src, switch_image_t **destP, int width, int height)
switch_status_t switch_core_session_get_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
void switch_color_set_rgb(switch_rgb_color_t *color, const char *color_str)
Set RGB color with a string.
switch_status_t switch_core_timer_destroy(switch_timer_t *timer)
Destroy an allocated timer.
void switch_core_media_bug_get_media_params(switch_media_bug_t *bug, switch_mm_t *mm)
switch_status_t switch_core_timer_next(switch_timer_t *timer)
Wait for one cycle on an existing timer.
switch_stream_handle_write_function_t write_function
uint8_t number_of_channels
switch_memory_pool_t * pool
switch_status_t
Common return values.
const cJSON *const target
uint32_t switch_core_media_bug_patch_video(switch_core_session_t *orig_session, switch_frame_t *frame)
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.
#define switch_event_create(event, id)
Create a new event assuming it will not be custom event and therefore hiding the unused parameters...
void switch_core_media_bug_resume(switch_core_session_t *session)
Resume a media bug on the session.
#define switch_channel_set_flag(_c, _f)
#define SWITCH_IMG_FMT_I420
switch_codec_implementation_t read_impl
time_t switch_epoch_time_now(time_t *t)
Get the current epoch time.
#define switch_core_session_alloc(_session, _memory)
Allocate memory from a session's pool.
switch_status_t switch_queue_push(switch_queue_t *queue, void *data)
void(* switch_media_bug_exec_cb_t)(switch_media_bug_t *bug, void *user_data)
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
void switch_channel_clear_flag_recursive(switch_channel_t *channel, switch_channel_flag_t flag)
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_threadattr_create(switch_threadattr_t **new_attr, switch_memory_pool_t *pool)
switch_status_t switch_thread_create(switch_thread_t **new_thread, switch_threadattr_t *attr, switch_thread_start_t func, void *data, switch_memory_pool_t *cont)
A table of settings and callbacks that define a paticular implementation of a codec.
#define switch_normalize_to_16bit(n)
uint32_t switch_media_bug_flag_t
switch_frame_t * switch_core_media_bug_get_native_write_frame(switch_media_bug_t *bug)
struct fspr_pool_t switch_memory_pool_t
switch_status_t switch_queue_create(switch_queue_t **queue, unsigned int queue_capacity, switch_memory_pool_t *pool)
#define switch_core_session_strdup(_session, _todup)
Copy a string using memory allocation from a session's pool.
switch_thread_id_t switch_thread_self(void)
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)
void switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Clear given flag(s) from a channel.
struct fspr_thread_t switch_thread_t
#define switch_channel_pre_answer(channel)
Indicate progress on a channel to attempt early media.
#define SWITCH_BUFFER_BLOCK_FRAMES
switch_size_t switch_buffer_inuse(_In_ switch_buffer_t *buffer)
Get the in use amount of a switch_buffer_t.
void switch_buffer_destroy(switch_buffer_t **buffer)
Destroy the buffer.
char * switch_channel_get_name(switch_channel_t *channel)
Retrieve the name of a given channel.
switch_memory_pool_t * switch_core_session_get_pool(_In_ switch_core_session_t *session)
Retrieve the memory pool from a session.