[asterisk-dev] Volume Control

Murthy Gandikota mgandikota at nts.net
Thu Dec 25 11:53:16 CST 2014


Thank you for your kind comments. I have blown up my connection with ISP every time I tried writing frames using ast_write for the equivalent of echo. I am copying the relevant code fromconference.c  for elucidation. Kindly forgive me for bringing up the App Konference  code here.

// loop over member list and retrieve incoming frames
        for (listentry = conf->listheaders->speakerlistheader.next; listentry != &conf->listheaders->speakerlistheader; listentry = listentry->next)
        {
                ast_conf_member *member = (ast_conf_member *)((char*)listentry - offsetof(ast_conf_member, speakerlistentry));
                member_process_spoken_frames(conf,member,&spoken_frames,
                                             &listener_count, &speaker_count);
        }

        // mix incoming frames and get batch of outgoing frames
        conf_frame *send_frames = spoken_frames ? mix_frames(conf, spoken_frames, speaker_count, listener_count) : NULL;

        // loop over member list and send outgoing frames
        for (listentry = conf->listheaders->memberlistheader.next; listentry != &conf->listheaders->memberlistheader; listentry = listentry->next)
        {
                ast_conf_member *member = (ast_conf_member *)((char*)listentry - offsetof(ast_conf_member, memberlistentry));
        /* ********************************************************this blows up the ISP connection
                  conf_frame * sendFrame=NULL;
                for(sendFrame=send_frames; sendFrame != NULL;sendFrame = send_frames->next) {
                        ast_write(member->chan, sendFrame->fr);
                }
        */
                member_process_outgoing_frames(conf, member);
        }

member_process_outgoing_frames queues the frames to be sent out to the listeners. What I don't understand is why the ISP drops the connection.

Thanks

From: asterisk-dev-bounces at lists.digium.com [mailto:asterisk-dev-bounces at lists.digium.com] On Behalf Of Matthew Jordan
Sent: Wednesday, December 24, 2014 11:30 AM
To: Asterisk Developers Mailing List
Subject: Re: [asterisk-dev] Volume Control



On Wed, Dec 24, 2014 at 1:14 PM, Murthy Gandikota <mgandikota at nts.net<mailto:mgandikota at nts.net>> wrote:
To correct myself, it has nothing to do with hardware. I am using ast_openstream acquire the stream object. I then use ast_write to send a frame on the stream to all the conference members. Meanwhile  another thread is waiting  for events  on the channel (ast_waitfor) and if a spoken frame is sensed, then it is being queued for the conference members. Here is the catch: if I do ast_write(stream, NULL) and speak up on the phone, then I can hear an echo of myself. So it must be possible to do ast_write(stream, frame) and hear an echo, if the talk volume is sufficiently higher than the listen volume?


I have no idea what App Konference is doing with the media mixing that it is performing. ast_write and ast_waitfor have nothing to do with the act of mixing media however - those are merely calls to write media to a channel and to wait for a file descriptor on a channel to be triggered. That actual act of mixing the media would have to be provided by something else.

In bridge_softmix - which is a bridging module for the Bridging Framework that mixes media between n channels - we explicitly remove the source channel from the media that is mixed for it - so you don't hear yourself. But that's an implementation detail of that mixer - other mixers could choose to echo back the audio from the speakers.
Volume, again, is handled by something else completely different from mixing media. In the case of func_volume, an audiohook is used to manipulate the media prior to it being written down into the channel technology. The audiohook itself is invoked via ast_write.

--
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20141225/f4a4e9f5/attachment-0001.html>


More information about the asterisk-dev mailing list