我正在尝试在AWS EC2上实现PJSUA2 python来进行调用.如何访问本地音频媒体,如麦克风和扬声器



我尝试使用STUN服务器使用NAT,并检查UA配置中的ICE标志,如下所示。

ua_cfg = pj.UAConfig()
ua_cfg.stun_host = "XX.XX.XXX.XX"
my_media_cfg = pj.MediaConfig()
my_media_cfg.enable_ice = True
log_cfg = pj.LogConfig(level=5, callback=log_cb)
lib.init(ua_cfg=ua_cfg, media_cfg=my_media_cfg, log_cfg=log_cfg)

在此之后,我创建了UDP传输,如下所示。

transport = lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(0))

最后,我注册了SIP,可以打电话了。但我无法访问系统的麦克风和扬声器。

有人尝试过使用Python为云实现同样的功能吗?

在询问此处之前,请检查文档

PJSUA2文件

class AudDevManager
#include <media.hpp>
Audio device manager.
Public Functions
int getCaptureDev() const
Get currently active capture sound devices.
If sound devices has not been created, it is possible that the function returns -1 as device IDs.
Return
Device ID of the capture device.
AudioMedia &getCaptureDevMedia()
Get the AudioMedia of the capture audio device.
Return
Audio media for the capture device.
int getPlaybackDev() const
Get currently active playback sound devices.
If sound devices has not been created, it is possible that the function returns -1 as device IDs.
Return
Device ID of the playback device.
AudioMedia &getPlaybackDevMedia()
Get the AudioMedia of the speaker/playback audio device.
Return
Audio media for the speaker/playback device.
void setCaptureDev(int capture_dev) const
Select or change capture sound device.
Application may call this function at any time to replace current sound device. Calling this method will not change the state of the sound device (opened/closed). Note that this method will override the mode set by setSndDevMode().
Parameters
capture_dev: Device ID of the capture device.
void setPlaybackDev(int playback_dev) const
Select or change playback sound device.
Application may call this function at any time to replace current sound device. Calling this method will not change the state of the sound device (opened/closed). Note that this method will override the mode set by setSndDevMode().
Parameters
playback_dev: Device ID of the playback device.
const AudioDevInfoVector &enumDev()
Warning: deprecated, use enumDev2 instead.
This function is not safe in multithreaded environment.
Enum all audio devices installed in the system. This function is not safe in multithreaded environment.
Return
The list of audio device info.
AudioDevInfoVector2 enumDev2() const
Enum all audio devices installed in the system.
Return
The list of audio device info.
void setNullDev()
Set pjsua to use null sound device.
The null sound device only provides the timing needed by the conference bridge, and will not interract with any hardware.
MediaPort *setNoDev()
Disconnect the main conference bridge from any sound devices, and let application connect the bridge to it’s own sound device/master port.
Return
The port interface of the conference bridge, so that application can connect this to it’s own sound device or master port.
void setSndDevMode(unsigned mode) const
Set sound device mode.

最新更新