--- ../manager.c 2005-03-06 16:53:18.000000000 +0000 +++ manager.c 2005-03-06 16:51:52.000000000 +0000 @@ -30,8 +30,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -818,6 +818,56 @@ return 0; } +static char mandescr_bridge[] = +"Description: Bridge 2 channels together\n" +"Variables: (Names marked with * are required)\n" +" *Channel1: First channel\n" +" *Channel2: Second channel\n" +"Return 0 on success."; +static int action_bridge(struct mansession *s, struct message *m) +{ + /* New command by "Carl de Billy" */ + char *name1 = astman_get_header(m, "Channel1"); + char *name2 = astman_get_header(m, "Channel2"); + struct ast_channel *chan1 = NULL, *chan2 = NULL; + struct ast_bridge_config config; + struct ast_frame *f; + struct ast_channel *who; + int res; + /* Validate params */ + if(!name1 || ast_strlen_zero(name1)){ + astman_send_error(s, m, "Channel1 not specified"); + return -1; + } + if(!name2 || ast_strlen_zero(name2)){ + astman_send_error(s, m, "Channel2 not specified"); + return -1; + } + /* Get channels */ + chan1 = ast_get_channel_by_name_locked(name1); + chan2 = ast_get_channel_by_name_locked(name2); + res = ast_channel_make_compatible(chan1, chan2); + if(res < 0){ + astman_send_error(s, m, "Impossible to make channels compatible"); + return -2; + } + ast_deactivate_generator(chan1); + ast_deactivate_generator(chan2); + config.timelimit=0; + config.play_warning=0; + config.warning_freq=0; + config.end_sound=NULL; + config.start_sound=NULL; + /* Do the job */ + res = ast_channel_bridge(chan1, chan2, &config, &f, &who); + /* Clean-up */ + if (chan1) + ast_mutex_unlock(&chan1->lock); + if (chan2) + ast_mutex_unlock(&chan2->lock); + return res; +} + static char mandescr_command[] = "Description: Run a CLI command.\n" "Variables: (Names marked with * are required)\n" @@ -1511,13 +1561,14 @@ ast_manager_register2( "Setvar", EVENT_FLAG_CALL, action_setvar, "Set Channel Variable", mandescr_setvar ); ast_manager_register2( "Getvar", EVENT_FLAG_CALL, action_getvar, "Gets a Channel Variable", mandescr_getvar ); ast_manager_register( "Redirect", EVENT_FLAG_CALL, action_redirect, "Redirect" ); - ast_manager_register2("Originate", EVENT_FLAG_CALL, action_originate, "Originate Call", mandescr_originate); + ast_manager_register2("Originate", EVENT_FLAG_CALL, action_originate, "Originate Call", mandescr_originate ); ast_manager_register2( "Command", EVENT_FLAG_COMMAND, action_command, "Execute Command", mandescr_command ); ast_manager_register2( "ExtensionState", EVENT_FLAG_CALL, action_extensionstate, "Check Extension Status", mandescr_extensionstate ); ast_manager_register2( "AbsoluteTimeout", EVENT_FLAG_CALL, action_timeout, "Set Absolute Timeout", mandescr_timeout ); ast_manager_register2( "MailboxStatus", EVENT_FLAG_CALL, action_mailboxstatus, "Check Mailbox", mandescr_mailboxstatus ); ast_manager_register2( "MailboxCount", EVENT_FLAG_CALL, action_mailboxcount, "Check Mailbox Message Count", mandescr_mailboxcount ); ast_manager_register2("ListCommands", 0, action_listcommands, "List available manager commands", mandescr_listcommands); + ast_manager_register2( "Bridge", EVENT_FLAG_CALL, action_bridge, "Bridge 2 channels", mandescr_bridge ); ast_cli_register(&show_mancmd_cli); ast_cli_register(&show_mancmds_cli);