| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
#include "asterisk.h" |
| 31 |
|
| 32 |
#include "asterisk/logger.h" |
| 33 |
#include "asterisk/config.h" |
| 34 |
#include "asterisk/config_options.h" |
| 35 |
#include "include/confbridge.h" |
| 36 |
#include "asterisk/astobj2.h" |
| 37 |
#include "asterisk/cli.h" |
| 38 |
#include "asterisk/bridge_features.h" |
| 39 |
#include "asterisk/stringfields.h" |
| 40 |
#include "asterisk/pbx.h" |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
|
| 742 |
|
| 743 |
|
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
|
| 837 |
|
| 838 |
|
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
|
| 852 |
|
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
|
| 865 |
|
| 866 |
|
| 867 |
|
| 868 |
|
| 869 |
|
| 870 |
|
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
|
| 881 |
|
| 882 |
|
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
|
| 891 |
|
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
|
| 896 |
struct confbridge_cfg { |
| 897 |
struct ao2_container *bridge_profiles; |
| 898 |
struct ao2_container *user_profiles; |
| 899 |
struct ao2_container *menus; |
| 900 |
}; |
| 901 |
|
| 902 |
static int verify_default_profiles(void); |
| 903 |
static void *bridge_profile_alloc(const char *category); |
| 904 |
static void *bridge_profile_find(struct ao2_container *container, const char *category); |
| 905 |
static struct bridge_profile_sounds *bridge_profile_sounds_alloc(void); |
| 906 |
|
| 907 |
static void bridge_profile_destructor(void *obj) |
| 908 |
{ |
| 909 |
struct bridge_profile *b_profile = obj; |
| 910 |
ao2_cleanup(b_profile->sounds); |
| 911 |
} |
| 912 |
|
| 913 |
static void *bridge_profile_alloc(const char *category) |
| 914 |
{ |
| 915 |
struct bridge_profile *b_profile; |
| 916 |
|
| 917 |
if (!(b_profile = ao2_alloc(sizeof(*b_profile), bridge_profile_destructor))) { |
| 918 |
return NULL; |
| 919 |
} |
| 920 |
|
| 921 |
if (!(b_profile->sounds = bridge_profile_sounds_alloc())) { |
| 922 |
ao2_ref(b_profile, -1); |
| 923 |
return NULL; |
| 924 |
} |
| 925 |
|
| 926 |
ast_copy_string(b_profile->name, category, sizeof(b_profile->name)); |
| 927 |
|
| 928 |
return b_profile; |
| 929 |
} |
| 930 |
|
| 931 |
static void *bridge_profile_find(struct ao2_container *container, const char *category) |
| 932 |
{ |
| 933 |
return ao2_find(container, category, OBJ_KEY); |
| 934 |
} |
| 935 |
|
| 936 |
static struct aco_type bridge_type = { |
| 937 |
.type = ACO_ITEM, |
| 938 |
.name = "bridge_profile", |
| 939 |
.category_match = ACO_BLACKLIST_EXACT, |
| 940 |
.category = "general", |
| 941 |
.matchfield = "type", |
| 942 |
.matchvalue = "bridge", |
| 943 |
.item_alloc = bridge_profile_alloc, |
| 944 |
.item_find = bridge_profile_find, |
| 945 |
.item_offset = offsetof(struct confbridge_cfg, bridge_profiles), |
| 946 |
}; |
| 947 |
|
| 948 |
static void *user_profile_alloc(const char *category); |
| 949 |
static void *user_profile_find(struct ao2_container *container, const char *category); |
| 950 |
static void user_profile_destructor(void *obj) |
| 951 |
{ |
| 952 |
return; |
| 953 |
} |
| 954 |
|
| 955 |
static void *user_profile_alloc(const char *category) |
| 956 |
{ |
| 957 |
struct user_profile *u_profile; |
| 958 |
|
| 959 |
if (!(u_profile = ao2_alloc(sizeof(*u_profile), user_profile_destructor))) { |
| 960 |
return NULL; |
| 961 |
} |
| 962 |
|
| 963 |
ast_copy_string(u_profile->name, category, sizeof(u_profile->name)); |
| 964 |
|
| 965 |
return u_profile; |
| 966 |
} |
| 967 |
|
| 968 |
static void *user_profile_find(struct ao2_container *container, const char *category) |
| 969 |
{ |
| 970 |
return ao2_find(container, category, OBJ_KEY); |
| 971 |
} |
| 972 |
|
| 973 |
static struct aco_type user_type = { |
| 974 |
.type = ACO_ITEM, |
| 975 |
.name = "user_profile", |
| 976 |
.category_match = ACO_BLACKLIST_EXACT, |
| 977 |
.category = "general", |
| 978 |
.matchfield = "type", |
| 979 |
.matchvalue = "user", |
| 980 |
.item_alloc = user_profile_alloc, |
| 981 |
.item_find = user_profile_find, |
| 982 |
.item_offset = offsetof(struct confbridge_cfg, user_profiles), |
| 983 |
}; |
| 984 |
|
| 985 |
static void *menu_alloc(const char *category); |
| 986 |
static void *menu_find(struct ao2_container *container, const char *category); |
| 987 |
static void menu_destructor(void *obj); |
| 988 |
|
| 989 |
static void *menu_alloc(const char *category) |
| 990 |
{ |
| 991 |
struct conf_menu *menu; |
| 992 |
if (!(menu = ao2_alloc(sizeof(*menu), menu_destructor))) { |
| 993 |
return NULL; |
| 994 |
} |
| 995 |
ast_copy_string(menu->name, category, sizeof(menu->name)); |
| 996 |
return menu; |
| 997 |
} |
| 998 |
|
| 999 |
static void *menu_find(struct ao2_container *container, const char *category) |
| 1000 |
{ |
| 1001 |
return ao2_find(container, category, OBJ_KEY); |
| 1002 |
} |
| 1003 |
|
| 1004 |
static struct aco_type menu_type = { |
| 1005 |
.type = ACO_ITEM, |
| 1006 |
.name = "menu", |
| 1007 |
.category_match = ACO_BLACKLIST_EXACT, |
| 1008 |
.category = "general", |
| 1009 |
.matchfield = "type", |
| 1010 |
.matchvalue = "menu", |
| 1011 |
.item_alloc = menu_alloc, |
| 1012 |
.item_find = menu_find, |
| 1013 |
.item_offset = offsetof(struct confbridge_cfg, menus), |
| 1014 |
}; |
| 1015 |
|
| 1016 |
|
| 1017 |
static struct aco_type *bridge_types[] = ACO_TYPES(&bridge_type); |
| 1018 |
static struct aco_type *menu_types[] = ACO_TYPES(&menu_type); |
| 1019 |
static struct aco_type *user_types[] = ACO_TYPES(&user_type); |
| 1020 |
|
| 1021 |
|
| 1022 |
static struct aco_type general_type = { |
| 1023 |
.type = ACO_GLOBAL, |
| 1024 |
.name = "global", |
| 1025 |
.category_match = ACO_WHITELIST_EXACT, |
| 1026 |
.category = "general", |
| 1027 |
}; |
| 1028 |
|
| 1029 |
static struct aco_file confbridge_conf = { |
| 1030 |
.filename = "confbridge.conf", |
| 1031 |
.types = ACO_TYPES(&bridge_type, &user_type, &menu_type, &general_type), |
| 1032 |
}; |
| 1033 |
|
| 1034 |
static AO2_GLOBAL_OBJ_STATIC(cfg_handle); |
| 1035 |
|
| 1036 |
static void *confbridge_cfg_alloc(void); |
| 1037 |
|
| 1038 |
CONFIG_INFO_STANDARD(cfg_info, cfg_handle, confbridge_cfg_alloc, |
| 1039 |
.files = ACO_FILES(&confbridge_conf), |
| 1040 |
.pre_apply_config = verify_default_profiles, |
| 1041 |
); |
| 1042 |
|
| 1043 |
|
| 1044 |
static int bridge_cmp_cb(void *obj, void *arg, int flags) |
| 1045 |
{ |
| 1046 |
const struct bridge_profile *left = obj; |
| 1047 |
const struct bridge_profile *right = arg; |
| 1048 |
const char *right_name = arg; |
| 1049 |
int cmp; |
| 1050 |
|
| 1051 |
switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) { |
| 1052 |
default: |
| 1053 |
case OBJ_POINTER: |
| 1054 |
right_name = right->name; |
| 1055 |
|
| 1056 |
case OBJ_KEY: |
| 1057 |
cmp = strcasecmp(left->name, right_name); |
| 1058 |
break; |
| 1059 |
case OBJ_PARTIAL_KEY: |
| 1060 |
cmp = strncasecmp(left->name, right_name, strlen(right_name)); |
| 1061 |
break; |
| 1062 |
} |
| 1063 |
return cmp ? 0 : CMP_MATCH; |
| 1064 |
} |
| 1065 |
|
| 1066 |
static int bridge_hash_cb(const void *obj, const int flags) |
| 1067 |
{ |
| 1068 |
const struct bridge_profile *b_profile = obj; |
| 1069 |
const char *name = obj; |
| 1070 |
int hash; |
| 1071 |
|
| 1072 |
switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) { |
| 1073 |
default: |
| 1074 |
case OBJ_POINTER: |
| 1075 |
name = b_profile->name; |
| 1076 |
|
| 1077 |
case OBJ_KEY: |
| 1078 |
hash = ast_str_case_hash(name); |
| 1079 |
break; |
| 1080 |
case OBJ_PARTIAL_KEY: |
| 1081 |
|
| 1082 |
ast_assert(0); |
| 1083 |
hash = 0; |
| 1084 |
break; |
| 1085 |
} |
| 1086 |
return hash; |
| 1087 |
} |
| 1088 |
|
| 1089 |
|
| 1090 |
static int menu_cmp_cb(void *obj, void *arg, int flags) |
| 1091 |
{ |
| 1092 |
const struct conf_menu *left = obj; |
| 1093 |
const struct conf_menu *right = arg; |
| 1094 |
const char *right_name = arg; |
| 1095 |
int cmp; |
| 1096 |
|
| 1097 |
switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) { |
| 1098 |
default: |
| 1099 |
case OBJ_POINTER: |
| 1100 |
right_name = right->name; |
| 1101 |
|
| 1102 |
case OBJ_KEY: |
| 1103 |
cmp = strcasecmp(left->name, right_name); |
| 1104 |
break; |
| 1105 |
case OBJ_PARTIAL_KEY: |
| 1106 |
cmp = strncasecmp(left->name, right_name, strlen(right_name)); |
| 1107 |
break; |
| 1108 |
} |
| 1109 |
return cmp ? 0 : CMP_MATCH; |
| 1110 |
} |
| 1111 |
|
| 1112 |
static int menu_hash_cb(const void *obj, const int flags) |
| 1113 |
{ |
| 1114 |
const struct conf_menu *menu = obj; |
| 1115 |
const char *name = obj; |
| 1116 |
int hash; |
| 1117 |
|
| 1118 |
switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) { |
| 1119 |
default: |
| 1120 |
case OBJ_POINTER: |
| 1121 |
name = menu->name; |
| 1122 |
|
| 1123 |
case OBJ_KEY: |
| 1124 |
hash = ast_str_case_hash(name); |
| 1125 |
break; |
| 1126 |
case OBJ_PARTIAL_KEY: |
| 1127 |
|
| 1128 |
ast_assert(0); |
| 1129 |
hash = 0; |
| 1130 |
break; |
| 1131 |
} |
| 1132 |
return hash; |
| 1133 |
} |
| 1134 |
|
| 1135 |
static void menu_destructor(void *obj) |
| 1136 |
{ |
| 1137 |
struct conf_menu *menu = obj; |
| 1138 |
struct conf_menu_entry *entry = NULL; |
| 1139 |
|
| 1140 |
while ((entry = AST_LIST_REMOVE_HEAD(&menu->entries, entry))) { |
| 1141 |
conf_menu_entry_destroy(entry); |
| 1142 |
ast_free(entry); |
| 1143 |
} |
| 1144 |
} |
| 1145 |
|
| 1146 |
|
| 1147 |
static int user_cmp_cb(void *obj, void *arg, int flags) |
| 1148 |
{ |
| 1149 |
const struct user_profile *left = obj; |
| 1150 |
const struct user_profile *right = arg; |
| 1151 |
const char *right_name = arg; |
| 1152 |
int cmp; |
| 1153 |
|
| 1154 |
switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) { |
| 1155 |
default: |
| 1156 |
case OBJ_POINTER: |
| 1157 |
right_name = right->name; |
| 1158 |
|
| 1159 |
case OBJ_KEY: |
| 1160 |
cmp = strcasecmp(left->name, right_name); |
| 1161 |
break; |
| 1162 |
case OBJ_PARTIAL_KEY: |
| 1163 |
cmp = strncasecmp(left->name, right_name, strlen(right_name)); |
| 1164 |
break; |
| 1165 |
} |
| 1166 |
return cmp ? 0 : CMP_MATCH; |
| 1167 |
} |
| 1168 |
|
| 1169 |
static int user_hash_cb(const void *obj, const int flags) |
| 1170 |
{ |
| 1171 |
const struct user_profile *u_profile = obj; |
| 1172 |
const char *name = obj; |
| 1173 |
int hash; |
| 1174 |
|
| 1175 |
switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) { |
| 1176 |
default: |
| 1177 |
case OBJ_POINTER: |
| 1178 |
name = u_profile->name; |
| 1179 |
|
| 1180 |
case OBJ_KEY: |
| 1181 |
hash = ast_str_case_hash(name); |
| 1182 |
break; |
| 1183 |
case OBJ_PARTIAL_KEY: |
| 1184 |
|
| 1185 |
ast_assert(0); |
| 1186 |
hash = 0; |
| 1187 |
break; |
| 1188 |
} |
| 1189 |
return hash; |
| 1190 |
} |
| 1191 |
|
| 1192 |
|
| 1193 |
static void bridge_profile_sounds_destroy_cb(void *obj) |
| 1194 |
{ |
| 1195 |
struct bridge_profile_sounds *sounds = obj; |
| 1196 |
ast_string_field_free_memory(sounds); |
| 1197 |
} |
| 1198 |
|
| 1199 |
static struct bridge_profile_sounds *bridge_profile_sounds_alloc(void) |
| 1200 |
{ |
| 1201 |
struct bridge_profile_sounds *sounds = ao2_alloc(sizeof(*sounds), bridge_profile_sounds_destroy_cb); |
| 1202 |
|
| 1203 |
if (!sounds) { |
| 1204 |
return NULL; |
| 1205 |
} |
| 1206 |
if (ast_string_field_init(sounds, 512)) { |
| 1207 |
ao2_ref(sounds, -1); |
| 1208 |
return NULL; |
| 1209 |
} |
| 1210 |
|
| 1211 |
return sounds; |
| 1212 |
} |
| 1213 |
|
| 1214 |
static int set_sound(const char *sound_name, const char *sound_file, struct bridge_profile *b_profile) |
| 1215 |
{ |
| 1216 |
struct bridge_profile_sounds *sounds = b_profile->sounds; |
| 1217 |
if (ast_strlen_zero(sound_file)) { |
| 1218 |
return -1; |
| 1219 |
} |
| 1220 |
|
| 1221 |
if (!strcasecmp(sound_name, "sound_only_person")) { |
| 1222 |
ast_string_field_set(sounds, onlyperson, sound_file); |
| 1223 |
} else if (!strcasecmp(sound_name, "sound_only_one")) { |
| 1224 |
ast_string_field_set(sounds, onlyone, sound_file); |
| 1225 |
} else if (!strcasecmp(sound_name, "sound_has_joined")) { |
| 1226 |
ast_string_field_set(sounds, hasjoin, sound_file); |
| 1227 |
} else if (!strcasecmp(sound_name, "sound_has_left")) { |
| 1228 |
ast_string_field_set(sounds, hasleft, sound_file); |
| 1229 |
} else if (!strcasecmp(sound_name, "sound_kicked")) { |
| 1230 |
ast_string_field_set(sounds, kicked, sound_file); |
| 1231 |
} else if (!strcasecmp(sound_name, "sound_muted")) { |
| 1232 |
ast_string_field_set(sounds, muted, sound_file); |
| 1233 |
} else if (!strcasecmp(sound_name, "sound_unmuted")) { |
| 1234 |
ast_string_field_set(sounds, unmuted, sound_file); |
| 1235 |
} else if (!strcasecmp(sound_name, "sound_binaural_on")) { |
| 1236 |
ast_string_field_set(sounds, binauralon, sound_file); |
| 1237 |
} else if (!strcasecmp(sound_name, "sound_binaural_off")) { |
| 1238 |
ast_string_field_set(sounds, binauraloff, sound_file); |
| 1239 |
} else if (!strcasecmp(sound_name, "sound_there_are")) { |
| 1240 |
ast_string_field_set(sounds, thereare, sound_file); |
| 1241 |
} else if (!strcasecmp(sound_name, "sound_other_in_party")) { |
| 1242 |
ast_string_field_set(sounds, otherinparty, sound_file); |
| 1243 |
} else if (!strcasecmp(sound_name, "sound_place_into_conference")) { |
| 1244 |
static int deprecation_warning = 1; |
| 1245 |
if (deprecation_warning) { |
| 1246 |
ast_log(LOG_WARNING, "sound_place_into_conference is deprecated" |
| 1247 |
" and unused. Use sound_begin for similar functionality."); |
| 1248 |
deprecation_warning = 0; |
| 1249 |
} |
| 1250 |
ast_string_field_set(sounds, placeintoconf, sound_file); |
| 1251 |
} else if (!strcasecmp(sound_name, "sound_wait_for_leader")) { |
| 1252 |
ast_string_field_set(sounds, waitforleader, sound_file); |
| 1253 |
} else if (!strcasecmp(sound_name, "sound_leader_has_left")) { |
| 1254 |
ast_string_field_set(sounds, leaderhasleft, sound_file); |
| 1255 |
} else if (!strcasecmp(sound_name, "sound_get_pin")) { |
| 1256 |
ast_string_field_set(sounds, getpin, sound_file); |
| 1257 |
} else if (!strcasecmp(sound_name, "sound_invalid_pin")) { |
| 1258 |
ast_string_field_set(sounds, invalidpin, sound_file); |
| 1259 |
} else if (!strcasecmp(sound_name, "sound_locked")) { |
| 1260 |
ast_string_field_set(sounds, locked, sound_file); |
| 1261 |
} else if (!strcasecmp(sound_name, "sound_unlocked_now")) { |
| 1262 |
ast_string_field_set(sounds, unlockednow, sound_file); |
| 1263 |
} else if (!strcasecmp(sound_name, "sound_locked_now")) { |
| 1264 |
ast_string_field_set(sounds, lockednow, sound_file); |
| 1265 |
} else if (!strcasecmp(sound_name, "sound_error_menu")) { |
| 1266 |
ast_string_field_set(sounds, errormenu, sound_file); |
| 1267 |
} else if (!strcasecmp(sound_name, "sound_join")) { |
| 1268 |
ast_string_field_set(sounds, join, sound_file); |
| 1269 |
} else if (!strcasecmp(sound_name, "sound_leave")) { |
| 1270 |
ast_string_field_set(sounds, leave, sound_file); |
| 1271 |
} else if (!strcasecmp(sound_name, "sound_participants_muted")) { |
| 1272 |
ast_string_field_set(sounds, participantsmuted, sound_file); |
| 1273 |
} else if (!strcasecmp(sound_name, "sound_participants_unmuted")) { |
| 1274 |
ast_string_field_set(sounds, participantsunmuted, sound_file); |
| 1275 |
} else if (!strcasecmp(sound_name, "sound_begin")) { |
| 1276 |
ast_string_field_set(sounds, begin, sound_file); |
| 1277 |
} else { |
| 1278 |
return -1; |
| 1279 |
} |
| 1280 |
|
| 1281 |
return 0; |
| 1282 |
} |
| 1283 |
|
| 1284 |
|
| 1285 |
struct func_confbridge_data { |
| 1286 |
struct bridge_profile b_profile; |
| 1287 |
struct user_profile u_profile; |
| 1288 |
struct conf_menu *menu; |
| 1289 |
unsigned int b_usable:1; |
| 1290 |
unsigned int u_usable:1; |
| 1291 |
unsigned int m_usable:1; |
| 1292 |
}; |
| 1293 |
|
| 1294 |
static void func_confbridge_data_destructor(struct func_confbridge_data *b_data) |
| 1295 |
{ |
| 1296 |
conf_bridge_profile_destroy(&b_data->b_profile); |
| 1297 |
ao2_cleanup(b_data->menu); |
| 1298 |
ast_free(b_data); |
| 1299 |
} |
| 1300 |
|
| 1301 |
static void func_confbridge_destroy_cb(void *data) |
| 1302 |
{ |
| 1303 |
struct func_confbridge_data *b_data = data; |
| 1304 |
func_confbridge_data_destructor(b_data); |
| 1305 |
}; |
| 1306 |
|
| 1307 |
static const struct ast_datastore_info confbridge_datastore = { |
| 1308 |
.type = "confbridge", |
| 1309 |
.destroy = func_confbridge_destroy_cb |
| 1310 |
}; |
| 1311 |
|
| 1312 |
int func_confbridge_helper(struct ast_channel *chan, const char *cmd, char *data, const char *value) |
| 1313 |
{ |
| 1314 |
struct ast_datastore *datastore; |
| 1315 |
struct func_confbridge_data *b_data; |
| 1316 |
char *parse; |
| 1317 |
struct ast_variable tmpvar = { 0, }; |
| 1318 |
struct ast_variable template = { |
| 1319 |
.name = "template", |
| 1320 |
.file = "CONFBRIDGE" |
| 1321 |
}; |
| 1322 |
AST_DECLARE_APP_ARGS(args, |
| 1323 |
AST_APP_ARG(type); |
| 1324 |
AST_APP_ARG(option); |
| 1325 |
); |
| 1326 |
|
| 1327 |
if (!chan) { |
| 1328 |
ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd); |
| 1329 |
return -1; |
| 1330 |
} |
| 1331 |
|
| 1332 |
|
| 1333 |
if (ast_strlen_zero(data)) { |
| 1334 |
return -1; |
| 1335 |
} |
| 1336 |
parse = ast_strdupa(data); |
| 1337 |
AST_STANDARD_APP_ARGS(args, parse); |
| 1338 |
if (ast_strlen_zero(args.type) || ast_strlen_zero(args.option)) { |
| 1339 |
return -1; |
| 1340 |
} |
| 1341 |
|
| 1342 |
ast_channel_lock(chan); |
| 1343 |
datastore = ast_channel_datastore_find(chan, &confbridge_datastore, NULL); |
| 1344 |
if (!datastore) { |
| 1345 |
datastore = ast_datastore_alloc(&confbridge_datastore, NULL); |
| 1346 |
if (!datastore) { |
| 1347 |
ast_channel_unlock(chan); |
| 1348 |
return 0; |
| 1349 |
} |
| 1350 |
b_data = ast_calloc(1, sizeof(*b_data)); |
| 1351 |
if (!b_data) { |
| 1352 |
ast_channel_unlock(chan); |
| 1353 |
ast_datastore_free(datastore); |
| 1354 |
return 0; |
| 1355 |
} |
| 1356 |
datastore->data = b_data; |
| 1357 |
b_data->b_profile.sounds = bridge_profile_sounds_alloc(); |
| 1358 |
if (!b_data->b_profile.sounds) { |
| 1359 |
ast_channel_unlock(chan); |
| 1360 |
ast_datastore_free(datastore); |
| 1361 |
return 0; |
| 1362 |
} |
| 1363 |
if (!(b_data->menu = menu_alloc("dialplan"))) { |
| 1364 |
ast_channel_unlock(chan); |
| 1365 |
ast_datastore_free(datastore); |
| 1366 |
return 0; |
| 1367 |
} |
| 1368 |
ast_channel_datastore_add(chan, datastore); |
| 1369 |
} else { |
| 1370 |
b_data = datastore->data; |
| 1371 |
} |
| 1372 |
ast_channel_unlock(chan); |
| 1373 |
|
| 1374 |
|
| 1375 |
if (!value) { |
| 1376 |
value = ""; |
| 1377 |
} |
| 1378 |
tmpvar.name = args.option; |
| 1379 |
tmpvar.value = value; |
| 1380 |
tmpvar.file = "CONFBRIDGE"; |
| 1381 |
if (!strcasecmp(args.type, "bridge")) { |
| 1382 |
if (!strcasecmp(args.option, "clear")) { |
| 1383 |
b_data->b_usable = 0; |
| 1384 |
conf_bridge_profile_destroy(&b_data->b_profile); |
| 1385 |
memset(&b_data->b_profile, 0, sizeof(b_data->b_profile)) ; |
| 1386 |
if (!(b_data->b_profile.sounds = bridge_profile_sounds_alloc())) { |
| 1387 |
|
| 1388 |
ast_channel_lock(chan); |
| 1389 |
ast_channel_datastore_remove(chan, datastore); |
| 1390 |
ast_channel_unlock(chan); |
| 1391 |
ast_datastore_free(datastore); |
| 1392 |
} |
| 1393 |
return 0; |
| 1394 |
} |
| 1395 |
|
| 1396 |
if (b_data && !b_data->b_usable && strcasecmp(args.option, "template")) { |
| 1397 |
template.value = DEFAULT_BRIDGE_PROFILE; |
| 1398 |
aco_process_var(&bridge_type, "dialplan", &template, &b_data->b_profile); |
| 1399 |
} |
| 1400 |
|
| 1401 |
if (!aco_process_var(&bridge_type, "dialplan", &tmpvar, &b_data->b_profile)) { |
| 1402 |
b_data->b_usable = 1; |
| 1403 |
return 0; |
| 1404 |
} |
| 1405 |
} else if (!strcasecmp(args.type, "user")) { |
| 1406 |
if (!strcasecmp(args.option, "clear")) { |
| 1407 |
b_data->u_usable = 0; |
| 1408 |
user_profile_destructor(&b_data->u_profile); |
| 1409 |
memset(&b_data->u_profile, 0, sizeof(b_data->u_profile)); |
| 1410 |
return 0; |
| 1411 |
} |
| 1412 |
|
| 1413 |
if (b_data && !b_data->u_usable && strcasecmp(args.option, "template")) { |
| 1414 |
template.value = DEFAULT_USER_PROFILE; |
| 1415 |
aco_process_var(&user_type, "dialplan", &template, &b_data->u_profile); |
| 1416 |
} |
| 1417 |
|
| 1418 |
if (!aco_process_var(&user_type, "dialplan", &tmpvar, &b_data->u_profile)) { |
| 1419 |
b_data->u_usable = 1; |
| 1420 |
return 0; |
| 1421 |
} |
| 1422 |
} else if (!strcasecmp(args.type, "menu")) { |
| 1423 |
if (!strcasecmp(args.option, "clear")) { |
| 1424 |
b_data->m_usable = 0; |
| 1425 |
ao2_cleanup(b_data->menu); |
| 1426 |
if (!(b_data->menu = menu_alloc("dialplan"))) { |
| 1427 |
|
| 1428 |
ast_channel_lock(chan); |
| 1429 |
ast_channel_datastore_remove(chan, datastore); |
| 1430 |
ast_channel_unlock(chan); |
| 1431 |
ast_datastore_free(datastore); |
| 1432 |
} |
| 1433 |
return 0; |
| 1434 |
} |
| 1435 |
|
| 1436 |
if (b_data && !b_data->m_usable && strcasecmp(args.option, "template")) { |
| 1437 |
template.value = DEFAULT_MENU_PROFILE; |
| 1438 |
aco_process_var(&menu_type, "dialplan", &template, &b_data->menu); |
| 1439 |
} |
| 1440 |
|
| 1441 |
if (!aco_process_var(&menu_type, "dialplan", &tmpvar, b_data->menu)) { |
| 1442 |
b_data->m_usable = 1; |
| 1443 |
return 0; |
| 1444 |
} |
| 1445 |
} |
| 1446 |
|
| 1447 |
ast_log(LOG_WARNING, "%s(%s,%s) cannot be set to '%s'. Invalid type, option, or value.\n", |
| 1448 |
cmd, args.type, args.option, value); |
| 1449 |
return -1; |
| 1450 |
} |
| 1451 |
|
| 1452 |
static int add_action_to_menu_entry(struct conf_menu_entry *menu_entry, enum conf_menu_action_id id, char *databuf) |
| 1453 |
{ |
| 1454 |
struct conf_menu_action *menu_action = ast_calloc(1, sizeof(*menu_action)); |
| 1455 |
|
| 1456 |
if (!menu_action) { |
| 1457 |
return -1; |
| 1458 |
} |
| 1459 |
menu_action->id = id; |
| 1460 |
|
| 1461 |
switch (id) { |
| 1462 |
case MENU_ACTION_NOOP: |
| 1463 |
case MENU_ACTION_TOGGLE_MUTE: |
| 1464 |
case MENU_ACTION_TOGGLE_BINAURAL: |
| 1465 |
case MENU_ACTION_INCREASE_LISTENING: |
| 1466 |
case MENU_ACTION_DECREASE_LISTENING: |
| 1467 |
case MENU_ACTION_INCREASE_TALKING: |
| 1468 |
case MENU_ACTION_DECREASE_TALKING: |
| 1469 |
case MENU_ACTION_RESET_LISTENING: |
| 1470 |
case MENU_ACTION_RESET_TALKING: |
| 1471 |
case MENU_ACTION_ADMIN_TOGGLE_LOCK: |
| 1472 |
case MENU_ACTION_ADMIN_TOGGLE_MUTE_PARTICIPANTS: |
| 1473 |
case MENU_ACTION_PARTICIPANT_COUNT: |
| 1474 |
case MENU_ACTION_ADMIN_KICK_LAST: |
| 1475 |
case MENU_ACTION_LEAVE: |
| 1476 |
case MENU_ACTION_SET_SINGLE_VIDEO_SRC: |
| 1477 |
case MENU_ACTION_RELEASE_SINGLE_VIDEO_SRC: |
| 1478 |
break; |
| 1479 |
case MENU_ACTION_PLAYBACK: |
| 1480 |
case MENU_ACTION_PLAYBACK_AND_CONTINUE: |
| 1481 |
if (!(ast_strlen_zero(databuf))) { |
| 1482 |
ast_copy_string(menu_action->data.playback_file, databuf, sizeof(menu_action->data.playback_file)); |
| 1483 |
} else { |
| 1484 |
ast_free(menu_action); |
| 1485 |
return -1; |
| 1486 |
} |
| 1487 |
break; |
| 1488 |
case MENU_ACTION_DIALPLAN_EXEC: |
| 1489 |
if (!(ast_strlen_zero(databuf))) { |
| 1490 |
AST_DECLARE_APP_ARGS(args, |
| 1491 |
AST_APP_ARG(context); |
| 1492 |
AST_APP_ARG(exten); |
| 1493 |
AST_APP_ARG(priority); |
| 1494 |
); |
| 1495 |
AST_STANDARD_APP_ARGS(args, databuf); |
| 1496 |
if (!ast_strlen_zero(args.context)) { |
| 1497 |
ast_copy_string(menu_action->data.dialplan_args.context, |
| 1498 |
args.context, |
| 1499 |
sizeof(menu_action->data.dialplan_args.context)); |
| 1500 |
} |
| 1501 |
if (!ast_strlen_zero(args.exten)) { |
| 1502 |
ast_copy_string(menu_action->data.dialplan_args.exten, |
| 1503 |
args.exten, |
| 1504 |
sizeof(menu_action->data.dialplan_args.exten)); |
| 1505 |
} |
| 1506 |
menu_action->data.dialplan_args.priority = 1; |
| 1507 |
if (!ast_strlen_zero(args.priority) && |
| 1508 |
(sscanf(args.priority, "%30d", &menu_action->data.dialplan_args.priority) != 1)) { |
| 1509 |
|
| 1510 |
ast_free(menu_action); |
| 1511 |
return -1; |
| 1512 |
} |
| 1513 |
} else { |
| 1514 |
ast_free(menu_action); |
| 1515 |
return -1; |
| 1516 |
} |
| 1517 |
}; |
| 1518 |
|
| 1519 |
AST_LIST_INSERT_TAIL(&menu_entry->actions, menu_action, action); |
| 1520 |
|
| 1521 |
return 0; |
| 1522 |
} |
| 1523 |
|
| 1524 |
static int add_menu_entry(struct conf_menu *menu, const char *dtmf, const char *action_names) |
| 1525 |
{ |
| 1526 |
struct conf_menu_entry *menu_entry = NULL, *cur = NULL; |
| 1527 |
int res = 0; |
| 1528 |
char *tmp_action_names = ast_strdupa(action_names); |
| 1529 |
char *action = NULL; |
| 1530 |
char *action_args; |
| 1531 |
char *tmp; |
| 1532 |
char buf[PATH_MAX]; |
| 1533 |
char *delimiter = ","; |
| 1534 |
|
| 1535 |
if (!(menu_entry = ast_calloc(1, sizeof(*menu_entry)))) { |
| 1536 |
return -1; |
| 1537 |
} |
| 1538 |
|
| 1539 |
for (;;) { |
| 1540 |
char *comma; |
| 1541 |
char *startbrace; |
| 1542 |
char *endbrace; |
| 1543 |
unsigned int action_len; |
| 1544 |
|
| 1545 |
if (ast_strlen_zero(tmp_action_names)) { |
| 1546 |
break; |
| 1547 |
} |
| 1548 |
startbrace = strchr(tmp_action_names, '('); |
| 1549 |
endbrace = strchr(tmp_action_names, ')'); |
| 1550 |
comma = strchr(tmp_action_names, ','); |
| 1551 |
|
| 1552 |
|
| 1553 |
|
| 1554 |
if (startbrace && endbrace && comma && (comma > startbrace && comma < endbrace)) { |
| 1555 |
delimiter = ")"; |
| 1556 |
} else { |
| 1557 |
delimiter = ","; |
| 1558 |
} |
| 1559 |
|
| 1560 |
if (!(action = strsep(&tmp_action_names, delimiter))) { |
| 1561 |
break; |
| 1562 |
} |
| 1563 |
|
| 1564 |
action = ast_strip(action); |
| 1565 |
if (ast_strlen_zero(action)) { |
| 1566 |
continue; |
| 1567 |
} |
| 1568 |
|
| 1569 |
action_len = strlen(action); |
| 1570 |
ast_copy_string(menu_entry->dtmf, dtmf, sizeof(menu_entry->dtmf)); |
| 1571 |
if (!strcasecmp(action, "toggle_mute")) { |
| 1572 |
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_TOGGLE_MUTE, NULL); |
| 1573 |
} else if (!strcasecmp(action, "toggle_binaural")) { |
| 1574 |
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_TOGGLE_BINAURAL, NULL); |
| 1575 |
} else if (!strcasecmp(action, "no_op")) { |
| 1576 |
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_NOOP, NULL); |
| 1577 |
} else if (!strcasecmp(action, "increase_listening_volume")) { |
| 1578 |
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_INCREASE_LISTENING, NULL); |
| 1579 |
} else if (!strcasecmp(action, "decrease_listening_volume")) { |
| 1580 |
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DECREASE_LISTENING, NULL); |
| 1581 |
} else if (!strcasecmp(action, "increase_talking_volume")) { |
| 1582 |
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_INCREASE_TALKING, NULL); |
| 1583 |
} else if (!strcasecmp(action, "reset_listening_volume")) { |
| 1584 |
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_RESET_LISTENING, NULL); |
| 1585 |
} else if (!strcasecmp(action, "reset_talking_volume")) { |
| 1586 |
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_RESET_TALKING, NULL); |
| 1587 |
} else if (!strcasecmp(action, "decrease_talking_volume")) { |
| 1588 |
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DECREASE_TALKING, NULL); |
| 1589 |
} else if (!strcasecmp(action, "admin_toggle_conference_lock")) { |
| 1590 |
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_ADMIN_TOGGLE_LOCK, NULL); |
| 1591 |
} else if (!strcasecmp(action, "admin_toggle_mute_participants")) { |
| 1592 |
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_ADMIN_TOGGLE_MUTE_PARTICIPANTS, NULL); |
| 1593 |
} else if (!strcasecmp(action, "participant_count")) { |
| 1594 |
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PARTICIPANT_COUNT, NULL); |
| 1595 |
} else if (!strcasecmp(action, "admin_kick_last")) { |
| 1596 |
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_ADMIN_KICK_LAST, NULL); |
| 1597 |
} else if (!strcasecmp(action, "leave_conference")) { |
| 1598 |
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_LEAVE, NULL); |
| 1599 |
} else if (!strcasecmp(action, "set_as_single_video_src")) { |
| 1600 |
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_SET_SINGLE_VIDEO_SRC, NULL); |
| 1601 |
} else if (!strcasecmp(action, "release_as_single_video_src")) { |
| 1602 |
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_RELEASE_SINGLE_VIDEO_SRC, NULL); |
| 1603 |
} else if (!strncasecmp(action, "dialplan_exec(", 14)) { |
| 1604 |
ast_copy_string(buf, action, sizeof(buf)); |
| 1605 |
action_args = buf; |
| 1606 |
if ((action_args = strchr(action, '('))) { |
| 1607 |
action_args++; |
| 1608 |
} |
| 1609 |
|
| 1610 |
|
| 1611 |
|
| 1612 |
if ((tmp = strchr(action, ')'))) { |
| 1613 |
*tmp = '\0'; |
| 1614 |
} |
| 1615 |
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DIALPLAN_EXEC, action_args); |
| 1616 |
} else if (action_len >= 21 && !strncasecmp(action, "playback_and_continue(", 22)) { |
| 1617 |
ast_copy_string(buf, action, sizeof(buf)); |
| 1618 |
action_args = buf; |
| 1619 |
if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) { |
| 1620 |
*tmp = '\0'; |
| 1621 |
action_args++; |
| 1622 |
} |
| 1623 |
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PLAYBACK_AND_CONTINUE, action_args); |
| 1624 |
} else if (action_len >= 8 && !strncasecmp(action, "playback(", 9)) { |
| 1625 |
ast_copy_string(buf, action, sizeof(buf)); |
| 1626 |
action_args = buf; |
| 1627 |
if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) { |
| 1628 |
*tmp = '\0'; |
| 1629 |
action_args++; |
| 1630 |
} |
| 1631 |
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PLAYBACK, action_args); |
| 1632 |
} |
| 1633 |
} |
| 1634 |
|
| 1635 |
|
| 1636 |
if (res) { |
| 1637 |
conf_menu_entry_destroy(menu_entry); |
| 1638 |
ast_free(menu_entry); |
| 1639 |
return -1; |
| 1640 |
} |
| 1641 |
|
| 1642 |
|
| 1643 |
AST_LIST_TRAVERSE_SAFE_BEGIN(&menu->entries, cur, entry) { |
| 1644 |
if (!strcasecmp(cur->dtmf, menu_entry->dtmf)) { |
| 1645 |
AST_LIST_REMOVE_CURRENT(entry); |
| 1646 |
conf_menu_entry_destroy(cur); |
| 1647 |
ast_free(cur); |
| 1648 |
break; |
| 1649 |
} |
| 1650 |
} |
| 1651 |
AST_LIST_TRAVERSE_SAFE_END; |
| 1652 |
|
| 1653 |
AST_LIST_INSERT_TAIL(&menu->entries, menu_entry, entry); |
| 1654 |
|
| 1655 |
return 0; |
| 1656 |
} |
| 1657 |
|
| 1658 |
static char *complete_user_profile_name(const char *line, const char *word, int pos, int state) |
| 1659 |
{ |
| 1660 |
int which = 0; |
| 1661 |
char *res = NULL; |
| 1662 |
int wordlen = strlen(word); |
| 1663 |
struct ao2_iterator i; |
| 1664 |
struct user_profile *u_profile = NULL; |
| 1665 |
RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup); |
| 1666 |
|
| 1667 |
if (!cfg) { |
| 1668 |
return NULL; |
| 1669 |
} |
| 1670 |
|
| 1671 |
i = ao2_iterator_init(cfg->user_profiles, 0); |
| 1672 |
while ((u_profile = ao2_iterator_next(&i))) { |
| 1673 |
if (!strncasecmp(u_profile->name, word, wordlen) && ++which > state) { |
| 1674 |
res = ast_strdup(u_profile->name); |
| 1675 |
ao2_ref(u_profile, -1); |
| 1676 |
break; |
| 1677 |
} |
| 1678 |
ao2_ref(u_profile, -1); |
| 1679 |
} |
| 1680 |
ao2_iterator_destroy(&i); |
| 1681 |
|
| 1682 |
return res; |
| 1683 |
} |
| 1684 |
|
| 1685 |
static char *handle_cli_confbridge_show_user_profiles(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| 1686 |
{ |
| 1687 |
struct ao2_iterator it; |
| 1688 |
struct user_profile *u_profile; |
| 1689 |
RAII_VAR(struct confbridge_cfg *, cfg, NULL, ao2_cleanup); |
| 1690 |
|
| 1691 |
switch (cmd) { |
| 1692 |
case CLI_INIT: |
| 1693 |
e->command = "confbridge show profile users"; |
| 1694 |
e->usage = |
| 1695 |
"Usage: confbridge show profile users\n"; |
| 1696 |
return NULL; |
| 1697 |
case CLI_GENERATE: |
| 1698 |
return NULL; |
| 1699 |
} |
| 1700 |
|
| 1701 |
if (!(cfg = ao2_global_obj_ref(cfg_handle))) { |
| 1702 |
return NULL; |
| 1703 |
} |
| 1704 |
|
| 1705 |
ast_cli(a->fd,"--------- User Profiles -----------\n"); |
| 1706 |
ao2_lock(cfg->user_profiles); |
| 1707 |
it = ao2_iterator_init(cfg->user_profiles, 0); |
| 1708 |
while ((u_profile = ao2_iterator_next(&it))) { |
| 1709 |
ast_cli(a->fd,"%s\n", u_profile->name); |
| 1710 |
ao2_ref(u_profile, -1); |
| 1711 |
} |
| 1712 |
ao2_iterator_destroy(&it); |
| 1713 |
ao2_unlock(cfg->user_profiles); |
| 1714 |
|
| 1715 |
return CLI_SUCCESS; |
| 1716 |
} |
| 1717 |
static char *handle_cli_confbridge_show_user_profile(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| 1718 |
{ |
| 1719 |
struct user_profile u_profile; |
| 1720 |
|
| 1721 |
switch (cmd) { |
| 1722 |
case CLI_INIT: |
| 1723 |
e->command = "confbridge show profile user"; |
| 1724 |
e->usage = |
| 1725 |
"Usage: confbridge show profile user [<profile name>]\n"; |
| 1726 |
return NULL; |
| 1727 |
case CLI_GENERATE: |
| 1728 |
if (a->pos == 4) { |
| 1729 |
return complete_user_profile_name(a->line, a->word, a->pos, a->n); |
| 1730 |
} |
| 1731 |
return NULL; |
| 1732 |
} |
| 1733 |
|
| 1734 |
if (a->argc != 5) { |
| 1735 |
return CLI_SHOWUSAGE; |
| 1736 |
} |
| 1737 |
|
| 1738 |
if (!(conf_find_user_profile(NULL, a->argv[4], &u_profile))) { |
| 1739 |
ast_cli(a->fd, "No conference user profile named '%s' found!\n", a->argv[4]); |
| 1740 |
return CLI_SUCCESS; |
| 1741 |
} |
| 1742 |
|
| 1743 |
ast_cli(a->fd,"--------------------------------------------\n"); |
| 1744 |
ast_cli(a->fd,"Name: %s\n", |
| 1745 |
u_profile.name); |
| 1746 |
ast_cli(a->fd,"Admin: %s\n", |
| 1747 |
u_profile.flags & USER_OPT_ADMIN ? |
| 1748 |
"true" : "false"); |
| 1749 |
ast_cli(a->fd,"Send Events: %s\n", |
| 1750 |
u_profile.flags & USER_OPT_SEND_EVENTS ? |
| 1751 |
"true" : "false"); |
| 1752 |
ast_cli(a->fd,"Echo Events: %s\n", |
| 1753 |
u_profile.flags & USER_OPT_ECHO_EVENTS ? |
| 1754 |
"true" : "false"); |
| 1755 |
ast_cli(a->fd,"Marked User: %s\n", |
| 1756 |
u_profile.flags & USER_OPT_MARKEDUSER ? |
| 1757 |
"true" : "false"); |
| 1758 |
ast_cli(a->fd,"Start Muted: %s\n", |
| 1759 |
u_profile.flags & USER_OPT_STARTMUTED? |
| 1760 |
"true" : "false"); |
| 1761 |
ast_cli(a->fd,"MOH When Empty: %s\n", |
| 1762 |
u_profile.flags & USER_OPT_MUSICONHOLD ? |
| 1763 |
"enabled" : "disabled"); |
| 1764 |
ast_cli(a->fd,"MOH Class: %s\n", |
| 1765 |
ast_strlen_zero(u_profile.moh_class) ? |
| 1766 |
"default" : u_profile.moh_class); |
| 1767 |
ast_cli(a->fd,"Announcement: %s\n", |
| 1768 |
u_profile.announcement); |
| 1769 |
ast_cli(a->fd,"Quiet: %s\n", |
| 1770 |
u_profile.flags & USER_OPT_QUIET ? |
| 1771 |
"enabled" : "disabled"); |
| 1772 |
ast_cli(a->fd,"Hear Join: %s\n", |
| 1773 |
u_profile.flags & USER_OPT_HEAR_OWN_JOIN_SOUND ? |
| 1774 |
"enabled" : "disabled"); |
| 1775 |
ast_cli(a->fd,"Wait Marked: %s\n", |
| 1776 |
u_profile.flags & USER_OPT_WAITMARKED ? |
| 1777 |
"enabled" : "disabled"); |
| 1778 |
ast_cli(a->fd,"END Marked (All): %s\n", |
| 1779 |
u_profile.flags & USER_OPT_ENDMARKED ? |
| 1780 |
"enabled" : "disabled"); |
| 1781 |
ast_cli(a->fd,"END Marked (Any): %s\n", |
| 1782 |
u_profile.flags & USER_OPT_ENDMARKEDANY ? |
| 1783 |
"enabled" : "disabled"); |
| 1784 |
ast_cli(a->fd,"Drop_silence: %s\n", |
| 1785 |
u_profile.flags & USER_OPT_DROP_SILENCE ? |
| 1786 |
"enabled" : "disabled"); |
| 1787 |
ast_cli(a->fd,"Silence Threshold: %ums\n", |
| 1788 |
u_profile.silence_threshold); |
| 1789 |
ast_cli(a->fd,"Talking Threshold: %u\n", |
| 1790 |
u_profile.talking_threshold); |
| 1791 |
ast_cli(a->fd,"Denoise: %s\n", |
| 1792 |
u_profile.flags & USER_OPT_DENOISE ? |
| 1793 |
"enabled" : "disabled"); |
| 1794 |
ast_cli(a->fd,"Jitterbuffer: %s\n", |
| 1795 |
u_profile.flags & USER_OPT_JITTERBUFFER ? |
| 1796 |
"enabled" : "disabled"); |
| 1797 |
ast_cli(a->fd,"Talk Detect Events: %s\n", |
| 1798 |
u_profile.flags & USER_OPT_TALKER_DETECT ? |
| 1799 |
"enabled" : "disabled"); |
| 1800 |
ast_cli(a->fd,"DTMF Pass Through: %s\n", |
| 1801 |
u_profile.flags & USER_OPT_DTMF_PASS ? |
| 1802 |
"enabled" : "disabled"); |
| 1803 |
ast_cli(a->fd,"PIN: %s\n", |
| 1804 |
ast_strlen_zero(u_profile.pin) ? |
| 1805 |
"None" : u_profile.pin); |
| 1806 |
ast_cli(a->fd,"Announce User Count: %s\n", |
| 1807 |
u_profile.flags & USER_OPT_ANNOUNCEUSERCOUNT ? |
| 1808 |
"enabled" : "disabled"); |
| 1809 |
ast_cli(a->fd,"Announce join/leave: %s\n", |
| 1810 |
u_profile.flags & (USER_OPT_ANNOUNCE_JOIN_LEAVE | USER_OPT_ANNOUNCE_JOIN_LEAVE_REVIEW) ? |
| 1811 |
u_profile.flags & USER_OPT_ANNOUNCE_JOIN_LEAVE_REVIEW ? |
| 1812 |
"enabled (with review)" : "enabled" : "disabled"); |
| 1813 |
ast_cli(a->fd,"Announce User Count all: %s\n", |
| 1814 |
u_profile.flags & USER_OPT_ANNOUNCEUSERCOUNTALL ? |
| 1815 |
"enabled" : "disabled"); |
| 1816 |
ast_cli(a->fd,"Text Messaging: %s\n", |
| 1817 |
u_profile.flags & USER_OPT_TEXT_MESSAGING ? |
| 1818 |
"enabled" : "disabled"); |
| 1819 |
ast_cli(a->fd,"Answer Channel: %s\n", |
| 1820 |
u_profile.flags & USER_OPT_ANSWER_CHANNEL ? |
| 1821 |
"true" : "false"); |
| 1822 |
ast_cli(a->fd, "\n"); |
| 1823 |
|
| 1824 |
return CLI_SUCCESS; |
| 1825 |
} |
| 1826 |
|
| 1827 |
static char *complete_bridge_profile_name(const char *line, const char *word, int pos, int state) |
| 1828 |
{ |
| 1829 |
int which = 0; |
| 1830 |
char *res = NULL; |
| 1831 |
int wordlen = strlen(word); |
| 1832 |
struct ao2_iterator i; |
| 1833 |
struct bridge_profile *b_profile = NULL; |
| 1834 |
RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup); |
| 1835 |
|
| 1836 |
if (!cfg) { |
| 1837 |
return NULL; |
| 1838 |
} |
| 1839 |
|
| 1840 |
i = ao2_iterator_init(cfg->bridge_profiles, 0); |
| 1841 |
while ((b_profile = ao2_iterator_next(&i))) { |
| 1842 |
if (!strncasecmp(b_profile->name, word, wordlen) && ++which > state) { |
| 1843 |
res = ast_strdup(b_profile->name); |
| 1844 |
ao2_ref(b_profile, -1); |
| 1845 |
break; |
| 1846 |
} |
| 1847 |
ao2_ref(b_profile, -1); |
| 1848 |
} |
| 1849 |
ao2_iterator_destroy(&i); |
| 1850 |
|
| 1851 |
return res; |
| 1852 |
} |
| 1853 |
|
| 1854 |
static char *handle_cli_confbridge_show_bridge_profiles(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| 1855 |
{ |
| 1856 |
struct ao2_iterator it; |
| 1857 |
struct bridge_profile *b_profile; |
| 1858 |
RAII_VAR(struct confbridge_cfg *, cfg, NULL, ao2_cleanup); |
| 1859 |
|
| 1860 |
switch (cmd) { |
| 1861 |
case CLI_INIT: |
| 1862 |
e->command = "confbridge show profile bridges"; |
| 1863 |
e->usage = |
| 1864 |
"Usage: confbridge show profile bridges\n"; |
| 1865 |
return NULL; |
| 1866 |
case CLI_GENERATE: |
| 1867 |
return NULL; |
| 1868 |
} |
| 1869 |
|
| 1870 |
if (!(cfg = ao2_global_obj_ref(cfg_handle))) { |
| 1871 |
return NULL; |
| 1872 |
} |
| 1873 |
|
| 1874 |
ast_cli(a->fd,"--------- Bridge Profiles -----------\n"); |
| 1875 |
ao2_lock(cfg->bridge_profiles); |
| 1876 |
it = ao2_iterator_init(cfg->bridge_profiles, 0); |
| 1877 |
while ((b_profile = ao2_iterator_next(&it))) { |
| 1878 |
ast_cli(a->fd,"%s\n", b_profile->name); |
| 1879 |
ao2_ref(b_profile, -1); |
| 1880 |
} |
| 1881 |
ao2_iterator_destroy(&it); |
| 1882 |
ao2_unlock(cfg->bridge_profiles); |
| 1883 |
|
| 1884 |
return CLI_SUCCESS; |
| 1885 |
} |
| 1886 |
|
| 1887 |
static char *handle_cli_confbridge_show_bridge_profile(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| 1888 |
{ |
| 1889 |
struct bridge_profile b_profile; |
| 1890 |
char tmp[64]; |
| 1891 |
|
| 1892 |
switch (cmd) { |
| 1893 |
case CLI_INIT: |
| 1894 |
e->command = "confbridge show profile bridge"; |
| 1895 |
e->usage = |
| 1896 |
"Usage: confbridge show profile bridge <profile name>\n"; |
| 1897 |
return NULL; |
| 1898 |
case CLI_GENERATE: |
| 1899 |
if (a->pos == 4) { |
| 1900 |
return complete_bridge_profile_name(a->line, a->word, a->pos, a->n); |
| 1901 |
} |
| 1902 |
return NULL; |
| 1903 |
} |
| 1904 |
|
| 1905 |
if (a->argc != 5) { |
| 1906 |
return CLI_SHOWUSAGE; |
| 1907 |
} |
| 1908 |
|
| 1909 |
if (!(conf_find_bridge_profile(NULL, a->argv[4], &b_profile))) { |
| 1910 |
ast_cli(a->fd, "No conference bridge profile named '%s' found!\n", a->argv[4]); |
| 1911 |
return CLI_SUCCESS; |
| 1912 |
} |
| 1913 |
|
| 1914 |
ast_cli(a->fd,"--------------------------------------------\n"); |
| 1915 |
ast_cli(a->fd,"Name: %s\n", b_profile.name); |
| 1916 |
ast_cli(a->fd,"Language: %s\n", b_profile.language); |
| 1917 |
|
| 1918 |
if (b_profile.internal_sample_rate) { |
| 1919 |
snprintf(tmp, sizeof(tmp), "%u", b_profile.internal_sample_rate); |
| 1920 |
} else { |
| 1921 |
ast_copy_string(tmp, "auto", sizeof(tmp)); |
| 1922 |
} |
| 1923 |
ast_cli(a->fd,"Internal Sample Rate: %s\n", tmp); |
| 1924 |
|
| 1925 |
if (b_profile.maximum_sample_rate) { |
| 1926 |
snprintf(tmp, sizeof(tmp), "%u", b_profile.maximum_sample_rate); |
| 1927 |
} else { |
| 1928 |
ast_copy_string(tmp, "none", sizeof(tmp)); |
| 1929 |
} |
| 1930 |
ast_cli(a->fd,"Maximum Sample Rate: %s\n", tmp); |
| 1931 |
|
| 1932 |
if (b_profile.mix_interval) { |
| 1933 |
ast_cli(a->fd,"Mixing Interval: %u\n", b_profile.mix_interval); |
| 1934 |
} else { |
| 1935 |
ast_cli(a->fd,"Mixing Interval: Default 20ms\n"); |
| 1936 |
} |
| 1937 |
|
| 1938 |
ast_cli(a->fd,"Record Conference: %s\n", |
| 1939 |
b_profile.flags & BRIDGE_OPT_RECORD_CONFERENCE ? |
| 1940 |
"yes" : "no"); |
| 1941 |
|
| 1942 |
ast_cli(a->fd,"Record File Append: %s\n", |
| 1943 |
b_profile.flags & BRIDGE_OPT_RECORD_FILE_APPEND ? |
| 1944 |
"yes" : "no"); |
| 1945 |
|
| 1946 |
ast_cli(a->fd,"Record File Timestamp: %s\n", |
| 1947 |
b_profile.flags & BRIDGE_OPT_RECORD_FILE_TIMESTAMP ? |
| 1948 |
"yes" : "no"); |
| 1949 |
|
| 1950 |
ast_cli(a->fd,"Record File: %s\n", |
| 1951 |
ast_strlen_zero(b_profile.rec_file) ? "Auto Generated" : |
| 1952 |
b_profile.rec_file); |
| 1953 |
|
| 1954 |
ast_cli(a->fd,"Record Options: %s\n", |
| 1955 |
b_profile.rec_options); |
| 1956 |
|
| 1957 |
ast_cli(a->fd,"Record Command: %s\n", |
| 1958 |
b_profile.rec_command); |
| 1959 |
|
| 1960 |
if (b_profile.max_members) { |
| 1961 |
ast_cli(a->fd,"Max Members: %u\n", b_profile.max_members); |
| 1962 |
} else { |
| 1963 |
ast_cli(a->fd,"Max Members: No Limit\n"); |
| 1964 |
} |
| 1965 |
|
| 1966 |
ast_cli(a->fd,"Registration context: %s\n", b_profile.regcontext); |
| 1967 |
|
| 1968 |
switch (b_profile.flags |
| 1969 |
& (BRIDGE_OPT_VIDEO_SRC_LAST_MARKED | |
| 1970 |
BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED | |
| 1971 |
BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER | |
| 1972 |
BRIDGE_OPT_VIDEO_SRC_SFU)) { |
| 1973 |
case BRIDGE_OPT_VIDEO_SRC_LAST_MARKED: |
| 1974 |
ast_cli(a->fd, "Video Mode: last_marked\n"); |
| 1975 |
break; |
| 1976 |
case BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED: |
| 1977 |
ast_cli(a->fd, "Video Mode: first_marked\n"); |
| 1978 |
break; |
| 1979 |
case BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER: |
| 1980 |
ast_cli(a->fd, "Video Mode: follow_talker\n"); |
| 1981 |
break; |
| 1982 |
case BRIDGE_OPT_VIDEO_SRC_SFU: |
| 1983 |
ast_cli(a->fd, "Video Mode: sfu\n"); |
| 1984 |
break; |
| 1985 |
case 0: |
| 1986 |
ast_cli(a->fd, "Video Mode: no video\n"); |
| 1987 |
break; |
| 1988 |
default: |
| 1989 |
|
| 1990 |
ast_assert(0); |
| 1991 |
break; |
| 1992 |
} |
| 1993 |
|
| 1994 |
ast_cli(a->fd,"Video Update Discard: %u\n", b_profile.video_update_discard); |
| 1995 |
ast_cli(a->fd,"REMB Send Interval: %u\n", b_profile.remb_send_interval); |
| 1996 |
|
| 1997 |
switch (b_profile.flags |
| 1998 |
& (BRIDGE_OPT_REMB_BEHAVIOR_AVERAGE | BRIDGE_OPT_REMB_BEHAVIOR_LOWEST |
| 1999 |
| BRIDGE_OPT_REMB_BEHAVIOR_HIGHEST | BRIDGE_OPT_REMB_BEHAVIOR_AVERAGE_ALL |
| 2000 |
| BRIDGE_OPT_REMB_BEHAVIOR_LOWEST_ALL | BRIDGE_OPT_REMB_BEHAVIOR_LOWEST_ALL)) { |
| 2001 |
case BRIDGE_OPT_REMB_BEHAVIOR_AVERAGE: |
| 2002 |
ast_cli(a->fd, "REMB Behavior: average\n"); |
| 2003 |
break; |
| 2004 |
case BRIDGE_OPT_REMB_BEHAVIOR_LOWEST: |
| 2005 |
ast_cli(a->fd, "REMB Behavior: lowest\n"); |
| 2006 |
break; |
| 2007 |
case BRIDGE_OPT_REMB_BEHAVIOR_HIGHEST: |
| 2008 |
ast_cli(a->fd, "REMB Behavior: highest\n"); |
| 2009 |
break; |
| 2010 |
case BRIDGE_OPT_REMB_BEHAVIOR_AVERAGE_ALL: |
| 2011 |
ast_cli(a->fd, "REMB Behavior: average_all\n"); |
| 2012 |
break; |
| 2013 |
case BRIDGE_OPT_REMB_BEHAVIOR_LOWEST_ALL: |
| 2014 |
ast_cli(a->fd, "REMB Behavior: lowest_all\n"); |
| 2015 |
break; |
| 2016 |
case BRIDGE_OPT_REMB_BEHAVIOR_HIGHEST_ALL: |
| 2017 |
ast_cli(a->fd, "REMB Behavior: highest_all\n"); |
| 2018 |
break; |
| 2019 |
default: |
| 2020 |
ast_assert(0); |
| 2021 |
break; |
| 2022 |
} |
| 2023 |
|
| 2024 |
ast_cli(a->fd,"Enable Events: %s\n", |
| 2025 |
b_profile.flags & BRIDGE_OPT_ENABLE_EVENTS ? |
| 2026 |
"yes" : "no"); |
| 2027 |
|
| 2028 |
ast_cli(a->fd,"sound_only_person: %s\n", conf_get_sound(CONF_SOUND_ONLY_PERSON, b_profile.sounds)); |
| 2029 |
ast_cli(a->fd,"sound_only_one: %s\n", conf_get_sound(CONF_SOUND_ONLY_ONE, b_profile.sounds)); |
| 2030 |
ast_cli(a->fd,"sound_has_joined: %s\n", conf_get_sound(CONF_SOUND_HAS_JOINED, b_profile.sounds)); |
| 2031 |
ast_cli(a->fd,"sound_has_left: %s\n", conf_get_sound(CONF_SOUND_HAS_LEFT, b_profile.sounds)); |
| 2032 |
ast_cli(a->fd,"sound_kicked: %s\n", conf_get_sound(CONF_SOUND_KICKED, b_profile.sounds)); |
| 2033 |
ast_cli(a->fd,"sound_muted: %s\n", conf_get_sound(CONF_SOUND_MUTED, b_profile.sounds)); |
| 2034 |
ast_cli(a->fd,"sound_unmuted: %s\n", conf_get_sound(CONF_SOUND_UNMUTED, b_profile.sounds)); |
| 2035 |
ast_cli(a->fd,"sound_binaural_on: %s\n", conf_get_sound(CONF_SOUND_BINAURAL_ON, b_profile.sounds)); |
| 2036 |
ast_cli(a->fd,"sound_binaural_off: %s\n", conf_get_sound(CONF_SOUND_BINAURAL_OFF, b_profile.sounds)); |
| 2037 |
ast_cli(a->fd,"sound_there_are: %s\n", conf_get_sound(CONF_SOUND_THERE_ARE, b_profile.sounds)); |
| 2038 |
ast_cli(a->fd,"sound_other_in_party: %s\n", conf_get_sound(CONF_SOUND_OTHER_IN_PARTY, b_profile.sounds)); |
| 2039 |
ast_cli(a->fd,"sound_place_into_conference: %s\n", conf_get_sound(CONF_SOUND_PLACE_IN_CONF, b_profile.sounds)); |
| 2040 |
ast_cli(a->fd,"sound_wait_for_leader: %s\n", conf_get_sound(CONF_SOUND_WAIT_FOR_LEADER, b_profile.sounds)); |
| 2041 |
ast_cli(a->fd,"sound_leader_has_left: %s\n", conf_get_sound(CONF_SOUND_LEADER_HAS_LEFT, b_profile.sounds)); |
| 2042 |
ast_cli(a->fd,"sound_get_pin: %s\n", conf_get_sound(CONF_SOUND_GET_PIN, b_profile.sounds)); |
| 2043 |
ast_cli(a->fd,"sound_invalid_pin: %s\n", conf_get_sound(CONF_SOUND_INVALID_PIN, b_profile.sounds)); |
| 2044 |
ast_cli(a->fd,"sound_locked: %s\n", conf_get_sound(CONF_SOUND_LOCKED, b_profile.sounds)); |
| 2045 |
ast_cli(a->fd,"sound_unlocked_now: %s\n", conf_get_sound(CONF_SOUND_UNLOCKED_NOW, b_profile.sounds)); |
| 2046 |
ast_cli(a->fd,"sound_lockednow: %s\n", conf_get_sound(CONF_SOUND_LOCKED_NOW, b_profile.sounds)); |
| 2047 |
ast_cli(a->fd,"sound_error_menu: %s\n", conf_get_sound(CONF_SOUND_ERROR_MENU, b_profile.sounds)); |
| 2048 |
ast_cli(a->fd,"sound_join: %s\n", conf_get_sound(CONF_SOUND_JOIN, b_profile.sounds)); |
| 2049 |
ast_cli(a->fd,"sound_leave: %s\n", conf_get_sound(CONF_SOUND_LEAVE, b_profile.sounds)); |
| 2050 |
ast_cli(a->fd,"sound_participants_muted: %s\n", conf_get_sound(CONF_SOUND_PARTICIPANTS_MUTED, b_profile.sounds)); |
| 2051 |
ast_cli(a->fd,"sound_participants_unmuted: %s\n", conf_get_sound(CONF_SOUND_PARTICIPANTS_UNMUTED, b_profile.sounds)); |
| 2052 |
ast_cli(a->fd,"sound_begin: %s\n", conf_get_sound(CONF_SOUND_BEGIN, b_profile.sounds)); |
| 2053 |
ast_cli(a->fd,"\n"); |
| 2054 |
|
| 2055 |
conf_bridge_profile_destroy(&b_profile); |
| 2056 |
return CLI_SUCCESS; |
| 2057 |
} |
| 2058 |
|
| 2059 |
static char *complete_menu_name(const char *line, const char *word, int pos, int state) |
| 2060 |
{ |
| 2061 |
int which = 0; |
| 2062 |
char *res = NULL; |
| 2063 |
int wordlen = strlen(word); |
| 2064 |
struct ao2_iterator i; |
| 2065 |
struct conf_menu *menu = NULL; |
| 2066 |
RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup); |
| 2067 |
|
| 2068 |
if (!cfg) { |
| 2069 |
return NULL; |
| 2070 |
} |
| 2071 |
|
| 2072 |
i = ao2_iterator_init(cfg->menus, 0); |
| 2073 |
while ((menu = ao2_iterator_next(&i))) { |
| 2074 |
if (!strncasecmp(menu->name, word, wordlen) && ++which > state) { |
| 2075 |
res = ast_strdup(menu->name); |
| 2076 |
ao2_ref(menu, -1); |
| 2077 |
break; |
| 2078 |
} |
| 2079 |
ao2_ref(menu, -1); |
| 2080 |
} |
| 2081 |
ao2_iterator_destroy(&i); |
| 2082 |
|
| 2083 |
return res; |
| 2084 |
} |
| 2085 |
|
| 2086 |
static char *handle_cli_confbridge_show_menus(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| 2087 |
{ |
| 2088 |
struct ao2_iterator it; |
| 2089 |
struct conf_menu *menu; |
| 2090 |
RAII_VAR(struct confbridge_cfg *, cfg, NULL, ao2_cleanup); |
| 2091 |
|
| 2092 |
switch (cmd) { |
| 2093 |
case CLI_INIT: |
| 2094 |
e->command = "confbridge show menus"; |
| 2095 |
e->usage = |
| 2096 |
"Usage: confbridge show profile menus\n"; |
| 2097 |
return NULL; |
| 2098 |
case CLI_GENERATE: |
| 2099 |
return NULL; |
| 2100 |
} |
| 2101 |
|
| 2102 |
if (!(cfg = ao2_global_obj_ref(cfg_handle))) { |
| 2103 |
return NULL; |
| 2104 |
} |
| 2105 |
|
| 2106 |
ast_cli(a->fd,"--------- Menus -----------\n"); |
| 2107 |
ao2_lock(cfg->menus); |
| 2108 |
it = ao2_iterator_init(cfg->menus, 0); |
| 2109 |
while ((menu = ao2_iterator_next(&it))) { |
| 2110 |
ast_cli(a->fd,"%s\n", menu->name); |
| 2111 |
ao2_ref(menu, -1); |
| 2112 |
} |
| 2113 |
ao2_iterator_destroy(&it); |
| 2114 |
ao2_unlock(cfg->menus); |
| 2115 |
|
| 2116 |
return CLI_SUCCESS; |
| 2117 |
} |
| 2118 |
|
| 2119 |
static char *handle_cli_confbridge_show_menu(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| 2120 |
{ |
| 2121 |
RAII_VAR(struct conf_menu *, menu, NULL, ao2_cleanup); |
| 2122 |
RAII_VAR(struct confbridge_cfg *, cfg, NULL, ao2_cleanup); |
| 2123 |
struct conf_menu_entry *menu_entry = NULL; |
| 2124 |
struct conf_menu_action *menu_action = NULL; |
| 2125 |
|
| 2126 |
switch (cmd) { |
| 2127 |
case CLI_INIT: |
| 2128 |
e->command = "confbridge show menu"; |
| 2129 |
e->usage = |
| 2130 |
"Usage: confbridge show menu [<menu name>]\n"; |
| 2131 |
return NULL; |
| 2132 |
case CLI_GENERATE: |
| 2133 |
if (a->pos == 3) { |
| 2134 |
return complete_menu_name(a->line, a->word, a->pos, a->n); |
| 2135 |
} |
| 2136 |
return NULL; |
| 2137 |
} |
| 2138 |
|
| 2139 |
if (a->argc != 4) { |
| 2140 |
return CLI_SHOWUSAGE; |
| 2141 |
} |
| 2142 |
|
| 2143 |
if (!(cfg = ao2_global_obj_ref(cfg_handle))) { |
| 2144 |
return NULL; |
| 2145 |
} |
| 2146 |
|
| 2147 |
if (!(menu = menu_find(cfg->menus, a->argv[3]))) { |
| 2148 |
ast_cli(a->fd, "No conference menu named '%s' found!\n", a->argv[3]); |
| 2149 |
return CLI_SUCCESS; |
| 2150 |
} |
| 2151 |
ao2_lock(menu); |
| 2152 |
|
| 2153 |
ast_cli(a->fd,"Name: %s\n", menu->name); |
| 2154 |
AST_LIST_TRAVERSE(&menu->entries, menu_entry, entry) { |
| 2155 |
int action_num = 0; |
| 2156 |
ast_cli(a->fd, "%s=", menu_entry->dtmf); |
| 2157 |
AST_LIST_TRAVERSE(&menu_entry->actions, menu_action, action) { |
| 2158 |
if (action_num) { |
| 2159 |
ast_cli(a->fd, ", "); |
| 2160 |
} |
| 2161 |
switch (menu_action->id) { |
| 2162 |
case MENU_ACTION_TOGGLE_MUTE: |
| 2163 |
ast_cli(a->fd, "toggle_mute"); |
| 2164 |
break; |
| 2165 |
case MENU_ACTION_TOGGLE_BINAURAL: |
| 2166 |
ast_cli(a->fd, "toggle_binaural"); |
| 2167 |
break; |
| 2168 |
case MENU_ACTION_NOOP: |
| 2169 |
ast_cli(a->fd, "no_op"); |
| 2170 |
break; |
| 2171 |
case MENU_ACTION_INCREASE_LISTENING: |
| 2172 |
ast_cli(a->fd, "increase_listening_volume"); |
| 2173 |
break; |
| 2174 |
case MENU_ACTION_DECREASE_LISTENING: |
| 2175 |
ast_cli(a->fd, "decrease_listening_volume"); |
| 2176 |
break; |
| 2177 |
case MENU_ACTION_RESET_LISTENING: |
| 2178 |
ast_cli(a->fd, "reset_listening_volume"); |
| 2179 |
break; |
| 2180 |
case MENU_ACTION_RESET_TALKING: |
| 2181 |
ast_cli(a->fd, "reset_talking_volume"); |
| 2182 |
break; |
| 2183 |
case MENU_ACTION_INCREASE_TALKING: |
| 2184 |
ast_cli(a->fd, "increase_talking_volume"); |
| 2185 |
break; |
| 2186 |
case MENU_ACTION_DECREASE_TALKING: |
| 2187 |
ast_cli(a->fd, "decrease_talking_volume"); |
| 2188 |
break; |
| 2189 |
case MENU_ACTION_PLAYBACK: |
| 2190 |
ast_cli(a->fd, "playback(%s)", menu_action->data.playback_file); |
| 2191 |
break; |
| 2192 |
case MENU_ACTION_PLAYBACK_AND_CONTINUE: |
| 2193 |
ast_cli(a->fd, "playback_and_continue(%s)", menu_action->data.playback_file); |
| 2194 |
break; |
| 2195 |
case MENU_ACTION_DIALPLAN_EXEC: |
| 2196 |
ast_cli(a->fd, "dialplan_exec(%s,%s,%d)", |
| 2197 |
menu_action->data.dialplan_args.context, |
| 2198 |
menu_action->data.dialplan_args.exten, |
| 2199 |
menu_action->data.dialplan_args.priority); |
| 2200 |
break; |
| 2201 |
case MENU_ACTION_ADMIN_TOGGLE_LOCK: |
| 2202 |
ast_cli(a->fd, "admin_toggle_conference_lock"); |
| 2203 |
break; |
| 2204 |
case MENU_ACTION_ADMIN_TOGGLE_MUTE_PARTICIPANTS: |
| 2205 |
ast_cli(a->fd, "admin_toggle_mute_participants"); |
| 2206 |
break; |
| 2207 |
case MENU_ACTION_PARTICIPANT_COUNT: |
| 2208 |
ast_cli(a->fd, "participant_count"); |
| 2209 |
break; |
| 2210 |
case MENU_ACTION_ADMIN_KICK_LAST: |
| 2211 |
ast_cli(a->fd, "admin_kick_last"); |
| 2212 |
break; |
| 2213 |
case MENU_ACTION_LEAVE: |
| 2214 |
ast_cli(a->fd, "leave_conference"); |
| 2215 |
break; |
| 2216 |
case MENU_ACTION_SET_SINGLE_VIDEO_SRC: |
| 2217 |
ast_cli(a->fd, "set_as_single_video_src"); |
| 2218 |
break; |
| 2219 |
case MENU_ACTION_RELEASE_SINGLE_VIDEO_SRC: |
| 2220 |
ast_cli(a->fd, "release_as_single_video_src"); |
| 2221 |
break; |
| 2222 |
} |
| 2223 |
action_num++; |
| 2224 |
} |
| 2225 |
ast_cli(a->fd,"\n"); |
| 2226 |
} |
| 2227 |
|
| 2228 |
|
| 2229 |
ao2_unlock(menu); |
| 2230 |
return CLI_SUCCESS; |
| 2231 |
} |
| 2232 |
|
| 2233 |
static struct ast_cli_entry cli_confbridge_parser[] = { |
| 2234 |
AST_CLI_DEFINE(handle_cli_confbridge_show_user_profile, "Show a conference user profile."), |
| 2235 |
AST_CLI_DEFINE(handle_cli_confbridge_show_bridge_profile, "Show a conference bridge profile."), |
| 2236 |
AST_CLI_DEFINE(handle_cli_confbridge_show_menu, "Show a conference menu"), |
| 2237 |
AST_CLI_DEFINE(handle_cli_confbridge_show_user_profiles, "Show a list of conference user profiles."), |
| 2238 |
AST_CLI_DEFINE(handle_cli_confbridge_show_bridge_profiles, "Show a list of conference bridge profiles."), |
| 2239 |
AST_CLI_DEFINE(handle_cli_confbridge_show_menus, "Show a list of conference menus"), |
| 2240 |
|
| 2241 |
}; |
| 2242 |
|
| 2243 |
static void confbridge_cfg_destructor(void *obj) |
| 2244 |
{ |
| 2245 |
struct confbridge_cfg *cfg = obj; |
| 2246 |
ao2_cleanup(cfg->user_profiles); |
| 2247 |
ao2_cleanup(cfg->bridge_profiles); |
| 2248 |
ao2_cleanup(cfg->menus); |
| 2249 |
} |
| 2250 |
|
| 2251 |
void *confbridge_cfg_alloc(void) |
| 2252 |
{ |
| 2253 |
struct confbridge_cfg *cfg; |
| 2254 |
|
| 2255 |
if (!(cfg = ao2_alloc(sizeof(*cfg), confbridge_cfg_destructor))) { |
| 2256 |
return NULL; |
| 2257 |
} |
| 2258 |
|
| 2259 |
cfg->user_profiles = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, 283, |
| 2260 |
user_hash_cb, NULL, user_cmp_cb); |
| 2261 |
if (!cfg->user_profiles) { |
| 2262 |
goto error; |
| 2263 |
} |
| 2264 |
|
| 2265 |
cfg->bridge_profiles = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, 283, |
| 2266 |
bridge_hash_cb, NULL, bridge_cmp_cb); |
| 2267 |
if (!cfg->bridge_profiles) { |
| 2268 |
goto error; |
| 2269 |
} |
| 2270 |
|
| 2271 |
cfg->menus = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, 283, |
| 2272 |
menu_hash_cb, NULL, menu_cmp_cb); |
| 2273 |
if (!cfg->menus) { |
| 2274 |
goto error; |
| 2275 |
} |
| 2276 |
|
| 2277 |
return cfg; |
| 2278 |
error: |
| 2279 |
ao2_ref(cfg, -1); |
| 2280 |
return NULL; |
| 2281 |
} |
| 2282 |
|
| 2283 |
static int announce_user_count_all_handler(const struct aco_option *opt, struct ast_variable *var, void *obj) |
| 2284 |
{ |
| 2285 |
struct user_profile *u_profile = obj; |
| 2286 |
|
| 2287 |
if (strcasecmp(var->name, "announce_user_count_all")) { |
| 2288 |
return -1; |
| 2289 |
} |
| 2290 |
if (ast_true(var->value)) { |
| 2291 |
u_profile->flags = u_profile->flags | USER_OPT_ANNOUNCEUSERCOUNTALL; |
| 2292 |
} else if (ast_false(var->value)) { |
| 2293 |
u_profile->flags = u_profile->flags & ~USER_OPT_ANNOUNCEUSERCOUNTALL; |
| 2294 |
} else if (sscanf(var->value, "%30u", &u_profile->announce_user_count_all_after) == 1) { |
| 2295 |
u_profile->flags = u_profile->flags | USER_OPT_ANNOUNCEUSERCOUNTALL; |
| 2296 |
} else { |
| 2297 |
return -1; |
| 2298 |
} |
| 2299 |
return 0; |
| 2300 |
} |
| 2301 |
|
| 2302 |
static int mix_interval_handler(const struct aco_option *opt, struct ast_variable *var, void *obj) |
| 2303 |
{ |
| 2304 |
struct bridge_profile *b_profile = obj; |
| 2305 |
|
| 2306 |
if (strcasecmp(var->name, "mixing_interval")) { |
| 2307 |
return -1; |
| 2308 |
} |
| 2309 |
if (sscanf(var->value, "%30u", &b_profile->mix_interval) != 1) { |
| 2310 |
return -1; |
| 2311 |
} |
| 2312 |
switch (b_profile->mix_interval) { |
| 2313 |
case 10: |
| 2314 |
case 20: |
| 2315 |
case 40: |
| 2316 |
case 80: |
| 2317 |
return 0; |
| 2318 |
default: |
| 2319 |
return -1; |
| 2320 |
} |
| 2321 |
} |
| 2322 |
|
| 2323 |
static int video_mode_handler(const struct aco_option *opt, struct ast_variable *var, void *obj) |
| 2324 |
{ |
| 2325 |
struct bridge_profile *b_profile = obj; |
| 2326 |
|
| 2327 |
if (strcasecmp(var->name, "video_mode")) { |
| 2328 |
return -1; |
| 2329 |
} |
| 2330 |
if (!strcasecmp(var->value, "first_marked")) { |
| 2331 |
ast_set_flags_to(b_profile, |
| 2332 |
BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED |
| 2333 |
| BRIDGE_OPT_VIDEO_SRC_LAST_MARKED |
| 2334 |
| BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER |
| 2335 |
| BRIDGE_OPT_VIDEO_SRC_SFU, |
| 2336 |
BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED); |
| 2337 |
} else if (!strcasecmp(var->value, "last_marked")) { |
| 2338 |
ast_set_flags_to(b_profile, |
| 2339 |
BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED |
| 2340 |
| BRIDGE_OPT_VIDEO_SRC_LAST_MARKED |
| 2341 |
| BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER |
| 2342 |
| BRIDGE_OPT_VIDEO_SRC_SFU, |
| 2343 |
BRIDGE_OPT_VIDEO_SRC_LAST_MARKED); |
| 2344 |
} else if (!strcasecmp(var->value, "follow_talker")) { |
| 2345 |
ast_set_flags_to(b_profile, |
| 2346 |
BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED |
| 2347 |
| BRIDGE_OPT_VIDEO_SRC_LAST_MARKED |
| 2348 |
| BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER |
| 2349 |
| BRIDGE_OPT_VIDEO_SRC_SFU, |
| 2350 |
BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER); |
| 2351 |
} else if (!strcasecmp(var->value, "sfu")) { |
| 2352 |
ast_set_flags_to(b_profile, |
| 2353 |
BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED |
| 2354 |
| BRIDGE_OPT_VIDEO_SRC_LAST_MARKED |
| 2355 |
| BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER |
| 2356 |
| BRIDGE_OPT_VIDEO_SRC_SFU, |
| 2357 |
BRIDGE_OPT_VIDEO_SRC_SFU); |
| 2358 |
} else if (!strcasecmp(var->value, "none")) { |
| 2359 |
ast_clear_flag(b_profile, |
| 2360 |
BRIDGE_OPT_VIDEO_SRC_FIRST_MARKED |
| 2361 |
| BRIDGE_OPT_VIDEO_SRC_LAST_MARKED |
| 2362 |
| BRIDGE_OPT_VIDEO_SRC_FOLLOW_TALKER |
| 2363 |
| BRIDGE_OPT_VIDEO_SRC_SFU); |
| 2364 |
} else { |
| 2365 |
return -1; |
| 2366 |
} |
| 2367 |
return 0; |
| 2368 |
} |
| 2369 |
|
| 2370 |
static int remb_behavior_handler(const struct aco_option *opt, struct ast_variable *var, void *obj) |
| 2371 |
{ |
| 2372 |
struct bridge_profile *b_profile = obj; |
| 2373 |
|
| 2374 |
if (strcasecmp(var->name, "remb_behavior")) { |
| 2375 |
return -1; |
| 2376 |
} |
| 2377 |
|
| 2378 |
ast_clear_flag(b_profile, BRIDGE_OPT_REMB_BEHAVIOR_AVERAGE | |
| 2379 |
BRIDGE_OPT_REMB_BEHAVIOR_LOWEST | |
| 2380 |
BRIDGE_OPT_REMB_BEHAVIOR_HIGHEST | |
| 2381 |
BRIDGE_OPT_REMB_BEHAVIOR_AVERAGE_ALL | |
| 2382 |
BRIDGE_OPT_REMB_BEHAVIOR_LOWEST_ALL | |
| 2383 |
BRIDGE_OPT_REMB_BEHAVIOR_HIGHEST_ALL | |
| 2384 |
BRIDGE_OPT_REMB_BEHAVIOR_FORCE |
| 2385 |
); |
| 2386 |
|
| 2387 |
if (!strcasecmp(var->value, "average")) { |
| 2388 |
ast_set_flag(b_profile, BRIDGE_OPT_REMB_BEHAVIOR_AVERAGE); |
| 2389 |
} else if (!strcasecmp(var->value, "lowest")) { |
| 2390 |
ast_set_flag(b_profile, BRIDGE_OPT_REMB_BEHAVIOR_LOWEST); |
| 2391 |
} else if (!strcasecmp(var->value, "highest")) { |
| 2392 |
ast_set_flag(b_profile, BRIDGE_OPT_REMB_BEHAVIOR_HIGHEST); |
| 2393 |
} else if (!strcasecmp(var->value, "average_all")) { |
| 2394 |
ast_set_flag(b_profile, BRIDGE_OPT_REMB_BEHAVIOR_AVERAGE_ALL); |
| 2395 |
} else if (!strcasecmp(var->value, "lowest_all")) { |
| 2396 |
ast_set_flag(b_profile, BRIDGE_OPT_REMB_BEHAVIOR_LOWEST_ALL); |
| 2397 |
} else if (!strcasecmp(var->value, "highest_all")) { |
| 2398 |
ast_set_flag(b_profile, BRIDGE_OPT_REMB_BEHAVIOR_HIGHEST_ALL); |
| 2399 |
} else if (!strcasecmp(var->value, "force")) { |
| 2400 |
ast_set_flag(b_profile, BRIDGE_OPT_REMB_BEHAVIOR_FORCE); |
| 2401 |
} else { |
| 2402 |
return -1; |
| 2403 |
} |
| 2404 |
return 0; |
| 2405 |
} |
| 2406 |
|
| 2407 |
static int user_template_handler(const struct aco_option *opt, struct ast_variable *var, void *obj) |
| 2408 |
{ |
| 2409 |
struct user_profile *u_profile = obj; |
| 2410 |
|
| 2411 |
return conf_find_user_profile(NULL, var->value, u_profile) ? 0 : -1; |
| 2412 |
} |
| 2413 |
|
| 2414 |
static int sample_rate_handler(const struct aco_option *opt, struct ast_variable *var, void *obj) |
| 2415 |
{ |
| 2416 |
struct bridge_profile *b_profile = obj; |
| 2417 |
unsigned int *slot; |
| 2418 |
|
| 2419 |
if (!strcasecmp(var->name, "internal_sample_rate")) { |
| 2420 |
slot = &b_profile->internal_sample_rate; |
| 2421 |
if (!strcasecmp(var->value, "auto")) { |
| 2422 |
*slot = 0; |
| 2423 |
return 0; |
| 2424 |
} |
| 2425 |
} else if (!strcasecmp(var->name, "maximum_sample_rate")) { |
| 2426 |
slot = &b_profile->maximum_sample_rate; |
| 2427 |
if (!strcasecmp(var->value, "none")) { |
| 2428 |
*slot = 0; |
| 2429 |
return 0; |
| 2430 |
} |
| 2431 |
} else { |
| 2432 |
return -1; |
| 2433 |
} |
| 2434 |
|
| 2435 |
return ast_parse_arg(var->value, PARSE_UINT32 | PARSE_IN_RANGE, slot, 8000, 192000); |
| 2436 |
} |
| 2437 |
|
| 2438 |
static int bridge_template_handler(const struct aco_option *opt, struct ast_variable *var, void *obj) |
| 2439 |
{ |
| 2440 |
struct bridge_profile *b_profile = obj; |
| 2441 |
struct bridge_profile_sounds *sounds = bridge_profile_sounds_alloc(); |
| 2442 |
struct bridge_profile_sounds *oldsounds = b_profile->sounds; |
| 2443 |
|
| 2444 |
if (!sounds) { |
| 2445 |
return -1; |
| 2446 |
} |
| 2447 |
if (!(conf_find_bridge_profile(NULL, var->value, b_profile))) { |
| 2448 |
ao2_ref(sounds, -1); |
| 2449 |
return -1; |
| 2450 |
} |
| 2451 |
|
| 2452 |
|
| 2453 |
|
| 2454 |
ast_string_field_set(sounds, onlyperson, b_profile->sounds->onlyperson); |
| 2455 |
ast_string_field_set(sounds, onlyone, b_profile->sounds->onlyone); |
| 2456 |
ast_string_field_set(sounds, hasjoin, b_profile->sounds->hasjoin); |
| 2457 |
ast_string_field_set(sounds, hasleft, b_profile->sounds->hasleft); |
| 2458 |
ast_string_field_set(sounds, kicked, b_profile->sounds->kicked); |
| 2459 |
ast_string_field_set(sounds, muted, b_profile->sounds->muted); |
| 2460 |
ast_string_field_set(sounds, unmuted, b_profile->sounds->unmuted); |
| 2461 |
ast_string_field_set(sounds, thereare, b_profile->sounds->thereare); |
| 2462 |
ast_string_field_set(sounds, otherinparty, b_profile->sounds->otherinparty); |
| 2463 |
ast_string_field_set(sounds, placeintoconf, b_profile->sounds->placeintoconf); |
| 2464 |
ast_string_field_set(sounds, waitforleader, b_profile->sounds->waitforleader); |
| 2465 |
ast_string_field_set(sounds, leaderhasleft, b_profile->sounds->leaderhasleft); |
| 2466 |
ast_string_field_set(sounds, getpin, b_profile->sounds->getpin); |
| 2467 |
ast_string_field_set(sounds, invalidpin, b_profile->sounds->invalidpin); |
| 2468 |
ast_string_field_set(sounds, locked, b_profile->sounds->locked); |
| 2469 |
ast_string_field_set(sounds, unlockednow, b_profile->sounds->unlockednow); |
| 2470 |
ast_string_field_set(sounds, lockednow, b_profile->sounds->lockednow); |
| 2471 |
ast_string_field_set(sounds, errormenu, b_profile->sounds->errormenu); |
| 2472 |
ast_string_field_set(sounds, join, b_profile->sounds->join); |
| 2473 |
ast_string_field_set(sounds, leave, b_profile->sounds->leave); |
| 2474 |
ast_string_field_set(sounds, participantsmuted, b_profile->sounds->participantsmuted); |
| 2475 |
ast_string_field_set(sounds, participantsunmuted, b_profile->sounds->participantsunmuted); |
| 2476 |
ast_string_field_set(sounds, begin, b_profile->sounds->begin); |
| 2477 |
|
| 2478 |
ao2_ref(b_profile->sounds, -1); |
| 2479 |
ao2_ref(oldsounds, -1); |
| 2480 |
b_profile->sounds = sounds; |
| 2481 |
|
| 2482 |
return 0; |
| 2483 |
} |
| 2484 |
|
| 2485 |
static int copy_menu_entry(struct conf_menu_entry *dst, struct conf_menu_entry *src) |
| 2486 |
{ |
| 2487 |
struct conf_menu_action *menu_action; |
| 2488 |
struct conf_menu_action *new_menu_action; |
| 2489 |
|
| 2490 |
ast_copy_string(dst->dtmf, src->dtmf, sizeof(dst->dtmf)); |
| 2491 |
AST_LIST_HEAD_INIT_NOLOCK(&dst->actions); |
| 2492 |
|
| 2493 |
AST_LIST_TRAVERSE(&src->actions, menu_action, action) { |
| 2494 |
if (!(new_menu_action = ast_calloc(1, sizeof(*new_menu_action)))) { |
| 2495 |
return -1; |
| 2496 |
} |
| 2497 |
memcpy(new_menu_action, menu_action, sizeof(*new_menu_action)); |
| 2498 |
AST_LIST_NEXT(new_menu_action, action) = NULL; |
| 2499 |
AST_LIST_INSERT_TAIL(&dst->actions, new_menu_action, action); |
| 2500 |
} |
| 2501 |
|
| 2502 |
return 0; |
| 2503 |
} |
| 2504 |
|
| 2505 |
static int conf_menu_profile_copy(struct conf_menu *dst, struct conf_menu *src) |
| 2506 |
{ |
| 2507 |
|
| 2508 |
struct conf_menu_entry *cur; |
| 2509 |
|
| 2510 |
AST_LIST_TRAVERSE(&src->entries, cur, entry) { |
| 2511 |
struct conf_menu_entry *cpy; |
| 2512 |
|
| 2513 |
if (!(cpy = ast_calloc(1, sizeof(*cpy)))) { |
| 2514 |
return -1; |
| 2515 |
} |
| 2516 |
|
| 2517 |
if (copy_menu_entry(cpy, cur)) { |
| 2518 |
conf_menu_entry_destroy(cpy); |
| 2519 |
ast_free(cpy); |
| 2520 |
return -1; |
| 2521 |
} |
| 2522 |
AST_LIST_INSERT_TAIL(&dst->entries, cpy, entry); |
| 2523 |
} |
| 2524 |
|
| 2525 |
return 0; |
| 2526 |
} |
| 2527 |
|
| 2528 |
static int menu_template_handler(const struct aco_option *opt, struct ast_variable *var, void *obj) |
| 2529 |
{ |
| 2530 |
struct conf_menu *dst_menu = obj; |
| 2531 |
RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup); |
| 2532 |
RAII_VAR(struct conf_menu *, src_menu, NULL, ao2_cleanup); |
| 2533 |
|
| 2534 |
if (!cfg) { |
| 2535 |
return 0; |
| 2536 |
} |
| 2537 |
|
| 2538 |
if (!(src_menu = ao2_find(cfg->menus, var->value, OBJ_KEY))) { |
| 2539 |
return -1; |
| 2540 |
} |
| 2541 |
|
| 2542 |
if (conf_menu_profile_copy(dst_menu, src_menu)) { |
| 2543 |
return -1; |
| 2544 |
} |
| 2545 |
|
| 2546 |
return 0; |
| 2547 |
} |
| 2548 |
|
| 2549 |
static int sound_option_handler(const struct aco_option *opt, struct ast_variable *var, void *obj) |
| 2550 |
{ |
| 2551 |
set_sound(var->name, var->value, obj); |
| 2552 |
return 0; |
| 2553 |
} |
| 2554 |
|
| 2555 |
static int menu_option_handler(const struct aco_option *opt, struct ast_variable *var, void *obj) |
| 2556 |
{ |
| 2557 |
add_menu_entry(obj, var->name, var->value); |
| 2558 |
return 0; |
| 2559 |
} |
| 2560 |
|
| 2561 |
static int verify_default_profiles(void) |
| 2562 |
{ |
| 2563 |
RAII_VAR(struct user_profile *, user_profile, NULL, ao2_cleanup); |
| 2564 |
RAII_VAR(struct bridge_profile *, bridge_profile, NULL, ao2_cleanup); |
| 2565 |
RAII_VAR(struct conf_menu *, menu_profile, NULL, ao2_cleanup); |
| 2566 |
|
| 2567 |
struct confbridge_cfg *cfg = aco_pending_config(&cfg_info); |
| 2568 |
|
| 2569 |
if (!cfg) { |
| 2570 |
return 0; |
| 2571 |
} |
| 2572 |
|
| 2573 |
bridge_profile = ao2_find(cfg->bridge_profiles, DEFAULT_BRIDGE_PROFILE, OBJ_KEY); |
| 2574 |
if (!bridge_profile) { |
| 2575 |
bridge_profile = bridge_profile_alloc(DEFAULT_BRIDGE_PROFILE); |
| 2576 |
if (!bridge_profile) { |
| 2577 |
return -1; |
| 2578 |
} |
| 2579 |
ast_log(AST_LOG_NOTICE, "Adding %s profile to app_confbridge\n", DEFAULT_BRIDGE_PROFILE); |
| 2580 |
aco_set_defaults(&bridge_type, DEFAULT_BRIDGE_PROFILE, bridge_profile); |
| 2581 |
ao2_link(cfg->bridge_profiles, bridge_profile); |
| 2582 |
} |
| 2583 |
|
| 2584 |
user_profile = ao2_find(cfg->user_profiles, DEFAULT_USER_PROFILE, OBJ_KEY); |
| 2585 |
if (!user_profile) { |
| 2586 |
user_profile = user_profile_alloc(DEFAULT_USER_PROFILE); |
| 2587 |
if (!user_profile) { |
| 2588 |
return -1; |
| 2589 |
} |
| 2590 |
ast_log(AST_LOG_NOTICE, "Adding %s profile to app_confbridge\n", DEFAULT_USER_PROFILE); |
| 2591 |
aco_set_defaults(&user_type, DEFAULT_USER_PROFILE, user_profile); |
| 2592 |
ao2_link(cfg->user_profiles, user_profile); |
| 2593 |
} |
| 2594 |
|
| 2595 |
menu_profile = ao2_find(cfg->menus, DEFAULT_MENU_PROFILE, OBJ_KEY); |
| 2596 |
if (!menu_profile) { |
| 2597 |
menu_profile = menu_alloc(DEFAULT_MENU_PROFILE); |
| 2598 |
if (!menu_profile) { |
| 2599 |
return -1; |
| 2600 |
} |
| 2601 |
ast_log(AST_LOG_NOTICE, "Adding %s menu to app_confbridge\n", DEFAULT_MENU_PROFILE); |
| 2602 |
aco_set_defaults(&menu_type, DEFAULT_MENU_PROFILE, menu_profile); |
| 2603 |
ao2_link(cfg->menus, menu_profile); |
| 2604 |
} |
| 2605 |
|
| 2606 |
return 0; |
| 2607 |
} |
| 2608 |
|
| 2609 |
int conf_load_config(void) |
| 2610 |
{ |
| 2611 |
if (aco_info_init(&cfg_info)) { |
| 2612 |
return -1; |
| 2613 |
} |
| 2614 |
|
| 2615 |
|
| 2616 |
aco_option_register(&cfg_info, "type", ACO_EXACT, user_types, NULL, OPT_NOOP_T, 0, 0); |
| 2617 |
aco_option_register(&cfg_info, "admin", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_ADMIN); |
| 2618 |
aco_option_register(&cfg_info, "send_events", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_SEND_EVENTS); |
| 2619 |
aco_option_register(&cfg_info, "echo_events", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_ECHO_EVENTS); |
| 2620 |
aco_option_register(&cfg_info, "marked", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_MARKEDUSER); |
| 2621 |
aco_option_register(&cfg_info, "startmuted", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_STARTMUTED); |
| 2622 |
aco_option_register(&cfg_info, "music_on_hold_when_empty", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_MUSICONHOLD); |
| 2623 |
aco_option_register(&cfg_info, "quiet", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_QUIET); |
| 2624 |
aco_option_register(&cfg_info, "hear_own_join_sound", ACO_EXACT, user_types, "yes", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_HEAR_OWN_JOIN_SOUND); |
| 2625 |
aco_option_register_custom(&cfg_info, "announce_user_count_all", ACO_EXACT, user_types, "no", announce_user_count_all_handler, 0); |
| 2626 |
aco_option_register(&cfg_info, "announce_user_count", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_ANNOUNCEUSERCOUNT); |
| 2627 |
|
| 2628 |
aco_option_register(&cfg_info, "announce_only_user", ACO_EXACT, user_types, "yes", OPT_BOOLFLAG_T, 0, FLDSET(struct user_profile, flags), USER_OPT_NOONLYPERSON); |
| 2629 |
aco_option_register(&cfg_info, "wait_marked", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_WAITMARKED); |
| 2630 |
aco_option_register(&cfg_info, "end_marked", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_ENDMARKED); |
| 2631 |
aco_option_register(&cfg_info, "end_marked_any", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_ENDMARKEDANY); |
| 2632 |
aco_option_register(&cfg_info, "talk_detection_events", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_TALKER_DETECT); |
| 2633 |
aco_option_register(&cfg_info, "dtmf_passthrough", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_DTMF_PASS); |
| 2634 |
aco_option_register(&cfg_info, "announce_join_leave", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_ANNOUNCE_JOIN_LEAVE); |
| 2635 |
aco_option_register(&cfg_info, "announce_join_leave_review", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_ANNOUNCE_JOIN_LEAVE_REVIEW); |
| 2636 |
aco_option_register(&cfg_info, "pin", ACO_EXACT, user_types, NULL, OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct user_profile, pin)); |
| 2637 |
aco_option_register(&cfg_info, "music_on_hold_class", ACO_EXACT, user_types, NULL, OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct user_profile, moh_class)); |
| 2638 |
aco_option_register(&cfg_info, "announcement", ACO_EXACT, user_types, NULL, OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct user_profile, announcement)); |
| 2639 |
aco_option_register(&cfg_info, "denoise", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_DENOISE); |
| 2640 |
aco_option_register(&cfg_info, "dsp_drop_silence", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_DROP_SILENCE); |
| 2641 |
aco_option_register(&cfg_info, "dsp_silence_threshold", ACO_EXACT, user_types, __stringify(DEFAULT_SILENCE_THRESHOLD), OPT_UINT_T, 0, FLDSET(struct user_profile, silence_threshold)); |
| 2642 |
aco_option_register(&cfg_info, "dsp_talking_threshold", ACO_EXACT, user_types, __stringify(DEFAULT_TALKING_THRESHOLD), OPT_UINT_T, 0, FLDSET(struct user_profile, talking_threshold)); |
| 2643 |
aco_option_register(&cfg_info, "jitterbuffer", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_JITTERBUFFER); |
| 2644 |
aco_option_register(&cfg_info, "timeout", ACO_EXACT, user_types, "0", OPT_UINT_T, 0, FLDSET(struct user_profile, timeout)); |
| 2645 |
aco_option_register(&cfg_info, "text_messaging", ACO_EXACT, user_types, "yes", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_TEXT_MESSAGING); |
| 2646 |
aco_option_register(&cfg_info, "answer_channel", ACO_EXACT, user_types, "yes", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_ANSWER_CHANNEL); |
| 2647 |
|
| 2648 |
|
| 2649 |
aco_option_register_custom(&cfg_info, "template", ACO_EXACT, user_types, NULL, user_template_handler, 0); |
| 2650 |
|
| 2651 |
|
| 2652 |
|
| 2653 |
aco_option_register(&cfg_info, "type", ACO_EXACT, bridge_types, NULL, OPT_NOOP_T, 0, 0); |
| 2654 |
aco_option_register(&cfg_info, "jitterbuffer", ACO_EXACT, bridge_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct bridge_profile, flags), USER_OPT_JITTERBUFFER); |
| 2655 |
aco_option_register_custom(&cfg_info, "internal_sample_rate", ACO_EXACT, bridge_types, "auto", sample_rate_handler, 0); |
| 2656 |
aco_option_register(&cfg_info, "binaural_active", ACO_EXACT, bridge_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct bridge_profile, flags), BRIDGE_OPT_BINAURAL_ACTIVE); |
| 2657 |
aco_option_register_custom(&cfg_info, "maximum_sample_rate", ACO_EXACT, bridge_types, "none", sample_rate_handler, 0); |
| 2658 |
aco_option_register_custom(&cfg_info, "mixing_interval", ACO_EXACT, bridge_types, "20", mix_interval_handler, 0); |
| 2659 |
aco_option_register(&cfg_info, "record_conference", ACO_EXACT, bridge_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct bridge_profile, flags), BRIDGE_OPT_RECORD_CONFERENCE); |
| 2660 |
aco_option_register_custom(&cfg_info, "video_mode", ACO_EXACT, bridge_types, NULL, video_mode_handler, 0); |
| 2661 |
aco_option_register(&cfg_info, "record_file_append", ACO_EXACT, bridge_types, "yes", OPT_BOOLFLAG_T, 1, FLDSET(struct bridge_profile, flags), BRIDGE_OPT_RECORD_FILE_APPEND); |
| 2662 |
aco_option_register(&cfg_info, "record_file_timestamp", ACO_EXACT, bridge_types, "yes", OPT_BOOLFLAG_T, 1, FLDSET(struct bridge_profile, flags), BRIDGE_OPT_RECORD_FILE_TIMESTAMP); |
| 2663 |
aco_option_register(&cfg_info, "max_members", ACO_EXACT, bridge_types, "0", OPT_UINT_T, 0, FLDSET(struct bridge_profile, max_members)); |
| 2664 |
aco_option_register(&cfg_info, "record_file", ACO_EXACT, bridge_types, NULL, OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct bridge_profile, rec_file)); |
| 2665 |
aco_option_register(&cfg_info, "record_options", ACO_EXACT, bridge_types, NULL, OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct bridge_profile, rec_options)); |
| 2666 |
aco_option_register(&cfg_info, "record_command", ACO_EXACT, bridge_types, NULL, OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct bridge_profile, rec_command)); |
| 2667 |
aco_option_register(&cfg_info, "regcontext", ACO_EXACT, bridge_types, NULL, OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct bridge_profile, regcontext)); |
| 2668 |
aco_option_register(&cfg_info, "language", ACO_EXACT, bridge_types, "en", OPT_CHAR_ARRAY_T, 0, CHARFLDSET(struct bridge_profile, language)); |
| 2669 |
aco_option_register_custom(&cfg_info, "sound_", ACO_PREFIX, bridge_types, NULL, sound_option_handler, 0); |
| 2670 |
aco_option_register(&cfg_info, "video_update_discard", ACO_EXACT, bridge_types, "2000", OPT_UINT_T, 0, FLDSET(struct bridge_profile, video_update_discard)); |
| 2671 |
aco_option_register(&cfg_info, "remb_send_interval", ACO_EXACT, bridge_types, "0", OPT_UINT_T, 0, FLDSET(struct bridge_profile, remb_send_interval)); |
| 2672 |
aco_option_register_custom(&cfg_info, "remb_behavior", ACO_EXACT, bridge_types, "average", remb_behavior_handler, 0); |
| 2673 |
aco_option_register(&cfg_info, "remb_estimated_bitrate", ACO_EXACT, bridge_types, "0", OPT_UINT_T, 0, FLDSET(struct bridge_profile, remb_estimated_bitrate)); |
| 2674 |
aco_option_register(&cfg_info, "enable_events", ACO_EXACT, bridge_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct bridge_profile, flags), BRIDGE_OPT_ENABLE_EVENTS); |
| 2675 |
|
| 2676 |
aco_option_register_custom(&cfg_info, "template", ACO_EXACT, bridge_types, NULL, bridge_template_handler, 0); |
| 2677 |
|
| 2678 |
|
| 2679 |
aco_option_register(&cfg_info, "type", ACO_EXACT, menu_types, NULL, OPT_NOOP_T, 0, 0); |
| 2680 |
|
| 2681 |
aco_option_register_custom(&cfg_info, "template", ACO_EXACT, menu_types, NULL, menu_template_handler, 0); |
| 2682 |
aco_option_register_custom(&cfg_info, "^[0-9A-D*#]+$", ACO_REGEX, menu_types, NULL, menu_option_handler, 0); |
| 2683 |
|
| 2684 |
if (aco_process_config(&cfg_info, 0) == ACO_PROCESS_ERROR) { |
| 2685 |
goto error; |
| 2686 |
} |
| 2687 |
|
| 2688 |
if (ast_cli_register_multiple(cli_confbridge_parser, ARRAY_LEN(cli_confbridge_parser))) { |
| 2689 |
goto error; |
| 2690 |
} |
| 2691 |
|
| 2692 |
return 0; |
| 2693 |
error: |
| 2694 |
conf_destroy_config(); |
| 2695 |
return -1; |
| 2696 |
} |
| 2697 |
|
| 2698 |
int conf_reload_config(void) |
| 2699 |
{ |
| 2700 |
if (aco_process_config(&cfg_info, 1) == ACO_PROCESS_ERROR) { |
| 2701 |
|
| 2702 |
return -1; |
| 2703 |
} |
| 2704 |
return 0; |
| 2705 |
} |
| 2706 |
|
| 2707 |
static void conf_user_profile_copy(struct user_profile *dst, struct user_profile *src) |
| 2708 |
{ |
| 2709 |
*dst = *src; |
| 2710 |
} |
| 2711 |
|
| 2712 |
const struct user_profile *conf_find_user_profile(struct ast_channel *chan, const char *user_profile_name, struct user_profile *result) |
| 2713 |
{ |
| 2714 |
struct user_profile *tmp2; |
| 2715 |
struct ast_datastore *datastore = NULL; |
| 2716 |
struct func_confbridge_data *b_data = NULL; |
| 2717 |
RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup); |
| 2718 |
|
| 2719 |
if (chan && ast_strlen_zero(user_profile_name)) { |
| 2720 |
ast_channel_lock(chan); |
| 2721 |
datastore = ast_channel_datastore_find(chan, &confbridge_datastore, NULL); |
| 2722 |
ast_channel_unlock(chan); |
| 2723 |
if (datastore) { |
| 2724 |
b_data = datastore->data; |
| 2725 |
if (b_data->u_usable) { |
| 2726 |
conf_user_profile_copy(result, &b_data->u_profile); |
| 2727 |
return result; |
| 2728 |
} |
| 2729 |
} |
| 2730 |
} |
| 2731 |
|
| 2732 |
if (!cfg) { |
| 2733 |
return NULL; |
| 2734 |
} |
| 2735 |
if (ast_strlen_zero(user_profile_name)) { |
| 2736 |
user_profile_name = DEFAULT_USER_PROFILE; |
| 2737 |
} |
| 2738 |
if (!(tmp2 = ao2_find(cfg->user_profiles, user_profile_name, OBJ_KEY))) { |
| 2739 |
return NULL; |
| 2740 |
} |
| 2741 |
ao2_lock(tmp2); |
| 2742 |
conf_user_profile_copy(result, tmp2); |
| 2743 |
ao2_unlock(tmp2); |
| 2744 |
ao2_ref(tmp2, -1); |
| 2745 |
|
| 2746 |
return result; |
| 2747 |
} |
| 2748 |
|
| 2749 |
void conf_bridge_profile_copy(struct bridge_profile *dst, struct bridge_profile *src) |
| 2750 |
{ |
| 2751 |
*dst = *src; |
| 2752 |
if (src->sounds) { |
| 2753 |
ao2_ref(src->sounds, +1); |
| 2754 |
} |
| 2755 |
} |
| 2756 |
|
| 2757 |
void conf_bridge_profile_destroy(struct bridge_profile *b_profile) |
| 2758 |
{ |
| 2759 |
if (b_profile->sounds) { |
| 2760 |
ao2_ref(b_profile->sounds, -1); |
| 2761 |
b_profile->sounds = NULL; |
| 2762 |
} |
| 2763 |
} |
| 2764 |
|
| 2765 |
const struct bridge_profile *conf_find_bridge_profile(struct ast_channel *chan, const char *bridge_profile_name, struct bridge_profile *result) |
| 2766 |
{ |
| 2767 |
struct bridge_profile *tmp2; |
| 2768 |
struct ast_datastore *datastore = NULL; |
| 2769 |
struct func_confbridge_data *b_data = NULL; |
| 2770 |
RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup); |
| 2771 |
|
| 2772 |
if (chan && ast_strlen_zero(bridge_profile_name)) { |
| 2773 |
ast_channel_lock(chan); |
| 2774 |
datastore = ast_channel_datastore_find(chan, &confbridge_datastore, NULL); |
| 2775 |
ast_channel_unlock(chan); |
| 2776 |
if (datastore) { |
| 2777 |
b_data = datastore->data; |
| 2778 |
if (b_data->b_usable) { |
| 2779 |
conf_bridge_profile_copy(result, &b_data->b_profile); |
| 2780 |
return result; |
| 2781 |
} |
| 2782 |
} |
| 2783 |
} |
| 2784 |
|
| 2785 |
if (!cfg) { |
| 2786 |
return NULL; |
| 2787 |
} |
| 2788 |
if (ast_strlen_zero(bridge_profile_name)) { |
| 2789 |
bridge_profile_name = DEFAULT_BRIDGE_PROFILE; |
| 2790 |
} |
| 2791 |
if (!(tmp2 = ao2_find(cfg->bridge_profiles, bridge_profile_name, OBJ_KEY))) { |
| 2792 |
return NULL; |
| 2793 |
} |
| 2794 |
ao2_lock(tmp2); |
| 2795 |
conf_bridge_profile_copy(result, tmp2); |
| 2796 |
ao2_unlock(tmp2); |
| 2797 |
ao2_ref(tmp2, -1); |
| 2798 |
|
| 2799 |
return result; |
| 2800 |
} |
| 2801 |
|
| 2802 |
struct dtmf_menu_hook_pvt { |
| 2803 |
struct confbridge_user *user; |
| 2804 |
struct conf_menu_entry menu_entry; |
| 2805 |
struct conf_menu *menu; |
| 2806 |
}; |
| 2807 |
|
| 2808 |
static void menu_hook_destroy(void *hook_pvt) |
| 2809 |
{ |
| 2810 |
struct dtmf_menu_hook_pvt *pvt = hook_pvt; |
| 2811 |
struct conf_menu_action *action = NULL; |
| 2812 |
|
| 2813 |
ao2_cleanup(pvt->menu); |
| 2814 |
|
| 2815 |
while ((action = AST_LIST_REMOVE_HEAD(&pvt->menu_entry.actions, action))) { |
| 2816 |
ast_free(action); |
| 2817 |
} |
| 2818 |
ast_free(pvt); |
| 2819 |
} |
| 2820 |
|
| 2821 |
static int menu_hook_callback(struct ast_bridge_channel *bridge_channel, void *hook_pvt) |
| 2822 |
{ |
| 2823 |
struct dtmf_menu_hook_pvt *pvt = hook_pvt; |
| 2824 |
|
| 2825 |
return conf_handle_dtmf(bridge_channel, pvt->user, &pvt->menu_entry, pvt->menu); |
| 2826 |
} |
| 2827 |
|
| 2828 |
void conf_menu_entry_destroy(struct conf_menu_entry *menu_entry) |
| 2829 |
{ |
| 2830 |
struct conf_menu_action *menu_action = NULL; |
| 2831 |
while ((menu_action = AST_LIST_REMOVE_HEAD(&menu_entry->actions, action))) { |
| 2832 |
ast_free(menu_action); |
| 2833 |
} |
| 2834 |
} |
| 2835 |
|
| 2836 |
int conf_find_menu_entry_by_sequence(const char *dtmf_sequence, struct conf_menu *menu, struct conf_menu_entry *result) |
| 2837 |
{ |
| 2838 |
struct conf_menu_entry *menu_entry = NULL; |
| 2839 |
|
| 2840 |
ao2_lock(menu); |
| 2841 |
AST_LIST_TRAVERSE(&menu->entries, menu_entry, entry) { |
| 2842 |
if (!strcasecmp(menu_entry->dtmf, dtmf_sequence)) { |
| 2843 |
copy_menu_entry(result, menu_entry); |
| 2844 |
ao2_unlock(menu); |
| 2845 |
return 1; |
| 2846 |
} |
| 2847 |
} |
| 2848 |
ao2_unlock(menu); |
| 2849 |
|
| 2850 |
return 0; |
| 2851 |
} |
| 2852 |
|
| 2853 |
static int apply_menu_to_user(struct confbridge_user *user, struct conf_menu *menu) |
| 2854 |
{ |
| 2855 |
struct conf_menu_entry *menu_entry; |
| 2856 |
|
| 2857 |
SCOPED_AO2LOCK(menu_lock, menu); |
| 2858 |
AST_LIST_TRAVERSE(&menu->entries, menu_entry, entry) { |
| 2859 |
struct dtmf_menu_hook_pvt *pvt; |
| 2860 |
|
| 2861 |
if (!(pvt = ast_calloc(1, sizeof(*pvt)))) { |
| 2862 |
return -1; |
| 2863 |
} |
| 2864 |
pvt->user = user; |
| 2865 |
pvt->menu = ao2_bump(menu); |
| 2866 |
|
| 2867 |
if (copy_menu_entry(&pvt->menu_entry, menu_entry)) { |
| 2868 |
menu_hook_destroy(pvt); |
| 2869 |
return -1; |
| 2870 |
} |
| 2871 |
|
| 2872 |
if (ast_bridge_dtmf_hook(&user->features, pvt->menu_entry.dtmf, |
| 2873 |
menu_hook_callback, pvt, menu_hook_destroy, 0)) { |
| 2874 |
menu_hook_destroy(pvt); |
| 2875 |
} |
| 2876 |
} |
| 2877 |
strcpy(user->menu_name, menu->name); |
| 2878 |
|
| 2879 |
return 0; |
| 2880 |
} |
| 2881 |
|
| 2882 |
int conf_set_menu_to_user(struct ast_channel *chan, struct confbridge_user *user, const char *menu_profile_name) |
| 2883 |
{ |
| 2884 |
RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup); |
| 2885 |
RAII_VAR(struct conf_menu *, menu, NULL, ao2_cleanup); |
| 2886 |
|
| 2887 |
if (chan && ast_strlen_zero(menu_profile_name)) { |
| 2888 |
struct ast_datastore *datastore; |
| 2889 |
struct func_confbridge_data *b_data; |
| 2890 |
|
| 2891 |
ast_channel_lock(chan); |
| 2892 |
datastore = ast_channel_datastore_find(chan, &confbridge_datastore, NULL); |
| 2893 |
ast_channel_unlock(chan); |
| 2894 |
if (datastore) { |
| 2895 |
|
| 2896 |
b_data = datastore->data; |
| 2897 |
if (b_data->m_usable) { |
| 2898 |
menu = ao2_bump(b_data->menu); |
| 2899 |
return apply_menu_to_user(user, menu); |
| 2900 |
} |
| 2901 |
} |
| 2902 |
} |
| 2903 |
|
| 2904 |
|
| 2905 |
if (!cfg) { |
| 2906 |
return -1; |
| 2907 |
} |
| 2908 |
|
| 2909 |
if (ast_strlen_zero(menu_profile_name)) { |
| 2910 |
menu_profile_name = DEFAULT_MENU_PROFILE; |
| 2911 |
} |
| 2912 |
|
| 2913 |
if (!(menu = ao2_find(cfg->menus, menu_profile_name, OBJ_KEY))) { |
| 2914 |
return -1; |
| 2915 |
} |
| 2916 |
|
| 2917 |
return apply_menu_to_user(user, menu); |
| 2918 |
} |
| 2919 |
|
| 2920 |
void conf_destroy_config(void) |
| 2921 |
{ |
| 2922 |
ast_cli_unregister_multiple(cli_confbridge_parser, ARRAY_LEN(cli_confbridge_parser)); |
| 2923 |
aco_info_destroy(&cfg_info); |
| 2924 |
ao2_global_obj_release(cfg_handle); |
| 2925 |
} |