fix emacs tabs mode
This commit is contained in:
Anthony Minessale 2015-04-17 18:00:19 -05:00 committed by Michael Jerris
parent 48c21b6998
commit d697acb281
14 changed files with 184 additions and 182 deletions

View File

@ -391,7 +391,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_bert_shutdown)
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:
* mode:c * mode:c
* indent-tabs-mode:nil * indent-tabs-mode:t
* tab-width:4 * tab-width:4
* c-basic-offset:4 * c-basic-offset:4
* End: * End:

View File

@ -1,4 +1,4 @@
/* /*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org> * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
* *
@ -22,7 +22,7 @@
* the Initial Developer. All Rights Reserved. * the Initial Developer. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
* *
* Anthony Minessale II <anthm@freeswitch.org> * Anthony Minessale II <anthm@freeswitch.org>
* Seven Du <dujinfang@gmail.com> * Seven Du <dujinfang@gmail.com>
* *
@ -129,7 +129,7 @@ typedef struct cv_context_s {
int tick_x; int tick_x;
uint32_t overlay_idx; uint32_t overlay_idx;
uint32_t overlay_count; uint32_t overlay_count;
switch_core_session_t *session; switch_core_session_t *session;
char *cascade_path; char *cascade_path;
char *nested_cascade_path; char *nested_cascade_path;
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
@ -174,7 +174,7 @@ static void context_render_text(cv_context_t *context, struct overlay *overlay,
switch_rgb_color_t bgcolor = { 0 }; switch_rgb_color_t bgcolor = { 0 };
int width, font_size = 0; int width, font_size = 0;
int w, h; int w, h;
if (!(context->w && context->h)) return; if (!(context->w && context->h)) return;
w = context->w; w = context->w;
@ -201,19 +201,19 @@ static void context_render_text(cv_context_t *context, struct overlay *overlay,
width = (int) (float)(font_size * 0.75f * len); width = (int) (float)(font_size * 0.75f * len);
switch_color_set_rgb(&bgcolor, overlay->bg); switch_color_set_rgb(&bgcolor, overlay->bg);
if (!overlay->png || (overlay->png->d_w != width || overlay->png->d_h != font_size * 2)) { if (!overlay->png || (overlay->png->d_w != width || overlay->png->d_h != font_size * 2)) {
switch_img_free(&overlay->png); switch_img_free(&overlay->png);
overlay->png = switch_img_alloc(NULL, SWITCH_IMG_FMT_I420, width, font_size * 2, 1); overlay->png = switch_img_alloc(NULL, SWITCH_IMG_FMT_I420, width, font_size * 2, 1);
} }
switch_img_txt_handle_destroy(&overlay->txthandle); switch_img_txt_handle_destroy(&overlay->txthandle);
switch_img_txt_handle_create(&overlay->txthandle, overlay->font_face, overlay->fg, overlay->bg, font_size, 0, NULL); switch_img_txt_handle_create(&overlay->txthandle, overlay->font_face, overlay->fg, overlay->bg, font_size, 0, NULL);
switch_img_fill(overlay->png, 0, 0, overlay->png->d_w, overlay->png->d_h, &bgcolor); switch_img_fill(overlay->png, 0, 0, overlay->png->d_w, overlay->png->d_h, &bgcolor);
switch_img_txt_handle_render(overlay->txthandle, switch_img_txt_handle_render(overlay->txthandle,
overlay->png, overlay->png,
font_size / 2, font_size / 2, font_size / 2, font_size / 2,
text, NULL, overlay->fg, overlay->bg, 0, 0); text, NULL, overlay->fg, overlay->bg, 0, 0);
@ -225,7 +225,7 @@ static void context_render_text(cv_context_t *context, struct overlay *overlay,
static void check_text(cv_context_t *context) static void check_text(cv_context_t *context)
{ {
int i; int i;
for (i = 0; i < context->overlay_count; i++) { for (i = 0; i < context->overlay_count; i++) {
struct overlay *overlay = context->overlay[i]; struct overlay *overlay = context->overlay[i];
@ -263,7 +263,7 @@ static void ticker_tick(cv_context_t *context, switch_image_t *IMG)
if (context->tick_x < 0) { if (context->tick_x < 0) {
img = switch_img_copy_rect(context->ticker->png, img = switch_img_copy_rect(context->ticker->png,
abs(context->tick_x), 0, abs(context->tick_x), 0,
context->ticker->png->d_w - abs(context->tick_x), context->ticker->png->d_h); context->ticker->png->d_w - abs(context->tick_x), context->ticker->png->d_h);
} }
@ -421,7 +421,7 @@ static int add_overlay(cv_context_t *context, const char *png_path, const char *
context->overlay[i]->png_path = new_png_path; context->overlay[i]->png_path = new_png_path;
if (!zstr(nick)) { if (!zstr(nick)) {
context->overlay[i]->nick = switch_core_strdup(context->pool, nick); context->overlay[i]->nick = switch_core_strdup(context->pool, nick);
} }
r = (int) i; r = (int) i;
} else { } else {
context->overlay[i]->png_path = NULL; context->overlay[i]->png_path = NULL;
@ -528,7 +528,7 @@ static void parse_stats(struct detect_stats *stats, uint32_t size, uint64_t skip
if (stats->itr >= 500) { if (stats->itr >= 500) {
reset_stats(stats); reset_stats(stats);
} }
if (stats->itr >= 60) { if (stats->itr >= 60) {
if (stats->last_score > stats->avg + 10) { if (stats->last_score > stats->avg + 10) {
stats->above_avg_simo_count += skip; stats->above_avg_simo_count += skip;
@ -578,7 +578,7 @@ void detectAndDraw(cv_context_t *context)
int i = 0; int i = 0;
vector<Rect> detectedObjs, detectedObjs2; vector<Rect> detectedObjs, detectedObjs2;
const static Scalar colors[] = { CV_RGB(0,0,255), const static Scalar colors[] = { CV_RGB(0,0,255),
CV_RGB(0,128,255), CV_RGB(0,128,255),
CV_RGB(0,255,255), CV_RGB(0,255,255),
CV_RGB(0,255,0), CV_RGB(0,255,0),
@ -617,13 +617,13 @@ void detectAndDraw(cv_context_t *context)
Point center; Point center;
Scalar color = colors[i%8]; Scalar color = colors[i%8];
int radius; int radius;
double aspect_ratio = (double)r->width/r->height; double aspect_ratio = (double)r->width/r->height;
if (context->shape_idx >= MAX_SHAPES) { if (context->shape_idx >= MAX_SHAPES) {
break; break;
} }
if(0.75 < aspect_ratio && aspect_ratio < 1.3 ) { if(0.75 < aspect_ratio && aspect_ratio < 1.3 ) {
center.x = switch_round_to_step(cvRound((r->x + r->width*0.5)*scale), 20); center.x = switch_round_to_step(cvRound((r->x + r->width*0.5)*scale), 20);
@ -651,7 +651,7 @@ void detectAndDraw(cv_context_t *context)
context->shape[context->shape_idx].h = context->shape[context->shape_idx].y2 - context->shape[context->shape_idx].y; context->shape[context->shape_idx].h = context->shape[context->shape_idx].y2 - context->shape[context->shape_idx].y;
context->shape[context->shape_idx].cx = context->shape[context->shape_idx].x + (context->shape[context->shape_idx].w / 2); context->shape[context->shape_idx].cx = context->shape[context->shape_idx].x + (context->shape[context->shape_idx].w / 2);
context->shape[context->shape_idx].cy = context->shape[context->shape_idx].y + (context->shape[context->shape_idx].h / 2); context->shape[context->shape_idx].cy = context->shape[context->shape_idx].y + (context->shape[context->shape_idx].h / 2);
if (context->debug || !context->overlay_count) { if (context->debug || !context->overlay_count) {
rectangle( img, cvPoint(context->shape[context->shape_idx].x, context->shape[context->shape_idx].y), rectangle( img, cvPoint(context->shape[context->shape_idx].x, context->shape[context->shape_idx].y),
cvPoint(context->shape[context->shape_idx].x2, context->shape[context->shape_idx].y2), cvPoint(context->shape[context->shape_idx].x2, context->shape[context->shape_idx].y2),
@ -678,7 +678,7 @@ void detectAndDraw(cv_context_t *context)
|CV_HAAR_SCALE_IMAGE |CV_HAAR_SCALE_IMAGE
, ,
Size(30, 30) ); Size(30, 30) );
// Draw rectangle reflecting confidence // Draw rectangle reflecting confidence
@ -689,11 +689,11 @@ void detectAndDraw(cv_context_t *context)
rectangle(img, cvPoint(0, img.rows), cvPoint(img.cols/10, img.rows - rect_height), col, -1); rectangle(img, cvPoint(0, img.rows), cvPoint(img.cols/10, img.rows - rect_height), col, -1);
parse_stats(&context->nestDetected, nestedObjects.size(), context->skip); parse_stats(&context->nestDetected, nestedObjects.size(), context->skip);
//printf("NEST: %d %f %d\n", context->nestDetected.simo_count, context->nestDetected.avg, context->nestDetected.last_score); //printf("NEST: %d %f %d\n", context->nestDetected.simo_count, context->nestDetected.avg, context->nestDetected.last_score);
} }
switch_mutex_unlock(context->mutex); switch_mutex_unlock(context->mutex);
} }
@ -724,7 +724,7 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
if (context->cascade) { if (context->cascade) {
switch_event_t *event; switch_event_t *event;
if (!context->rawImage) { if (!context->rawImage) {
context->rawImage = cvCreateImage(cvSize(context->w, context->h), IPL_DEPTH_8U, 3); context->rawImage = cvCreateImage(cvSize(context->w, context->h), IPL_DEPTH_8U, 3);
switch_assert(context->rawImage); switch_assert(context->rawImage);
@ -738,11 +738,11 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
context->rawImage->width, context->rawImage->height); context->rawImage->width, context->rawImage->height);
detectAndDraw(context); detectAndDraw(context);
if (context->detected.simo_count > 20) { if (context->detected.simo_count > 20) {
if (!context->detect_event) { if (!context->detect_event) {
context->detect_event = 1; context->detect_event = 1;
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_VIDEO_DETECT) == SWITCH_STATUS_SUCCESS) { if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_VIDEO_DETECT) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Detect-Type", "primary"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Detect-Type", "primary");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Detect-Disposition", "start"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Detect-Disposition", "start");
@ -754,9 +754,9 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
DUMP_EVENT(event); DUMP_EVENT(event);
switch_event_fire(&event); switch_event_fire(&event);
} }
switch_channel_execute_on(channel, "execute_on_cv_detect_primary"); switch_channel_execute_on(channel, "execute_on_cv_detect_primary");
} }
} else { } else {
if (context->detected.simo_miss_count >= 20) { if (context->detected.simo_miss_count >= 20) {
@ -773,7 +773,7 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
switch_event_fire(&event); switch_event_fire(&event);
} }
memset(context->shape, 0, sizeof(context->shape[0]) * MAX_SHAPES); memset(context->shape, 0, sizeof(context->shape[0]) * MAX_SHAPES);
switch_channel_execute_on(channel, "execute_on_cv_detect_off_primary"); switch_channel_execute_on(channel, "execute_on_cv_detect_off_primary");
@ -789,7 +789,7 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
if (context->nestedCascade && context->detected.simo_count > 20) { if (context->nestedCascade && context->detected.simo_count > 20) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "CHECKING: %d %d %f %d\n", context->nestDetected.itr, context->nestDetected.last_score, context->nestDetected.avg, context->nestDetected.above_avg_simo_count); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "CHECKING: %d %d %f %d\n", context->nestDetected.itr, context->nestDetected.last_score, context->nestDetected.avg, context->nestDetected.above_avg_simo_count);
if (context->nestDetected.simo_count > 20 && context->nestDetected.last_score > context->nestDetected.avg && if (context->nestDetected.simo_count > 20 && context->nestDetected.last_score > context->nestDetected.avg &&
context->nestDetected.above_avg_simo_count > 5) { context->nestDetected.above_avg_simo_count > 5) {
if (!context->nest_detect_event) { if (!context->nest_detect_event) {
context->nest_detect_event = 1; context->nest_detect_event = 1;
@ -824,7 +824,7 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
switch_channel_execute_on(channel, "execute_on_cv_detect_off_nested"); switch_channel_execute_on(channel, "execute_on_cv_detect_off_nested");
reset_stats(&context->nestDetected); reset_stats(&context->nestDetected);
} }
context->nest_detect_event = 0; context->nest_detect_event = 0;
} }
} }
@ -862,10 +862,10 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
shape_w = context->shape[0].w; shape_w = context->shape[0].w;
shape_h = context->shape[0].h; shape_h = context->shape[0].h;
cx = context->shape[0].cx; cx = context->shape[0].cx;
cy = context->shape[0].cy; cy = context->shape[0].cy;
if (overlay->abs != POS_NONE) { if (overlay->abs != POS_NONE) {
if (overlay->scale_w || overlay->scale_h) { if (overlay->scale_w || overlay->scale_h) {
if (overlay->scale_w && !overlay->scale_h) { if (overlay->scale_w && !overlay->scale_h) {
@ -903,15 +903,15 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
if (overlay->xo) { if (overlay->xo) {
xo = overlay->xo * shape_w; xo = overlay->xo * shape_w;
} }
if (overlay->yo) { if (overlay->yo) {
yo = overlay->yo * context->shape[0].h; yo = overlay->yo * context->shape[0].h;
} }
x = cx - ((scale_w / 2) + xo); x = cx - ((scale_w / 2) + xo);
y = cy - ((scale_h / 2) + yo); y = cy - ((scale_h / 2) + yo);
} }
if (scale_w && scale_h && (overlay->png->d_w != scale_w || overlay->png->d_h != scale_h)) { if (scale_w && scale_h && (overlay->png->d_w != scale_w || overlay->png->d_h != scale_h)) {
switch_img_scale(overlay->png, &img, scale_w, scale_h); switch_img_scale(overlay->png, &img, scale_w, scale_h);
@ -924,7 +924,7 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
} }
} }
} }
if (context->ticker_ready) { if (context->ticker_ready) {
ticker_tick(context, frame->img); ticker_tick(context, frame->img);
} }
@ -952,7 +952,7 @@ static int do_sort(cv_context_t *context)
context->overlay[pos] = swap; context->overlay[pos] = swap;
} }
} }
return 0; return 0;
} }
@ -962,7 +962,7 @@ static void parse_params(cv_context_t *context, int start, int argc, char **argv
char *nick = NULL; char *nick = NULL;
png_count = context->overlay_count; png_count = context->overlay_count;
for (i = start; i < argc ; i ++) { for (i = start; i < argc ; i ++) {
char *name = strdup(argv[i]); char *name = strdup(argv[i]);
char *val = NULL; char *val = NULL;
@ -1004,7 +1004,7 @@ static void parse_params(cv_context_t *context, int start, int argc, char **argv
context->overlay[png_idx]->scale_h = 0; context->overlay[png_idx]->scale_h = 0;
} }
} else if (!strcasecmp(name, "scale")) { } else if (!strcasecmp(name, "scale")) {
context->overlay[png_idx]->shape_scale = atof(val); context->overlay[png_idx]->shape_scale = atof(val);
} else if (!strcasecmp(name, "skip")) { } else if (!strcasecmp(name, "skip")) {
context->skip = atoi(val); context->skip = atoi(val);
} else if (!strcasecmp(name, "debug")) { } else if (!strcasecmp(name, "debug")) {
@ -1097,19 +1097,19 @@ SWITCH_STANDARD_APP(cv_start_function)
char *lbuf; char *lbuf;
char *cascade_path; char *cascade_path;
char *nested_cascade_path; char *nested_cascade_path;
char *argv[25]; char *argv[25];
int argc; int argc;
init_context(&context); init_context(&context);
if (data && (lbuf = switch_core_session_strdup(session, data)) if (data && (lbuf = switch_core_session_strdup(session, data))
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
context.cascade_path = argv[0]; context.cascade_path = argv[0];
context.nested_cascade_path = argv[1]; context.nested_cascade_path = argv[1];
parse_params(&context, 2, argc, argv); parse_params(&context, 2, argc, argv);
} }
switch_channel_answer(channel); switch_channel_answer(channel);
switch_channel_set_flag_recursive(channel, CF_VIDEO_DECODED_READ); switch_channel_set_flag_recursive(channel, CF_VIDEO_DECODED_READ);
switch_channel_set_flag_recursive(channel, CF_VIDEO_ECHO); switch_channel_set_flag_recursive(channel, CF_VIDEO_ECHO);
@ -1118,23 +1118,23 @@ SWITCH_STANDARD_APP(cv_start_function)
switch_core_session_set_video_read_callback(session, video_thread_callback, &context); switch_core_session_set_video_read_callback(session, video_thread_callback, &context);
while (switch_channel_ready(channel)) { while (switch_channel_ready(channel)) {
switch_status_t status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0); switch_status_t status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
if (!SWITCH_READ_ACCEPTABLE(status)) { if (!SWITCH_READ_ACCEPTABLE(status)) {
break; break;
} }
if (switch_test_flag(read_frame, SFF_CNG)) { if (switch_test_flag(read_frame, SFF_CNG)) {
continue; continue;
} }
memset(read_frame->data, 0, read_frame->datalen); memset(read_frame->data, 0, read_frame->datalen);
switch_core_session_write_frame(session, read_frame, SWITCH_IO_FLAG_NONE, 0); switch_core_session_write_frame(session, read_frame, SWITCH_IO_FLAG_NONE, 0);
} }
switch_core_session_set_video_read_callback(session, NULL, NULL); switch_core_session_set_video_read_callback(session, NULL, NULL);
uninit_context(&context); uninit_context(&context);
switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE); switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
@ -1150,75 +1150,75 @@ static switch_bool_t cv_bug_callback(switch_media_bug_t *bug, void *user_data, s
switch_channel_t *channel = switch_core_session_get_channel(context->session); switch_channel_t *channel = switch_core_session_get_channel(context->session);
switch (type) { switch (type) {
case SWITCH_ABC_TYPE_INIT: case SWITCH_ABC_TYPE_INIT:
{ {
switch_channel_set_flag_recursive(channel, CF_VIDEO_DECODED_READ); switch_channel_set_flag_recursive(channel, CF_VIDEO_DECODED_READ);
} }
break; break;
case SWITCH_ABC_TYPE_CLOSE: case SWITCH_ABC_TYPE_CLOSE:
{ {
switch_thread_rwlock_unlock(MODULE_INTERFACE->rwlock); switch_thread_rwlock_unlock(MODULE_INTERFACE->rwlock);
switch_channel_clear_flag_recursive(channel, CF_VIDEO_DECODED_READ); switch_channel_clear_flag_recursive(channel, CF_VIDEO_DECODED_READ);
uninit_context(context); uninit_context(context);
} }
break; break;
case SWITCH_ABC_TYPE_READ_VIDEO_PING: case SWITCH_ABC_TYPE_READ_VIDEO_PING:
{ {
switch_frame_t *frame = switch_core_media_bug_get_video_ping_frame(bug); switch_frame_t *frame = switch_core_media_bug_get_video_ping_frame(bug);
video_thread_callback(context->session, frame, context); video_thread_callback(context->session, frame, context);
} }
break; break;
default: default:
break; break;
} }
return SWITCH_TRUE; return SWITCH_TRUE;
} }
SWITCH_STANDARD_APP(cv_bug_start_function) SWITCH_STANDARD_APP(cv_bug_start_function)
{ {
switch_media_bug_t *bug; switch_media_bug_t *bug;
switch_status_t status; switch_status_t status;
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
cv_context_t *context; cv_context_t *context;
char *lbuf = NULL; char *lbuf = NULL;
int x, n; int x, n;
char *argv[25] = { 0 }; char *argv[25] = { 0 };
int argc; int argc;
if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_cv_bug_"))) { if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_cv_bug_"))) {
if (!zstr(data) && !strcasecmp(data, "stop")) { if (!zstr(data) && !strcasecmp(data, "stop")) {
switch_channel_set_private(channel, "_cv_bug_", NULL); switch_channel_set_private(channel, "_cv_bug_", NULL);
switch_core_media_bug_remove(session, &bug); switch_core_media_bug_remove(session, &bug);
} else { } else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot run 2 at once on the same channel!\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot run 2 at once on the same channel!\n");
} }
return; return;
} }
switch_channel_wait_for_flag(channel, CF_VIDEO_READY, SWITCH_TRUE, 10000, NULL); switch_channel_wait_for_flag(channel, CF_VIDEO_READY, SWITCH_TRUE, 10000, NULL);
context = (cv_context_t *) switch_core_session_alloc(session, sizeof(*context)); context = (cv_context_t *) switch_core_session_alloc(session, sizeof(*context));
assert(context != NULL); assert(context != NULL);
context->session = session; context->session = session;
init_context(context); init_context(context);
if (data && (lbuf = switch_core_session_strdup(session, data)) if (data && (lbuf = switch_core_session_strdup(session, data))
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
parse_params(context, 1, argc, argv); parse_params(context, 1, argc, argv);
} }
switch_thread_rwlock_rdlock(MODULE_INTERFACE->rwlock); switch_thread_rwlock_rdlock(MODULE_INTERFACE->rwlock);
if ((status = switch_core_media_bug_add(session, "cv_bug", NULL, cv_bug_callback, context, 0, SMBF_READ_VIDEO_PING, &bug)) != SWITCH_STATUS_SUCCESS) { if ((status = switch_core_media_bug_add(session, "cv_bug", NULL, cv_bug_callback, context, 0, SMBF_READ_VIDEO_PING, &bug)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failure!\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failure!\n");
switch_thread_rwlock_unlock(MODULE_INTERFACE->rwlock); switch_thread_rwlock_unlock(MODULE_INTERFACE->rwlock);
return; return;
} }
switch_channel_set_private(channel, "_cv_bug_", bug); switch_channel_set_private(channel, "_cv_bug_", bug);
} }
@ -1226,45 +1226,45 @@ SWITCH_STANDARD_APP(cv_bug_start_function)
#define CV_BUG_API_SYNTAX "<uuid> [start|stop]" #define CV_BUG_API_SYNTAX "<uuid> [start|stop]"
SWITCH_STANDARD_API(cv_bug_api_function) SWITCH_STANDARD_API(cv_bug_api_function)
{ {
switch_core_session_t *rsession = NULL; switch_core_session_t *rsession = NULL;
switch_channel_t *channel = NULL; switch_channel_t *channel = NULL;
switch_media_bug_t *bug; switch_media_bug_t *bug;
switch_status_t status; switch_status_t status;
cv_context_t *context; cv_context_t *context;
char *mycmd = NULL; char *mycmd = NULL;
int argc = 0; int argc = 0;
char *argv[25] = { 0 }; char *argv[25] = { 0 };
char *uuid = NULL; char *uuid = NULL;
char *action = NULL; char *action = NULL;
char *cascade_path = NULL; char *cascade_path = NULL;
char *nested_cascade_path = NULL; char *nested_cascade_path = NULL;
char *lbuf = NULL; char *lbuf = NULL;
int x, n, i; int x, n, i;
if (zstr(cmd)) { if (zstr(cmd)) {
goto usage; goto usage;
} }
if (!(mycmd = strdup(cmd))) { if (!(mycmd = strdup(cmd))) {
goto usage; goto usage;
} }
if ((argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 2) { if ((argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 2) {
goto usage; goto usage;
} }
uuid = argv[0]; uuid = argv[0];
action = argv[1]; action = argv[1];
if (!(rsession = switch_core_session_locate(uuid))) { if (!(rsession = switch_core_session_locate(uuid))) {
stream->write_function(stream, "-ERR Cannot locate session!\n"); stream->write_function(stream, "-ERR Cannot locate session!\n");
goto done; goto done;
} }
channel = switch_core_session_get_channel(rsession); channel = switch_core_session_get_channel(rsession);
if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_cv_bug_"))) { if ((bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_cv_bug_"))) {
if (!zstr(action)) { if (!zstr(action)) {
if (!strcasecmp(action, "stop")) { if (!strcasecmp(action, "stop")) {
switch_channel_set_private(channel, "_cv_bug_", NULL); switch_channel_set_private(channel, "_cv_bug_", NULL);
switch_core_media_bug_remove(rsession, &bug); switch_core_media_bug_remove(rsession, &bug);
@ -1279,42 +1279,42 @@ SWITCH_STANDARD_API(cv_bug_api_function)
stream->write_function(stream, "-ERR Invalid action\n"); stream->write_function(stream, "-ERR Invalid action\n");
} }
goto done; goto done;
} }
if (!zstr(action) && strcasecmp(action, "start")) { if (!zstr(action) && strcasecmp(action, "start")) {
goto usage; goto usage;
} }
context = (cv_context_t *) switch_core_session_alloc(rsession, sizeof(*context)); context = (cv_context_t *) switch_core_session_alloc(rsession, sizeof(*context));
assert(context != NULL); assert(context != NULL);
context->session = rsession; context->session = rsession;
init_context(context); init_context(context);
parse_params(context, 2, argc, argv); parse_params(context, 2, argc, argv);
switch_thread_rwlock_rdlock(MODULE_INTERFACE->rwlock); switch_thread_rwlock_rdlock(MODULE_INTERFACE->rwlock);
if ((status = switch_core_media_bug_add(rsession, "cv_bug", NULL, cv_bug_callback, context, 0, SMBF_READ_VIDEO_PING, &bug)) != SWITCH_STATUS_SUCCESS) { if ((status = switch_core_media_bug_add(rsession, "cv_bug", NULL, cv_bug_callback, context, 0, SMBF_READ_VIDEO_PING, &bug)) != SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "-ERR Failure!\n"); stream->write_function(stream, "-ERR Failure!\n");
switch_thread_rwlock_unlock(MODULE_INTERFACE->rwlock); switch_thread_rwlock_unlock(MODULE_INTERFACE->rwlock);
goto done; goto done;
} else { } else {
switch_channel_set_private(channel, "_cv_bug_", bug); switch_channel_set_private(channel, "_cv_bug_", bug);
stream->write_function(stream, "+OK Success\n"); stream->write_function(stream, "+OK Success\n");
goto done; goto done;
} }
usage: usage:
stream->write_function(stream, "-USAGE: %s\n", CV_BUG_API_SYNTAX); stream->write_function(stream, "-USAGE: %s\n", CV_BUG_API_SYNTAX);
done: done:
if (rsession) { if (rsession) {
switch_core_session_rwunlock(rsession); switch_core_session_rwunlock(rsession);
} }
switch_safe_free(mycmd); switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
/////// ///////
@ -1323,24 +1323,24 @@ SWITCH_STANDARD_API(cv_bug_api_function)
SWITCH_MODULE_LOAD_FUNCTION(mod_cv_load) SWITCH_MODULE_LOAD_FUNCTION(mod_cv_load)
{ {
switch_application_interface_t *app_interface; switch_application_interface_t *app_interface;
switch_api_interface_t *api_interface; switch_api_interface_t *api_interface;
*module_interface = switch_loadable_module_create_module_interface(pool, modname); *module_interface = switch_loadable_module_create_module_interface(pool, modname);
MODULE_INTERFACE = *module_interface; MODULE_INTERFACE = *module_interface;
SWITCH_ADD_APP(app_interface, "cv", "", "", cv_start_function, "", SAF_NONE); SWITCH_ADD_APP(app_interface, "cv", "", "", cv_start_function, "", SAF_NONE);
SWITCH_ADD_APP(app_interface, "cv_bug", "connect cv", "connect cv", SWITCH_ADD_APP(app_interface, "cv_bug", "connect cv", "connect cv",
cv_bug_start_function, "[</path/to/haar.xml>]", SAF_NONE); cv_bug_start_function, "[</path/to/haar.xml>]", SAF_NONE);
SWITCH_ADD_API(api_interface, "cv_bug", "cv_bug", cv_bug_api_function, CV_BUG_API_SYNTAX); SWITCH_ADD_API(api_interface, "cv_bug", "cv_bug", cv_bug_api_function, CV_BUG_API_SYNTAX);
switch_console_set_complete("add cv_bug ::console::list_uuid ::[start:stop"); switch_console_set_complete("add cv_bug ::console::list_uuid ::[start:stop");
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cv_shutdown) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cv_shutdown)
@ -1348,13 +1348,15 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cv_shutdown)
return SWITCH_STATUS_UNLOAD; return SWITCH_STATUS_UNLOAD;
} }
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:
* mode:c * mode:c
* indent-tabs-mode:nil * indent-tabs-mode:t
* tab-width:4 * tab-width:4
* c-basic-offset:4 * c-basic-offset:4
* End: * End:
* For VIM: * For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/ */

View File

@ -779,7 +779,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_oreka_shutdown)
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:
* mode:c * mode:c
* indent-tabs-mode:nil * indent-tabs-mode:t
* tab-width:4 * tab-width:4
* c-basic-offset:4 * c-basic-offset:4
* End: * End:

View File

@ -466,7 +466,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_soundtouch_load)
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:
* mode:c * mode:c
* indent-tabs-mode:nil * indent-tabs-mode:t
* tab-width:4 * tab-width:4
* c-basic-offset:4 * c-basic-offset:4
* End: * End:

View File

@ -878,7 +878,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spandsp_shutdown)
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:
* mode:c * mode:c
* indent-tabs-mode:nil * indent-tabs-mode:t
* tab-width:4 * tab-width:4
* c-basic-offset:4 * c-basic-offset:4
* End: * End:

View File

@ -164,7 +164,7 @@ switch_status_t spandsp_tdd_send_session(switch_core_session_t *session, const c
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:
* mode:c * mode:c
* indent-tabs-mode:nil * indent-tabs-mode:t
* tab-width:4 * tab-width:4
* c-basic-offset:4 * c-basic-offset:4
* End: * End:

View File

@ -862,7 +862,7 @@ void mod_spandsp_dsp_shutdown(void)
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:
* mode:c * mode:c
* indent-tabs-mode:nil * indent-tabs-mode:t
* tab-width:4 * tab-width:4
* c-basic-offset:4 * c-basic-offset:4
* End: * End:

View File

@ -2359,7 +2359,7 @@ switch_status_t spandsp_fax_detect_session(switch_core_session_t *session,
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:
* mode:c * mode:c
* indent-tabs-mode:nil * indent-tabs-mode:t
* tab-width:4 * tab-width:4
* c-basic-offset:4 * c-basic-offset:4
* End: * End:

View File

@ -1444,7 +1444,7 @@ void modem_global_shutdown(void)
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:
* mode:c * mode:c
* indent-tabs-mode:nil * indent-tabs-mode:t
* tab-width:4 * tab-width:4
* c-basic-offset:4 * c-basic-offset:4
* End: * End:

View File

@ -165,7 +165,7 @@ void modem_global_shutdown(void);
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:
* mode:c * mode:c
* indent-tabs-mode:nil * indent-tabs-mode:t
* tab-width:4 * tab-width:4
* c-basic-offset:4 * c-basic-offset:4
* End: * End:

View File

@ -259,7 +259,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_stress_shutdown)
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:
* mode:c * mode:c
* indent-tabs-mode:nil * indent-tabs-mode:t
* tab-width:4 * tab-width:4
* c-basic-offset:4 * c-basic-offset:4
* End: * End:

View File

@ -1508,7 +1508,7 @@ switch_status_t FSMediaStream::write_frame(const switch_frame_t *frame, switch_i
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:
* mode:c * mode:c
* indent-tabs-mode:nil * indent-tabs-mode:t
* tab-width:4 * tab-width:4
* c-basic-offset:4 * c-basic-offset:4
* End: * End:

View File

@ -322,7 +322,7 @@ class FSConnection : public OpalLocalConnection
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:
* mode:c * mode:c
* indent-tabs-mode:nil * indent-tabs-mode:t
* tab-width:4 * tab-width:4
* c-basic-offset:4 * c-basic-offset:4
* End: * End:

View File

@ -1165,12 +1165,12 @@ static void default_logger(const char *file, const char *func, int line, int lev
} }
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:
* mode:c * mode:c
* indent-tabs-mode:nil * indent-tabs-mode:t
* tab-width:4 * tab-width:4
* c-basic-offset:4 * c-basic-offset:4
* End: * End:
* For VIM: * For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/ */