Newer
Older
}
/*
if (a->pos == 3) {
return complete_confbridge_channel(a->line, a->word, a->pos, a->n);
}
*/
if (a->argc != 4) {
return CLI_SHOWUSAGE;
}
ast_copy_string(tmp.name, a->argv[2], sizeof(tmp.name));
bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
if (!bridge) {
ast_cli(a->fd, "No conference bridge named '%s' found!\n", a->argv[2]);
return CLI_SUCCESS;
}
ao2_lock(bridge);
AST_LIST_TRAVERSE(&bridge->users_list, participant, list) {
if (!strncmp(a->argv[3], ast_channel_name(participant->chan), strlen(ast_channel_name(participant->chan)))) {
break;
}
}
if (participant) {
ast_cli(a->fd, "Kicking %s from confbridge %s\n", ast_channel_name(participant->chan), bridge->name);
participant->kicked = 1;
ast_bridge_remove(bridge->bridge, participant->chan);
}
ao2_unlock(bridge);
ao2_ref(bridge, -1);
return CLI_SUCCESS;
}
static char *handle_cli_confbridge_list(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct ao2_iterator i;
struct conference_bridge *bridge = NULL;
struct conference_bridge tmp;
struct conference_bridge_user *participant = NULL;
switch (cmd) {
case CLI_INIT:
e->command = "confbridge list";
e->usage =
"Usage: confbridge list [<name>]\n"
" Lists all currently active conference bridges.\n";
return NULL;
case CLI_GENERATE:
if (a->pos == 2) {
return complete_confbridge_name(a->line, a->word, a->pos, a->n);
}
if (a->argc == 2) {
ast_cli(a->fd, "Conference Bridge Name Users Marked Locked?\n");
ast_cli(a->fd, "================================ ====== ====== ========\n");
i = ao2_iterator_init(conference_bridges, 0);
while ((bridge = ao2_iterator_next(&i))) {
ast_cli(a->fd, "%-32s %6i %6i %s\n", bridge->name, bridge->users, bridge->markedusers, (bridge->locked ? "locked" : "unlocked"));
ao2_ref(bridge, -1);
}
ao2_iterator_destroy(&i);
return CLI_SUCCESS;
}
if (a->argc == 3) {
ast_copy_string(tmp.name, a->argv[2], sizeof(tmp.name));
bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
if (!bridge) {
ast_cli(a->fd, "No conference bridge named '%s' found!\n", a->argv[2]);
return CLI_SUCCESS;
}
Matthew Jordan
committed
ast_cli(a->fd, "Channel User Profile Bridge Profile Menu CallerID\n");
ast_cli(a->fd, "============================= ================ ================ ================ ================\n");
ao2_lock(bridge);
AST_LIST_TRAVERSE(&bridge->users_list, participant, list) {
ast_cli(a->fd, "%-29s ", ast_channel_name(participant->chan));
ast_cli(a->fd, "%-17s", participant->u_profile.name);
ast_cli(a->fd, "%-17s", participant->b_profile.name);
ast_cli(a->fd, "%-17s", participant->menu_name);
ast_cli(a->fd, "%-17s", S_COR(ast_channel_caller(participant->chan)->id.number.valid, ast_channel_caller(participant->chan)->id.number.str, "<unknown>"));
ast_cli(a->fd, "\n");
}
ao2_unlock(bridge);
ao2_ref(bridge, -1);
return CLI_SUCCESS;
}
return CLI_SHOWUSAGE;
}
/* \internal
* \brief finds a conference by name and locks/unlocks.
*
* \retval 0 success
* \retval -1 conference not found
*/
static int generic_lock_unlock_helper(int lock, const char *conference)
{
struct conference_bridge *bridge = NULL;
struct conference_bridge tmp;
int res = 0;
ast_copy_string(tmp.name, conference, sizeof(tmp.name));
bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
if (!bridge) {
return -1;
}
ao2_lock(bridge);
bridge->locked = lock;
ast_test_suite_event_notify("CONF_LOCK", "Message: conference %s\r\nConference: %s", bridge->locked ? "locked" : "unlocked", bridge->b_profile.name);
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
ao2_unlock(bridge);
ao2_ref(bridge, -1);
return res;
}
/* \internal
* \brief finds a conference user by channel name and mutes/unmutes them.
*
* \retval 0 success
* \retval -1 conference not found
* \retval -2 user not found
*/
static int generic_mute_unmute_helper(int mute, const char *conference, const char *user)
{
struct conference_bridge *bridge = NULL;
struct conference_bridge tmp;
struct conference_bridge_user *participant = NULL;
int res = 0;
ast_copy_string(tmp.name, conference, sizeof(tmp.name));
bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
if (!bridge) {
return -1;
}
ao2_lock(bridge);
AST_LIST_TRAVERSE(&bridge->users_list, participant, list) {
if (!strncmp(user, ast_channel_name(participant->chan), strlen(user))) {
break;
}
}
if (participant) {
participant->features.mute = mute;
ast_test_suite_event_notify("CONF_MUTE", "Message: participant %s %s\r\nConference: %s\r\nChannel: %s", ast_channel_name(participant->chan), participant->features.mute ? "muted" : "unmuted", bridge->b_profile.name, ast_channel_name(participant->chan));
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
} else {
res = -2;;
}
ao2_unlock(bridge);
ao2_ref(bridge, -1);
return res;
}
static int cli_mute_unmute_helper(int mute, struct ast_cli_args *a)
{
int res = generic_mute_unmute_helper(mute, a->argv[2], a->argv[3]);
if (res == -1) {
ast_cli(a->fd, "No conference bridge named '%s' found!\n", a->argv[2]);
return -1;
} else if (res == -2) {
ast_cli(a->fd, "No channel named '%s' found in conference %s\n", a->argv[3], a->argv[2]);
return -1;
}
ast_cli(a->fd, "%s %s from confbridge %s\n", mute ? "Muting" : "Unmuting", a->argv[3], a->argv[2]);
return 0;
}
static char *handle_cli_confbridge_mute(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
switch (cmd) {
case CLI_INIT:
e->command = "confbridge mute";
e->usage =
"Usage: confbridge mute <conference> <channel>\n";
return NULL;
case CLI_GENERATE:
if (a->pos == 2) {
return complete_confbridge_name(a->line, a->word, a->pos, a->n);
}
return NULL;
}
if (a->argc != 4) {
return CLI_SHOWUSAGE;
}
cli_mute_unmute_helper(1, a);
return CLI_SUCCESS;
}
static char *handle_cli_confbridge_unmute(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
switch (cmd) {
case CLI_INIT:
e->command = "confbridge unmute";
e->usage =
"Usage: confbridge unmute <conference> <channel>\n";
return NULL;
case CLI_GENERATE:
if (a->pos == 2) {
return complete_confbridge_name(a->line, a->word, a->pos, a->n);
}
return NULL;
}
if (a->argc != 4) {
return CLI_SHOWUSAGE;
}
cli_mute_unmute_helper(0, a);
return CLI_SUCCESS;
}
static char *handle_cli_confbridge_lock(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
switch (cmd) {
case CLI_INIT:
e->command = "confbridge lock";
e->usage =
"Usage: confbridge lock <conference>\n";
return NULL;
case CLI_GENERATE:
if (a->pos == 2) {
return complete_confbridge_name(a->line, a->word, a->pos, a->n);
}
return NULL;
}
if (a->argc != 3) {
return CLI_SHOWUSAGE;
}
if (generic_lock_unlock_helper(1, a->argv[2])) {
ast_cli(a->fd, "Conference %s is not found\n", a->argv[2]);
} else {
ast_cli(a->fd, "Conference %s is locked.\n", a->argv[2]);
}
return CLI_SUCCESS;
}
static char *handle_cli_confbridge_unlock(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
switch (cmd) {
case CLI_INIT:
e->command = "confbridge unlock";
e->usage =
"Usage: confbridge unlock <conference>\n";
return NULL;
case CLI_GENERATE:
if (a->pos == 2) {
return complete_confbridge_name(a->line, a->word, a->pos, a->n);
}
return NULL;
}
if (a->argc != 3) {
return CLI_SHOWUSAGE;
}
if (generic_lock_unlock_helper(0, a->argv[2])) {
ast_cli(a->fd, "Conference %s is not found\n", a->argv[2]);
} else {
ast_cli(a->fd, "Conference %s is unlocked.\n", a->argv[2]);
}
return CLI_SUCCESS;
}
static char *handle_cli_confbridge_start_record(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
const char *rec_file = NULL;
struct conference_bridge *bridge = NULL;
struct conference_bridge tmp;
switch (cmd) {
case CLI_INIT:
e->command = "confbridge record start";
e->usage =
"Usage: confbridge record start <conference> <file>\n"
" <file> is optional, Otherwise the bridge profile\n"
" record file will be used. If the bridge profile\n"
" has no record file specified, a file will automatically\n"
" be generated in the monitor directory\n";
return NULL;
case CLI_GENERATE:
if (a->pos == 3) {
return complete_confbridge_name(a->line, a->word, a->pos, a->n);
}
return NULL;
}
if (a->argc < 4) {
return CLI_SHOWUSAGE;
}
if (a->argc == 5) {
rec_file = a->argv[4];
}
ast_copy_string(tmp.name, a->argv[3], sizeof(tmp.name));
bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
if (!bridge) {
ast_cli(a->fd, "Conference not found.\n");
return CLI_FAILURE;
}
if (conf_is_recording(bridge)) {
ast_cli(a->fd, "Conference is already being recorded.\n");
ao2_ref(bridge, -1);
return CLI_SUCCESS;
}
if (!ast_strlen_zero(rec_file)) {
ao2_lock(bridge);
ast_copy_string(bridge->b_profile.rec_file, rec_file, sizeof(bridge->b_profile.rec_file));
ao2_unlock(bridge);
}
if (conf_start_record(bridge)) {
ast_cli(a->fd, "Could not start recording due to internal error.\n");
ao2_ref(bridge, -1);
return CLI_FAILURE;
}
ast_cli(a->fd, "Recording started\n");
ao2_ref(bridge, -1);
return CLI_SUCCESS;
}
static char *handle_cli_confbridge_stop_record(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct conference_bridge *bridge = NULL;
struct conference_bridge tmp;
switch (cmd) {
case CLI_INIT:
e->command = "confbridge record stop";
e->usage =
"Usage: confbridge record stop <conference>\n";
return NULL;
case CLI_GENERATE:
if (a->pos == 3) {
return complete_confbridge_name(a->line, a->word, a->pos, a->n);
}
return NULL;
}
if (a->argc != 4) {
return CLI_SHOWUSAGE;
}
ast_copy_string(tmp.name, a->argv[3], sizeof(tmp.name));
bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
if (!bridge) {
ast_cli(a->fd, "Conference not found.\n");
return CLI_SUCCESS;
}
conf_stop_record(bridge);
ast_cli(a->fd, "Recording stopped.\n");
ao2_ref(bridge, -1);
return CLI_SUCCESS;
}
static struct ast_cli_entry cli_confbridge[] = {
AST_CLI_DEFINE(handle_cli_confbridge_list, "List conference bridges and participants."),
AST_CLI_DEFINE(handle_cli_confbridge_kick, "Kick participants out of conference bridges."),
AST_CLI_DEFINE(handle_cli_confbridge_mute, "Mute a participant."),
AST_CLI_DEFINE(handle_cli_confbridge_unmute, "Unmute a participant."),
AST_CLI_DEFINE(handle_cli_confbridge_lock, "Lock a conference."),
AST_CLI_DEFINE(handle_cli_confbridge_unlock, "Unlock a conference."),
AST_CLI_DEFINE(handle_cli_confbridge_start_record, "Start recording a conference"),
AST_CLI_DEFINE(handle_cli_confbridge_stop_record, "Stop recording a conference."),
};
static struct ast_custom_function confbridge_function = {
.name = "CONFBRIDGE",
.write = func_confbridge_helper,
};
static int func_confbridge_info(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len);
static struct ast_custom_function confbridge_info_function = {
.name = "CONFBRIDGE_INFO",
.read = func_confbridge_info,
};
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
static int action_confbridgelist(struct mansession *s, const struct message *m)
{
const char *actionid = astman_get_header(m, "ActionID");
const char *conference = astman_get_header(m, "Conference");
struct conference_bridge_user *participant = NULL;
struct conference_bridge *bridge = NULL;
struct conference_bridge tmp;
char id_text[80] = "";
int total = 0;
if (!ast_strlen_zero(actionid)) {
snprintf(id_text, sizeof(id_text), "ActionID: %s\r\n", actionid);
}
if (ast_strlen_zero(conference)) {
astman_send_error(s, m, "No Conference name provided.");
return 0;
}
if (!ao2_container_count(conference_bridges)) {
astman_send_error(s, m, "No active conferences.");
return 0;
}
ast_copy_string(tmp.name, conference, sizeof(tmp.name));
bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
if (!bridge) {
astman_send_error(s, m, "No Conference by that name found.");
return 0;
}
astman_send_listack(s, m, "Confbridge user list will follow", "start");
ao2_lock(bridge);
AST_LIST_TRAVERSE(&bridge->users_list, participant, list) {
total++;
astman_append(s,
"Event: ConfbridgeList\r\n"
"%s"
"Conference: %s\r\n"
"CallerIDNum: %s\r\n"
"CallerIDName: %s\r\n"
"Channel: %s\r\n"
"Admin: %s\r\n"
"MarkedUser: %s\r\n"
"\r\n",
id_text,
bridge->name,
S_COR(ast_channel_caller(participant->chan)->id.number.valid, ast_channel_caller(participant->chan)->id.number.str, "<unknown>"),
S_COR(ast_channel_caller(participant->chan)->id.name.valid, ast_channel_caller(participant->chan)->id.name.str, "<no name>"),
ast_channel_name(participant->chan),
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
ast_test_flag(&participant->u_profile, USER_OPT_ADMIN) ? "Yes" : "No",
ast_test_flag(&participant->u_profile, USER_OPT_MARKEDUSER) ? "Yes" : "No");
}
ao2_unlock(bridge);
ao2_ref(bridge, -1);
astman_append(s,
"Event: ConfbridgeListComplete\r\n"
"EventList: Complete\r\n"
"ListItems: %d\r\n"
"%s"
"\r\n", total, id_text);
return 0;
}
static int action_confbridgelistrooms(struct mansession *s, const struct message *m)
{
const char *actionid = astman_get_header(m, "ActionID");
struct conference_bridge *bridge = NULL;
struct ao2_iterator i;
char id_text[512] = "";
int totalitems = 0;
if (!ast_strlen_zero(actionid)) {
snprintf(id_text, sizeof(id_text), "ActionID: %s\r\n", actionid);
}
if (!ao2_container_count(conference_bridges)) {
astman_send_error(s, m, "No active conferences.");
return 0;
}
astman_send_listack(s, m, "Confbridge conferences will follow", "start");
/* Traverse the conference list */
i = ao2_iterator_init(conference_bridges, 0);
while ((bridge = ao2_iterator_next(&i))) {
totalitems++;
ao2_lock(bridge);
astman_append(s,
"Event: ConfbridgeListRooms\r\n"
"%s"
"Conference: %s\r\n"
"Parties: %d\r\n"
"Marked: %d\r\n"
"Locked: %s\r\n"
"\r\n",
id_text,
bridge->name,
bridge->users,
bridge->markedusers,
bridge->locked ? "Yes" : "No");
ao2_unlock(bridge);
ao2_ref(bridge, -1);
}
ao2_iterator_destroy(&i);
/* Send final confirmation */
astman_append(s,
"Event: ConfbridgeListRoomsComplete\r\n"
"EventList: Complete\r\n"
"ListItems: %d\r\n"
"%s"
"\r\n", totalitems, id_text);
return 0;
}
static int action_mute_unmute_helper(struct mansession *s, const struct message *m, int mute)
{
const char *conference = astman_get_header(m, "Conference");
const char *channel = astman_get_header(m, "Channel");
int res = 0;
if (ast_strlen_zero(conference)) {
astman_send_error(s, m, "No Conference name provided.");
return 0;
}
if (ast_strlen_zero(channel)) {
astman_send_error(s, m, "No channel name provided.");
return 0;
}
if (!ao2_container_count(conference_bridges)) {
astman_send_error(s, m, "No active conferences.");
return 0;
}
res = generic_mute_unmute_helper(mute, conference, channel);
if (res == -1) {
astman_send_error(s, m, "No Conference by that name found.");
return 0;
} else if (res == -2) {
astman_send_error(s, m, "No Channel by that name found in Conference.");
return 0;
}
astman_send_ack(s, m, mute ? "User muted" : "User unmuted");
return 0;
}
static int action_confbridgeunmute(struct mansession *s, const struct message *m)
{
return action_mute_unmute_helper(s, m, 0);
}
static int action_confbridgemute(struct mansession *s, const struct message *m)
{
return action_mute_unmute_helper(s, m, 1);
}
static int action_lock_unlock_helper(struct mansession *s, const struct message *m, int lock)
{
const char *conference = astman_get_header(m, "Conference");
int res = 0;
if (ast_strlen_zero(conference)) {
astman_send_error(s, m, "No Conference name provided.");
return 0;
}
if (!ao2_container_count(conference_bridges)) {
astman_send_error(s, m, "No active conferences.");
return 0;
}
if ((res = generic_lock_unlock_helper(lock, conference))) {
astman_send_error(s, m, "No Conference by that name found.");
return 0;
}
astman_send_ack(s, m, lock ? "Conference locked" : "Conference unlocked");
return 0;
}
static int action_confbridgeunlock(struct mansession *s, const struct message *m)
{
return action_lock_unlock_helper(s, m, 0);
}
static int action_confbridgelock(struct mansession *s, const struct message *m)
{
return action_lock_unlock_helper(s, m, 1);
}
static int action_confbridgekick(struct mansession *s, const struct message *m)
{
const char *conference = astman_get_header(m, "Conference");
const char *channel = astman_get_header(m, "Channel");
struct conference_bridge_user *participant = NULL;
struct conference_bridge *bridge = NULL;
struct conference_bridge tmp;
int found = 0;
if (ast_strlen_zero(conference)) {
astman_send_error(s, m, "No Conference name provided.");
return 0;
}
if (!ao2_container_count(conference_bridges)) {
astman_send_error(s, m, "No active conferences.");
return 0;
}
ast_copy_string(tmp.name, conference, sizeof(tmp.name));
bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
if (!bridge) {
astman_send_error(s, m, "No Conference by that name found.");
return 0;
}
ao2_lock(bridge);
AST_LIST_TRAVERSE(&bridge->users_list, participant, list) {
if (!strcasecmp(ast_channel_name(participant->chan), channel)) {
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
participant->kicked = 1;
ast_bridge_remove(bridge->bridge, participant->chan);
found = 1;
break;
}
}
ao2_unlock(bridge);
ao2_ref(bridge, -1);
if (found) {
astman_send_ack(s, m, "User kicked");
} else {
astman_send_error(s, m, "No Channel by that name found in Conference.");
}
return 0;
}
static int action_confbridgestartrecord(struct mansession *s, const struct message *m)
{
const char *conference = astman_get_header(m, "Conference");
const char *recordfile = astman_get_header(m, "RecordFile");
struct conference_bridge *bridge = NULL;
struct conference_bridge tmp;
if (ast_strlen_zero(conference)) {
astman_send_error(s, m, "No Conference name provided.");
return 0;
}
if (!ao2_container_count(conference_bridges)) {
astman_send_error(s, m, "No active conferences.");
return 0;
}
ast_copy_string(tmp.name, conference, sizeof(tmp.name));
bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
if (!bridge) {
astman_send_error(s, m, "No Conference by that name found.");
return 0;
}
if (conf_is_recording(bridge)) {
astman_send_error(s, m, "Conference is already being recorded.");
ao2_ref(bridge, -1);
return 0;
}
if (!ast_strlen_zero(recordfile)) {
ao2_lock(bridge);
ast_copy_string(bridge->b_profile.rec_file, recordfile, sizeof(bridge->b_profile.rec_file));
ao2_unlock(bridge);
}
if (conf_start_record(bridge)) {
astman_send_error(s, m, "Internal error starting conference recording.");
ao2_ref(bridge, -1);
return 0;
}
ao2_ref(bridge, -1);
astman_send_ack(s, m, "Conference Recording Started.");
return 0;
}
static int action_confbridgestoprecord(struct mansession *s, const struct message *m)
{
const char *conference = astman_get_header(m, "Conference");
struct conference_bridge *bridge = NULL;
struct conference_bridge tmp;
if (ast_strlen_zero(conference)) {
astman_send_error(s, m, "No Conference name provided.");
return 0;
}
if (!ao2_container_count(conference_bridges)) {
astman_send_error(s, m, "No active conferences.");
return 0;
}
ast_copy_string(tmp.name, conference, sizeof(tmp.name));
bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
if (!bridge) {
astman_send_error(s, m, "No Conference by that name found.");
return 0;
}
if (conf_stop_record(bridge)) {
astman_send_error(s, m, "Internal error while stopping recording.");
ao2_ref(bridge, -1);
return 0;
}
ao2_ref(bridge, -1);
astman_send_ack(s, m, "Conference Recording Stopped.");
return 0;
}
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
static int action_confbridgesetsinglevideosrc(struct mansession *s, const struct message *m)
{
const char *conference = astman_get_header(m, "Conference");
const char *channel = astman_get_header(m, "Channel");
struct conference_bridge_user *participant = NULL;
struct conference_bridge *bridge = NULL;
struct conference_bridge tmp;
if (ast_strlen_zero(conference)) {
astman_send_error(s, m, "No Conference name provided.");
return 0;
}
if (ast_strlen_zero(channel)) {
astman_send_error(s, m, "No channel name provided.");
return 0;
}
if (!ao2_container_count(conference_bridges)) {
astman_send_error(s, m, "No active conferences.");
return 0;
}
ast_copy_string(tmp.name, conference, sizeof(tmp.name));
bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
if (!bridge) {
astman_send_error(s, m, "No Conference by that name found.");
return 0;
}
/* find channel and set as video src. */
ao2_lock(bridge);
AST_LIST_TRAVERSE(&bridge->users_list, participant, list) {
if (!strncmp(channel, ast_channel_name(participant->chan), strlen(channel))) {
ast_bridge_set_single_src_video_mode(bridge->bridge, participant->chan);
break;
}
}
ao2_unlock(bridge);
ao2_ref(bridge, -1);
/* do not access participant after bridge unlock. We are just
* using this check to see if it was found or not */
if (!participant) {
astman_send_error(s, m, "No channel by that name found in conference.");
return 0;
}
astman_send_ack(s, m, "Conference single video source set.");
return 0;
}
static int func_confbridge_info(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{
char *parse = NULL;
struct conference_bridge *bridge = NULL;
struct conference_bridge_user *participant = NULL;
struct conference_bridge tmp;
int count = 0;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(type);
AST_APP_ARG(confno);
);
/* parse all the required arguments and make sure they exist. */
if (ast_strlen_zero(data)) {
return -1;
}
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
if (ast_strlen_zero(args.confno) || ast_strlen_zero(args.type)) {
return -1;
}
if (!ao2_container_count(conference_bridges)) {
snprintf(buf, len, "0");
return 0;
}
ast_copy_string(tmp.name, args.confno, sizeof(tmp.name));
bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
if (!bridge) {
snprintf(buf, len, "0");
return 0;
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
}
/* get the correct count for the type requested */
ao2_lock(bridge);
if (!strncasecmp(args.type, "parties", 7)) {
AST_LIST_TRAVERSE(&bridge->users_list, participant, list) {
count++;
}
} else if (!strncasecmp(args.type, "admins", 6)) {
AST_LIST_TRAVERSE(&bridge->users_list, participant, list) {
if (ast_test_flag(&participant->u_profile, USER_OPT_ADMIN)) {
count++;
}
}
} else if (!strncasecmp(args.type, "marked", 6)) {
AST_LIST_TRAVERSE(&bridge->users_list, participant, list) {
if (ast_test_flag(&participant->u_profile, USER_OPT_MARKEDUSER)) {
count++;
}
}
} else if (!strncasecmp(args.type, "locked", 6)) {
count = bridge->locked;
} else {
ast_log(LOG_ERROR, "Invalid keyword '%s' passed to CONFBRIDGE_INFO. Should be one of: "
"parties, admins, marked, or locked.\n", args.type);
}
snprintf(buf, len, "%d", count);
ao2_unlock(bridge);
ao2_ref(bridge, -1);
return 0;
}
/*! \brief Called when module is being unloaded */
static int unload_module(void)
{
int res = ast_unregister_application(app);
ast_custom_function_unregister(&confbridge_function);
ast_custom_function_unregister(&confbridge_info_function);
ast_cli_unregister_multiple(cli_confbridge, sizeof(cli_confbridge) / sizeof(struct ast_cli_entry));
/* Get rid of the conference bridges container. Since we only allow dynamic ones none will be active. */
ao2_ref(conference_bridges, -1);
conf_destroy_config();
ast_channel_unregister(&record_tech);
record_tech.capabilities = ast_format_cap_destroy(record_tech.capabilities);
res |= ast_manager_unregister("ConfbridgeList");
res |= ast_manager_unregister("ConfbridgeListRooms");
res |= ast_manager_unregister("ConfbridgeMute");
res |= ast_manager_unregister("ConfbridgeUnmute");
res |= ast_manager_unregister("ConfbridgeKick");
res |= ast_manager_unregister("ConfbridgeUnlock");
res |= ast_manager_unregister("ConfbridgeLock");
res |= ast_manager_unregister("ConfbridgeStartRecord");
res |= ast_manager_unregister("ConfbridgeStopRecord");
return res;
}
/*! \brief Called when module is being loaded */
static int load_module(void)
{
int res = 0;
if ((ast_custom_function_register(&confbridge_function))) {
return AST_MODULE_LOAD_FAILURE;
}
if ((ast_custom_function_register(&confbridge_info_function))) {
return AST_MODULE_LOAD_FAILURE;
}
if (!(record_tech.capabilities = ast_format_cap_alloc())) {
return AST_MODULE_LOAD_FAILURE;
}
ast_format_cap_add_all(record_tech.capabilities);
if (ast_channel_register(&record_tech)) {
ast_log(LOG_ERROR, "Unable to register ConfBridge recorder.\n");
return AST_MODULE_LOAD_FAILURE;
}
/* Create a container to hold the conference bridges */
if (!(conference_bridges = ao2_container_alloc(CONFERENCE_BRIDGE_BUCKETS, conference_bridge_hash_cb, conference_bridge_cmp_cb))) {
return AST_MODULE_LOAD_FAILURE;
}
if (ast_register_application_xml(app, confbridge_exec)) {
ao2_ref(conference_bridges, -1);
return AST_MODULE_LOAD_FAILURE;
res |= ast_cli_register_multiple(cli_confbridge, sizeof(cli_confbridge) / sizeof(struct ast_cli_entry));
res |= ast_manager_register_xml("ConfbridgeList", EVENT_FLAG_REPORTING, action_confbridgelist);
res |= ast_manager_register_xml("ConfbridgeListRooms", EVENT_FLAG_REPORTING, action_confbridgelistrooms);
res |= ast_manager_register_xml("ConfbridgeMute", EVENT_FLAG_CALL, action_confbridgemute);
res |= ast_manager_register_xml("ConfbridgeUnmute", EVENT_FLAG_CALL, action_confbridgeunmute);
res |= ast_manager_register_xml("ConfbridgeKick", EVENT_FLAG_CALL, action_confbridgekick);
res |= ast_manager_register_xml("ConfbridgeUnlock", EVENT_FLAG_CALL, action_confbridgeunlock);
res |= ast_manager_register_xml("ConfbridgeLock", EVENT_FLAG_CALL, action_confbridgelock);
res |= ast_manager_register_xml("ConfbridgeStartRecord", EVENT_FLAG_CALL, action_confbridgestartrecord);
res |= ast_manager_register_xml("ConfbridgeStopRecord", EVENT_FLAG_CALL, action_confbridgestoprecord);
res |= ast_manager_register_xml("ConfbridgeSetSingleVideoSrc", EVENT_FLAG_CALL, action_confbridgesetsinglevideosrc);
res |= conf_load_config(0);
static int reload(void)
{
return conf_load_config(1);
Tilghman Lesher
committed
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Conference Bridge Application",
.load = load_module,
.unload = unload_module,
Tilghman Lesher
committed
.load_pri = AST_MODPRI_DEVSTATE_PROVIDER,
);