Inband-DTMF detection

MS
Maarten Sander
Wed, Aug 20, 2008 12:43 PM

Hello,

I'm developing a call-center application using PJSIP (actually, mostly
PJSUA) and currently I'm trying to implement an inband-DTMF detector port
(I can't rely on SIP INFO messages).

Right now, I'm using SpanDSP for reading DTMF digits.  However, it doesn't
seem to work (no digits are received).  Has anyone tried to integrate
SpanDSP and PJSIP before?

Currently, I'm feeding the samples as-is to SpanDSP, and I'm relying on
SpanDSP's callback mechanism to receive the digits:

static pj_status_t dtmfdet_put_frame(pjmedia_port *this_port,
const pjmedia_frame frame)
{
struct dtmfdet_port dport = (struct dtmfdet_port) this_port;
dtmf_rx(&dport->state, (const pj_int16_t
) frame->buf,
dport->base.info.samples_per_frame);
return PJ_SUCCESS;
}

static void dtmfdet_digits_rx(void *user_data, const char *digits,
int len)
{
struct dtmfdet_port dport = (struct dtmfdet_port) user_data;
int i;

if (dport->cfg.cb.on_dtmf_digit != NULL) {
  for (i = 0; i < len; i++) {
    dport->cfg.cb.on_dtmf_digit(dport->cfg.call_id, digits[i]);
  }
}

}

Is this the right way to do it?  Should I convert the samples?  I'm
assuming the frame contains linear samples, and as far as I can tell,
SpanDSP expects them to be linear.

Thanks for your help.

Regards,

Maarten

P.S. I've also tried to implement the Goertzel algorithm
(http://en.wikipedia.org/wiki/Goertzel_algorithm) directly, but it didn't
work out, so I thought it would be wise to try integrating SpanDSP first.
Eventually, I'd like to get rid of the SpanDSP dependency, and use Goertzel
directly.

--
Privateer Software Development (www.privateer-software.nl)

  • web usability, web accessibility, web development
  • cross-platform software development
Hello, I'm developing a call-center application using PJSIP (actually, mostly PJSUA) and currently I'm trying to implement an inband-DTMF detector port (I can't rely on SIP INFO messages). Right now, I'm using SpanDSP for reading DTMF digits. However, it doesn't seem to work (no digits are received). Has anyone tried to integrate SpanDSP and PJSIP before? Currently, I'm feeding the samples as-is to SpanDSP, and I'm relying on SpanDSP's callback mechanism to receive the digits: static pj_status_t dtmfdet_put_frame(pjmedia_port *this_port, const pjmedia_frame *frame) { struct dtmfdet_port *dport = (struct dtmfdet_port*) this_port; dtmf_rx(&dport->state, (const pj_int16_t*) frame->buf, dport->base.info.samples_per_frame); return PJ_SUCCESS; } static void dtmfdet_digits_rx(void *user_data, const char *digits, int len) { struct dtmfdet_port *dport = (struct dtmfdet_port*) user_data; int i; if (dport->cfg.cb.on_dtmf_digit != NULL) { for (i = 0; i < len; i++) { dport->cfg.cb.on_dtmf_digit(dport->cfg.call_id, digits[i]); } } } Is this the right way to do it? Should I convert the samples? I'm assuming the frame contains linear samples, and as far as I can tell, SpanDSP expects them to be linear. Thanks for your help. Regards, Maarten P.S. I've also tried to implement the Goertzel algorithm (http://en.wikipedia.org/wiki/Goertzel_algorithm) directly, but it didn't work out, so I thought it would be wise to try integrating SpanDSP first. Eventually, I'd like to get rid of the SpanDSP dependency, and use Goertzel directly. -- Privateer Software Development (www.privateer-software.nl) * web usability, web accessibility, web development * cross-platform software development
SI
Saúl Ibarra
Wed, Aug 20, 2008 3:52 PM

I don' know about integrating pjsip and spandsp, but why don't you use
rfc2833 or sip info? What codec are you using?

--
Saúl -- "Nunca subestimes el ancho de banda de un camión lleno de disketes."

http://www.saghul.net/

I don' know about integrating pjsip and spandsp, but why don't you use rfc2833 or sip info? What codec are you using? -- Saúl -- "Nunca subestimes el ancho de banda de un camión lleno de disketes." ---------------------------------------------------------------- http://www.saghul.net/
BP
Benny Prijono
Wed, Aug 20, 2008 8:35 PM

On Wed, Aug 20, 2008 at 1:43 PM, Maarten Sander
info@privateer-software.nlwrote:

Hello,

I'm developing a call-center application using PJSIP (actually, mostly
PJSUA) and currently I'm trying to implement an inband-DTMF detector port
(I can't rely on SIP INFO messages).

Right now, I'm using SpanDSP for reading DTMF digits.  However, it doesn't
seem to work (no digits are received).  Has anyone tried to integrate
SpanDSP and PJSIP before?

Could you explain exactly what you mean by "doesn't work"?

Currently, I'm feeding the samples as-is to SpanDSP, and I'm relying on
SpanDSP's callback mechanism to receive the digits:

static pj_status_t dtmfdet_put_frame(pjmedia_port *this_port,
const pjmedia_frame frame)
{
struct dtmfdet_port dport = (struct dtmfdet_port) this_port;
dtmf_rx(&dport->state, (const pj_int16_t
) frame->buf,
dport->base.info.samples_per_frame);
return PJ_SUCCESS;
}

Not knowing SpanDSP, that looks fine. But perhaps you'd want to handle the
case where frame->type is not FRAME_TYPE_AUDIO (i.e. just ignore them if
it's not audio).

static void dtmfdet_digits_rx(void *user_data, const char *digits,

                            int len)

{
struct dtmfdet_port dport = (struct dtmfdet_port) user_data;
int i;

if (dport->cfg.cb.on_dtmf_digit != NULL) {
  for (i = 0; i < len; i++) {
    dport->cfg.cb.on_dtmf_digit(dport->cfg.call_id, digits[i]);
  }
}

}

Is this the right way to do it?  Should I convert the samples?  I'm
assuming the frame contains linear samples, and as far as I can tell,
SpanDSP expects them to be linear.

The frame should contain linear samples.

Cheers
Benny

Thanks for your help.

Regards,

Maarten

P.S. I've also tried to implement the Goertzel algorithm
(http://en.wikipedia.org/wiki/Goertzel_algorithm) directly, but it didn't
work out, so I thought it would be wise to try integrating SpanDSP first.
Eventually, I'd like to get rid of the SpanDSP dependency, and use Goertzel
directly.

--
Privateer Software Development (www.privateer-software.nl)

  • web usability, web accessibility, web development
  • cross-platform software development

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

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

On Wed, Aug 20, 2008 at 1:43 PM, Maarten Sander <info@privateer-software.nl>wrote: > Hello, > > I'm developing a call-center application using PJSIP (actually, mostly > PJSUA) and currently I'm trying to implement an inband-DTMF detector port > (I can't rely on SIP INFO messages). > > Right now, I'm using SpanDSP for reading DTMF digits. However, it doesn't > seem to work (no digits are received). Has anyone tried to integrate > SpanDSP and PJSIP before? > > Could you explain exactly what you mean by "doesn't work"? > Currently, I'm feeding the samples as-is to SpanDSP, and I'm relying on > SpanDSP's callback mechanism to receive the digits: > > static pj_status_t dtmfdet_put_frame(pjmedia_port *this_port, > const pjmedia_frame *frame) > { > struct dtmfdet_port *dport = (struct dtmfdet_port*) this_port; > dtmf_rx(&dport->state, (const pj_int16_t*) frame->buf, > dport->base.info.samples_per_frame); > return PJ_SUCCESS; > } > > Not knowing SpanDSP, that looks fine. But perhaps you'd want to handle the case where frame->type is not FRAME_TYPE_AUDIO (i.e. just ignore them if it's not audio). static void dtmfdet_digits_rx(void *user_data, const char *digits, > int len) > { > struct dtmfdet_port *dport = (struct dtmfdet_port*) user_data; > int i; > > if (dport->cfg.cb.on_dtmf_digit != NULL) { > for (i = 0; i < len; i++) { > dport->cfg.cb.on_dtmf_digit(dport->cfg.call_id, digits[i]); > } > } > } > > Is this the right way to do it? Should I convert the samples? I'm > assuming the frame contains linear samples, and as far as I can tell, > SpanDSP expects them to be linear. > > The frame should contain linear samples. Cheers Benny > Thanks for your help. > > Regards, > > Maarten > > P.S. I've also tried to implement the Goertzel algorithm > (http://en.wikipedia.org/wiki/Goertzel_algorithm) directly, but it didn't > work out, so I thought it would be wise to try integrating SpanDSP first. > Eventually, I'd like to get rid of the SpanDSP dependency, and use Goertzel > directly. > > -- > Privateer Software Development (www.privateer-software.nl) > * web usability, web accessibility, web development > * cross-platform software development > > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip@lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org >
MS
Maarten Sander
Thu, Aug 21, 2008 8:23 AM

On Wed, 2008-08-20 at 17:52 +0200, Saúl Ibarra wrote:

I don' know about integrating pjsip and spandsp, but why don't you use
rfc2833 or sip info? What codec are you using?

Locally, I'm using SIP INFO (and it works just fine).  However, my
client told me that in the live environment, SIP INFO and RFC 2833 are
not available.  The application will directly connect to a carrier, and
they won't do DTMF detection for us.

I'll verify if this is really true, but I thought it would be fairly
straightforward to integrate an existing DTMF detector.

I'm using the standard G.711 PCMU codec.

--
Privateer Software Development (www.privateer-software.nl)

  • web usability, web accessibility, web development
  • cross-platform software development
On Wed, 2008-08-20 at 17:52 +0200, Saúl Ibarra wrote: > I don' know about integrating pjsip and spandsp, but why don't you use > rfc2833 or sip info? What codec are you using? Locally, I'm using SIP INFO (and it works just fine). However, my client told me that in the live environment, SIP INFO and RFC 2833 are not available. The application will directly connect to a carrier, and they won't do DTMF detection for us. I'll verify if this is really true, but I thought it would be fairly straightforward to integrate an existing DTMF detector. I'm using the standard G.711 PCMU codec. -- Privateer Software Development (www.privateer-software.nl) * web usability, web accessibility, web development * cross-platform software development
MS
Maarten Sander
Thu, Aug 21, 2008 9:02 AM

On Wed, 20 Aug 2008 21:35:25 +0100, "Benny Prijono" bennylp@pjsip.org
wrote:

Right now, I'm using SpanDSP for reading DTMF digits.  However, it
doesn't
seem to work (no digits are received).  Has anyone tried to integrate
SpanDSP and PJSIP before?

Could you explain exactly what you mean by "doesn't work"?

I'm sorry, I should have been more clear!

When I connect to an Asterisk server, and press the digits on my phone, my
application receives the digits properly using the callback I supplied to
PJSUA.

Now when I disable the callback, and use my own module, nothing happens.
I've verified that dtmfdet_put_frame() is called correctly.  However,
SpanDSP doesn't seem to detect the digits, and the callback function
supplied to SpanDSP (dtmfdet_digits_rx()) is never called.

While typing this, I realized that something else could be happening:
perhaps the DTMF tones generated by my phone aren't in the stream at all.
I've Googled this, and found
http://www.experts-exchange.com/Networking/Telecommunications/IP_Telephony/Asterisk_/Q_23280368.html.

I guess I'll have to record the stream and find out.

Currently, I'm feeding the samples as-is to SpanDSP, and I'm relying on
SpanDSP's callback mechanism to receive the digits:

[snip]

Not knowing SpanDSP, that looks fine. But perhaps you'd want to handle

the

case where frame->type is not FRAME_TYPE_AUDIO (i.e. just ignore them if
it's not audio).

Yes, good point, thanks.

Regards,

Maarten

--
Privateer Software Development (www.privateer-software.nl)

  • web usability, web accessibility, web development
  • cross-platform software development
On Wed, 20 Aug 2008 21:35:25 +0100, "Benny Prijono" <bennylp@pjsip.org> wrote: >> Right now, I'm using SpanDSP for reading DTMF digits. However, it >> doesn't >> seem to work (no digits are received). Has anyone tried to integrate >> SpanDSP and PJSIP before? >> > Could you explain exactly what you mean by "doesn't work"? I'm sorry, I should have been more clear! When I connect to an Asterisk server, and press the digits on my phone, my application receives the digits properly using the callback I supplied to PJSUA. Now when I disable the callback, and use my own module, nothing happens. I've verified that dtmfdet_put_frame() is called correctly. However, SpanDSP doesn't seem to detect the digits, and the callback function supplied to SpanDSP (dtmfdet_digits_rx()) is never called. While typing this, I realized that something else could be happening: perhaps the DTMF tones generated by my phone aren't in the stream at all. I've Googled this, and found http://www.experts-exchange.com/Networking/Telecommunications/IP_Telephony/Asterisk_/Q_23280368.html. I guess I'll have to record the stream and find out. >> Currently, I'm feeding the samples as-is to SpanDSP, and I'm relying on >> SpanDSP's callback mechanism to receive the digits: >> [snip] >> >> > Not knowing SpanDSP, that looks fine. But perhaps you'd want to handle the > case where frame->type is not FRAME_TYPE_AUDIO (i.e. just ignore them if > it's not audio). Yes, good point, thanks. Regards, Maarten -- Privateer Software Development (www.privateer-software.nl) * web usability, web accessibility, web development * cross-platform software development
MS
Maarten Sander
Thu, Aug 21, 2008 12:09 PM

Hi,

While typing this, I realized that something else could be happening:
perhaps the DTMF tones generated by my phone aren't in the stream at all.
I've Googled this, and found
http://www.experts-exchange.com/Networking/Telecommunications/IP_Telephony/Asterisk_/Q_23280368.html.

I guess I'll have to record the stream and find out.

I just recorded it, and indeed, Asterisk seems to filter out the tones
(probably to prevent double detection).

Thanks for your support though, without writing the e-mail to list I
probably wouldn't have thought of this :)

Regards,

Maarten

--
Privateer Software Development (www.privateer-software.nl)

  • web usability, web accessibility, web development
  • cross-platform software development
Hi, > While typing this, I realized that something else could be happening: > perhaps the DTMF tones generated by my phone aren't in the stream at all. > I've Googled this, and found > http://www.experts-exchange.com/Networking/Telecommunications/IP_Telephony/Asterisk_/Q_23280368.html. > > I guess I'll have to record the stream and find out. I just recorded it, and indeed, Asterisk seems to filter out the tones (probably to prevent double detection). Thanks for your support though, without writing the e-mail to list I probably wouldn't have thought of this :) Regards, Maarten -- Privateer Software Development (www.privateer-software.nl) * web usability, web accessibility, web development * cross-platform software development
SI
Saúl Ibarra
Thu, Aug 21, 2008 10:54 PM

Locally, I'm using SIP INFO (and it works just fine).  However, my
client told me that in the live environment, SIP INFO and RFC 2833 are
not available.  The application will directly connect to a carrier, and
they won't do DTMF detection for us.

What do you mean with live environment? At least every sip-thing I
know supports info or rfc2833... And notice you can't use inband whith
compressed codecs...

--
Saúl -- "Nunca subestimes el ancho de banda de un camión lleno de disketes."

http://www.saghul.net/

> Locally, I'm using SIP INFO (and it works just fine). However, my > client told me that in the live environment, SIP INFO and RFC 2833 are > not available. The application will directly connect to a carrier, and > they won't do DTMF detection for us. What do you mean with live environment? At least every sip-thing I know supports info or rfc2833... And notice you can't use inband whith compressed codecs... -- Saúl -- "Nunca subestimes el ancho de banda de un camión lleno de disketes." ---------------------------------------------------------------- http://www.saghul.net/
MS
Maarten Sander
Mon, Sep 8, 2008 1:01 PM

Saúl Ibarra wrote:

Locally, I'm using SIP INFO (and it works just fine).  However, my
client told me that in the live environment, SIP INFO and RFC 2833 are
not available.  The application will directly connect to a carrier, and
they won't do DTMF detection for us.

What do you mean with live environment? At least every sip-thing I
know supports info or rfc2833... And notice you can't use inband whith
compressed codecs...

After your e-mail I asked a few more questions, and it turned out my
client was just making an 'educated guess' and assumed all detections
should be done inband.

Anyway, if someone is interested in an (untested) inband DTMF detector,
just drop me a line.  I've got two versions, one depending on SpanDSP
and one using the algorithm described in my first e-mail.

Sorry for bothering the list about this :)

--
Privateer Software Development (www.privateer-software.nl)

  • web usability, web accessibility, web development
  • cross-platform software development
Saúl Ibarra wrote: >> Locally, I'm using SIP INFO (and it works just fine). However, my >> client told me that in the live environment, SIP INFO and RFC 2833 are >> not available. The application will directly connect to a carrier, and >> they won't do DTMF detection for us. > > What do you mean with live environment? At least every sip-thing I > know supports info or rfc2833... And notice you can't use inband whith > compressed codecs... After your e-mail I asked a few more questions, and it turned out my client was just making an 'educated guess' and assumed all detections should be done inband. Anyway, if someone is interested in an (untested) inband DTMF detector, just drop me a line. I've got two versions, one depending on SpanDSP and one using the algorithm described in my first e-mail. Sorry for bothering the list about this :) -- Privateer Software Development (www.privateer-software.nl) * web usability, web accessibility, web development * cross-platform software development
AR
Archie Rosenblum
Sat, Aug 15, 2009 6:50 PM

Hi,

Does anyone have an in-band DTMF solution for pjsip?  I know this question
has been raised in the past and I am hoping some crackerjack coder has
figured it out and would like to share it with the group.  I've been seeing
more and more DTMF converted to in-band through various voip providers and I
just not savvy enough to understand how to code this detection in pjsip.

Any help is appreciated.

Sincerely,

Archie

Hi, Does anyone have an in-band DTMF solution for pjsip? I know this question has been raised in the past and I am hoping some crackerjack coder has figured it out and would like to share it with the group. I've been seeing more and more DTMF converted to in-band through various voip providers and I just not savvy enough to understand how to code this detection in pjsip. Any help is appreciated. Sincerely, Archie
DC
David Clark
Sat, Aug 15, 2009 11:17 PM

Ok I have not done inband but I have done FFT and they are similar in
terms of approach.  For inband dtmf check out this algorithm.
http://en.wikipedia.org/wiki/Goertzel_algorithm

Now for how to get the audio data from the conference port source to
the detection algorithm.  Do this.
Just a memory capture device and every time you get a packet of audio
data call this dedection function to determine what dtmf's are
present, then you can call your on_dtmf_callback function for a
seemless interface between inband and non-inband calls.

That is the short answer.

At 01:50 PM 8/15/2009, Archie Rosenblum wrote:

Content-Type: multipart/alternative;
boundary="----=_NextPart_000_000B_01CA1DB7.BED967A0"
Content-Language: en-us

Hi,

Does anyone have an in-band DTMF solution for pjsip?  I know this
question has been raised in the past and I am hoping some
crackerjack coder has figured it out and would like to share it with
the group.  I've been seeing more and more DTMF converted to in-band
through various voip providers and I just not savvy enough to
understand how to code this detection in pjsip.

Any help is appreciated.

Sincerely,
Archie


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

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

Ok I have not done inband but I have done FFT and they are similar in terms of approach. For inband dtmf check out this algorithm. http://en.wikipedia.org/wiki/Goertzel_algorithm Now for how to get the audio data from the conference port source to the detection algorithm. Do this. Just a memory capture device and every time you get a packet of audio data call this dedection function to determine what dtmf's are present, then you can call your on_dtmf_callback function for a seemless interface between inband and non-inband calls. That is the short answer. At 01:50 PM 8/15/2009, Archie Rosenblum wrote: >Content-Type: multipart/alternative; > boundary="----=_NextPart_000_000B_01CA1DB7.BED967A0" >Content-Language: en-us > >Hi, > >Does anyone have an in-band DTMF solution for pjsip? I know this >question has been raised in the past and I am hoping some >crackerjack coder has figured it out and would like to share it with >the group. I've been seeing more and more DTMF converted to in-band >through various voip providers and I just not savvy enough to >understand how to code this detection in pjsip. > >Any help is appreciated. > >Sincerely, >Archie >_______________________________________________ >Visit our blog: http://blog.pjsip.org > >pjsip mailing list >pjsip@lists.pjsip.org >http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
AR
Archie Rosenblum
Thu, Aug 20, 2009 12:49 PM

Thank you, David.  I'll take a crack at this at some point ,and if I get it
working, I'll share it with the group.

Take care,
Archie

-----Original Message-----
From: pjsip-bounces@lists.pjsip.org [mailto:pjsip-bounces@lists.pjsip.org]
On Behalf Of David Clark
Sent: Saturday, August 15, 2009 7:18 PM
To: pjsip list; 'pjsip list'
Subject: Re: [pjsip] In-band DTMF detection

Ok I have not done inband but I have done FFT and they are similar in
terms of approach.  For inband dtmf check out this algorithm.
http://en.wikipedia.org/wiki/Goertzel_algorithm

Now for how to get the audio data from the conference port source to
the detection algorithm.  Do this.
Just a memory capture device and every time you get a packet of audio
data call this dedection function to determine what dtmf's are
present, then you can call your on_dtmf_callback function for a
seemless interface between inband and non-inband calls.

That is the short answer.

At 01:50 PM 8/15/2009, Archie Rosenblum wrote:

Content-Type: multipart/alternative;
boundary="----=_NextPart_000_000B_01CA1DB7.BED967A0"
Content-Language: en-us

Hi,

Does anyone have an in-band DTMF solution for pjsip?  I know this
question has been raised in the past and I am hoping some
crackerjack coder has figured it out and would like to share it with
the group.  I've been seeing more and more DTMF converted to in-band
through various voip providers and I just not savvy enough to
understand how to code this detection in pjsip.

Any help is appreciated.

Sincerely,
Archie


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

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


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

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



This email has been scanned by the MxScan Email Security System.


Thank you, David. I'll take a crack at this at some point ,and if I get it working, I'll share it with the group. Take care, Archie -----Original Message----- From: pjsip-bounces@lists.pjsip.org [mailto:pjsip-bounces@lists.pjsip.org] On Behalf Of David Clark Sent: Saturday, August 15, 2009 7:18 PM To: pjsip list; 'pjsip list' Subject: Re: [pjsip] In-band DTMF detection Ok I have not done inband but I have done FFT and they are similar in terms of approach. For inband dtmf check out this algorithm. http://en.wikipedia.org/wiki/Goertzel_algorithm Now for how to get the audio data from the conference port source to the detection algorithm. Do this. Just a memory capture device and every time you get a packet of audio data call this dedection function to determine what dtmf's are present, then you can call your on_dtmf_callback function for a seemless interface between inband and non-inband calls. That is the short answer. At 01:50 PM 8/15/2009, Archie Rosenblum wrote: >Content-Type: multipart/alternative; > boundary="----=_NextPart_000_000B_01CA1DB7.BED967A0" >Content-Language: en-us > >Hi, > >Does anyone have an in-band DTMF solution for pjsip? I know this >question has been raised in the past and I am hoping some >crackerjack coder has figured it out and would like to share it with >the group. I've been seeing more and more DTMF converted to in-band >through various voip providers and I just not savvy enough to >understand how to code this detection in pjsip. > >Any help is appreciated. > >Sincerely, >Archie >_______________________________________________ >Visit our blog: http://blog.pjsip.org > >pjsip mailing list >pjsip@lists.pjsip.org >http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org _______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip@lists.pjsip.org http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org ---------------------------------------------------------------------------- --------- This email has been scanned by the MxScan Email Security System. ---------------------------------------------------------------------------- ---------
AR
Archie Rosenblum
Tue, Sep 15, 2009 3:37 PM

Would someone mind pointing me in the right direction for capturing audio to
a buffer?  I have multiple inbound calls and I would like to check for
in-band DTMF (no rfc2833). What is the API order for setting up PJSIP to get
the audio data?  I just need some framework help -- I have reviewed the
sample files on the web site but I'm having trouble grasping which APIs to
use. I do know how to do play audio files, it's the capturing to a buffer
that has me confused.  I mostly use the PJSUA APIs.

Global


pjsua_pool_create

[Shared pool used for all calls]

Call comes in (for each call do below)


pjmedia_mem_capture_create

[What size buffer should I use? Does it matter?]

[How do I get the call information such clockrate, etc, so I can set this
API to use the same values as the call?  Does it matter? Or should I use the
values in the sample programs?]

pjmedia_mem_capture_set_eof_cb

[How do I connect the call to this media port for so the media port is
"listening" and the callback works]

Call ends


pjmedia_port_destroy

Thank you in advance,

Archie

Would someone mind pointing me in the right direction for capturing audio to a buffer? I have multiple inbound calls and I would like to check for in-band DTMF (no rfc2833). What is the API order for setting up PJSIP to get the audio data? I just need some framework help -- I have reviewed the sample files on the web site but I'm having trouble grasping which APIs to use. I do know how to do play audio files, it's the capturing to a buffer that has me confused. I mostly use the PJSUA APIs. Global --------- pjsua_pool_create [Shared pool used for all calls] Call comes in (for each call do below) ------------- pjmedia_mem_capture_create [What size buffer should I use? Does it matter?] [How do I get the call information such clockrate, etc, so I can set this API to use the same values as the call? Does it matter? Or should I use the values in the sample programs?] pjmedia_mem_capture_set_eof_cb [How do I connect the call to this media port for so the media port is "listening" and the callback works] Call ends ---------- pjmedia_port_destroy Thank you in advance, Archie
DC
David Clark
Fri, Sep 18, 2009 1:43 AM

At 10:37 AM 9/15/2009, Archie Rosenblum wrote:

Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0088_01CA35F8.E071DB00"
Content-Language: en-us

Would someone mind pointing me in the right direction for capturing
audio to a buffer?  I have multiple inbound calls and I would like
to check for in-band DTMF (no rfc2833). What is the API order for
setting up PJSIP to get the audio data?  I just need some framework
help -- I have reviewed the sample files on the web site but I'm
having trouble grasping which APIs to use. I do know how to do play
audio files, it's the capturing to a buffer that has me confused.  I
mostly use the PJSUA APIs.

Global

pjsua_pool_create
[Shared pool used for all calls]

Call comes in (for each call do below)

pjmedia_mem_capture_create
[What size buffer should I use? Does it matter?]

For FFT analysis I used a buffer size of 2000 bytes.  The idea being
the bigger the buffer size the more accurate the result.  The smaller
the buffer the more real time
the data result.

[How do I get the call information such clockrate, etc, so I can set
this API to use the same values as the call?  Does it matter? Or
should I use the values in the sample programs?]

Yes I think it matters.  I use the pjsua_conf_get_port_info()
function to get this data then pass it along.  It looks something like this:
pjsua_conf_get_port_info(sip_data[line].conf_slot, &info);
sip_data[line].cpa_clock_rate=info.clock_rate;
pjmedia_mem_capture_create(sip_data[line].cpa_pool,
sip_data[line].cpa_int_data, CPA_FFT_SIZE,
info.clock_rate, info.channel_count,
info.samples_per_frame, info.bits_per_sample, 0, &sip_data[line].cpa_port);

pjmedia_mem_capture_set_eof_cb

[How do I connect the call to this media port for so the media port
is "listening" and the callback works]

// line_number is supplied by the application to sort out multiple
line implmentation.
pjmedia_mem_capture_set_eof_cb(sip_data[line].cpa_port,
&sip_data[line].line_number, cpa_fft_got_data);

// add the memory capture port to the bridge
pjsua_conf_add_port(sip_data[line].cpa_pool, sip_data[line].cpa_port,
&sip_data[line].cpa_conf_port);

// then connect the conf_slot for the call and the cpa_conf_slot.
pjsua_conf_connect(sip_data[line].conf_slot, sip_data[line].cpa_conf_port);

The callback function will look like this:
pj_status_t cpa_fft_got_data(pjmedia_port *port, void *usr_data)
{

usr_data will contain the line_number passed int.
Then I think you call pjmedia_port_get_frame(port, frame);
and frame->buf I think has your audio data.

Yea I didn't realize until I typed out this message, my code was 

missing that piece.  So
helping you helped me.
}

Call ends

pjmedia_port_destroy

Thank you in advance,
Archie


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

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

At 10:37 AM 9/15/2009, Archie Rosenblum wrote: >Content-Type: multipart/alternative; > boundary="----=_NextPart_000_0088_01CA35F8.E071DB00" >Content-Language: en-us > >Would someone mind pointing me in the right direction for capturing >audio to a buffer? I have multiple inbound calls and I would like >to check for in-band DTMF (no rfc2833). What is the API order for >setting up PJSIP to get the audio data? I just need some framework >help -- I have reviewed the sample files on the web site but I'm >having trouble grasping which APIs to use. I do know how to do play >audio files, it's the capturing to a buffer that has me confused. I >mostly use the PJSUA APIs. > >Global >--------- >pjsua_pool_create >[Shared pool used for all calls] > >Call comes in (for each call do below) >------------- >pjmedia_mem_capture_create >[What size buffer should I use? Does it matter?] For FFT analysis I used a buffer size of 2000 bytes. The idea being the bigger the buffer size the more accurate the result. The smaller the buffer the more real time the data result. >[How do I get the call information such clockrate, etc, so I can set >this API to use the same values as the call? Does it matter? Or >should I use the values in the sample programs?] Yes I think it matters. I use the pjsua_conf_get_port_info() function to get this data then pass it along. It looks something like this: pjsua_conf_get_port_info(sip_data[line].conf_slot, &info); sip_data[line].cpa_clock_rate=info.clock_rate; pjmedia_mem_capture_create(sip_data[line].cpa_pool, sip_data[line].cpa_int_data, CPA_FFT_SIZE, info.clock_rate, info.channel_count, info.samples_per_frame, info.bits_per_sample, 0, &sip_data[line].cpa_port); > >pjmedia_mem_capture_set_eof_cb > >[How do I connect the call to this media port for so the media port >is "listening" and the callback works] // line_number is supplied by the application to sort out multiple line implmentation. pjmedia_mem_capture_set_eof_cb(sip_data[line].cpa_port, &sip_data[line].line_number, cpa_fft_got_data); // add the memory capture port to the bridge pjsua_conf_add_port(sip_data[line].cpa_pool, sip_data[line].cpa_port, &sip_data[line].cpa_conf_port); // then connect the conf_slot for the call and the cpa_conf_slot. pjsua_conf_connect(sip_data[line].conf_slot, sip_data[line].cpa_conf_port); The callback function will look like this: pj_status_t cpa_fft_got_data(pjmedia_port *port, void *usr_data) { usr_data will contain the line_number passed int. Then I think you call pjmedia_port_get_frame(port, frame); and frame->buf I think has your audio data. Yea I didn't realize until I typed out this message, my code was missing that piece. So helping you helped me. } > > >Call ends >---------- >pjmedia_port_destroy > > >Thank you in advance, >Archie > >_______________________________________________ >Visit our blog: http://blog.pjsip.org > >pjsip mailing list >pjsip@lists.pjsip.org >http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
AR
Archie Rosenblum
Tue, Sep 22, 2009 6:07 PM

David,

Thank you for the information!  I appreciate the help.

Take care,

Archie

From: pjsip-bounces@lists.pjsip.org [mailto:pjsip-bounces@lists.pjsip.org]
On Behalf Of David Clark
Sent: Thursday, September 17, 2009 9:43 PM
To: pjsip list; 'pjsip list'
Subject: Re: [pjsip] Capture Call Audio to Buffer

At 10:37 AM 9/15/2009, Archie Rosenblum wrote:

Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0088_01CA35F8.E071DB00"
Content-Language: en-us

Would someone mind pointing me in the right direction for capturing audio to
a buffer?  I have multiple inbound calls and I would like to check for
in-band DTMF (no rfc2833). What is the API order for setting up PJSIP to get
the audio data?  I just need some framework help -- I have reviewed the
sample files on the web site but I'm having trouble grasping which APIs to
use. I do know how to do play audio files, it's the capturing to a buffer
that has me confused.  I mostly use the PJSUA APIs.

Global

pjsua_pool_create
[Shared pool used for all calls]

Call comes in (for each call do below)

pjmedia_mem_capture_create
[What size buffer should I use? Does it matter?]

For FFT analysis I used a buffer size of 2000 bytes.  The idea being the
bigger the buffer size the more accurate the result.  The smaller the buffer
the more real time
the data result.

[How do I get the call information such clockrate, etc, so I can set this
API to use the same values as the call?  Does it matter? Or should I use the
values in the sample programs?]

Yes I think it matters.  I use the pjsua_conf_get_port_info() function to
get this data then pass it along.  It looks something like this:
pjsua_conf_get_port_info(sip_data[line].conf_slot, &info);
sip_data[line].cpa_clock_rate=info.clock_rate;
pjmedia_mem_capture_create(sip_data[line].cpa_pool,
sip_data[line].cpa_int_data, CPA_FFT_SIZE,
info.clock_rate, info.channel_count,
info.samples_per_frame, info.bits_per_sample, 0, &sip_data[line].cpa_port);

pjmedia_mem_capture_set_eof_cb

[How do I connect the call to this media port for so the media port is
"listening" and the callback works]

// line_number is supplied by the application to sort out multiple line
implmentation.
pjmedia_mem_capture_set_eof_cb(sip_data[line].cpa_port,
&sip_data[line].line_number, cpa_fft_got_data);

// add the memory capture port to the bridge
pjsua_conf_add_port(sip_data[line].cpa_pool, sip_data[line].cpa_port,
&sip_data[line].cpa_conf_port);

// then connect the conf_slot for the call and the cpa_conf_slot.
pjsua_conf_connect(sip_data[line].conf_slot, sip_data[line].cpa_conf_port);

The callback function will look like this:
pj_status_t cpa_fft_got_data(pjmedia_port *port, void *usr_data)
{

usr_data will contain the line_number passed int.
Then I think you call pjmedia_port_get_frame(port, frame);
and frame->buf I think has your audio data.

Yea I didn't realize until I typed out this message, my code was missing
that piece.  So
helping you helped me.
}

Call ends

pjmedia_port_destroy

Thank you in advance,
Archie


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

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



This email has been scanned by the MxScan Email Security System.


David, Thank you for the information! I appreciate the help. Take care, Archie From: pjsip-bounces@lists.pjsip.org [mailto:pjsip-bounces@lists.pjsip.org] On Behalf Of David Clark Sent: Thursday, September 17, 2009 9:43 PM To: pjsip list; 'pjsip list' Subject: Re: [pjsip] Capture Call Audio to Buffer At 10:37 AM 9/15/2009, Archie Rosenblum wrote: Content-Type: multipart/alternative; boundary="----=_NextPart_000_0088_01CA35F8.E071DB00" Content-Language: en-us Would someone mind pointing me in the right direction for capturing audio to a buffer? I have multiple inbound calls and I would like to check for in-band DTMF (no rfc2833). What is the API order for setting up PJSIP to get the audio data? I just need some framework help -- I have reviewed the sample files on the web site but I'm having trouble grasping which APIs to use. I do know how to do play audio files, it's the capturing to a buffer that has me confused. I mostly use the PJSUA APIs. Global --------- pjsua_pool_create [Shared pool used for all calls] Call comes in (for each call do below) ------------- pjmedia_mem_capture_create [What size buffer should I use? Does it matter?] For FFT analysis I used a buffer size of 2000 bytes. The idea being the bigger the buffer size the more accurate the result. The smaller the buffer the more real time the data result. [How do I get the call information such clockrate, etc, so I can set this API to use the same values as the call? Does it matter? Or should I use the values in the sample programs?] Yes I think it matters. I use the pjsua_conf_get_port_info() function to get this data then pass it along. It looks something like this: pjsua_conf_get_port_info(sip_data[line].conf_slot, &info); sip_data[line].cpa_clock_rate=info.clock_rate; pjmedia_mem_capture_create(sip_data[line].cpa_pool, sip_data[line].cpa_int_data, CPA_FFT_SIZE, info.clock_rate, info.channel_count, info.samples_per_frame, info.bits_per_sample, 0, &sip_data[line].cpa_port); pjmedia_mem_capture_set_eof_cb [How do I connect the call to this media port for so the media port is "listening" and the callback works] // line_number is supplied by the application to sort out multiple line implmentation. pjmedia_mem_capture_set_eof_cb(sip_data[line].cpa_port, &sip_data[line].line_number, cpa_fft_got_data); // add the memory capture port to the bridge pjsua_conf_add_port(sip_data[line].cpa_pool, sip_data[line].cpa_port, &sip_data[line].cpa_conf_port); // then connect the conf_slot for the call and the cpa_conf_slot. pjsua_conf_connect(sip_data[line].conf_slot, sip_data[line].cpa_conf_port); The callback function will look like this: pj_status_t cpa_fft_got_data(pjmedia_port *port, void *usr_data) { usr_data will contain the line_number passed int. Then I think you call pjmedia_port_get_frame(port, frame); and frame->buf I think has your audio data. Yea I didn't realize until I typed out this message, my code was missing that piece. So helping you helped me. } Call ends ---------- pjmedia_port_destroy Thank you in advance, Archie _______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip@lists.pjsip.org http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org ---------------------------------------------------------------------------- --------- This email has been scanned by the MxScan Email Security System. ---------------------------------------------------------------------------- ---------