diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-03-08 12:37:22 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-03-08 12:37:22 +0000 |
commit | 2979b937447c7b15352682e44a9f465c08fea112 (patch) | |
tree | a875beed51a49505c841f21ca9df6c0dacda0f65 /pjmedia | |
parent | 21d3fdbca30845ee7f78dc4f641c03747b9cd1c0 (diff) |
Added options to disable microphone device, usefull for streaming server (some systems only have sound player)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@312 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia')
-rw-r--r-- | pjmedia/include/pjmedia/conference.h | 55 | ||||
-rw-r--r-- | pjmedia/src/pjmedia/conference.c | 20 |
2 files changed, 61 insertions, 14 deletions
diff --git a/pjmedia/include/pjmedia/conference.h b/pjmedia/include/pjmedia/conference.h index 3b850cbd..d6500a14 100644 --- a/pjmedia/include/pjmedia/conference.h +++ b/pjmedia/include/pjmedia/conference.h @@ -40,29 +40,68 @@ typedef struct pjmedia_conf pjmedia_conf; */ typedef struct pjmedia_conf_port_info { - unsigned slot; - pj_str_t name; - pjmedia_port_op tx_setting; - pjmedia_port_op rx_setting; - pj_bool_t *listener; - unsigned clock_rate; - unsigned samples_per_frame; + unsigned slot; /**< Slot number. */ + pj_str_t name; /**< Port name. */ + pjmedia_port_op tx_setting; /**< Transmit settings. */ + pjmedia_port_op rx_setting; /**< Receive settings. */ + pj_bool_t *listener; /**< Array of listeners. */ + unsigned clock_rate; /**< Clock rate of the port. */ + unsigned samples_per_frame; /**< Samples per frame */ } 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, unsigned max_slots, unsigned sampling_rate, unsigned samples_per_frame, unsigned bits_per_sample, + unsigned options, pjmedia_conf **p_conf ); /** * Destroy conference bridge. + * + * @param conf The conference bridge. + * + * @return PJ_SUCCESS on success. */ PJ_DECL(pj_status_t) pjmedia_conf_destroy( pjmedia_conf *conf ); diff --git a/pjmedia/src/pjmedia/conference.c b/pjmedia/src/pjmedia/conference.c index 53a2bf4b..09b79312 100644 --- a/pjmedia/src/pjmedia/conference.c +++ b/pjmedia/src/pjmedia/conference.c @@ -127,6 +127,7 @@ struct conf_port */ struct pjmedia_conf { + unsigned options; /**< Bitmask options. */ unsigned max_ports; /**< Maximum ports. */ unsigned port_cnt; /**< Current number of ports. */ 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 samples_per_frame, unsigned bits_per_sample, + unsigned options, pjmedia_conf **p_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*)); PJ_ASSERT_RETURN(conf->ports, PJ_ENOMEM); + conf->options = options; conf->max_ports = max_ports; conf->clock_rate = clock_rate; 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 ) { - /* Open recorder. */ - conf->snd_rec = pj_snd_open_recorder(-1 ,&conf->snd_info, &rec_cb, conf); - if (conf->snd_rec == NULL) { - return -1; + /* Open recorder only if mic is not disabled. */ + if ((conf->options & PJMEDIA_CONF_NO_MIC) == 0) { + conf->snd_rec = pj_snd_open_recorder(-1 ,&conf->snd_info, + &rec_cb, conf); + if (conf->snd_rec == NULL) { + return -1; + } } /* Open player */ conf->snd_player = pj_snd_open_player(-1, &conf->snd_info, &play_cb, conf); 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; } @@ -425,7 +433,7 @@ static pj_status_t resume_sound( pjmedia_conf *conf ) char errmsg[PJ_ERR_MSG_SIZE]; pj_status_t status; - if (conf->snd_rec == NULL) { + if (conf->snd_player == NULL) { status = create_sound(conf); if (status != PJ_SUCCESS) return status; |