您的位置:首页 > Web前端 > JavaScript

PJSUA-API Media Manipulation 媒体操作api

2015-04-01 12:50 253 查看


PJSUA-API Media Manipulation

[PJSUA API - High Level Softphone API]

Media manipulation. More...

Data Structures 数据结构

struct pjsua_media_config
struct pjsua_codec_info
struct pjsua_conf_port_info
struct pjsua_media_transport

Defines

#define PJSUA_MAX_CONF_PORTS 254
#define PJSUA_DEFAULT_CLOCK_RATE 16000
#define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
#define PJSUA_DEFAULT_CODEC_QUALITY 8
#define PJSUA_DEFAULT_ILBC_MODE 30
#define PJSUA_DEFAULT_EC_TAIL_LEN 200
#define PJSUA_MAX_PLAYERS 32
#define PJSUA_MAX_RECORDERS 32

Functions

void pjsua_media_config_default (pjsua_media_config *cfg)
unsigned pjsua_conf_get_max_ports (void)
unsigned pjsua_conf_get_active_ports (void)
pj_status_t pjsua_enum_conf_ports (pjsua_conf_port_id id[],
unsigned *count)
pj_status_t pjsua_conf_get_port_info (pjsua_conf_port_id port_id, pjsua_conf_port_info *info)
pj_status_t pjsua_conf_add_port (pj_pool_t *pool, pjmedia_port *port, pjsua_conf_port_id *p_id)
pj_status_t pjsua_conf_remove_port (pjsua_conf_port_id port_id)
pj_status_t pjsua_conf_connect (pjsua_conf_port_id source, pjsua_conf_port_id sink)
pj_status_t pjsua_conf_disconnect (pjsua_conf_port_id source, pjsua_conf_port_id sink)
pj_status_t pjsua_conf_adjust_tx_level (pjsua_conf_port_id slot,
float level)
pj_status_t pjsua_conf_adjust_rx_level (pjsua_conf_port_id slot,
float level)
pj_status_t pjsua_conf_get_signal_level (pjsua_conf_port_id slot,
unsigned *tx_level, unsigned *rx_level)
pj_status_t pjsua_player_create (const pj_str_t *filename,
unsigned options, pjsua_player_id *p_id)
pj_status_t pjsua_playlist_create (const pj_str_t file_names[],
unsigned file_count, const pj_str_t *label, unsigned options, pjsua_player_id *p_id)
pjsua_conf_port_id pjsua_player_get_conf_port (pjsua_player_id id)
pj_status_t pjsua_player_get_port (pjsua_player_id id, pjmedia_port **p_port)
pj_status_t pjsua_player_set_pos (pjsua_player_id id, pj_uint32_t samples)
pj_status_t pjsua_player_destroy (pjsua_player_id id)
pj_status_t pjsua_recorder_create (const pj_str_t *filename,
unsigned enc_type, void *enc_param, pj_ssize_t max_size, unsigned options, pjsua_recorder_id *p_id)
pjsua_conf_port_id pjsua_recorder_get_conf_port (pjsua_recorder_id id)
pj_status_t pjsua_recorder_get_port (pjsua_recorder_id id, pjmedia_port **p_port)
pj_status_t pjsua_recorder_destroy (pjsua_recorder_id id)
pj_status_t pjsua_enum_aud_devs (pjmedia_aud_dev_info info[],
unsigned *count)
pj_status_t pjsua_enum_snd_devs (pjmedia_snd_dev_info info[],
unsigned *count)
pj_status_t pjsua_get_snd_dev (int *capture_dev, int *playback_dev)
pj_status_t pjsua_set_snd_dev (int capture_dev, int playback_dev)
pj_status_t pjsua_set_null_snd_dev (void)
pjmedia_port * pjsua_set_no_snd_dev (void)
pj_status_t pjsua_set_ec (unsigned
tail_ms, unsigned options)
pj_status_t pjsua_get_ec_tail (unsigned
*p_tail_ms)
pj_bool_t pjsua_snd_is_active (void)
pj_status_t pjsua_snd_set_setting (pjmedia_aud_dev_cap cap,
const void *pval, pj_bool_t keep)
pj_status_t pjsua_snd_get_setting (pjmedia_aud_dev_cap cap,
void *pval)
pj_status_t pjsua_enum_codecs (pjsua_codec_info id[],
unsigned *count)
pj_status_t pjsua_codec_set_priority (const pj_str_t *codec_id, pj_uint8_t priority)
pj_status_t pjsua_codec_get_param (const pj_str_t *codec_id, pjmedia_codec_param *param)
pj_status_t pjsua_codec_set_param (const pj_str_t *codec_id,
const pjmedia_codec_param *param)
pj_status_t pjsua_media_transports_create (const pjsua_transport_config *cfg)
pj_status_t pjsua_media_transports_attach (pjsua_media_transport tp[],
unsigned count, pj_bool_t auto_delete)


Detailed Description

PJSUA has rather powerful media features, which are built around the PJMEDIA conference bridge. Basically, all media "ports" (such as calls, W*** players, W*** playlist, file recorders, sound device, tone generators, etc) are terminated in the conference bridge,
and application can manipulate the interconnection between these terminations freely.

PJSUA具备丰富的媒体特征,这都建立在 PJMESIA 会议桥基础上,基本上所有的"端口"(例如呼叫,wav播放,wav播放列表,文件录音,声音设备,双音频产生等等)都挂接在会议桥上,应用程序就可以自由操作互联这些挂接

The conference bridge provides powerful switching and mixing functionality for application. With the conference bridge, each conference slot (e.g. a call) can transmit to multiple destinations, and one destination can receive from multiple sources. If more
than one media terminations are terminated in the same slot, the conference bridge will mix the signal automatically.

会议桥提供丰富的交换和混音功能,利用会议桥,每个会议槽(例如一个呼叫)可以传输到多个目的路由,并且一个目的路由可以接收多个源路由。如果不止一个媒体流端口挂接到相同的会议槽上,那么会议桥将会自动将其混音

Application connects one media termination/slot to another by calling pjsua_conf_connect() function.
This will establish unidirectional media flow from the source termination to the sink termination. To establish bidirectional media flow, application wound need to make another call to pjsua_conf_connect(),
this time inverting the source and destination slots in the parameter.

应用程序使用pjsua_conf_connect()函数将媒体端口挂接的会议槽与其它会议槽相连接,这将建立从源端口挂接会议槽到接收槽的单向媒体流。如果需要建立双向媒体流则需要同时在调用一次pjsua_conf_connect()函数,但参数中的源和目的槽需要反向

For example, to stream a W*** file to remote call, application may use the following steps:

例如播放一个wav声音文件给一个呼叫,需要下面步骤:

<a target=_blank class="codeRef" href="http://www.pjsip.org/pjlib/docs/html/group__PJ__BASIC.htm#gab43ba3167bd2a2ab4580509dbf79200e" style="color: rgb(51, 102, 153); text-decoration: none;">pj_status_t</a> stream_to_call( <a target=_blank class="code" href="http://www.pjsip.org/pjsip/docs/html/group__PJSUA__LIB__BASE.htm#gad4eb99a78c98ddbd83aecf7e933fc684" style="color: rgb(51, 102, 153); text-decoration: none;">pjsua_call_id</a> call_id )
  {
     <a target=_blank class="code" href="http://www.pjsip.org/pjsip/docs/html/group__PJSUA__LIB__BASE.htm#ga266a56483961431df7a5ebae457b9f3f" style="color: rgb(51, 102, 153); text-decoration: none;">pjsua_player_id</a> player_id;
     
     status = <a target=_blank class="code" href="http://www.pjsip.org/pjsip/docs/html/group__PJSUA__LIB__MEDIA.htm#ga90a2ec9c8516b5ad13b061a46ae1d07a" style="color: rgb(51, 102, 153); text-decoration: none;">pjsua_player_create</a>(<span class="stringliteral">"mysong.wav"</span>, 0, NULL, &player_id);
     <span class="keywordflow">if</span> (status != PJ_SUCCESS)
        <span class="keywordflow">return</span> status;

     status = <a target=_blank class="code" href="http://www.pjsip.org/pjsip/docs/html/group__PJSUA__LIB__MEDIA.htm#ga3451304d677e013130dfb9e6b37e3ee6" style="color: rgb(51, 102, 153); text-decoration: none;">pjsua_conf_connect</a>( <a target=_blank class="code" href="http://www.pjsip.org/pjsip/docs/html/group__PJSUA__LIB__MEDIA.htm#ga4b7a4ad09c9edad41ae516cea468819c" style="color: rgb(51, 102, 153); text-decoration: none;">pjsua_player_get_conf_port</a>(),
                                  <a target=_blank class="code" href="http://www.pjsip.org/pjsip/docs/html/group__PJSUA__LIB__CALL.htm#ga90c100b6e00d146ba824145fe6861aef" style="color: rgb(51, 102, 153); text-decoration: none;">pjsua_call_get_conf_port</a>() );
  }


Other features of PJSUA media: 其它特性

efficient N to M interconnections between media terminations. 媒体端口会议槽上的高效连接
media termination can be connected to itself to create loopback media. 通过环回媒体可以连接自己
the media termination may have different clock rates, and resampling will be done automatically by conference bridge. 媒体可能有不同的时钟速率,会议桥可以自动重采样
media terminations may also have different frame time; the conference bridge will perform the necessary bufferring to adjust the difference between terminations. 媒体可能有不同的帧时间,会议桥可以进行必要的缓冲来调整不同的帧时间
interconnections are removed automatically when media termination is removed from the bridge.媒体端口从桥中移除的时候,连接会自动移除
sound device may be changed even when there are active media interconnections. 即使有激活的媒体桥接,声音设备也可以改变
correctly report call's media quality (in pjsua_call_dump())
from RTCP packet exchange.用pjsua_call_dump来输出RTCP包交换的媒体质量的报表


Define Documentation

#define PJSUA_MAX_CONF_PORTS 254
Max ports in the conference bridge. This setting is the default value for pjsua_media_config.max_media_ports.
会议桥的最大端口数

#define PJSUA_DEFAULT_CLOCK_RATE 16000
The default clock rate to be used by the conference bridge. This setting is the default value for pjsua_media_config.clock_rate.
会议桥缺省的时钟速率

#define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Default frame length in the conference bridge. This setting is the default value for pjsua_media_config.audio_frame_ptime.
会议桥缺省的帧长度

#define PJSUA_DEFAULT_CODEC_QUALITY 8
Default codec quality settings. This setting is the default value for pjsua_media_config.quality.
缺省编码质量设定

#define PJSUA_DEFAULT_ILBC_MODE 30
Default iLBC mode. This setting is the default value for pjsua_media_config.ilbc_mode.
缺省的iLBC编码模式

#define PJSUA_DEFAULT_EC_TAIL_LEN 200
The default echo canceller tail length. This setting is the default value for pjsua_media_config.ec_tail_len.
缺省的回音消除尾长

#define PJSUA_MAX_PLAYERS 32
The maximum file player. 最大文件播放

#define PJSUA_MAX_RECORDERS 32
The maximum file player. 最大文件录音


Function Documentation

void pjsua_media_config_default(pjsua_media_config * cfg)
Use this function to initialize media config. 初始化媒体设置函数

Parameters:
cfg The media config to be initialized.
unsigned pjsua_conf_get_max_ports(void )
Get maxinum number of conference ports. 获得最大会议桥端口数

Returns:Maximum number of ports in the conference bridge.

unsigned pjsua_conf_get_active_ports(void )
Get current number of active ports in the bridge. 当前激活的会议桥端口数

Returns:The number.

pj_status_t pjsua_enum_conf_ports(pjsua_conf_port_id id[],
unsigned * count
)
Enumerate all conference ports. 枚举所有会议桥端口

Parameters:
id Array of conference port ID to be initialized.
count On input, specifies max elements in the array. On return, it contains actual number of elements that have been initialized.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_conf_get_port_info(pjsua_conf_port_id port_id,
pjsua_conf_port_info * info
)
Get information about the specified conference port 获取指定端口的信息

Parameters:
port_id Port identification.
info Pointer to store the port info.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_conf_add_port(pj_pool_t * pool,
pjmedia_port * port,
pjsua_conf_port_id * p_id
)
Add arbitrary media port to PJSUA's conference bridge. Application can use this function to add the media port that it creates. For media ports that are created by PJSUA-LIB (such as calls, file player, or file recorder), PJSUA-LIB will automatically add
the port to the bridge.

增加任意媒体端口到会议桥,应用程序可以使用该函数增加已经创建的媒体端口,创建端口使用PJSUA-LIB(例如呼叫,媒体播放,媒体录音等),PJSUA-LIB自动增加端口到桥

Parameters:
pool Pool to use.
port Media port to be added to the bridge.
p_id Optional pointer to receive the conference slot id.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_conf_remove_port(pjsua_conf_port_id port_id)
Remove arbitrary slot from the conference bridge. Application should only call this function if it registered the port manually with previous call to pjsua_conf_add_port().

从会议桥删除任意会议槽,该函数仅在使用pjsua_conf_add_port()手动添加端口时使用

Parameters:
port_id The slot id of the port to be removed.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_conf_connect(pjsua_conf_port_id source,
pjsua_conf_port_id sink
)
Establish unidirectional media flow from souce to sink. One source may transmit to multiple destinations/sink. And if multiple sources are transmitting to the same sink, the media will be mixed together. Source and sink may refer to the same ID, effectively
looping the media.

If bidirectional media flow is desired, application needs to call this function twice, with the second one having the arguments reversed.

建立从源端口到接收端口单向的媒体流,一个源端口可以传输到多个目的(接收)端口。多个源端口也可以传输到相同的接收端口,此时将产生混音,源端口和接收端口相同则为环回媒体效果

双向媒体流的建立,需要再次调用该函数,并将源端口和目的端口反向

Parameters:
source Port ID of the source media/transmitter.
sink Port ID of the destination media/received.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_conf_disconnect(pjsua_conf_port_id source,
pjsua_conf_port_id sink
)
Disconnect media flow from the source to destination port.

中断媒体流

Parameters:
source Port ID of the source media/transmitter.
sink Port ID of the destination media/received.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
float level
)
Adjust the signal level to be transmitted from the bridge to the specified port by making it louder or quieter.

调发送端信号能量级别,使其增大或减小音量

Parameters:
slot The conference bridge slot number.
level Signal level adjustment. Value 1.0 means no level adjustment, while value 0 means to mute the port.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
float level
)
Adjust the signal level to be received from the specified port (to the bridge) by making it louder or quieter.

调节接收端信号能量级别,使其增大或减小音量

Parameters:
slot The conference bridge slot number.
level Signal level adjustment. Value 1.0 means no level adjustment, while value 0 means to mute the port.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
unsigned * tx_level,
unsigned * rx_level
)
Get last signal level transmitted to or received from the specified port. The signal level is an integer value in zero to 255, with zero indicates no signal, and 255 indicates the loudest signal level.

获得发送端或接收端信号能量级别,信号量是从0-255的整形,0为静音,255为最大音量

Parameters:
slot The conference bridge slot number.
tx_level Optional argument to receive the level of signal transmitted to the specified port (i.e. the direction is from the bridge to the port).
rx_level Optional argument to receive the level of signal received from the port (i.e. the direction is from the port to the bridge).
Returns:PJ_SUCCESS on success.

pj_status_t pjsua_player_create(const pj_str_t * filename,
unsigned options,
pjsua_player_id * p_id
)
Create a file player, and automatically add this player to the conference bridge.

创建媒体播放,自动添加到会议桥

Parameters:
filename The filename to be played. Currently only W*** files are supported, and the W*** file MUST be formatted as 16bit PCM mono/single channel (any clock rate is supported).

播放的声音文件,当前仅支持wav格式,而且必须是16bit的PCM格式,单声道,任何时钟速度都可以

options Optional option flag. Application may specify PJMEDIA_FILE_NO_LOOP to prevent playback loop.

可选项,可用于防止循环播放
p_id Pointer to receive player ID.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_playlist_create(const pj_str_t file_names[],
unsigned file_count,
const pj_str_t * label,
unsigned options,
pjsua_player_id * p_id
)
Create a file playlist media port, and automatically add the port to the conference bridge.

创建媒体播放列表端口,自动添加到会议桥

Parameters:
file_names Array of file names to be added to the play list. Note that the files must have the same clock rate, number of channels, and number of bits per sample.

播放文件列表名称的数组,所有文件必须相同的时钟速率,声道数和比特率,采样数等

file_count Number of files in the array. 文件数量
label Optional label to be set for the media port.
options Optional option flag. Application may specify PJMEDIA_FILE_NO_LOOP to prevent looping.
p_id Optional pointer to receive player ID.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pjsua_conf_port_id pjsua_player_get_conf_port(pjsua_player_id id)
Get conference port ID associated with player or playlist.

获得分配给播放(列表或单个文件)的会议桥端口id

Parameters:
id The file player ID.
Returns:Conference port ID associated with this player.

pj_status_t pjsua_player_get_port(pjsua_player_id id,
pjmedia_port ** p_port
)
Get the media port for the player or playlist.



Parameters:
id The player ID.
p_port The media port associated with the player.
Returns:PJ_SUCCESS on success.

pj_status_t pjsua_player_set_pos(pjsua_player_id id,
pj_uint32_t samples
)
Set playback position. This operation is not valid for playlist.

Parameters:
id The file player ID.
samples The playback position, in samples. Application can specify zero to re-start the playback.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_player_destroy(pjsua_player_id id)
Close the file of playlist, remove the player from the bridge, and free resources associated with the file player or playlist.

Parameters:
id The file player ID.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_recorder_create(const pj_str_t * filename,
unsigned enc_type,
void * enc_param,
pj_ssize_t max_size,
unsigned options,
pjsua_recorder_id * p_id
)
Create a file recorder, and automatically connect this recorder to the conference bridge. The recorder currently supports recording W*** file. The type of the recorder to use is determined by the extension of the file (e.g. ".wav").

创建一个录音文件。自动连接该录音到会议桥,录音当前支持wav格式,录音类型用于检测文件扩展名

Parameters:
filename Output file name. The function will determine the default format to be used based on the file extension. Currently ".wav" is supported on all platforms.

输出文件名,函数会检测默认格式用于文件扩展名,.wav支持所有平台

enc_type Optionally specify the type of encoder to be used to compress the media, if the file can support different encodings. This value must be zero for now.

可选的,如果文件支持不同编码,指定用于压缩媒体的编码格式。该值设置为0

enc_param Optionally specify codec specific parameter to be passed to the file writer. For .W*** recorder, this value must be NULL.
max_size Maximum file size. Specify zero or -1 to remove size limitation. This value must be zero or -1 for now.

文件大小,0或者-1不限制

options Optional options.
p_id Pointer to receive the recorder instance.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pjsua_conf_port_id pjsua_recorder_get_conf_port(pjsua_recorder_id id)
Get conference port associated with recorder.

获得分配到录音的会议端口id

Parameters:
id The recorder ID.
Returns:Conference port ID associated with this recorder.

pj_status_t pjsua_recorder_get_port(pjsua_recorder_id id,
pjmedia_port ** p_port
)
Get the media port for the recorder.

获得录音的媒体端口

Parameters:
id The recorder ID.
p_port The media port associated with the recorder.
Returns:PJ_SUCCESS on success.

pj_status_t pjsua_recorder_destroy(pjsua_recorder_id id)
Destroy recorder (this will complete recording).

销毁录音(将完成录音)

Parameters:
id The recorder ID.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_enum_aud_devs(pjmedia_aud_dev_info info[],
unsigned * count
)
Enum all audio devices installed in the system.

枚举所有安装在系统的音频设备

Parameters:
info Array of info to be initialized.
count On input, specifies max elements in the array. On return, it contains actual number of elements that have been initialized.

Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
unsigned * count
)
Enum all sound devices installed in the system (old API).

枚举所有声音设备(老api)

Parameters:
info Array of info to be initialized.
count On input, specifies max elements in the array. On return, it contains actual number of elements that have been initialized.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_get_snd_dev(int * capture_dev,
int * playback_dev
)
Get currently active sound devices. If sound devices has not been created (for example when pjsua_start() is
not called), it is possible that the function returns PJ_SUCCESS with -1 as device IDs.

获得当前激活的声音设备,如果声音设备没有被创建(例如当pjsua_start()没有调用之前),函数可能会返回PJ_SUCCESS和设备id为-1

Parameters:
capture_dev On return it will be filled with device ID of the capture device.

playback_dev On return it will be filled with device ID of the device ID of the playback device.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_set_snd_dev(int capture_dev,
int playback_dev
)
Select or change sound device. Application may call this function at any time to replace current sound device.

选择或改变声音设备,应用程序可以在任何时候调用该函数改变当前声音设备

Parameters:
capture_dev Device ID of the capture device.
playback_dev Device ID of the playback device.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_set_null_snd_dev(void )
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.

设置为不用声音设备,用于为会议桥提供时钟,从而不启用硬件

Returns:PJ_SUCCESS on success, or the appropriate error code.

pjmedia_port* pjsua_set_no_snd_dev(void )
Disconnect the main conference bridge from any sound devices, and let application connect the bridge to it's own sound device/master port.

将主会议桥与声音设备断掉,让程序用自己的声音设备和主端口连接会议桥

Returns:The port interface of the conference bridge, so that application can connect this to it's own sound device or master port.

pj_status_t pjsua_set_ec(unsigned tail_ms,
unsigned options
)
Change the echo cancellation settings.

The behavior of this function depends on whether the sound device is currently active, and if it is, whether device or software AEC is being used.

If the sound device is currently active, and if the device supports AEC, this function will forward the change request to the device and it will be up to the device on whether support the request. If software AEC is being used (the software EC will be used
if the device does not support AEC), this function will change the software EC settings. In all cases, the setting will be saved for future opening of the sound device.

If the sound device is not currently active, this will only change the default AEC settings and the setting will be applied next time the sound device is opened.

改变回音消除设置

函数的该行为依赖于声音设备当前是否激活,如果激活,设备或软件的声音回音消除将被使用。

如果声音设备当前激活,并且设备支持回音消除,函数将会传递修改请求给硬件,并且在支持回音消除的设备上生效。如果使用软件回音消除(硬件不支持回音消除的时候,软件回音消除才使用),该函数将修改软件回音消除设置。2种方法中,设置都会保存以便下次使用设置打开声音设备。

如果当前设备没有激活,将会修改默认的回音消除设置,在下次设备打开时应用。

Parameters:
tail_ms The tail length, in miliseconds. Set to zero to disable AEC.
options Options to be passed to pjmedia_echo_create(). Normally
the value should be zero.
Returns:PJ_SUCCESS on success.

pj_status_t pjsua_get_ec_tail(unsigned * p_tail_ms)
Get current echo canceller tail length.

Parameters:
p_tail_ms Pointer to receive the tail length, in miliseconds. If AEC is disabled, the value will be zero.
Returns:PJ_SUCCESS on success.

pj_bool_t pjsua_snd_is_active(void )
Check whether the sound device is currently active. The sound device may be inactive if the application has set the auto close feature to non-zero (the snd_auto_close_time setting in pjsua_media_config),
or if null sound device or no sound device has been configured via the pjsua_set_no_snd_dev() function.

检查声音设备是否激活,如果程序设置了自动关闭特征为0(在pjsua_media_config中的snd_auto_close_time)那么声音设备或许不会激活,亦或没有声音设备,或者通过pjsua_set_no_snd_dev()函数配置没有声音设备



pj_status_t pjsua_snd_set_setting(pjmedia_aud_dev_cap cap,
const void * pval,
pj_bool_t keep
)
Configure sound device setting to the sound device being used. If sound device is currently active, the function will forward the setting to the sound device instance to be applied immediately, if it supports it.

The setting will be saved for future opening of the sound device, if the "keep" argument is set to non-zero. If the sound device is currently inactive, and the "keep" argument is false, this function will return error.

Note that in case the setting is kept for future use, it will be applied to any devices, even when application has changed the sound device to be used.

Note also that the echo cancellation setting should be set with pjsua_set_ec() API
instead.

See also pjmedia_aud_stream_set_cap() for more
information about setting an audio device capability.



Parameters:
cap The sound device setting to change.
pval Pointer to value. Please see pjmedia_aud_dev_cap documentation
about the type of value to be supplied for each setting.
keep Specify whether the setting is to be kept for future use.
Returns:PJ_SUCCESS on success or the appropriate error code.

pj_status_t pjsua_snd_get_setting(pjmedia_aud_dev_cap cap,
void * pval
)
Retrieve a sound device setting. If sound device is currently active, the function will forward the request to the sound device. If sound device is currently inactive, and if application had previously set the setting and mark the setting as kept, then that
setting will be returned. Otherwise, this function will return error.

Note that echo cancellation settings should be retrieved with pjsua_get_ec_tail() API
instead.

检索声音设备设置。

Parameters:
cap The sound device setting to retrieve.
pval Pointer to receive the value. Please see pjmedia_aud_dev_cap documentation
about the type of value to be supplied for each setting.
Returns:PJ_SUCCESS on success or the appropriate error code.

pj_status_t pjsua_enum_codecs(pjsua_codec_info id[],
unsigned * count
)
Enum all supported codecs in the system.

枚举所有系统支持的编码格式

Parameters:
id Array of ID to be initialized.
count On input, specifies max elements in the array. On return, it contains actual number of elements that have been initialized.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_codec_set_priority(const pj_str_t * codec_id,
pj_uint8_t priority
)
Change codec priority.

改变编码优先级

Parameters:
codec_id Codec ID, which is a string that uniquely identify the codec (such as "speex/8000"). Please see pjsua manual or pjmedia codec reference for details.
priority Codec priority, 0-255, where zero means to disable the codec.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_codec_get_param(const pj_str_t * codec_id,
pjmedia_codec_param * param
)
Get codec parameters.

获得编码参数

Parameters:
codec_id Codec ID.
param Structure to receive codec parameters.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_codec_set_param(const pj_str_t * codec_id,
const pjmedia_codec_param * param
)
Set codec parameters.

设置编码参数

Parameters:
codec_id Codec ID.
param Codec parameter to set. Set to NULL to reset codec parameter to library default settings.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_media_transports_create(const pjsua_transport_config * cfg)
Create UDP media transports for all the calls. This function creates one UDP media transport for each call.

为所有呼叫创建UDP媒体传输。

Parameters:
cfg Media transport configuration. The "port" field in the configuration is used as the start port to bind the sockets.
Returns:PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_media_transports_attach(pjsua_media_transport tp[],
unsigned count,
pj_bool_t auto_delete
)
Register custom media transports to be used by calls. There must enough media transports for all calls.

注册自定义的呼叫媒体传输模式,呼叫必须有足够的传输模式

Parameters:
tp The media transport array.
count Number of elements in the array. This number MUST match the number of maximum calls configured when pjsua is created.
auto_delete Flag to indicate whether the transports should be destroyed when pjsua is shutdown.
Returns:PJ_SUCCESS on success, or the appropriate error code.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: