我正在尝试为pyt4上的程序软件电话和使用库PJSIP
制作一个静音/取消静音麦克风和扬声器的功能我在代码pjsip
中找到了这个
def conf_set_tx_level(self, slot, level): """Adjust the signal level to be transmitted from the bridge to the specified port by making it louder or quieter. Keyword arguments: slot -- integer to identify the conference slot number. level -- Signal level adjustment. Value 1.0 means no level adjustment, while value 0 means to mute the port. """ lck = self.auto_lock() err = _pjsua.conf_set_tx_level(slot, level) self._err_check("conf_set_tx_level()", self, err) def conf_set_rx_level(self, slot, level): """Adjust the signal level to be received from the specified port (to the bridge) by making it louder or quieter. Keyword arguments: slot -- integer to identify the conference slot number. level -- Signal level adjustment. Value 1.0 means no level adjustment, while value 0 means to mute the port. """ lck = self.auto_lock() err = _pjsua.conf_set_rx_level(slot, level) self._err_check("conf_set_rx_level()", self, err)
我明白我需要发送一个参数0,但怎么办? 并返回工作声音设备和麦克风 也许它“”“”“”pjsua_conf_adjust_tx_level(slot_number,0)“”“”“
答案 0 :(得分:1)
他自己回答: - )
在我的情况下是如此
# call window ################ self.MuteMic = False self.MuteSpeaker = False ################ #btn signals self.connect(self.MuteUnmuteMicButton, QtCore.SIGNAL("clicked()"), self.MuteUnmuteMic) self.connect(self.MuteUnmuteSpeakerButton, QtCore.SIGNAL("clicked()"), self.MuteUnmuteSpeaker) def MuteUnmuteMic(self): try: if self.MuteMic: self.MuteMic = False self.parent().unmute_mic() else: self.MuteMic = True self.parent().mute_mic() except: debug ("ошибка при вызове функции включение или отключение микрофона (call Window).") def MuteUnmuteSpeaker(self): try: if self.MuteSpeaker: self.MuteSpeaker = False self.parent().unmute_speaker() else: self.MuteSpeaker = True self.parent().mute_speaker() except: debug ("ошибка при вызове функции включение или отключение микрофона (call Window).") # other code ---------- # ----------------------core of the my app # ---import PJUA lib---- def mute_mic(self): #this that you need in my case my app connected to pjua "self.lib" self.lib.conf_set_rx_level(0,0) debug ("вызвана функция выключение микрофона") def unmute_mic(self): self.lib.conf_set_rx_level(0,1) debug ("вызвана функция включение микрофона") def mute_speaker(self): self.lib.conf_set_tx_level(0,0) debug ("вызвана функция выключение динамиков") def unmute_speaker(self): self.lib.conf_set_tx_level(0,1) debug ("вызвана функция включение динамиков")