Hi Dimitar, You have to be prepared for any parameters in create_stream, the caller can override the defaults you provide. It's likely pjsip is running at 16 kHz and 20 msec frame size, hence the 320 samples per frame. Bill On 4/3/2015 3:19 PM, dpn at switchvoice.com wrote: > Hi Bill, Hi Gents > I have implemented my audio devices as Bill pointed me out. > I even get some scrappy one direction audio already between my analog > phone and a sip client. > In my audio device in tdm_factory_default_param() I set > clock_rate = 8000 > channel_count = 1 > samples_per_frame = 160 > bits_per_sample = 16 > Then in tdm_factory_create_stream() however I get param structure with > samples_per_frame set to 320 instead, > and this value seems not affected by the settings I have in > tdm_factory_default_param(). > How should I set my frame size in pjmedia? > Thanks. > Dimitar > *From:* dpn at switchvoice.com <mailto:dpn at switchvoice.com> > *Sent:* Saturday, March 28, 2015 00:21 > *To:* pjsip at lists.pjsip.org <mailto:pjsip at lists.pjsip.org> > *Subject:* Re: [pjsip] TDM sound device to the pjmedia, how? > Hi Bill, > Thanks, I think I see the global picture now. > Dimitar > *From:* Bill Gardner <mailto:billg at wavearts.com> > *Sent:* Friday, March 27, 2015 21:20 > *To:* pjsip at lists.pjsip.org <mailto:pjsip at lists.pjsip.org> > *Subject:* Re: [pjsip] TDM sound device to the pjmedia, how? > Hi Dimitar, > > pjsip runs all media processing from the audio device callback, so it > is important that the callbacks happen periodically at the frame rate, > typically 10 or 20 msec. pjsip can tolerate some burstiness in the > callbacks, say two reads followed by two writes, but long pauses will > cause big problems. A typical implementation starts a high priority > thread with a loop that polls the hardware device and makes the > callbacks when data is to be transferred. > > Regards, > > Bill > > On 3/27/2015 2:38 PM, dpn at switchvoice.com wrote: >> Hi Bill, >> Thank you for the explanation. >> The only conceptual think I am not clear for my pjsua application now is >> if I can block in my audio device until my hardware has or requires >> audio data. >> Best Regards >> Dimitar >> *From:* Bill Gardner <mailto:billg at wavearts.com> >> *Sent:* Friday, March 27, 2015 15:56 >> *To:* pjsip at lists.pjsip.org <mailto:pjsip at lists.pjsip.org> >> *Subject:* Re: [pjsip] TDM sound device to the pjmedia, how? >> Hi Dimitar, >> >> You want to write a new audiodev following >> pjmedia/include/pjmedia-audiodev/audiodev_imp.h, >> then set up a macro to enable/disable this device, such as >> PJMEDIA_AUDIO_DEV_HAS_TDM, >> and then add the hooks in pjmedia\src\pjmedia-audiodev\audiodev.c so >> pjmedia will use this device, >> and then enable the device in config_site.h and disable the others. >> >> You can then enable/disable the hardware echo cancellation by using >> the pjmedia capability >> PJMEDIA_AUD_DEV_CAP_EC, then pjmedia can use the built-in AEC. >> >> Regards, >> >> Bill >> >> >> >> On 3/27/2015 8:30 AM, dpn at switchvoice.com wrote: >>> Hi All, >>> I?ve ported pjproject-1.16 on an embedded platform based on Mediatek >>> MT 7620 CPU running OpenWRT. >>> (Version 1.16 is rather old but I don?t need video and it seems it >>> covers my needs. ) >>> On this platform there is SLIC chip supporting FXS interface to an >>> analog phone. >>> The SLIC has TDM interface to the CPU and I have completed the TDM >>> driver (running in the Linux kernel space) >>> which works fine with Asterisk. >>> Now I am trying to test pjsua (or some other basic pjsip user agent? >>> ) so I would like to integrate my driver to pjmedia. >>> I?ve checked the very clean pjsip documentation but still I am not >>> fully clear how to approach the project. >>> I think using PortAudio or ALSA will overcomplicate my experiment. >>> My TDM driver expose ioctl interface which I can use from my pjsua >>> application from the user space. >>> I think the best would be to derive the application clock from my >>> tdm driver. >>> As far as I understand I should use ?Sound Device PortFramework? so >>> eventually the application hooks >>> two callbacks rec_cb and play_cb which are called when my TDM driver >>> has frame of data or needs frame of data. >>> I am looking at >>> /pjproject-1.16/pjmedia/src/pjmedia-audiodev/null_dev.c which looks >>> as the simplest starting point I could hack. >>> However sound devices in pjmedia provide lot of stuff which I don?t >>> think I need. >>> For example acoustic echo cancelation. I don?t need that. >>> I rather use line echo canceler in my TDM driver which is more >>> important I think for my softphone example. >>> From the other hand the ?Media Ports Framework? looks much cleaner >>> than ?Sound Device PortFramework?. >>> For example /pjproject-1.16/pjmedia/src/pjmedia/null_port.c looks >>> much simpler than null_dev.c. >>> But as far as understand using this framework the application calls >>> the functions get_frame and put_frame so what I could do >>> is to block the execution of those functions (using linux system >>> call select() for example) >>> and return when I get/send the frame data from/to my driver. This >>> way I will get the timings provided from my driver to the pjsua. >>> However I am not sure how this will fit with the SIP part of my test >>> softphone. >>> Anyone willing to clarify if I am on or fully out of track? Smile >>> Thanks >>> Dimitar >>> >>> >>> _______________________________________________ >>> Visit our blog:http://blog.pjsip.org >>> >>> pjsip mailing list >>> pjsip at lists.pjsip.org >>> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org >> >> ------------------------------------------------------------------------ >> _______________________________________________ >> Visit our blog: http://blog.pjsip.org >> >> pjsip mailing list >> pjsip at lists.pjsip.org >> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org >> >> >> _______________________________________________ >> Visit our blog:http://blog.pjsip.org >> >> pjsip mailing list >> pjsip at lists.pjsip.org >> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org > > ------------------------------------------------------------------------ > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip at lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org > > ------------------------------------------------------------------------ > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip at lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org > > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip at lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20150403/7689b546/attachment.html>