Friday, May 4, 2012

[SKYPEKIT][DM368][IPNC] Audio PCM Experiment on DM368-IPNC

The very beginning experiment of porting Skypekit to DM368-IPNC is enabling Audio PCM to test voice conversation. With basic DM368-IPNC developing experience, you shall be able to make it work within few days.

Before starting, please make sure you have scanned Audio PCM Tutorial from Skype Developer Network. (You have to join in and log in first to read the article)

Steps:
1. Prepare Skypekit environment

Skypekit runtime - linux-armv5-skypekit-voicepcm-novideo (version 4.1.2)
Skypekit client - skypekitclient (version 4.1.2), which can be build at directory skypekit-sdk_sdk-4.1.2/interfaces/skype/cpp_embedded

If you have no idea of those, please check the other article for startup [SKYPEKIT][DM368][IPNC] Starting Skypekit on DM368-IPNC - setup environment and build the 1st tutorial example

2. Build reference audio PCMHost loopback

Following Audio PCM Quick Start, you can get PCMHost loopback "voicepcmhost-loopback" and try it with the UI skypekitclient.

3. Modify voicepcmhost-loopback

By tracing voicepcmhost-loopback reference code (precisely, PCMLoopback.cpp), you can see the voice data loopback ( is actually done by Run() method of the class PCMLoopback. The thing we are going to do is quite simple -  get and put the voice data from/to physical device, instead of using loopback_buf.

The audio device we can use is /dev/dsp. According to Skypekit requirement, we need 16bit PCM, and at least 8k sample rate. Thus, the code would be something like:

fd = open("/dev/dsp", O_RDWR);
status = ioctl(fd, SOUND_PCM_WRITE_BITS, &arg);
status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg);

in the if statement "if(output_started)", add something like
write(fd, output_buf.m_data.data(),  output_buf.m_data.size()); // for incoming voice

in the if statement "if(input_started)", add something like
read(fd, input_buf.m_data.data(), input_buf.m_data.size()); // for outgoing voice

4. Kill av_server.out

av_server.out consumes MIC input data (see DRV_audioOpen() @ drv_audio.c) which we shall avoid. To simplify this experiment, we just kill av_server.out.

After all, we can repeat Step 2 to try our new voicepcmhost-loopback, which provides 2-way skype voice communication. Easy work, isn't it?








No comments:

Post a Comment