@@ -208,6 +208,96 @@ enum pjmedia_conf_option
208208 based. */
209209};
210210
211+ /**
212+ * This structure specifies the conference bridge creation parameters.
213+ */
214+ typedef struct pjmedia_conf_param
215+ {
216+ /**
217+ * Maximum number of slots/ports to be created in
218+ * the bridge. Note that the bridge internally uses
219+ * one port for the sound device, so the actual
220+ * maximum number of ports will be less one than
221+ * this value.
222+ */
223+ unsigned max_slots ;
224+
225+ /**
226+ * Set the sampling rate of the bridge. This value
227+ * is also used to set the sampling rate of the
228+ * sound device.
229+ */
230+ unsigned sampling_rate ;
231+
232+ /**
233+ * Number of channels in the PCM stream. Normally
234+ * the value will be 1 for mono, but application may
235+ * specify a value of 2 for stereo. Note that all
236+ * ports that will be connected to the bridge MUST
237+ * have the same number of channels as the bridge.
238+ */
239+ unsigned channel_count ;
240+
241+ /**
242+ * Set the number of samples per frame. This value
243+ * is also used to set the sound device.
244+ */
245+ unsigned samples_per_frame ;
246+
247+ /**
248+ * Set the number of bits per sample. This value
249+ * is also used to set the sound device. Currently
250+ * only 16bit per sample is supported.
251+ */
252+ unsigned bits_per_sample ;
253+
254+ /**
255+ * Bitmask options to be set for the bridge. The
256+ * options are constructed from #pjmedia_conf_option
257+ * enumeration.
258+ * The default value is zero.
259+ */
260+ unsigned options ;
261+
262+ /**
263+ * The number of worker threads to use by conference bridge.
264+ * Zero means the operations will be done only by get_frame() thread,
265+ * i.e. conference bridge will be sequential.
266+ * Set this parameter to non-zero value to enable parallel processing.
267+ * The number of worker threads should be less than or equal to the number
268+ * of the processor cores. However, the optimal number of worker threads
269+ * is application and hardware dependent.
270+ * The default value is zero - sequential conference bridge.
271+ * This value is compatible with previous behavior.
272+ * At compile time application developer can change the default value by
273+ * setting #PJMEDIA_CONF_THREADS macro in the config_site.h.
274+ * PJMEDIA_CONF_THREADS is total number of conference bridge threads
275+ * including get_frame() thread. worker_threads is the number of conference
276+ * bridge threads excluding get_frame() thread.
277+ * As a general rule worker_threads is 1 less than PJMEDIA_CONF_THREADS.
278+ * This value is ignored by all conference backends except for the
279+ * multithreaded conference bridge backend
280+ * (PJMEDIA_CONF_PARALLEL_BRIDGE_BACKEND).
281+ *
282+ * The total number of conference bridge threads can be configured at the
283+ * pjsua level using the pjsua_media_config::conf_threads parameter, or at
284+ * the pjsua2 level using the pjsua2::MediaConfig::confThreads parameter.
285+ */
286+ unsigned worker_threads ;
287+ } pjmedia_conf_param ;
288+
289+
290+ /**
291+ * Initialize conference bridge creation parameters.
292+ */
293+ PJ_INLINE (void ) pjmedia_conf_param_default (pjmedia_conf_param * param )
294+ {
295+ pj_bzero (param , sizeof (pjmedia_conf_param ));
296+ /* Set the default values */
297+ #if defined(PJMEDIA_CONF_THREADS ) && PJMEDIA_CONF_THREADS > 1
298+ param -> worker_threads = PJMEDIA_CONF_THREADS - 1 ;
299+ #endif
300+ }
211301
212302/**
213303 * Create conference bridge with the specified parameters. The sampling rate,
@@ -274,6 +364,47 @@ PJ_DECL(pj_status_t) pjmedia_conf_create( pj_pool_t *pool,
274364 unsigned options ,
275365 pjmedia_conf * * p_conf );
276366
367+ /**
368+ * Create conference bridge with the specified parameters. The sampling rate,
369+ * samples per frame, and bits per sample will be used for the internal
370+ * operation of the bridge (e.g. when mixing audio frames). However, ports
371+ * with different configuration may be connected to the bridge. In this case,
372+ * the bridge is able to perform sampling rate conversion, and buffering in
373+ * case the samples per frame is different.
374+ *
375+ * For this version of PJMEDIA, only 16bits per sample is supported.
376+ *
377+ * For this version of PJMEDIA, the channel count of the ports MUST match
378+ * the channel count of the bridge.
379+ *
380+ * Under normal operation (i.e. when PJMEDIA_CONF_NO_DEVICE option is NOT
381+ * specified), the bridge internally create an instance of sound device
382+ * and connect the sound device to port zero of the bridge.
383+ *
384+ * If PJMEDIA_CONF_NO_DEVICE options is specified, no sound device will
385+ * be created in the conference bridge. Application MUST acquire the port
386+ * interface of the bridge by calling #pjmedia_conf_get_master_port(), and
387+ * connect this port interface to a sound device port by calling
388+ * #pjmedia_snd_port_connect(), or to a master port (pjmedia_master_port)
389+ * if application doesn't want to instantiate any sound devices.
390+ *
391+ * The sound device or master port are crucial for the bridge's operation,
392+ * because it provides the bridge with necessary clock to process the audio
393+ * frames periodically. Internally, the bridge runs when get_frame() to
394+ * port zero is called.
395+ *
396+ * @param pool Pool to use to allocate the bridge and
397+ * additional buffers for the sound device.
398+ * @param param The conference bridge creation parameters.
399+ * See #pjmedia_conf_param for more information.
400+ * @param p_conf Pointer to receive the conference bridge instance.
401+ *
402+ * @return PJ_SUCCESS if conference bridge can be created.
403+ */
404+ PJ_DECL (pj_status_t ) pjmedia_conf_create2 (pj_pool_t * pool ,
405+ pjmedia_conf_param * param ,
406+ pjmedia_conf * * p_conf );
407+
277408
278409/**
279410 * Destroy conference bridge. This will also remove any port, thus application
0 commit comments