Re: Asterisk bridging framework

"Joshua C. Colp" <[email protected]> Wed, 27 Dec 2023 19:51:38 -0400
Newsgroups gmane.comp.telephony.pbx.asterisk.devel
Message-ID <CAM0A2Z3-O86-uxuxZr3C1HNR6PnD4vAcTeMig2VSZj5FV+rjrw@mail.gmail.com>
--===============1914160836956631733==
Content-Type: multipart/alternative; boundary="0000000000008d146a060d867b40"

--0000000000008d146a060d867b40
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Wed, Dec 27, 2023 at 5:23=E2=80=AFPM <[email protected]> wrote:

> A few questions about the native bridging framework:
>
> In contrast to DAHDI conferencing, which still requires manually
> servicing each channel in the conference, in whatever arbitrary threads
> desired, the bridging API is more "event oriented". I have a couple
> questions about the latter:
>
>   * Is there any way to retain control of a channel in a bridge and
>     service it manually, e.g. call ast_waitfor/ast_read on it? It seems
>     when a channel is imparted to a bridge, a thread is always created,
>     with the only difference being you don't need to join it later with
>     AST_BRIDGE_IMPART_CHAN_INDEPENDENT. I'm pretty sure the answer is
>     'no', since that's the entire point of native bridging, but just
>     want to confirm that... (and that the bridging framework requires 1
>     thread per channel)
>

No. Servicing is yielded to the bridge on being put into a bridge. Control
can be temporarily yielded to a different thread using ast_bridge_suspend
and returned to the bridge using ast_bridge_unsuspend while in a bridge.


>   * There are a couple functions for hooking into the bridge, e.g.
>     ast_bridge_dtmf_hook for DTMF events and ast_bridge_interval_hook
>     periodically. I don't see anything more generic than this, though.
>     Say that for certain channels in the bridge I wanted to intercept
>     the voice frames from the bridge and modify them. I suppose you just
>     use framehooks as usual on the channel? I'm guessing there's no
>     difference in behavior, and that ast_bridge_dtmf_hook is purely a
>     convenience function.
>

Framehooks would be used for that purpose. DTMF hooks aren't strictly a
convenience, because they are aware of the threading model of bridging and
can do things within the confines of the bridge without leaving it.


>   * Is there any current way to detect if a channel is muted in a
>     bridge? There's an ast_channel_suppress API, but no API to read the
>     datastore, and I don't see anything else that seems relevant to
>     determining this. Not sure if I've missed something... would code
>     need to be added to do this?
>

There is no explicit API for the bridge level muting to check, but provided
the channel lock was held you could probably grab the ast_bridge_channel
using ast_channel_get_bridge_channel, and then look at the features, and
check mute. If the suppress API method is used instead to mute it and an
API doesn't exist for that, then it would have to be extended.

--=20
Joshua C. Colp
Director of Engineering | Asterisk Project Lead
Sangoma Technologies
Check us out at www.sangoma.com and www.asterisk.org

--0000000000008d146a060d867b40
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr">On Wed, Dec 27, 2023 at 5:23=E2=80=AFPM &=
lt;<a href=3D"mailto:[email protected]">[email protected]</a>&gt;=
 wrote:<br></div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quot=
e" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204)=
;padding-left:1ex">A few questions about the native bridging framework:<br>
<br>
In contrast to DAHDI conferencing, which still requires manually <br>
servicing each channel in the conference, in whatever arbitrary threads <br=
>
desired, the bridging API is more &quot;event oriented&quot;. I have a coup=
le <br>
questions about the latter:<br>
<br>
=C2=A0 * Is there any way to retain control of a channel in a bridge and<br=
>
=C2=A0 =C2=A0 service it manually, e.g. call ast_waitfor/ast_read on it? It=
 seems<br>
=C2=A0 =C2=A0 when a channel is imparted to a bridge, a thread is always cr=
eated,<br>
=C2=A0 =C2=A0 with the only difference being you don&#39;t need to join it =
later with<br>
=C2=A0 =C2=A0 AST_BRIDGE_IMPART_CHAN_INDEPENDENT. I&#39;m pretty sure the a=
nswer is<br>
=C2=A0 =C2=A0 &#39;no&#39;, since that&#39;s the entire point of native bri=
dging, but just<br>
=C2=A0 =C2=A0 want to confirm that... (and that the bridging framework requ=
ires 1<br>
=C2=A0 =C2=A0 thread per channel)<br></blockquote><div><br></div><div>No. S=
ervicing is yielded to the bridge on being put into a bridge. Control can b=
e temporarily yielded to a different thread using ast_bridge_suspend and re=
turned to the bridge using ast_bridge_unsuspend while in a bridge.</div><di=
v>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px=
 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
=C2=A0 * There are a couple functions for hooking into the bridge, e.g.<br>
=C2=A0 =C2=A0 ast_bridge_dtmf_hook for DTMF events and ast_bridge_interval_=
hook<br>
=C2=A0 =C2=A0 periodically. I don&#39;t see anything more generic than this=
, though.<br>
=C2=A0 =C2=A0 Say that for certain channels in the bridge I wanted to inter=
cept<br>
=C2=A0 =C2=A0 the voice frames from the bridge and modify them. I suppose y=
ou just<br>
=C2=A0 =C2=A0 use framehooks as usual on the channel? I&#39;m guessing ther=
e&#39;s no<br>
=C2=A0 =C2=A0 difference in behavior, and that ast_bridge_dtmf_hook is pure=
ly a<br>
=C2=A0 =C2=A0 convenience function.<br></blockquote><div><br></div><div>Fra=
mehooks=C2=A0would be used for that purpose. DTMF hooks aren&#39;t strictly=
 a convenience, because they are aware of the threading model of bridging a=
nd can do things within the confines of the bridge without leaving it.</div=
><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px=
 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
=C2=A0 * Is there any current way to detect if a channel is muted in a<br>
=C2=A0 =C2=A0 bridge? There&#39;s an ast_channel_suppress API, but no API t=
o read the<br>
=C2=A0 =C2=A0 datastore, and I don&#39;t see anything else that seems relev=
ant to<br>
=C2=A0 =C2=A0 determining this. Not sure if I&#39;ve missed something... wo=
uld code<br>
=C2=A0 =C2=A0 need to be added to do this?<br></blockquote><div><br></div><=
div>There is no explicit API for the bridge level muting to check, but prov=
ided the channel lock was held you could probably grab the ast_bridge_chann=
el using ast_channel_get_bridge_channel, and then look at the features, and=
 check mute. If the suppress API method is used instead to mute it and an A=
PI doesn&#39;t exist for that, then it would have to be extended.</div></di=
v><div><br></div><span class=3D"gmail_signature_prefix">-- </span><br><div =
dir=3D"ltr" class=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr=
"><div><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr">=
<div style=3D"font-family:tahoma,sans-serif"><font color=3D"#073763">Joshua=
 C. Colp</font></div><div style=3D"font-family:tahoma,sans-serif"><font col=
or=3D"#073763">Director of Engineering | Asterisk Project Lead</font></div>=
<div style=3D"font-family:tahoma,sans-serif"><font color=3D"#073763">Sangom=
a Technologies</font></div><div style=3D"font-family:tahoma,sans-serif"><fo=
nt color=3D"#073763">Check us out at <a href=3D"http://www.sangoma.com" tar=
get=3D"_blank">www.sangoma.com</a> and <a href=3D"http://www.asterisk.org" =
target=3D"_blank">www.asterisk.org</a></font><br></div></div></div></div></=
div></div></div></div></div></div></div>

--0000000000008d146a060d867b40--


--===============1914160836956631733==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

LS0gCl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f
X19fX19fX19fX19fX19fXwotLSBCYW5kd2lkdGggYW5kIENvbG9jYXRpb24gUHJvdmlkZWQgYnkg
aHR0cDovL3d3dy5hcGktZGlnaXRhbC5jb20gLS0KCmFzdGVyaXNrLWRldiBtYWlsaW5nIGxpc3QK
VG8gVU5TVUJTQ1JJQkUgb3IgdXBkYXRlIG9wdGlvbnMgdmlzaXQ6CiAgIGh0dHA6Ly9saXN0cy5k
aWdpdW0uY29tL21haWxtYW4vbGlzdGluZm8vYXN0ZXJpc2stZGV2

--===============1914160836956631733==--