Changeset 4668
- Timestamp:
- Dec 3, 2013 7:14:22 AM (11 years ago)
- Location:
- pjproject/branches/projects/pjsua2
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/pjsua2.i
r4663 r4668 75 75 %template(AudioMediaVector) std::vector<pj::AudioMedia*>; 76 76 %template(MediaFormatVector) std::vector<pj::MediaFormat*>; 77 %template(AudioDevInfoVector) std::vector<AudioDevInfo*>; 77 78 78 79 %include "pjsua2/media.hpp" -
pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/symbols.i
r4663 r4668 46 46 47 47 enum pjmedia_vid_dev_std_index {PJMEDIA_VID_DEFAULT_CAPTURE_DEV = -1, PJMEDIA_VID_DEFAULT_RENDER_DEV = -2, PJMEDIA_VID_INVALID_DEV = -3}; 48 49 typedef enum pjmedia_aud_dev_route {PJMEDIA_AUD_DEV_ROUTE_DEFAULT = 0, PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER = 1, PJMEDIA_AUD_DEV_ROUTE_EARPIECE = 2, PJMEDIA_AUD_DEV_ROUTE_BLUETOOTH = 4} pjmedia_aud_dev_route; 50 51 typedef enum pjmedia_aud_dev_cap {PJMEDIA_AUD_DEV_CAP_EXT_FORMAT = 1, PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY = 2, PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY = 4, PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING = 8, PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING = 16, PJMEDIA_AUD_DEV_CAP_INPUT_SIGNAL_METER = 32, PJMEDIA_AUD_DEV_CAP_OUTPUT_SIGNAL_METER = 64, PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE = 128, PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE = 256, PJMEDIA_AUD_DEV_CAP_EC = 512, PJMEDIA_AUD_DEV_CAP_EC_TAIL = 1024, PJMEDIA_AUD_DEV_CAP_VAD = 2048, PJMEDIA_AUD_DEV_CAP_CNG = 4096, PJMEDIA_AUD_DEV_CAP_PLC = 8192, PJMEDIA_AUD_DEV_CAP_MAX = 16384} pjmedia_aud_dev_cap; 48 52 49 53 enum pjmedia_file_writer_option {PJMEDIA_FILE_WRITE_PCM = 0, PJMEDIA_FILE_WRITE_ALAW = 1, PJMEDIA_FILE_WRITE_ULAW = 2}; -
pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/symbols.lst
r4663 r4668 12 12 pjmedia/vid_stream.h pjmedia_vid_stream_rc_method 13 13 pjmedia-videodev/videodev.h pjmedia_vid_dev_index pjmedia_vid_dev_std_index 14 pjmedia-audiodev/audiodev.h pjmedia_aud_dev_route pjmedia_aud_dev_cap 14 15 pjmedia/wav_port.h pjmedia_file_writer_option pjmedia_file_player_option 15 16 pjmedia/types.h pjmedia_type pjmedia_dir pjmedia_tp_proto -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/endpoint.hpp
r4663 r4668 1005 1005 const AudioMediaVector &mediaEnumPorts() const throw(Error); 1006 1006 1007 AudDevManager &audDevManager(); 1008 1007 1009 public: 1008 1010 /* … … 1072 1074 LogWriter *writer; // Custom writer, if any 1073 1075 AudioMediaVector mediaList; 1076 AudDevManager audioDevMgr; 1074 1077 1075 1078 /* Endpoint static callbacks */ … … 1193 1196 pjmedia_transport *base_tp, 1194 1197 unsigned flags); 1198 1195 1199 }; 1196 1200 -
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 -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/endpoint.cpp
r4666 r4668 1360 1360 return (it != mediaList.end()); 1361 1361 } 1362 1363 AudDevManager &Endpoint::audDevManager() 1364 { 1365 return audioDevMgr; 1366 } -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/media.cpp
r4666 r4668 28 28 #define THIS_FILE "media.cpp" 29 29 #define MAX_FILE_NAMES 64 30 #define MAX_DEV_COUNT 64 31 32 /////////////////////////////////////////////////////////////////////////////// 33 void MediaFormatAudio::fromPj(const pjmedia_format &format) 34 { 35 if ((format.type != PJMEDIA_TYPE_AUDIO) && 36 (format.detail_type != PJMEDIA_FORMAT_DETAIL_AUDIO)) 37 { 38 type = PJMEDIA_TYPE_UNKNOWN; 39 return; 40 } 41 42 id = format.id; 43 type = format.type; 44 45 /* Detail. */ 46 clockRate = format.det.aud.clock_rate; 47 channelCount = format.det.aud.channel_count; 48 frameTimeUsec = format.det.aud.frame_time_usec; 49 bitsPerSample = format.det.aud.bits_per_sample; 50 avgBps = format.det.aud.avg_bps; 51 maxBps = format.det.aud.max_bps; 52 } 53 54 pjmedia_format MediaFormatAudio::toPj() const 55 { 56 pjmedia_format pj_format; 57 58 pj_format.id = id; 59 pj_format.type = type; 60 61 pj_format.detail_type = PJMEDIA_FORMAT_DETAIL_AUDIO; 62 pj_format.det.aud.clock_rate = clockRate; 63 pj_format.det.aud.channel_count = channelCount; 64 pj_format.det.aud.frame_time_usec = frameTimeUsec; 65 pj_format.det.aud.bits_per_sample = bitsPerSample; 66 pj_format.det.aud.avg_bps = avgBps; 67 pj_format.det.aud.max_bps = maxBps; 68 69 return pj_format; 70 } 30 71 31 72 /////////////////////////////////////////////////////////////////////////////// … … 254 295 255 296 /////////////////////////////////////////////////////////////////////////////// 256 257 297 AudioMediaRecorder::AudioMediaRecorder() 258 298 : recorderId(PJSUA_INVALID_ID) … … 287 327 registerMediaPort(NULL); 288 328 } 289 329 /////////////////////////////////////////////////////////////////////////////// 330 void AudioDevInfo::fromPj(const pjmedia_aud_dev_info &dev_info) 331 { 332 name = dev_info.name; 333 inputCount = dev_info.input_count; 334 outputCount = dev_info.output_count; 335 defaultSamplesPerSec = dev_info.default_samples_per_sec; 336 driver = dev_info.driver; 337 caps = dev_info.caps; 338 routes = dev_info.routes; 339 340 for (unsigned i=0; i<dev_info.ext_fmt_cnt;++i) { 341 MediaFormatAudio *format = new MediaFormatAudio; 342 343 format->fromPj(dev_info.ext_fmt[i]); 344 if (format->type == PJMEDIA_TYPE_AUDIO) 345 extFmt.push_back(format); 346 } 347 } 348 349 AudioDevInfo::~AudioDevInfo() 350 { 351 for(unsigned i=0;i<extFmt.size();++i) { 352 delete extFmt[i]; 353 } 354 extFmt.clear(); 355 } 356 /////////////////////////////////////////////////////////////////////////////// 357 /* Audio device operations. */ 358 359 int AudDevManager::getCaptureDev() const throw(Error) 360 { 361 return getActiveDev(true); 362 } 363 364 int AudDevManager::getPlaybackDev() const throw(Error) 365 { 366 return getActiveDev(false); 367 } 368 369 void AudDevManager::setCaptureDev(int capture_dev) const throw(Error) 370 { 371 int playback_dev = getPlaybackDev(); 372 373 PJSUA2_CHECK_EXPR( pjsua_set_snd_dev(capture_dev, playback_dev) ); 374 } 375 376 void AudDevManager::setPlaybackDev(int playback_dev) const throw(Error) 377 { 378 int capture_dev = getCaptureDev(); 379 380 PJSUA2_CHECK_EXPR( pjsua_set_snd_dev(capture_dev, playback_dev) ); 381 } 382 383 const AudioDevInfoVector &AudDevManager::enumDev() throw(Error) 384 { 385 pjmedia_aud_dev_info pj_info[MAX_DEV_COUNT]; 386 unsigned count; 387 388 clearAudioDevList(); 389 390 PJSUA2_CHECK_EXPR( pjsua_enum_aud_devs(pj_info, &count) ); 391 392 for (unsigned i = 0; (i<count && i<MAX_DEV_COUNT) ;++i) { 393 AudioDevInfo *dev_info = new AudioDevInfo; 394 dev_info->fromPj(pj_info[i]); 395 audioDevList.push_back(dev_info); 396 } 397 return audioDevList; 398 } 399 400 void AudDevManager::setNullDev() throw(Error) 401 { 402 PJSUA2_CHECK_EXPR( pjsua_set_null_snd_dev() ); 403 } 404 405 MediaPort *AudDevManager::setNoDev() 406 { 407 return (MediaPort*)pjsua_set_no_snd_dev(); 408 } 409 410 void AudDevManager::setEcOptions(unsigned tail_msec, 411 unsigned options) throw(Error) 412 { 413 PJSUA2_CHECK_EXPR( pjsua_set_ec(tail_msec, options) ); 414 } 415 416 unsigned AudDevManager::getEcTail() const throw(Error) 417 { 418 unsigned tail_msec = 0; 419 420 PJSUA2_CHECK_EXPR( pjsua_get_ec_tail(&tail_msec) ); 421 422 return tail_msec; 423 } 424 425 bool AudDevManager::sndIsActive() const 426 { 427 return pjsua_snd_is_active(); 428 } 429 430 void AudDevManager::refreshDevs() throw(Error) 431 { 432 PJSUA2_CHECK_EXPR( pjmedia_aud_dev_refresh() ); 433 } 434 435 unsigned AudDevManager::getDevCount() const 436 { 437 return pjmedia_aud_dev_count(); 438 } 439 440 AudioDevInfo 441 AudDevManager::getDevInfo(int id) const throw(Error) 442 { 443 AudioDevInfo dev_info; 444 pjmedia_aud_dev_info pj_info; 445 446 PJSUA2_CHECK_EXPR( pjmedia_aud_dev_get_info(id, &pj_info) ); 447 448 dev_info.fromPj(pj_info); 449 return dev_info; 450 } 451 452 int AudDevManager::lookupDev(const string &drv_name, 453 const string &dev_name) const throw(Error) 454 { 455 pjmedia_aud_dev_index pj_idx = 0; 456 457 PJSUA2_CHECK_EXPR( pjmedia_aud_dev_lookup(drv_name.c_str(), 458 dev_name.c_str(), 459 &pj_idx) ); 460 461 return pj_idx; 462 } 463 464 465 string AudDevManager::capName(pjmedia_aud_dev_cap cap) const 466 { 467 return pjmedia_aud_dev_cap_name(cap, NULL); 468 } 469 470 void 471 AudDevManager::setExtFormat(const MediaFormatAudio &format, 472 bool keep) throw(Error) 473 { 474 pjmedia_format pj_format = format.toPj(); 475 476 PJSUA2_CHECK_EXPR( pjsua_snd_set_setting(PJMEDIA_AUD_DEV_CAP_EXT_FORMAT, 477 &pj_format, 478 keep) ); 479 } 480 481 MediaFormatAudio AudDevManager::getExtFormat() const throw(Error) 482 { 483 pjmedia_format pj_format; 484 MediaFormatAudio format; 485 486 PJSUA2_CHECK_EXPR( pjsua_snd_get_setting(PJMEDIA_AUD_DEV_CAP_EXT_FORMAT, 487 &pj_format) ); 488 489 format.fromPj(pj_format); 490 491 return format; 492 } 493 494 void AudDevManager::setInputLatency(unsigned latency_msec, 495 bool keep) throw(Error) 496 { 497 PJSUA2_CHECK_EXPR( pjsua_snd_set_setting(PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY, 498 &latency_msec, 499 keep) ); 500 } 501 502 unsigned AudDevManager::getInputLatency() const throw(Error) 503 { 504 unsigned latency_msec = 0; 505 506 PJSUA2_CHECK_EXPR( pjsua_snd_get_setting(PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY, 507 &latency_msec) ); 508 509 return latency_msec; 510 } 511 512 void 513 AudDevManager::setOutputLatency(unsigned latency_msec, 514 bool keep) throw(Error) 515 { 516 PJSUA2_CHECK_EXPR( pjsua_snd_set_setting(PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY, 517 &latency_msec, 518 keep) ); 519 } 520 521 unsigned AudDevManager::getOutputLatency() const throw(Error) 522 { 523 unsigned latency_msec = 0; 524 525 PJSUA2_CHECK_EXPR( pjsua_snd_get_setting(PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY, 526 &latency_msec) ); 527 528 return latency_msec; 529 } 530 531 void AudDevManager::setInputVolume(unsigned volume, bool keep) throw(Error) 532 { 533 PJSUA2_CHECK_EXPR( 534 pjsua_snd_set_setting(PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING, 535 &volume, 536 keep) ); 537 } 538 539 unsigned AudDevManager::getInputVolume() const throw(Error) 540 { 541 unsigned volume = 0; 542 543 PJSUA2_CHECK_EXPR( 544 pjsua_snd_get_setting(PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING, 545 &volume) ); 546 547 return volume; 548 } 549 550 void AudDevManager::setOutputVolume(unsigned volume, bool keep) throw(Error) 551 { 552 PJSUA2_CHECK_EXPR( 553 pjsua_snd_set_setting(PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING, 554 &volume, 555 keep) ); 556 } 557 558 unsigned AudDevManager::getOutputVolume() const throw(Error) 559 { 560 unsigned volume = 0; 561 562 PJSUA2_CHECK_EXPR( 563 pjsua_snd_get_setting(PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING, 564 &volume) ); 565 566 return volume; 567 } 568 569 unsigned AudDevManager::getInputSignal() const throw(Error) 570 { 571 unsigned signal = 0; 572 573 PJSUA2_CHECK_EXPR( 574 pjsua_snd_get_setting(PJMEDIA_AUD_DEV_CAP_INPUT_SIGNAL_METER, 575 &signal) ); 576 577 return signal; 578 } 579 580 unsigned AudDevManager::getOutputSignal() const throw(Error) 581 { 582 unsigned signal = 0; 583 584 PJSUA2_CHECK_EXPR( 585 pjsua_snd_get_setting(PJMEDIA_AUD_DEV_CAP_OUTPUT_SIGNAL_METER, 586 &signal) ); 587 588 return signal; 589 } 590 591 void 592 AudDevManager::setInputRoute(pjmedia_aud_dev_route route, 593 bool keep) throw(Error) 594 { 595 PJSUA2_CHECK_EXPR( pjsua_snd_set_setting(PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE, 596 &route, 597 keep) ); 598 } 599 600 pjmedia_aud_dev_route AudDevManager::getInputRoute() const throw(Error) 601 { 602 pjmedia_aud_dev_route route = PJMEDIA_AUD_DEV_ROUTE_DEFAULT; 603 604 PJSUA2_CHECK_EXPR( pjsua_snd_get_setting(PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE, 605 &route) ); 606 607 return route; 608 } 609 610 void 611 AudDevManager::setOutputRoute(pjmedia_aud_dev_route route, 612 bool keep) throw(Error) 613 { 614 PJSUA2_CHECK_EXPR( pjsua_snd_set_setting(PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE, 615 &route, 616 keep) ); 617 } 618 619 pjmedia_aud_dev_route AudDevManager::getOutputRoute() const throw(Error) 620 { 621 pjmedia_aud_dev_route route = PJMEDIA_AUD_DEV_ROUTE_DEFAULT; 622 623 PJSUA2_CHECK_EXPR( pjsua_snd_get_setting(PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE, 624 &route) ); 625 626 return route; 627 } 628 629 void AudDevManager::setVad(bool enable, bool keep) throw(Error) 630 { 631 PJSUA2_CHECK_EXPR( pjsua_snd_set_setting(PJMEDIA_AUD_DEV_CAP_VAD, 632 &enable, 633 keep) ); 634 } 635 636 bool AudDevManager::getVad() const throw(Error) 637 { 638 bool enable = false; 639 640 PJSUA2_CHECK_EXPR( pjsua_snd_get_setting(PJMEDIA_AUD_DEV_CAP_VAD, 641 &enable) ); 642 643 return enable; 644 } 645 646 void AudDevManager::setCng(bool enable, bool keep) throw(Error) 647 { 648 PJSUA2_CHECK_EXPR( pjsua_snd_set_setting(PJMEDIA_AUD_DEV_CAP_CNG, 649 &enable, 650 keep) ); 651 } 652 653 bool AudDevManager::getCng() const throw(Error) 654 { 655 bool enable = false; 656 657 PJSUA2_CHECK_EXPR( pjsua_snd_get_setting(PJMEDIA_AUD_DEV_CAP_CNG, 658 &enable) ); 659 660 return enable; 661 } 662 663 void AudDevManager::setPlc(bool enable, bool keep) throw(Error) 664 { 665 PJSUA2_CHECK_EXPR( pjsua_snd_set_setting(PJMEDIA_AUD_DEV_CAP_PLC, 666 &enable, 667 keep) ); 668 } 669 670 bool AudDevManager::getPlc() const throw(Error) 671 { 672 bool enable = false; 673 674 PJSUA2_CHECK_EXPR( pjsua_snd_get_setting(PJMEDIA_AUD_DEV_CAP_PLC, 675 &enable) ); 676 677 return enable; 678 } 679 680 AudDevManager::AudDevManager() 681 { 682 683 684 } 685 686 AudDevManager::~AudDevManager() 687 { 688 clearAudioDevList(); 689 } 690 691 void AudDevManager::clearAudioDevList() 692 { 693 for(unsigned i=0;i<audioDevList.size();++i) { 694 delete audioDevList[i]; 695 } 696 audioDevList.clear(); 697 } 698 699 int AudDevManager::getActiveDev(bool is_capture) const throw(Error) 700 { 701 int capture_dev = 0, playback_dev = 0; 702 PJSUA2_CHECK_EXPR( pjsua_get_snd_dev(&capture_dev, &playback_dev) ); 703 704 return is_capture?capture_dev:playback_dev; 705 }
Note: See TracChangeset
for help on using the changeset viewer.