G.711 with stereo hardware

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Benny,

 

Well, what I'm trying to do is as follow:

 

1.Get the audio port created by "pjmedia_session_create()"

      status = pjmedia_session_get_port (mediaSession, 0, &mediaPort);

 

2. Open the sound device in full-duplex stereo (stereo is the only way
at moment)

      pjmedia_aud_param audioParam;

      audioParam.dir = PJMEDIA_DIR_ENCODING_DECODING;

      audioParam.rec_id = -1;   // auto select for audio device

      audioParam.play_id = -1;

      audioParam.clock_rate =  mediaPort->info.clock_rate;

      audioParam.channel_count =  2; //mediaPort->info.channel_count;

      audioParam.samples_per_frame = 2*
mediaPort->info.samples_per_frame;

      audioParam.bits_per_sample = mediaPort->info.bits_per_sample;

 

      PJ_LOG(3,(THIS_FILE, "create bidirectional audio ..."));

      status = pjmedia_snd_port_create2(inv->pool, &audioParam,
&soundBidir);

 

3.Create a stereo-to-mono converter, which have the  the G.711 audio
port as downstream

      status = pjmedia_stereo_port_create(inv->pool,

              mediaPort,

              2,

              0,

              &stereoPort);

 

4. Connect the stereo port to the sound device

    status = pjmedia_snd_port_connect(soundBidir, stereoPort);

 

All this is happening in the "on_media_update()" callback.

 

So the data path I think to have is like this:

In the capture direction (for 8kHz, 20 ms audio samples per frame):

1.sound device give a 320 samples / frame (2 channel, 160
samples/channel, 16 bit/sample) 

2.stereo port convert this in 160 samples / frame (1 channel, 160
samples / channel, 16 bit/sample)  and give it to the downstream port.

3.the G.711 encoder convert the pcm  samples (1 channel, 160  samples, 8
bit/sample) and send it to the network

 

Has I could see, the G.711 encoder receives 160 samples / frames without
the "stereo-mono" conversion, but 80 by adding this one -> this
observation started my changes in the stereo_port.

 

Maybe I'm doing all this really wrong L But I'm sure there must be a way
to solve my stereo - mono problem in PJ J

 

Thanks for helping.

 

David

 

From: pjsip-bounces@xxxxxxxxxxxxxxx
[mailto:pjsip-bounces at lists.pjsip.org] On Behalf Of Benny Prijono
Sent: Freitag, 3. Juli 2009 09:46
To: pjsip list
Subject: Re: G.711 with stereo hardware

 

On Thu, Jul 2, 2009 at 2:46 PM, David Andrey
<David.Andrey at netmodule.com> wrote:

	Maybe useful for someone J

	 

	I made the following changes in stereo_port.c:

	 

	static pj_status_t stereo_get_frame(pjmedia_port *this_port,

	                            pjmedia_frame *frame)

	 

	    //tmp_frame.buf = sport->get_buf? sport->get_buf :
frame->buf;    // allocate get buffer for stereo port ???

	    //tmp_frame.size = sport->dn_port->info.bytes_per_frame;

	    if (sport->get_buf)

	    {

	      tmp_frame.buf = sport->get_buf;

	      tmp_frame.size = sport->dn_port->info.bytes_per_frame;

	    }

	    else

	    {

	      tmp_frame.buf = frame->buf;

	      tmp_frame.size = frame->size;
// da, 2009-06-30

	    }

	 

	 

	static pj_status_t stereo_put_frame(pjmedia_port *this_port,

	                            const pjmedia_frame *frame)

	 

	      //tmp_frame.size = sport->dn_port->info.bytes_per_frame;

	      tmp_frame.size = sport->dn_port->info.samples_per_frame
// da, 2009-06-30

	                        * sport->base.info.bits_per_sample / 8;

	 

	Still have memory problems (heap) in relation with the stereo
usage. But stereo <-> G.711 seems ok now.


Sorry I don't understand your patch above. When calling get_frame() or
put_frame(), caller must supply frame size exactly as specified by
port_info.bytes_per_frame of the specified port. I have a felling that
somewhere your code does not do this hence the memory problem.

Also the stereo port was not supposed to support G.711 channel
conversion (i.e. only PCM), if this is what you're trying to do too.

cheers
 Benny

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20090703/da4ae471/attachment.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux