Added options to disable microphone device, usefull for streaming server (some systems only have sound player)
git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@312 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
parent
51f5bd5bc9
commit
8e3344c41d
|
@ -40,29 +40,68 @@ typedef struct pjmedia_conf pjmedia_conf;
|
||||||
*/
|
*/
|
||||||
typedef struct pjmedia_conf_port_info
|
typedef struct pjmedia_conf_port_info
|
||||||
{
|
{
|
||||||
unsigned slot;
|
unsigned slot; /**< Slot number. */
|
||||||
pj_str_t name;
|
pj_str_t name; /**< Port name. */
|
||||||
pjmedia_port_op tx_setting;
|
pjmedia_port_op tx_setting; /**< Transmit settings. */
|
||||||
pjmedia_port_op rx_setting;
|
pjmedia_port_op rx_setting; /**< Receive settings. */
|
||||||
pj_bool_t *listener;
|
pj_bool_t *listener; /**< Array of listeners. */
|
||||||
unsigned clock_rate;
|
unsigned clock_rate; /**< Clock rate of the port. */
|
||||||
unsigned samples_per_frame;
|
unsigned samples_per_frame; /**< Samples per frame */
|
||||||
} pjmedia_conf_port_info;
|
} pjmedia_conf_port_info;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create conference bridge.
|
* Conference port options. The values here can be combined in bitmask to
|
||||||
|
* be specified when the conference bridge is created.
|
||||||
|
*/
|
||||||
|
enum pjmedia_conf_option
|
||||||
|
{
|
||||||
|
PJMEDIA_CONF_NO_MIC = 1, /**< Disable audio streams from the
|
||||||
|
microphone device. */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create conference bridge. This normally will also create instances of
|
||||||
|
* sound device to be attached to the port zero of the bridge.
|
||||||
|
*
|
||||||
|
* @param pool Pool to use to allocate the bridge and
|
||||||
|
* additional buffers for the sound device.
|
||||||
|
* @param max_slots Maximum number of slots/ports to be created in
|
||||||
|
* the bridge. Note that the bridge internally uses
|
||||||
|
* one port for the sound device, so the actual
|
||||||
|
* maximum number of ports will be less one than
|
||||||
|
* this value.
|
||||||
|
* @param sampling_rate Set the sampling rate of the bridge. This value
|
||||||
|
* is also used to set the sampling rate of the
|
||||||
|
* sound device.
|
||||||
|
* @param samples_per_frame Set the number of samples per frame. This value
|
||||||
|
* is also used to set the sound device.
|
||||||
|
* @param bits_per_sample Set the number of bits per sample. This value
|
||||||
|
* is also used to set the sound device. Currently
|
||||||
|
* only 16bit per sample is supported.
|
||||||
|
* @param options Bitmask options to be set for the bridge. The
|
||||||
|
* options are constructed from #pjmedia_conf_option
|
||||||
|
* enumeration.
|
||||||
|
* @param p_conf Pointer to receive the conference bridge instance.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS if conference bridge can be created.
|
||||||
*/
|
*/
|
||||||
PJ_DECL(pj_status_t) pjmedia_conf_create( pj_pool_t *pool,
|
PJ_DECL(pj_status_t) pjmedia_conf_create( pj_pool_t *pool,
|
||||||
unsigned max_slots,
|
unsigned max_slots,
|
||||||
unsigned sampling_rate,
|
unsigned sampling_rate,
|
||||||
unsigned samples_per_frame,
|
unsigned samples_per_frame,
|
||||||
unsigned bits_per_sample,
|
unsigned bits_per_sample,
|
||||||
|
unsigned options,
|
||||||
pjmedia_conf **p_conf );
|
pjmedia_conf **p_conf );
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy conference bridge.
|
* Destroy conference bridge.
|
||||||
|
*
|
||||||
|
* @param conf The conference bridge.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS on success.
|
||||||
*/
|
*/
|
||||||
PJ_DECL(pj_status_t) pjmedia_conf_destroy( pjmedia_conf *conf );
|
PJ_DECL(pj_status_t) pjmedia_conf_destroy( pjmedia_conf *conf );
|
||||||
|
|
||||||
|
|
|
@ -127,6 +127,7 @@ struct conf_port
|
||||||
*/
|
*/
|
||||||
struct pjmedia_conf
|
struct pjmedia_conf
|
||||||
{
|
{
|
||||||
|
unsigned options; /**< Bitmask options. */
|
||||||
unsigned max_ports; /**< Maximum ports. */
|
unsigned max_ports; /**< Maximum ports. */
|
||||||
unsigned port_cnt; /**< Current number of ports. */
|
unsigned port_cnt; /**< Current number of ports. */
|
||||||
unsigned connect_cnt; /**< Total number of connections */
|
unsigned connect_cnt; /**< Total number of connections */
|
||||||
|
@ -333,6 +334,7 @@ PJ_DEF(pj_status_t) pjmedia_conf_create( pj_pool_t *pool,
|
||||||
unsigned clock_rate,
|
unsigned clock_rate,
|
||||||
unsigned samples_per_frame,
|
unsigned samples_per_frame,
|
||||||
unsigned bits_per_sample,
|
unsigned bits_per_sample,
|
||||||
|
unsigned options,
|
||||||
pjmedia_conf **p_conf )
|
pjmedia_conf **p_conf )
|
||||||
{
|
{
|
||||||
pjmedia_conf *conf;
|
pjmedia_conf *conf;
|
||||||
|
@ -351,6 +353,7 @@ PJ_DEF(pj_status_t) pjmedia_conf_create( pj_pool_t *pool,
|
||||||
conf->ports = pj_pool_zalloc(pool, max_ports*sizeof(void*));
|
conf->ports = pj_pool_zalloc(pool, max_ports*sizeof(void*));
|
||||||
PJ_ASSERT_RETURN(conf->ports, PJ_ENOMEM);
|
PJ_ASSERT_RETURN(conf->ports, PJ_ENOMEM);
|
||||||
|
|
||||||
|
conf->options = options;
|
||||||
conf->max_ports = max_ports;
|
conf->max_ports = max_ports;
|
||||||
conf->clock_rate = clock_rate;
|
conf->clock_rate = clock_rate;
|
||||||
conf->samples_per_frame = samples_per_frame;
|
conf->samples_per_frame = samples_per_frame;
|
||||||
|
@ -385,16 +388,21 @@ PJ_DEF(pj_status_t) pjmedia_conf_create( pj_pool_t *pool,
|
||||||
*/
|
*/
|
||||||
static pj_status_t create_sound( pjmedia_conf *conf )
|
static pj_status_t create_sound( pjmedia_conf *conf )
|
||||||
{
|
{
|
||||||
/* Open recorder. */
|
/* Open recorder only if mic is not disabled. */
|
||||||
conf->snd_rec = pj_snd_open_recorder(-1 ,&conf->snd_info, &rec_cb, conf);
|
if ((conf->options & PJMEDIA_CONF_NO_MIC) == 0) {
|
||||||
if (conf->snd_rec == NULL) {
|
conf->snd_rec = pj_snd_open_recorder(-1 ,&conf->snd_info,
|
||||||
return -1;
|
&rec_cb, conf);
|
||||||
|
if (conf->snd_rec == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open player */
|
/* Open player */
|
||||||
conf->snd_player = pj_snd_open_player(-1, &conf->snd_info, &play_cb, conf);
|
conf->snd_player = pj_snd_open_player(-1, &conf->snd_info, &play_cb, conf);
|
||||||
if (conf->snd_player == NULL) {
|
if (conf->snd_player == NULL) {
|
||||||
pj_snd_stream_close(conf->snd_rec);
|
if (conf->snd_rec) {
|
||||||
|
pj_snd_stream_close(conf->snd_rec);
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,7 +433,7 @@ static pj_status_t resume_sound( pjmedia_conf *conf )
|
||||||
char errmsg[PJ_ERR_MSG_SIZE];
|
char errmsg[PJ_ERR_MSG_SIZE];
|
||||||
pj_status_t status;
|
pj_status_t status;
|
||||||
|
|
||||||
if (conf->snd_rec == NULL) {
|
if (conf->snd_player == NULL) {
|
||||||
status = create_sound(conf);
|
status = create_sound(conf);
|
||||||
if (status != PJ_SUCCESS)
|
if (status != PJ_SUCCESS)
|
||||||
return status;
|
return status;
|
||||||
|
|
|
@ -182,6 +182,7 @@ struct pjsua
|
||||||
unsigned clock_rate; /**< Internal clock rate. */
|
unsigned clock_rate; /**< Internal clock rate. */
|
||||||
pjmedia_conf *mconf; /**< Media conference. */
|
pjmedia_conf *mconf; /**< Media conference. */
|
||||||
pj_bool_t null_audio; /**< Null audio flag. */
|
pj_bool_t null_audio; /**< Null audio flag. */
|
||||||
|
pj_bool_t no_mic; /**< Disable microphone. */
|
||||||
char *wav_file; /**< WAV file name to play. */
|
char *wav_file; /**< WAV file name to play. */
|
||||||
unsigned wav_slot; /**< WAV player slot in bridge */
|
unsigned wav_slot; /**< WAV player slot in bridge */
|
||||||
pj_bool_t auto_play; /**< Auto play file for calls? */
|
pj_bool_t auto_play; /**< Auto play file for calls? */
|
||||||
|
|
|
@ -611,7 +611,7 @@ int pjsua_find_account_for_outgoing(const pj_str_t *url)
|
||||||
*/
|
*/
|
||||||
static pj_status_t init_media(void)
|
static pj_status_t init_media(void)
|
||||||
{
|
{
|
||||||
|
unsigned options;
|
||||||
pj_status_t status;
|
pj_status_t status;
|
||||||
|
|
||||||
/* If user doesn't specify any codecs, register all of them. */
|
/* If user doesn't specify any codecs, register all of them. */
|
||||||
|
@ -732,12 +732,18 @@ static pj_status_t init_media(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Init options for conference bridge. */
|
||||||
|
options = 0;
|
||||||
|
if (pjsua.no_mic)
|
||||||
|
options |= PJMEDIA_CONF_NO_MIC;
|
||||||
|
|
||||||
/* Init conference bridge. */
|
/* Init conference bridge. */
|
||||||
|
|
||||||
status = pjmedia_conf_create(pjsua.pool,
|
status = pjmedia_conf_create(pjsua.pool,
|
||||||
pjsua.max_calls+PJSUA_CONF_MORE_PORTS,
|
pjsua.max_calls+PJSUA_CONF_MORE_PORTS,
|
||||||
pjsua.clock_rate,
|
pjsua.clock_rate,
|
||||||
pjsua.clock_rate * 20 / 1000, 16,
|
pjsua.clock_rate * 20 / 1000, 16,
|
||||||
|
options,
|
||||||
&pjsua.mconf);
|
&pjsua.mconf);
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
pj_caching_pool_destroy(&pjsua.cp);
|
pj_caching_pool_destroy(&pjsua.cp);
|
||||||
|
|
|
@ -86,6 +86,7 @@ static void usage(void)
|
||||||
puts (" --wb Enable wideband codecs and set clock-rate to 16KHz");
|
puts (" --wb Enable wideband codecs and set clock-rate to 16KHz");
|
||||||
puts (" --uwb Enable ultra-wideband codecs and set clock-rate to 32KHz");
|
puts (" --uwb Enable ultra-wideband codecs and set clock-rate to 32KHz");
|
||||||
puts (" --null-audio Use NULL audio device");
|
puts (" --null-audio Use NULL audio device");
|
||||||
|
puts (" --no-mic Disable microphone device");
|
||||||
puts (" --play-file=file Play WAV file in conference bridge");
|
puts (" --play-file=file Play WAV file in conference bridge");
|
||||||
puts (" --auto-play Automatically play the file (to incoming calls only)");
|
puts (" --auto-play Automatically play the file (to incoming calls only)");
|
||||||
puts (" --auto-loop Automatically loop incoming RTP to outgoing RTP");
|
puts (" --auto-loop Automatically loop incoming RTP to outgoing RTP");
|
||||||
|
@ -217,7 +218,7 @@ pj_status_t pjsua_parse_args(int argc, char *argv[])
|
||||||
int c;
|
int c;
|
||||||
int option_index;
|
int option_index;
|
||||||
enum { OPT_CONFIG_FILE, OPT_LOG_FILE, OPT_LOG_LEVEL, OPT_APP_LOG_LEVEL,
|
enum { OPT_CONFIG_FILE, OPT_LOG_FILE, OPT_LOG_LEVEL, OPT_APP_LOG_LEVEL,
|
||||||
OPT_HELP, OPT_VERSION, OPT_NULL_AUDIO,
|
OPT_HELP, OPT_VERSION, OPT_NULL_AUDIO, OPT_NO_MIC,
|
||||||
OPT_LOCAL_PORT, OPT_PROXY, OPT_OUTBOUND_PROXY, OPT_REGISTRAR,
|
OPT_LOCAL_PORT, OPT_PROXY, OPT_OUTBOUND_PROXY, OPT_REGISTRAR,
|
||||||
OPT_REG_TIMEOUT, OPT_ID, OPT_CONTACT,
|
OPT_REG_TIMEOUT, OPT_ID, OPT_CONTACT,
|
||||||
OPT_REALM, OPT_USERNAME, OPT_PASSWORD,
|
OPT_REALM, OPT_USERNAME, OPT_PASSWORD,
|
||||||
|
@ -240,6 +241,7 @@ pj_status_t pjsua_parse_args(int argc, char *argv[])
|
||||||
{ "wb", 0, 0, OPT_WB},
|
{ "wb", 0, 0, OPT_WB},
|
||||||
{ "uwb", 0, 0, OPT_UWB},
|
{ "uwb", 0, 0, OPT_UWB},
|
||||||
{ "null-audio", 0, 0, OPT_NULL_AUDIO},
|
{ "null-audio", 0, 0, OPT_NULL_AUDIO},
|
||||||
|
{ "no-mic", 0, 0, OPT_NO_MIC},
|
||||||
{ "local-port", 1, 0, OPT_LOCAL_PORT},
|
{ "local-port", 1, 0, OPT_LOCAL_PORT},
|
||||||
{ "proxy", 1, 0, OPT_PROXY},
|
{ "proxy", 1, 0, OPT_PROXY},
|
||||||
{ "outbound", 1, 0, OPT_OUTBOUND_PROXY},
|
{ "outbound", 1, 0, OPT_OUTBOUND_PROXY},
|
||||||
|
@ -343,6 +345,10 @@ pj_status_t pjsua_parse_args(int argc, char *argv[])
|
||||||
pjsua.null_audio = 1;
|
pjsua.null_audio = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OPT_NO_MIC:
|
||||||
|
pjsua.no_mic = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case OPT_WB:
|
case OPT_WB:
|
||||||
pjsua.clock_rate = 16000;
|
pjsua.clock_rate = 16000;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue