Bridging N calls together

MD
Matteo Dell'Orefice
Fri, Sep 20, 2019 9:28 PM

Hello,

I'm developing a server like program using pjsua. This program will receive N calls, and bridge them together (everyone hears everything). There is no need of capture/playback devices. What is the best way to achive this? I think I should use the conference bridge of pjmedia. Calling pjmedia_conf_connect_port N*N times is not a good idea, so I thought maybe I can create a "mixing" pjmedia_port, add it to the confbridge, then connect all calls' ports to it, and vice versa, the mixing port to all calls' ports. Would it work?

If this is the right idea, what kind of port should I use as mixing port? A master port? In this case, could I just connect everything to port 0 of the bridge (while also disconnecting port 0 from the sound devices)?

Thank you very much,

any suggestion is appreciated.

MD

[http://www.vitrociset.it/images/vitrociset.png]
Matteo Dell'Orefice

Real-Time & Simulation Systems

Engineering & Technologies

Via Tiburtina, 1020 - 00156 Rome - Italy

T +39 06 8820 3106

mailto:s.guetta@vitrociset.itm.dellorefice@vitrociset.itmailto:m.dellorefice@vitrociset.it

mailto:n.cognome@vitrociset.it

http://www.vitrociset.it/

Hello, I'm developing a server like program using pjsua. This program will receive N calls, and bridge them together (everyone hears everything). There is no need of capture/playback devices. What is the best way to achive this? I think I should use the conference bridge of pjmedia. Calling pjmedia_conf_connect_port N*N times is not a good idea, so I thought maybe I can create a "mixing" pjmedia_port, add it to the confbridge, then connect all calls' ports to it, and vice versa, the mixing port to all calls' ports. Would it work? If this is the right idea, what kind of port should I use as mixing port? A master port? In this case, could I just connect everything to port 0 of the bridge (while also disconnecting port 0 from the sound devices)? Thank you very much, any suggestion is appreciated. MD [http://www.vitrociset.it/images/vitrociset.png] Matteo Dell'Orefice Real-Time & Simulation Systems Engineering & Technologies Via Tiburtina, 1020 - 00156 Rome - Italy T +39 06 8820 3106 <mailto:s.guetta@vitrociset.it>m.dellorefice@vitrociset.it<mailto:m.dellorefice@vitrociset.it> <mailto:n.cognome@vitrociset.it> <http://www.vitrociset.it/>
MD
Matteo Dell'Orefice
Wed, Sep 25, 2019 11:42 AM

So, I've had a deeper look at the docs and source of pjmedia confbridge, if I understand correctly the master port is a totally different thing that I don't need.

I started from here: what I need would be a pjmedia_port added in the confbridge which loops frames back. That is, its put_frame() stores in an internal buffer, from which its get_frame() extracts.

To do this, the closest thing I could find is the splitcomb with a reverse channel. If I create a splitcomb with 1 reverse channel, when I put_frame in the reverse channel, the frame gets stored in the channel internal buffer; then, I can retrieve it with a get_frame on the splitcomb. (I think I could also do the other way around, that is put_frame in the splitcomb and retreive it with a get_frame on the reverse channel.)

Of course, I don't what to do it manually, I want the pjsua confbridge to do it. So if every call is connected like this:

conf_connect(call, revchan)

conf_connect(splitcomb, call)

which in my mind is:

pjmedia_port_get_frame(call, &f)

pjmedia_port_put_frame(revchan, &f)

...then...

pjmedia_port_get_frame(splitcomb, &f)

pjmedia_port_put_frame(call, &f)

it should work (?)

The following is pseudo-code describing what I did:

// create splitcomb with 1 channel and a reverse channel

pjmedia_splitcomb_create(pool, ..., &splitcomb)

pjmedia_splitcomb_create_rev_channel(pool, splitcomb, 0, 0, &revchan)

// add the splitcomb port and the reverse channel port to the pjsua confbridge

pjsua_conf_add_port(revchan, &revchan_slot)

pjsua_conf_add_port(splitcomb, &splitcomb_slot)

// then, when I receive a call, in its onCallMediaState callback:

pjsua_conf_connect(call_port_slot, revchan_slot)

pjsua_conf_connect(splitcomb_slot, call_port_slot)

And it kinda works, but the audio quality is low. Is this the right approach? Or am I using the splitcomb/revchannel in a way it is not intended to?

Thank you,

MD

mailto:m.dellorefice@vitrociset.it

mailto:n.cognome@vitrociset.it

http://www.vitrociset.it/


Da: Matteo Dell'Orefice
Inviato: venerdì 20 settembre 2019 23:28
A: pjsip@lists.pjsip.org
Oggetto: Bridging N calls together

Hello,

I'm developing a server like program using pjsua. This program will receive N calls, and bridge them together (everyone hears everything). There is no need of capture/playback devices. What is the best way to achive this? I think I should use the conference bridge of pjmedia. Calling pjmedia_conf_connect_port N*N times is not a good idea, so I thought maybe I can create a "mixing" pjmedia_port, add it to the confbridge, then connect all calls' ports to it, and vice versa, the mixing port to all calls' ports. Would it work?

If this is the right idea, what kind of port should I use as mixing port? A master port? In this case, could I just connect everything to port 0 of the bridge (while also disconnecting port 0 from the sound devices)?

Thank you very much,

any suggestion is appreciated.

MD

mailto:n.cognome@vitrociset.it

http://www.vitrociset.it/

So, I've had a deeper look at the docs and source of pjmedia confbridge, if I understand correctly the master port is a totally different thing that I don't need. I started from here: what I need would be a pjmedia_port added in the confbridge which loops frames back. That is, its put_frame() stores in an internal buffer, from which its get_frame() extracts. To do this, the closest thing I could find is the splitcomb with a reverse channel. If I create a splitcomb with 1 reverse channel, when I put_frame in the reverse channel, the frame gets stored in the channel internal buffer; then, I can retrieve it with a get_frame on the splitcomb. (I think I could also do the other way around, that is put_frame in the splitcomb and retreive it with a get_frame on the reverse channel.) Of course, I don't what to do it manually, I want the pjsua confbridge to do it. So if every call is connected like this: conf_connect(call, revchan) conf_connect(splitcomb, call) which in my mind is: pjmedia_port_get_frame(call, &f) pjmedia_port_put_frame(revchan, &f) ...then... pjmedia_port_get_frame(splitcomb, &f) pjmedia_port_put_frame(call, &f) it should work (?) The following is pseudo-code describing what I did: // create splitcomb with 1 channel and a reverse channel pjmedia_splitcomb_create(pool, ..., &splitcomb) pjmedia_splitcomb_create_rev_channel(pool, splitcomb, 0, 0, &revchan) // add the splitcomb port and the reverse channel port to the pjsua confbridge pjsua_conf_add_port(revchan, &revchan_slot) pjsua_conf_add_port(splitcomb, &splitcomb_slot) // then, when I receive a call, in its onCallMediaState callback: pjsua_conf_connect(call_port_slot, revchan_slot) pjsua_conf_connect(splitcomb_slot, call_port_slot) And it kinda works, but the audio quality is low. Is this the right approach? Or am I using the splitcomb/revchannel in a way it is not intended to? Thank you, MD <mailto:m.dellorefice@vitrociset.it> <mailto:n.cognome@vitrociset.it> <http://www.vitrociset.it/> ________________________________ Da: Matteo Dell'Orefice Inviato: venerdì 20 settembre 2019 23:28 A: pjsip@lists.pjsip.org Oggetto: Bridging N calls together Hello, I'm developing a server like program using pjsua. This program will receive N calls, and bridge them together (everyone hears everything). There is no need of capture/playback devices. What is the best way to achive this? I think I should use the conference bridge of pjmedia. Calling pjmedia_conf_connect_port N*N times is not a good idea, so I thought maybe I can create a "mixing" pjmedia_port, add it to the confbridge, then connect all calls' ports to it, and vice versa, the mixing port to all calls' ports. Would it work? If this is the right idea, what kind of port should I use as mixing port? A master port? In this case, could I just connect everything to port 0 of the bridge (while also disconnecting port 0 from the sound devices)? Thank you very much, any suggestion is appreciated. MD <mailto:n.cognome@vitrociset.it> <http://www.vitrociset.it/>
NI
Nanang Izzuddin
Thu, Sep 26, 2019 6:20 AM

Hi,

IMHO the splitcomb approach should work, though not sure why audio quality
is low. If it happens on low conf participant number (e.g: <=4), perhaps
somehow the splitcomb is not suitable, I guess you should consider to
implement your own pjmedia_port that simply buffers an audio frame.

Also, in case you haven't, null-audio, i.e: pjsua_set_null_snd_dev(),
generally should provide better clock for the conference bridge.

BR,
nanang

On Wed, Sep 25, 2019 at 6:43 PM Matteo Dell'Orefice <
m.dellorefice@vitrociset.it> wrote:

So, I've had a deeper look at the docs and source of pjmedia confbridge,
if I understand correctly the master port is a totally different thing that
I don't need.

I started from here: what I need would be a pjmedia_port added in the
confbridge which loops frames back. That is, its put_frame() stores in an
internal buffer, from which its get_frame() extracts.

To do this, the closest thing I could find is the splitcomb with a reverse
channel. If I create a splitcomb with 1 reverse channel, when I put_frame
in the reverse channel, the frame gets stored in the channel internal
buffer; then, I can retrieve it with a get_frame on the splitcomb. (I think
I could also do the other way around, that is put_frame in the splitcomb
and retreive it with a get_frame on the reverse channel.)

Of course, I don't what to do it manually, I want the pjsua confbridge to
do it. So if every call is connected like this:

conf_connect(call, revchan)

conf_connect(splitcomb, call)

which in my mind is:

pjmedia_port_get_frame(call, &f)

pjmedia_port_put_frame(revchan, &f)

...then...

pjmedia_port_get_frame(splitcomb, &f)

pjmedia_port_put_frame(call, &f)

it should work (?)

The following is pseudo-code describing what I did:

// create splitcomb with 1 channel and a reverse channel

pjmedia_splitcomb_create(pool, ..., &splitcomb)

pjmedia_splitcomb_create_rev_channel(pool, splitcomb, 0, 0, &revchan)

// add the splitcomb port and the reverse channel port to the pjsua
confbridge

pjsua_conf_add_port(revchan, &revchan_slot)

pjsua_conf_add_port(splitcomb, &splitcomb_slot)

// then, when I receive a call, in its onCallMediaState callback:

pjsua_conf_connect(call_port_slot, revchan_slot)

pjsua_conf_connect(splitcomb_slot, call_port_slot)

And it kinda works, but the audio quality is low. Is this the right
approach? Or am I using the splitcomb/revchannel in a way it is not
intended to?

Thank you,

MD


Da: Matteo Dell'Orefice
Inviato: venerdì 20 settembre 2019 23:28
A: pjsip@lists.pjsip.org
Oggetto: Bridging N calls together

Hello,

I'm developing a server like program using pjsua. This program will
receive N calls, and bridge them together (everyone hears everything).
There is no need of capture/playback devices. What is the best way to
achive this? I think I should use the conference bridge of pjmedia.
Calling pjmedia_conf_connect_port N*N times is not a good idea, so I
thought maybe I can create a "mixing" pjmedia_port, add it to the
confbridge, then connect all calls' ports to it, and vice versa, the mixing
port to all calls' ports. Would it work?

If this is the right idea, what kind of port should I use as mixing port?
A master port? In this case, could I just connect everything to port 0 of
the bridge (while also disconnecting port 0 from the sound devices)?

Thank you very much,

any suggestion is appreciated.

MD


Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

Hi, IMHO the splitcomb approach should work, though not sure why audio quality is low. If it happens on low conf participant number (e.g: <=4), perhaps somehow the splitcomb is not suitable, I guess you should consider to implement your own pjmedia_port that simply buffers an audio frame. Also, in case you haven't, null-audio, i.e: pjsua_set_null_snd_dev(), generally should provide better clock for the conference bridge. BR, nanang On Wed, Sep 25, 2019 at 6:43 PM Matteo Dell'Orefice < m.dellorefice@vitrociset.it> wrote: > So, I've had a deeper look at the docs and source of pjmedia confbridge, > if I understand correctly the master port is a totally different thing that > I don't need. > > I started from here: what I need would be a pjmedia_port added in the > confbridge which loops frames back. That is, its put_frame() stores in an > internal buffer, from which its get_frame() extracts. > > > To do this, the closest thing I could find is the splitcomb with a reverse > channel. If I create a splitcomb with 1 reverse channel, when I put_frame > in the reverse channel, the frame gets stored in the channel internal > buffer; then, I can retrieve it with a get_frame on the splitcomb. (I think > I could also do the other way around, that is put_frame in the splitcomb > and retreive it with a get_frame on the reverse channel.) > > Of course, I don't what to do it manually, I want the pjsua confbridge to > do it. So if every call is connected like this: > > > conf_connect(call, revchan) > > conf_connect(splitcomb, call) > > > which in my mind is: > > > pjmedia_port_get_frame(call, &f) > > pjmedia_port_put_frame(revchan, &f) > > ...then... > > pjmedia_port_get_frame(splitcomb, &f) > > pjmedia_port_put_frame(call, &f) > > > it should work (?) > > > The following is pseudo-code describing what I did: > > > // create splitcomb with 1 channel and a reverse channel > > pjmedia_splitcomb_create(pool, ..., &splitcomb) > > pjmedia_splitcomb_create_rev_channel(pool, splitcomb, 0, 0, &revchan) > > > // add the splitcomb port and the reverse channel port to the pjsua > confbridge > > pjsua_conf_add_port(revchan, &revchan_slot) > > pjsua_conf_add_port(splitcomb, &splitcomb_slot) > > > // then, when I receive a call, in its onCallMediaState callback: > > pjsua_conf_connect(call_port_slot, revchan_slot) > > pjsua_conf_connect(splitcomb_slot, call_port_slot) > > > And it kinda works, but the audio quality is low. Is this the right > approach? Or am I using the splitcomb/revchannel in a way it is not > intended to? > > > Thank you, > > MD > * <m.dellorefice@vitrociset.it>* > > > * <n.cognome@vitrociset.it>* > > > * <http://www.vitrociset.it/>* > > > ------------------------------ > *Da:* Matteo Dell'Orefice > *Inviato:* venerdì 20 settembre 2019 23:28 > *A:* pjsip@lists.pjsip.org > *Oggetto:* Bridging N calls together > > > Hello, > > I'm developing a server like program using pjsua. This program will > receive N calls, and bridge them together (everyone hears everything). > There is no need of capture/playback devices. What is the best way to > achive this? I think I should use the conference bridge of pjmedia. > Calling pjmedia_conf_connect_port N*N times is not a good idea, so I > thought maybe I can create a "mixing" pjmedia_port, add it to the > confbridge, then connect all calls' ports to it, and vice versa, the mixing > port to all calls' ports. Would it work? > > > If this is the right idea, what kind of port should I use as mixing port? > A master port? In this case, could I just connect everything to port 0 of > the bridge (while also disconnecting port 0 from the sound devices)? > > > Thank you very much, > > any suggestion is appreciated. > > MD > > > > * <n.cognome@vitrociset.it>* > > > * <http://www.vitrociset.it/>* > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip@lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org >
MD
Matteo Dell'Orefice
Thu, Sep 26, 2019 7:21 AM

I guess you should consider to implement your own pjmedia_port that simply buffers an audio frame.

This is something I'm starting to consider doing.

But actually now I've got another problem, that I had not think of initially: with my solution (or with a custom "loopback" port, it'd be the same) the caller can hear themselves talking, which of course I don't want. I have no clue on how this could be avoided, other than actually doing ~N*N pjsua_conf_connect, which I'm starting to think is not so bad a solution after all...

Thank you for your answer,

MD

mailto:n.cognome@vitrociset.it


Da: pjsip pjsip-bounces@lists.pjsip.org per conto di Nanang Izzuddin nanang@pjsip.org
Inviato: giovedì 26 settembre 2019 08:20
A: pjsip list
Oggetto: Re: [pjsip] Bridging N calls together

Hi,

IMHO the splitcomb approach should work, though not sure why audio quality is low. If it happens on low conf participant number (e.g: <=4), perhaps somehow the splitcomb is not suitable, I guess you should consider to implement your own pjmedia_port that simply buffers an audio frame.

Also, in case you haven't, null-audio, i.e: pjsua_set_null_snd_dev(), generally should provide better clock for the conference bridge.

BR,
nanang

On Wed, Sep 25, 2019 at 6:43 PM Matteo Dell'Orefice <m.dellorefice@vitrociset.itmailto:m.dellorefice@vitrociset.it> wrote:

So, I've had a deeper look at the docs and source of pjmedia confbridge, if I understand correctly the master port is a totally different thing that I don't need.

I started from here: what I need would be a pjmedia_port added in the confbridge which loops frames back. That is, its put_frame() stores in an internal buffer, from which its get_frame() extracts.

To do this, the closest thing I could find is the splitcomb with a reverse channel. If I create a splitcomb with 1 reverse channel, when I put_frame in the reverse channel, the frame gets stored in the channel internal buffer; then, I can retrieve it with a get_frame on the splitcomb. (I think I could also do the other way around, that is put_frame in the splitcomb and retreive it with a get_frame on the reverse channel.)

Of course, I don't what to do it manually, I want the pjsua confbridge to do it. So if every call is connected like this:

conf_connect(call, revchan)

conf_connect(splitcomb, call)

which in my mind is:

pjmedia_port_get_frame(call, &f)

pjmedia_port_put_frame(revchan, &f)

...then...

pjmedia_port_get_frame(splitcomb, &f)

pjmedia_port_put_frame(call, &f)

it should work (?)

The following is pseudo-code describing what I did:

// create splitcomb with 1 channel and a reverse channel

pjmedia_splitcomb_create(pool, ..., &splitcomb)

pjmedia_splitcomb_create_rev_channel(pool, splitcomb, 0, 0, &revchan)

// add the splitcomb port and the reverse channel port to the pjsua confbridge

pjsua_conf_add_port(revchan, &revchan_slot)

pjsua_conf_add_port(splitcomb, &splitcomb_slot)

// then, when I receive a call, in its onCallMediaState callback:

pjsua_conf_connect(call_port_slot, revchan_slot)

pjsua_conf_connect(splitcomb_slot, call_port_slot)

And it kinda works, but the audio quality is low. Is this the right approach? Or am I using the splitcomb/revchannel in a way it is not intended to?

Thank you,

MD

mailto:m.dellorefice@vitrociset.it

mailto:n.cognome@vitrociset.it

http://www.vitrociset.it/


Da: Matteo Dell'Orefice
Inviato: venerdì 20 settembre 2019 23:28
A: pjsip@lists.pjsip.orgmailto:pjsip@lists.pjsip.org
Oggetto: Bridging N calls together

Hello,

I'm developing a server like program using pjsua. This program will receive N calls, and bridge them together (everyone hears everything). There is no need of capture/playback devices. What is the best way to achive this? I think I should use the conference bridge of pjmedia. Calling pjmedia_conf_connect_port N*N times is not a good idea, so I thought maybe I can create a "mixing" pjmedia_port, add it to the confbridge, then connect all calls' ports to it, and vice versa, the mixing port to all calls' ports. Would it work?

If this is the right idea, what kind of port should I use as mixing port? A master port? In this case, could I just connect everything to port 0 of the bridge (while also disconnecting port 0 from the sound devices)?

Thank you very much,

any suggestion is appreciated.

MD

mailto:n.cognome@vitrociset.it

http://www.vitrociset.it/


Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.orgmailto:pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

> I guess you should consider to implement your own pjmedia_port that simply buffers an audio frame. This is something I'm starting to consider doing. But actually now I've got another problem, that I had not think of initially: with my solution (or with a custom "loopback" port, it'd be the same) the caller can hear themselves talking, which of course I don't want. I have no clue on how this could be avoided, other than actually doing ~N*N pjsua_conf_connect, which I'm starting to think is not so bad a solution after all... Thank you for your answer, MD <mailto:n.cognome@vitrociset.it> ________________________________ Da: pjsip <pjsip-bounces@lists.pjsip.org> per conto di Nanang Izzuddin <nanang@pjsip.org> Inviato: giovedì 26 settembre 2019 08:20 A: pjsip list Oggetto: Re: [pjsip] Bridging N calls together Hi, IMHO the splitcomb approach should work, though not sure why audio quality is low. If it happens on low conf participant number (e.g: <=4), perhaps somehow the splitcomb is not suitable, I guess you should consider to implement your own pjmedia_port that simply buffers an audio frame. Also, in case you haven't, null-audio, i.e: pjsua_set_null_snd_dev(), generally should provide better clock for the conference bridge. BR, nanang On Wed, Sep 25, 2019 at 6:43 PM Matteo Dell'Orefice <m.dellorefice@vitrociset.it<mailto:m.dellorefice@vitrociset.it>> wrote: So, I've had a deeper look at the docs and source of pjmedia confbridge, if I understand correctly the master port is a totally different thing that I don't need. I started from here: what I need would be a pjmedia_port added in the confbridge which loops frames back. That is, its put_frame() stores in an internal buffer, from which its get_frame() extracts. To do this, the closest thing I could find is the splitcomb with a reverse channel. If I create a splitcomb with 1 reverse channel, when I put_frame in the reverse channel, the frame gets stored in the channel internal buffer; then, I can retrieve it with a get_frame on the splitcomb. (I think I could also do the other way around, that is put_frame in the splitcomb and retreive it with a get_frame on the reverse channel.) Of course, I don't what to do it manually, I want the pjsua confbridge to do it. So if every call is connected like this: conf_connect(call, revchan) conf_connect(splitcomb, call) which in my mind is: pjmedia_port_get_frame(call, &f) pjmedia_port_put_frame(revchan, &f) ...then... pjmedia_port_get_frame(splitcomb, &f) pjmedia_port_put_frame(call, &f) it should work (?) The following is pseudo-code describing what I did: // create splitcomb with 1 channel and a reverse channel pjmedia_splitcomb_create(pool, ..., &splitcomb) pjmedia_splitcomb_create_rev_channel(pool, splitcomb, 0, 0, &revchan) // add the splitcomb port and the reverse channel port to the pjsua confbridge pjsua_conf_add_port(revchan, &revchan_slot) pjsua_conf_add_port(splitcomb, &splitcomb_slot) // then, when I receive a call, in its onCallMediaState callback: pjsua_conf_connect(call_port_slot, revchan_slot) pjsua_conf_connect(splitcomb_slot, call_port_slot) And it kinda works, but the audio quality is low. Is this the right approach? Or am I using the splitcomb/revchannel in a way it is not intended to? Thank you, MD <mailto:m.dellorefice@vitrociset.it> <mailto:n.cognome@vitrociset.it> <http://www.vitrociset.it/> ________________________________ Da: Matteo Dell'Orefice Inviato: venerdì 20 settembre 2019 23:28 A: pjsip@lists.pjsip.org<mailto:pjsip@lists.pjsip.org> Oggetto: Bridging N calls together Hello, I'm developing a server like program using pjsua. This program will receive N calls, and bridge them together (everyone hears everything). There is no need of capture/playback devices. What is the best way to achive this? I think I should use the conference bridge of pjmedia. Calling pjmedia_conf_connect_port N*N times is not a good idea, so I thought maybe I can create a "mixing" pjmedia_port, add it to the confbridge, then connect all calls' ports to it, and vice versa, the mixing port to all calls' ports. Would it work? If this is the right idea, what kind of port should I use as mixing port? A master port? In this case, could I just connect everything to port 0 of the bridge (while also disconnecting port 0 from the sound devices)? Thank you very much, any suggestion is appreciated. MD <mailto:n.cognome@vitrociset.it> <http://www.vitrociset.it/> _______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip@lists.pjsip.org<mailto:pjsip@lists.pjsip.org> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org