Changeset 5273
- Timestamp:
- Apr 4, 2016 1:44:10 AM (9 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/swig/symbols.i
r5165 r5273 166 166 typedef enum pjsua_create_media_transport_flag {PJSUA_MED_TP_CLOSE_MEMBER = 1} pjsua_create_media_transport_flag; 167 167 168 typedef enum pjsua_snd_dev_mode {PJSUA_SND_DEV_SPEAKER_ONLY = 1, PJSUA_SND_DEV_NO_IMMEDIATE_OPEN = 2} pjsua_snd_dev_mode; 169 -
pjproject/trunk/pjsip-apps/src/swig/symbols.lst
r5165 r5273 34 34 pjsip-ua/sip_inv.h pjsip_inv_state 35 35 36 pjsua-lib/pjsua.h pjsua_invalid_id_const_ pjsua_state pjsua_stun_use pjsua_call_hold_type pjsua_acc_id pjsua_destroy_flag pjsua_100rel_use pjsua_sip_timer_use pjsua_ipv6_use pjsua_buddy_status pjsua_call_media_status pjsua_vid_win_id pjsua_call_id pjsua_med_tp_st pjsua_call_vid_strm_op pjsua_vid_req_keyframe_method pjsua_call_flag pjsua_create_media_transport_flag 36 pjsua-lib/pjsua.h pjsua_invalid_id_const_ pjsua_state pjsua_stun_use pjsua_call_hold_type pjsua_acc_id pjsua_destroy_flag pjsua_100rel_use pjsua_sip_timer_use pjsua_ipv6_use pjsua_buddy_status pjsua_call_media_status pjsua_vid_win_id pjsua_call_id pjsua_med_tp_st pjsua_call_vid_strm_op pjsua_vid_req_keyframe_method pjsua_call_flag pjsua_create_media_transport_flag pjsua_snd_dev_mode -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r5242 r5273 5998 5998 } pjsua_media_transport; 5999 5999 6000 /** 6001 * This enumeration specifies the sound device mode. 6002 */ 6003 typedef enum pjsua_snd_dev_mode 6004 { 6005 /** 6006 * Open sound device without mic (speaker only). 6007 */ 6008 PJSUA_SND_DEV_SPEAKER_ONLY = 1, 6009 6010 /** 6011 * Do not open sound device, after setting the sound device. 6012 */ 6013 PJSUA_SND_DEV_NO_IMMEDIATE_OPEN = 2 6014 6015 } pjsua_snd_dev_mode; 6016 6017 6018 /** 6019 * This structure specifies the parameters to set the sound device. 6020 * Use pjsua_snd_dev_param_default() to initialize this structure with 6021 * default values. 6022 */ 6023 typedef struct pjsua_snd_dev_param 6024 { 6025 /* 6026 * Capture dev id. 6027 * 6028 * Default: PJMEDIA_AUD_DEFAULT_CAPTURE_DEV 6029 */ 6030 int capture_dev; 6031 6032 /* 6033 * Playback dev id. 6034 * 6035 * Default: PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV 6036 */ 6037 int playback_dev; 6038 6039 /* 6040 * Sound device mode, refer to #pjsua_snd_dev_mode. 6041 * 6042 * Default: 0 6043 */ 6044 unsigned mode; 6045 6046 } pjsua_snd_dev_param; 6047 6048 6049 /** 6050 * Initialize pjsua_snd_dev_param with default values. 6051 * 6052 * @param prm The parameter. 6053 */ 6054 PJ_DECL(void) pjsua_snd_dev_param_default(pjsua_snd_dev_param *prm); 6055 6000 6056 6001 6057 /** … … 6385 6441 int playback_dev); 6386 6442 6443 /** 6444 * Select or change sound device according to the specified param. 6445 * 6446 * @param snd_param Sound device param. 6447 * 6448 * @return PJ_SUCCESS on success, or the appropriate error code. 6449 */ 6450 PJ_DECL(pj_status_t) pjsua_set_snd_dev2(pjsua_snd_dev_param *snd_param); 6451 6387 6452 6388 6453 /** -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
r5217 r5273 479 479 pjmedia_port *null_port; /**< Null port. */ 480 480 pj_bool_t snd_is_on; /**< Media flow is currently active */ 481 unsigned snd_mode; /**< Sound device mode. */ 481 482 482 483 /* Video device */ -
pjproject/trunk/pjsip/include/pjsua2/media.hpp
r5165 r5273 768 768 /** 769 769 * Select or change capture sound device. Application may call this 770 * function at any time to replace current sound device. 770 * function at any time to replace current sound device. Calling this 771 * method will not change the state of the sound device (opened/closed). 772 * Note that this method will override the mode set by setSndDevMode(). 771 773 * 772 774 * @param capture_dev Device ID of the capture device. … … 776 778 /** 777 779 * Select or change playback sound device. Application may call this 778 * function at any time to replace current sound device. 780 * function at any time to replace current sound device. Calling this 781 * method will not change the state of the sound device (opened/closed). 782 * Note that this method will override the mode set by setSndDevMode(). 779 783 * 780 784 * @param playback_dev Device ID of the playback device. … … 806 810 */ 807 811 MediaPort *setNoDev(); 812 813 /** 814 * Set sound device mode. 815 * 816 * @param mode The sound device mode, as bitmask combination 817 * of #pjsua_snd_dev_mode 818 * 819 */ 820 void setSndDevMode(unsigned mode) const throw(Error); 808 821 809 822 /** -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_aud.c
r5205 r5273 688 688 } 689 689 690 PJ_DEF(void) pjsua_snd_dev_param_default(pjsua_snd_dev_param *prm) 691 { 692 pj_bzero(prm, sizeof(*prm)); 693 prm->capture_dev = PJMEDIA_AUD_DEFAULT_CAPTURE_DEV; 694 prm->playback_dev = PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV; 695 } 690 696 691 697 /* … … 1697 1703 pjmedia_port *conf_port; 1698 1704 pj_status_t status; 1705 pj_bool_t speaker_only = (pjsua_var.snd_mode & PJSUA_SND_DEV_SPEAKER_ONLY); 1699 1706 1700 1707 PJ_ASSERT_RETURN(param, PJ_EINVAL); … … 1725 1732 param->on_rec_frame = &on_aud_prev_rec_frame; 1726 1733 1727 PJ_LOG(4,(THIS_FILE, "Opening sound device %s@%d/%d/%dms", 1734 PJ_LOG(4,(THIS_FILE, "Opening sound device (%s) %s@%d/%d/%dms", 1735 speaker_only?"speaker only":"speaker + mic", 1728 1736 get_fmt_name(param->base.ext_fmt.id), 1729 1737 param->base.clock_rate, param->base.channel_count, … … 1732 1740 pj_log_push_indent(); 1733 1741 1734 status = pjmedia_snd_port_create2( pjsua_var.snd_pool, 1735 param, &pjsua_var.snd_port); 1742 if (speaker_only) { 1743 status = pjmedia_snd_port_create_player(pjsua_var.snd_pool, 1744 -1, 1745 param->base.clock_rate, 1746 param->base.channel_count, 1747 param->base.samples_per_frame, 1748 param->base.bits_per_sample, 1749 0, 1750 &pjsua_var.snd_port); 1751 1752 } else { 1753 status = pjmedia_snd_port_create2(pjsua_var.snd_pool, 1754 param, &pjsua_var.snd_port); 1755 } 1756 1736 1757 if (status != PJ_SUCCESS) 1737 1758 goto on_error; … … 1921 1942 1922 1943 1944 PJ_DEF(pj_status_t) pjsua_set_snd_dev(int capture_dev, 1945 int playback_dev) 1946 { 1947 pjsua_snd_dev_param param; 1948 1949 pjsua_snd_dev_param_default(¶m); 1950 1951 param.capture_dev = capture_dev; 1952 param.playback_dev = playback_dev; 1953 /* Always open the sound device. */ 1954 param.mode = 0; 1955 1956 return pjsua_set_snd_dev2(¶m); 1957 } 1958 1923 1959 /* 1924 1960 * Select or change sound device. Application may call this function at 1925 1961 * any time to replace current sound device. 1926 1962 */ 1927 PJ_DEF(pj_status_t) pjsua_set_snd_dev( int capture_dev, 1928 int playback_dev) 1963 PJ_DEF(pj_status_t) pjsua_set_snd_dev2(pjsua_snd_dev_param *snd_param) 1929 1964 { 1930 1965 unsigned alt_cr_cnt = 1; … … 1932 1967 unsigned i; 1933 1968 pj_status_t status = -1; 1969 unsigned orig_snd_dev_mode = pjsua_var.snd_mode; 1970 pj_bool_t no_change = (pjsua_var.snd_is_on || (!pjsua_var.snd_is_on && 1971 (snd_param->mode & 1972 PJSUA_SND_DEV_NO_IMMEDIATE_OPEN))); 1934 1973 1935 1974 PJ_LOG(4,(THIS_FILE, "Set sound device: capture=%d, playback=%d", 1936 capture_dev,playback_dev));1975 snd_param->capture_dev, snd_param->playback_dev)); 1937 1976 pj_log_push_indent(); 1938 1977 1939 1978 PJSUA_LOCK(); 1940 1979 1941 if (pjsua_var.cap_dev == capture_dev && 1942 pjsua_var.play_dev == playback_dev && 1943 pjsua_var.snd_is_on && !pjsua_var.no_snd) 1980 if (pjsua_var.cap_dev == snd_param->capture_dev && 1981 pjsua_var.play_dev == snd_param->playback_dev && 1982 pjsua_var.snd_mode == snd_param->mode && 1983 !pjsua_var.no_snd && no_change) 1944 1984 { 1945 1985 PJ_LOG(4, (THIS_FILE, "No changes in capture and playback devices")); … … 1950 1990 1951 1991 /* Null-sound */ 1952 if (capture_dev==NULL_SND_DEV_ID && playback_dev==NULL_SND_DEV_ID) { 1992 if (snd_param->capture_dev == NULL_SND_DEV_ID && 1993 snd_param->playback_dev == NULL_SND_DEV_ID) 1994 { 1953 1995 PJSUA_UNLOCK(); 1954 1996 status = pjsua_set_null_snd_dev(); 1955 1997 pj_log_pop_indent(); 1956 1998 return status; 1999 } 2000 2001 pjsua_var.snd_mode = snd_param->mode; 2002 2003 if (!pjsua_var.no_snd && 2004 (snd_param->mode & PJSUA_SND_DEV_NO_IMMEDIATE_OPEN)) 2005 { 2006 pjsua_var.cap_dev = snd_param->capture_dev; 2007 pjsua_var.play_dev = snd_param->playback_dev; 2008 2009 PJSUA_UNLOCK(); 2010 pj_log_pop_indent(); 2011 return PJ_SUCCESS; 1957 2012 } 1958 2013 … … 1983 2038 pjmedia_snd_port_param_default(¶m); 1984 2039 param.ec_options = pjsua_var.media_cfg.ec_options; 1985 status = create_aud_param(¶m.base, capture_dev, playback_dev, 2040 status = create_aud_param(¶m.base, snd_param->capture_dev, 2041 snd_param->playback_dev, 1986 2042 alt_cr[i], pjsua_var.media_cfg.channel_count, 1987 2043 samples_per_frame, 16); … … 2009 2065 2010 2066 on_error: 2067 pjsua_var.snd_mode = orig_snd_dev_mode; 2011 2068 PJSUA_UNLOCK(); 2012 2069 pj_log_pop_indent(); -
pjproject/trunk/pjsip/src/pjsua2/media.cpp
r5170 r5273 680 680 681 681 void AudDevManager::setCaptureDev(int capture_dev) const throw(Error) 682 { 683 int playback_dev = getPlaybackDev(); 684 685 PJSUA2_CHECK_EXPR( pjsua_set_snd_dev(capture_dev, playback_dev) ); 682 { 683 pjsua_snd_dev_param param; 684 pjsua_snd_dev_param_default(¶m); 685 686 param.capture_dev = capture_dev; 687 param.playback_dev = getPlaybackDev(); 688 689 param.mode = PJSUA_SND_DEV_NO_IMMEDIATE_OPEN; 690 691 PJSUA2_CHECK_EXPR( pjsua_set_snd_dev2(¶m) ); 686 692 } 687 693 688 694 void AudDevManager::setPlaybackDev(int playback_dev) const throw(Error) 689 695 { 690 int capture_dev = getCaptureDev(); 691 692 PJSUA2_CHECK_EXPR( pjsua_set_snd_dev(capture_dev, playback_dev) ); 696 pjsua_snd_dev_param param; 697 pjsua_snd_dev_param_default(¶m); 698 699 param.capture_dev = getCaptureDev(); 700 param.playback_dev = playback_dev; 701 702 param.mode = PJSUA_SND_DEV_NO_IMMEDIATE_OPEN; 703 704 PJSUA2_CHECK_EXPR( pjsua_set_snd_dev2(¶m) ); 693 705 } 694 706 … … 719 731 { 720 732 return (MediaPort*)pjsua_set_no_snd_dev(); 733 } 734 735 void AudDevManager::setSndDevMode(unsigned mode) const throw(Error) 736 { 737 int capture_dev = 0, playback_dev = 0; 738 pjsua_snd_dev_param param; 739 pj_status_t status = pjsua_get_snd_dev(&capture_dev, &playback_dev); 740 if (status != PJ_SUCCESS) { 741 PJSUA2_RAISE_ERROR2(status, "AudDevManager::setSndDevMode()"); 742 } 743 pjsua_snd_dev_param_default(¶m); 744 param.capture_dev = capture_dev; 745 param.playback_dev = playback_dev; 746 param.mode = mode; 747 PJSUA2_CHECK_EXPR( pjsua_set_snd_dev2(¶m) ); 721 748 } 722 749
Note: See TracChangeset
for help on using the changeset viewer.