- Timestamp:
- Dec 3, 2013 7:14:22 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/media.hpp
r4666 r4668 72 72 pj_uint32_t avgBps; /**< Average bitrate */ 73 73 pj_uint32_t maxBps; /**< Maximum bitrate */ 74 75 /** 76 * Construct from pjmedia_format. 77 */ 78 void fromPj(const pjmedia_format &format); 79 80 /** 81 * Export to pjmedia_format. 82 */ 83 pjmedia_format toPj() const; 74 84 }; 75 85 … … 90 100 typedef std::vector<MediaFormat*> MediaFormatVector; 91 101 92 93 102 /** 94 103 * This structure descibes information about a particular media port that … … 384 393 }; 385 394 395 /************************************************************************* 396 * Sound device management 397 */ 398 399 /** 400 * Audio device information structure. 401 */ 402 struct AudioDevInfo 403 { 404 /** 405 * The device name 406 */ 407 string name; 408 409 /** 410 * Maximum number of input channels supported by this device. If the 411 * value is zero, the device does not support input operation (i.e. 412 * it is a playback only device). 413 */ 414 unsigned inputCount; 415 416 /** 417 * Maximum number of output channels supported by this device. If the 418 * value is zero, the device does not support output operation (i.e. 419 * it is an input only device). 420 */ 421 unsigned outputCount; 422 423 /** 424 * Default sampling rate. 425 */ 426 unsigned defaultSamplesPerSec; 427 428 /** 429 * The underlying driver name 430 */ 431 string driver; 432 433 /** 434 * Device capabilities, as bitmask combination of #pjmedia_aud_dev_cap. 435 */ 436 unsigned caps; 437 438 /** 439 * Supported audio device routes, as bitmask combination of 440 * #pjmedia_aud_dev_route. The value may be zero if the device 441 * does not support audio routing. 442 */ 443 unsigned routes; 444 445 /** 446 * Array of supported extended audio formats 447 */ 448 MediaFormatVector extFmt; 449 450 /** 451 * Construct from pjmedia_aud_dev_info. 452 */ 453 void fromPj(const pjmedia_aud_dev_info &dev_info); 454 455 /** 456 * Destructor. 457 */ 458 ~AudioDevInfo(); 459 }; 460 461 /** Array of audio device info */ 462 typedef std::vector<AudioDevInfo*> AudioDevInfoVector; 463 464 /** 465 * Audio device manager. 466 */ 467 class AudDevManager 468 { 469 public: 470 /** 471 * Get currently active capture sound devices. If sound devices has not been 472 * created, it is possible that the function returns -1 as device IDs. 473 * 474 * @return Device ID of the capture device. 475 */ 476 int getCaptureDev() const throw(Error); 477 478 /** 479 * Get currently active playback sound devices. If sound devices has not 480 * been created, it is possible that the function returns -1 as device IDs. 481 * 482 * @return Device ID of the playback device. 483 */ 484 int getPlaybackDev() const throw(Error); 485 486 /** 487 * Select or change capture sound device. Application may call this 488 * function at any time to replace current sound device. 489 * 490 * @param capture dev Device ID of the capture device. 491 */ 492 void setCaptureDev(int capture_dev) const throw(Error); 493 494 /** 495 * Select or change playback sound device. Application may call this 496 * function at any time to replace current sound device. 497 * 498 * @param playback_dev Device ID of the playback device. 499 */ 500 void setPlaybackDev(int playback_dev) const throw(Error); 501 502 /** 503 * Enum all audio devices installed in the system. 504 * 505 * @return The list of audio device info. 506 */ 507 const AudioDevInfoVector &enumDev() throw(Error); 508 509 /** 510 * Set pjsua to use null sound device. The null sound device only provides 511 * the timing needed by the conference bridge, and will not interract with 512 * any hardware. 513 * 514 */ 515 void setNullDev() throw(Error); 516 517 /** 518 * Disconnect the main conference bridge from any sound devices, and let 519 * application connect the bridge to it's own sound device/master port. 520 * 521 * @return The port interface of the conference bridge, 522 * so that application can connect this to it's own 523 * sound device or master port. 524 */ 525 MediaPort *setNoDev(); 526 527 /** 528 * Change the echo cancellation settings. 529 * 530 * The behavior of this function depends on whether the sound device is 531 * currently active, and if it is, whether device or software AEC is 532 * being used. 533 * 534 * If the sound device is currently active, and if the device supports AEC, 535 * this function will forward the change request to the device and it will 536 * be up to the device on whether support the request. If software AEC is 537 * being used (the software EC will be used if the device does not support 538 * AEC), this function will change the software EC settings. In all cases, 539 * the setting will be saved for future opening of the sound device. 540 * 541 * If the sound device is not currently active, this will only change the 542 * default AEC settings and the setting will be applied next time the 543 * sound device is opened. 544 * 545 * @param tail_msec The tail length, in miliseconds. Set to zero to 546 * disable AEC. 547 * @param options Options to be passed to pjmedia_echo_create(). 548 * Normally the value should be zero. 549 * 550 */ 551 void setEcOptions(unsigned tail_msec, unsigned options) throw(Error); 552 553 /** 554 * Get current echo canceller tail length. 555 * 556 * @return The EC tail length in milliseconds, 557 * If AEC is disabled, the value will be zero. 558 */ 559 unsigned getEcTail() const throw(Error); 560 561 /** 562 * Check whether the sound device is currently active. The sound device 563 * may be inactive if the application has set the auto close feature to 564 * non-zero (the sndAutoCloseTime setting in #MediaConfig), or 565 * if null sound device or no sound device has been configured via the 566 * #setNoDev() function. 567 */ 568 bool sndIsActive() const; 569 570 /** 571 * Refresh the list of sound devices installed in the system. This method 572 * will only refresh the list of audio device so all active audio streams 573 * will be unaffected. After refreshing the device list, application MUST 574 * make sure to update all index references to audio devices before calling 575 * any method that accepts audio device index as its parameter. 576 * 577 */ 578 void refreshDevs() throw(Error); 579 580 /** 581 * Get the number of sound devices installed in the system. 582 * 583 * @return The number of sound devices installed in the system. 584 * 585 */ 586 unsigned getDevCount() const; 587 588 /** 589 * Get device information. 590 * 591 * @param id The audio device ID. 592 * 593 * @return The device information which will be filled in 594 * by this method once it returns successfully. 595 */ 596 AudioDevInfo getDevInfo(int id) const throw(Error); 597 598 /** 599 * Lookup device index based on the driver and device name. 600 * 601 * @param drv_name The driver name. 602 * @param dev_name The device name. 603 * 604 * @return The device ID. If the device is not found, Error will be 605 * thrown. 606 * 607 */ 608 int lookupDev(const string &drv_name, 609 const string &dev_name) const throw(Error); 610 611 /** 612 * Get string info for the specified capability. 613 * 614 * @param cap The capability ID. 615 * 616 * @return Capability name. 617 */ 618 string capName(pjmedia_aud_dev_cap cap) const; 619 620 /** 621 * This will configure audio format capability (other than PCM) to the 622 * sound device being used. If sound device is currently active, the method 623 * will forward the setting to the sound device instance to be applied 624 * immediately, if it supports it. 625 * 626 * This method is only valid if the device has 627 * PJMEDIA_AUD_DEV_CAP_EXT_FORMAT capability in AudioDevInfo.caps flags, 628 * otherwise Error will be thrown. 629 * 630 * Note that in case the setting is kept for future use, it will be applied 631 * to any devices, even when application has changed the sound device to be 632 * used. 633 * 634 * @param format The audio format. 635 * @param keep Specify whether the setting is to be kept for 636 * future use. 637 * 638 */ 639 void 640 setExtFormat(const MediaFormatAudio &format, bool keep=true) throw(Error); 641 642 /** 643 * Get the audio format capability (other than PCM) of the sound device 644 * being used. If sound device is currently active, the method will forward 645 * the request to the sound device. If sound device is currently inactive, 646 * and if application had previously set the setting and mark the setting 647 * as kept, then that setting will be returned. Otherwise, this method 648 * will raise error. 649 * 650 * This method is only valid if the device has 651 * PJMEDIA_AUD_DEV_CAP_EXT_FORMAT capability in AudioDevInfo.caps flags, 652 * otherwise Error will be thrown. 653 * 654 * @return The audio format. 655 * 656 */ 657 MediaFormatAudio getExtFormat() const throw(Error); 658 659 /** 660 * This will configure audio input latency control or query capability to 661 * the sound device being used. If sound device is currently active, 662 * the method will forward the setting to the sound device instance to be 663 * applied immediately, if it supports it. 664 * 665 * This method is only valid if the device has 666 * PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY capability in AudioDevInfo.caps flags, 667 * otherwise Error will be thrown. 668 * 669 * Note that in case the setting is kept for future use, it will be applied 670 * to any devices, even when application has changed the sound device to be 671 * used. 672 * 673 * @param latency_msec The input latency. 674 * @param keep Specify whether the setting is to be kept 675 * for future use. 676 * 677 */ 678 void 679 setInputLatency(unsigned latency_msec, bool keep=true) throw(Error); 680 681 /** 682 * Get the audio input latency control or query capability of the sound 683 * device being used. If sound device is currently active, the method will 684 * forward the request to the sound device. If sound device is currently 685 * inactive, and if application had previously set the setting and mark the 686 * setting as kept, then that setting will be returned. Otherwise, this 687 * method will raise error. 688 * 689 * This method is only valid if the device has 690 * PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY capability in AudioDevInfo.caps flags, 691 * otherwise Error will be thrown. 692 * 693 * @return The audio input latency. 694 * 695 */ 696 unsigned getInputLatency() const throw(Error); 697 698 /** 699 * This will configure audio output latency control or query capability to 700 * the sound device being used. If sound device is currently active, 701 * the method will forward the setting to the sound device instance to be 702 * applied immediately, if it supports it. 703 * 704 * This method is only valid if the device has 705 * PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY capability in AudioDevInfo.caps flags, 706 * otherwise Error will be thrown. 707 * 708 * Note that in case the setting is kept for future use, it will be applied 709 * to any devices, even when application has changed the sound device to be 710 * used. 711 * 712 * @param latency_msec The output latency. 713 * @param keep Specify whether the setting is to be kept 714 * for future use. 715 * 716 */ 717 void 718 setOutputLatency(unsigned latency_msec, bool keep=true) throw(Error); 719 720 /** 721 * Get the audio output latency control or query capability of the sound 722 * device being used. If sound device is currently active, the method will 723 * forward the request to the sound device. If sound device is currently 724 * inactive, and if application had previously set the setting and mark the 725 * setting as kept, then that setting will be returned. Otherwise, this 726 * method will raise error. 727 * 728 * This method is only valid if the device has 729 * PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY capability in AudioDevInfo.caps flags, 730 * otherwise Error will be thrown. 731 * 732 * @return The audio output latency. 733 * 734 */ 735 unsigned getOutputLatency() const throw(Error); 736 737 /** 738 * This will configure audio input volume level capability to the 739 * sound device being used. 740 * If sound device is currently active, the method will forward the 741 * setting to the sound device instance to be applied immediately, 742 * if it supports it. 743 * 744 * This method is only valid if the device has 745 * PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING capability in AudioDevInfo.caps 746 * flags, otherwise Error will be thrown. 747 * 748 * Note that in case the setting is kept for future use, it will be applied 749 * to any devices, even when application has changed the sound device to be 750 * used. 751 * 752 * @param volume The input volume level, in percent. 753 * @param keep Specify whether the setting is to be kept for future 754 * use. 755 * 756 */ 757 void setInputVolume(unsigned volume, bool keep=true) throw(Error); 758 759 /** 760 * Get the audio input volume level capability of the sound device being 761 * used. If sound device is currently active, the method will forward the 762 * request to the sound device. If sound device is currently inactive, 763 * and if application had previously set the setting and mark the setting 764 * as kept, then that setting will be returned. Otherwise, this method 765 * will raise error. 766 * 767 * This method is only valid if the device has 768 * PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING capability in AudioDevInfo.caps 769 * flags, otherwise Error will be thrown. * 770 771 * @return The audio input volume level, in percent. 772 * 773 */ 774 unsigned getInputVolume() const throw(Error); 775 776 /** 777 * This will configure audio output volume level capability to the sound 778 * device being used. If sound device is currently active, the method will 779 * forward the setting to the sound device instance to be applied 780 * immediately, if it supports it. 781 * 782 * This method is only valid if the device has 783 * PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING capability in AudioDevInfo.caps 784 * flags, otherwise Error will be thrown. 785 * 786 * Note that in case the setting is kept for future use, it will be applied 787 * to any devices, even when application has changed the sound device to be 788 * used. 789 * 790 * @param volume The output volume level, in percent. 791 * @param keep Specify whether the setting is to be kept 792 * for future use. 793 * 794 */ 795 void setOutputVolume(unsigned volume, bool keep=true) throw(Error); 796 797 /** 798 * Get the audio output volume level capability of the sound device being 799 * used. If sound device is currently active, the method will forward the 800 * request to the sound device. If sound device is currently inactive, 801 * and if application had previously set the setting and mark the setting 802 * as kept, then that setting will be returned. Otherwise, this method 803 * will raise error. 804 * 805 * This method is only valid if the device has 806 * PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING capability in AudioDevInfo.caps 807 * flags, otherwise Error will be thrown. 808 * 809 * @return The audio output volume level, in percent. 810 * 811 */ 812 unsigned getOutputVolume() const throw(Error); 813 814 /** 815 * Get the audio input signal level capability of the sound device being 816 * used. If sound device is currently active, the method will forward the 817 * request to the sound device. If sound device is currently inactive, 818 * and if application had previously set the setting and mark the setting 819 * as kept, then that setting will be returned. Otherwise, this method 820 * will raise error. 821 * 822 * This method is only valid if the device has 823 * PJMEDIA_AUD_DEV_CAP_INPUT_SIGNAL_METER capability in AudioDevInfo.caps 824 * flags, otherwise Error will be thrown. 825 * 826 * @return The audio input signal level, in percent. 827 * 828 */ 829 unsigned getInputSignal() const throw(Error); 830 831 /** 832 * Get the audio output signal level capability of the sound device being 833 * used. If sound device is currently active, the method will forward the 834 * request to the sound device. If sound device is currently inactive, 835 * and if application had previously set the setting and mark the setting 836 * as kept, then that setting will be returned. Otherwise, this method 837 * will raise error. 838 * 839 * This method is only valid if the device has 840 * PJMEDIA_AUD_DEV_CAP_OUTPUT_SIGNAL_METER capability in AudioDevInfo.caps 841 * flags, otherwise Error will be thrown. 842 * 843 * @return The audio output signal level, in percent. 844 * 845 */ 846 unsigned getOutputSignal() const throw(Error); 847 848 /** 849 * This will configure audio input route capability to the sound device 850 * being used. If sound device is currently active, the method will 851 * forward the setting to the sound device instance to be applied 852 * immediately, if it supports it. 853 * 854 * This method is only valid if the device has 855 * PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE capability in AudioDevInfo.caps 856 * flags, otherwise Error will be thrown. 857 * 858 * Note that in case the setting is kept for future use, it will be applied 859 * to any devices, even when application has changed the sound device to be 860 * used. 861 * 862 * @param route The audio input route. 863 * @param keep Specify whether the setting is to be kept 864 * for future use. 865 * 866 */ 867 void 868 setInputRoute(pjmedia_aud_dev_route route, bool keep=true) throw(Error); 869 870 /** 871 * Get the audio input route capability of the sound device being used. 872 * If sound device is currently active, the method will forward the 873 * request to the sound device. If sound device is currently inactive, 874 * and if application had previously set the setting and mark the setting 875 * as kept, then that setting will be returned. Otherwise, this method 876 * will raise error. 877 * 878 * This method is only valid if the device has 879 * PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE capability in AudioDevInfo.caps 880 * flags, otherwise Error will be thrown. 881 * 882 * @return The audio input route. 883 * 884 */ 885 pjmedia_aud_dev_route getInputRoute() const throw(Error); 886 887 /** 888 * This will configure audio output route capability to the sound device 889 * being used. If sound device is currently active, the method will 890 * forward the setting to the sound device instance to be applied 891 * immediately, if it supports it. 892 * 893 * This method is only valid if the device has 894 * PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE capability in AudioDevInfo.caps 895 * flags, otherwise Error will be thrown. 896 * 897 * Note that in case the setting is kept for future use, it will be applied 898 * to any devices, even when application has changed the sound device to be 899 * used. 900 * 901 * @param route The audio output route. 902 * @param keep Specify whether the setting is to be kept 903 * for future use. 904 * 905 */ 906 void 907 setOutputRoute(pjmedia_aud_dev_route route, bool keep=true) throw(Error); 908 909 /** 910 * Get the audio output route capability of the sound device being used. 911 * If sound device is currently active, the method will forward the 912 * request to the sound device. If sound device is currently inactive, 913 * and if application had previously set the setting and mark the setting 914 * as kept, then that setting will be returned. Otherwise, this method 915 * will raise error. 916 * 917 * This method is only valid if the device has 918 * PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE capability in AudioDevInfo.caps 919 * flags, otherwise Error will be thrown. 920 * 921 * @return The audio output route. 922 * 923 */ 924 pjmedia_aud_dev_route getOutputRoute() const throw(Error); 925 926 /** 927 * This will configure audio voice activity detection capability to 928 * the sound device being used. If sound device is currently active, 929 * the method will forward the setting to the sound device instance 930 * to be applied immediately, if it supports it. 931 * 932 * This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_VAD 933 * capability in AudioDevInfo.caps flags, otherwise Error will be thrown. 934 * 935 * Note that in case the setting is kept for future use, it will be applied 936 * to any devices, even when application has changed the sound device to be 937 * used. 938 * 939 * @param enable Enable/disable voice activity detection 940 * feature. Set true to enable. 941 * @param keep Specify whether the setting is to be kept for 942 * future use. 943 * 944 */ 945 void setVad(bool enable, bool keep=true) throw(Error); 946 947 /** 948 * Get the audio voice activity detection capability of the sound device 949 * being used. If sound device is currently active, the method will 950 * forward the request to the sound device. If sound device is currently 951 * inactive, and if application had previously set the setting and mark 952 * the setting as kept, then that setting will be returned. Otherwise, 953 * this method will raise error. 954 * 955 * This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_VAD 956 * capability in AudioDevInfo.caps flags, otherwise Error will be thrown. 957 * 958 * @return The audio voice activity detection feature. 959 * 960 */ 961 bool getVad() const throw(Error); 962 963 /** 964 * This will configure audio comfort noise generation capability to 965 * the sound device being used. If sound device is currently active, 966 * the method will forward the setting to the sound device instance 967 * to be applied immediately, if it supports it. 968 * 969 * This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_CNG 970 * capability in AudioDevInfo.caps flags, otherwise Error will be thrown. 971 * 972 * Note that in case the setting is kept for future use, it will be applied 973 * to any devices, even when application has changed the sound device to be 974 * used. 975 * 976 * @param enable Enable/disable comfort noise generation 977 * feature. Set true to enable. 978 * @param keep Specify whether the setting is to be kept for 979 * future use. 980 * 981 */ 982 void setCng(bool enable, bool keep=true) throw(Error); 983 984 /** 985 * Get the audio comfort noise generation capability of the sound device 986 * being used. If sound device is currently active, the method will 987 * forward the request to the sound device. If sound device is currently 988 * inactive, and if application had previously set the setting and mark 989 * the setting as kept, then that setting will be returned. Otherwise, 990 * this method will raise error. 991 * 992 * This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_CNG 993 * capability in AudioDevInfo.caps flags, otherwise Error will be thrown. 994 * 995 * @return The audio comfort noise generation feature. 996 * 997 */ 998 bool getCng() const throw(Error); 999 1000 /** 1001 * This will configure audio packet loss concealment capability to 1002 * the sound device being used. If sound device is currently active, 1003 * the method will forward the setting to the sound device instance 1004 * to be applied immediately, if it supports it. 1005 * 1006 * This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_PLC 1007 * capability in AudioDevInfo.caps flags, otherwise Error will be thrown. 1008 * 1009 * Note that in case the setting is kept for future use, it will be applied 1010 * to any devices, even when application has changed the sound device to be 1011 * used. 1012 * 1013 * @param enable Enable/disable packet loss concealment 1014 * feature. Set true to enable. 1015 * @param keep Specify whether the setting is to be kept for 1016 * future use. 1017 * 1018 */ 1019 void setPlc(bool enable, bool keep=true) throw(Error); 1020 1021 /** 1022 * Get the audio packet loss concealment capability of the sound device 1023 * being used. If sound device is currently active, the method will 1024 * forward the request to the sound device. If sound device is currently 1025 * inactive, and if application had previously set the setting and mark 1026 * the setting as kept, then that setting will be returned. Otherwise, 1027 * this method will raise error. 1028 * 1029 * This method is only valid if the device has PJMEDIA_AUD_DEV_CAP_PLC 1030 * capability in AudioDevInfo.caps flags, otherwise Error will be thrown. 1031 * 1032 * @return The audio packet loss concealment feature. 1033 * 1034 */ 1035 bool getPlc() const throw(Error); 1036 1037 private: 1038 AudioDevInfoVector audioDevList; 1039 1040 /** 1041 * Constructor. 1042 */ 1043 AudDevManager(); 1044 1045 /** 1046 * Destructor. 1047 */ 1048 ~AudDevManager(); 1049 1050 void clearAudioDevList(); 1051 int getActiveDev(bool is_capture) const throw(Error); 1052 1053 friend class Endpoint; 1054 }; 1055 386 1056 } // namespace pj 387 1057
Note: See TracChangeset
for help on using the changeset viewer.