Speakerphone

Do you need a registry key to do a specific task? Would you like to customize the way your PocketPC/Smartphone looks and works? This is the right place.

Moderators: Teksoft, admin

Speakerphone

Postby radhoo » Fri Jun 23, 2006 3:14 pm

Here are 2 samples for the article with the Speakerphone. You can read it at:

http://teksoftco.com/forum/viewtopic.php?t=80


The sample for WM2003:
www.teksoftco.com/radu/posts/addon/speakerphone2003.php

The sample for WM2005:
www.teksoftco.com/radu/posts/addon/speakerphone2005.php


Happy testing I know you'll love this,

Radu
radhoo
TEK-Insider
TEK-Insider
 
Posts: 640
Joined: Fri Mar 17, 2006 2:47 am

Postby sasha » Fri Jun 23, 2006 5:50 pm

Fabulous - just one question: in the WM2003 code, do you have an idea how to read the current speaker mode, as in your WM5 code?

Thanks again!

Sasha
sasha
TEK-Newbie
TEK-Newbie
 
Posts: 6
Joined: Sat May 27, 2006 10:15 pm

Postby radhoo » Fri Jun 23, 2006 5:59 pm

Well no because it works like this:

-cprog.exe (good as an example) is making a call. The user goes to speakerphone by pressing the green key. The audio driver only receives the command to go to speakerphone mode (that message i've talked about in the article)

-the user decides to stop the speakerphone, so he presses the green key again. Now the audio driver receives the same message.

-the user keeps the speakerphone on up to the end of his call. then he stops the call with the red key. the call is terminated and so is the speakerphone. The audio driver receives the same message.

As you can see we only have a command which means "switch it". Not even cprog doesnt check is previously the speakerphone was activated, it just sends that message (probably who wrote cprog.exe didnt think someone will do it from another application :lol: they didnt give any docs on this just joking).

So what you can do is to assume that the first thing when a call is established, you wont have the speakerphone on.

Is there a scenario in which you definitively need to know the status of the speakerphone?

Radu
radhoo
TEK-Insider
TEK-Insider
 
Posts: 640
Joined: Fri Mar 17, 2006 2:47 am

Postby sasha » Sat Jun 24, 2006 3:58 am

Thanks!

Not really, just thought that for completness, it would be nice, but as you say, no problems. You guys are amazing!

Sasha
sasha
TEK-Newbie
TEK-Newbie
 
Posts: 6
Joined: Sat May 27, 2006 10:15 pm

additional audio control

Postby qcorporation » Wed Jul 05, 2006 6:45 pm

Hi,
I would like to say great post first of all, controlling the speakerphone was a major issue which I could not get my head around. - Thanks

Was wondering if you were able to decifer other commands from ossvcs.dll? Currently I'm trying to stop audio from going out to the handset audio device on a WM5 CDMA device while in a call. I've tried setting the audio device to NONE via the RIL API calls with no luck (e.g. RIL_GetAudioDevices(...)). I could possibly use waveOut calls but i'm afraid that it might be device specific. Was wondering if there was a general call to control the audio device like the speakerphone toggle call from the ossvcs.dll. Any help would greatly be appreciated.
Thanks in Advance
Q.
qcorporation
TEK-Newbie
TEK-Newbie
 
Posts: 6
Joined: Wed Jul 05, 2006 2:22 pm

Postby radhoo » Wed Jul 05, 2006 8:41 pm

ossvcs.dll doesnt offer such support.

still what you want is possible by means of voice routing.

Radu
radhoo
TEK-Insider
TEK-Insider
 
Posts: 640
Joined: Fri Mar 17, 2006 2:47 am

re: voice routing

Postby qcorporation » Wed Jul 05, 2006 10:13 pm

Hi Radhoo,
When you talk about "voice routing" I'm assuming that you're speaking of using the WaveForm Audio Functions to set the preferred audio device?

Thanks for the quick response
Q.
qcorporation
TEK-Newbie
TEK-Newbie
 
Posts: 6
Joined: Wed Jul 05, 2006 2:22 pm

Postby radhoo » Wed Jul 05, 2006 10:22 pm

When you talk about "voice routing" I'm assuming that you're speaking of using the WaveForm Audio Functions to set the preferred audio device?


Actually not.
Voice routing is used in conjunctions with In-call audio. The audio is routed from sistem->speaker to phone->speaker. There also is routing used for bluetooth headsets.

So this means that if while in a call you re-route the audio to sistem->speaker, the other party in the phone call cant be heard in the speaker ~ muted.

Radu
radhoo
TEK-Insider
TEK-Insider
 
Posts: 640
Joined: Fri Mar 17, 2006 2:47 am

Postby ibm_thinkpad » Thu Jul 06, 2006 10:57 am

Hi,

I think this is the appropriate place to post my question :)

I am programming a client on my smartphone. I receive voice packets on it and am not able to play. I need to receive and send voice packets. How can I play the raw voice packets that I receive?

How can I record what I talk into my phone mic and send it as raw packet?

Would be very helpful if someone could answer..

I am doing it on a Smartphone 2003 device
ibm_thinkpad
TEK-Newbie
TEK-Newbie
 
Posts: 8
Joined: Thu Jul 06, 2006 9:29 am

Postby radhoo » Thu Jul 06, 2006 8:06 pm

hi ibm_thinkpad,

I receive voice packets on it and am not able to play

How are those pachets received? Are you using sockets and TCP/IP?

How can I play the raw voice packets that I receive?

What does the Raw data represent? How do you code the voice? In order for me to tell you how to play the data i need to know what data representation you are using.

How can I record what I talk into my phone mic and send it as raw packet?

At least for this question there is a direct answer: see WAVEIN api functions in order to use the microphone.

I am doing it on a Smartphone 2003 device


2003 is ok for this application. good luck!

Radu
radhoo
TEK-Insider
TEK-Insider
 
Posts: 640
Joined: Fri Mar 17, 2006 2:47 am

Postby ibm_thinkpad » Fri Jul 07, 2006 9:15 pm

Hi Radoo,

Thanks for the fast reply...

Yes, I receive the packets using TCP/IP
The voice is coded using SIP (Session Initiation Protocol)
I have sucessfully initiated the session and also have split the voice data from the packet.

But I dont know how to play the voice data on my phone...

Its wave format for sure but how to play is the question :)

For example...the following is the voice data I have split from the packet


[code]vcdata ="SÛ:yAmv5()Y)ØC
ibm_thinkpad
TEK-Newbie
TEK-Newbie
 
Posts: 8
Joined: Thu Jul 06, 2006 9:29 am

Postby ibm_thinkpad » Fri Jul 07, 2006 9:46 pm

Hi again Radhoo,

I just found out that it is compressed in Truespeech wave format.

Anyway to decompress it and play it? :)
ibm_thinkpad
TEK-Newbie
TEK-Newbie
 
Posts: 8
Joined: Thu Jul 06, 2006 9:29 am

Postby radhoo » Fri Jul 07, 2006 11:55 pm

Hi,

for playing wave files you must use the WAVEOUT set of functions. That would be:

waveOutOpen , waveOutPrepareHeader , waveOutWrite

We might write an article on this later. Until then try reading the docs available online, there are plenty of those!

Cheers,
Radu
radhoo
TEK-Insider
TEK-Insider
 
Posts: 640
Joined: Fri Mar 17, 2006 2:47 am

Postby ibm_thinkpad » Sat Jul 08, 2006 2:21 am

Hi Radoo,

I just finished coding waveout and wavein but what about the compression? How do i decomepress the stream?
ibm_thinkpad
TEK-Newbie
TEK-Newbie
 
Posts: 8
Joined: Thu Jul 06, 2006 9:29 am

Postby radhoo » Sat Jul 08, 2006 12:54 pm

You need to use a codec, or to code your own. Im not familiar with the audio format that you have mentioned.

Regards,
Radu
radhoo
TEK-Insider
TEK-Insider
 
Posts: 640
Joined: Fri Mar 17, 2006 2:47 am

Postby ibm_thinkpad » Sun Jul 09, 2006 3:52 pm

Hi Radhoo,

It is just wave format...

Will you be able to give me a sample code to play the string i had pasted over here?
ibm_thinkpad
TEK-Newbie
TEK-Newbie
 
Posts: 8
Joined: Thu Jul 06, 2006 9:29 am

Postby radhoo » Sun Jul 09, 2006 4:48 pm

Shouldnt be a problem as long as you know the format for the WAVE, like the sample rate (11025,22050..) and the bit depth for the sound representation: 8bits, 16bits...

Radu
radhoo
TEK-Insider
TEK-Insider
 
Posts: 640
Joined: Fri Mar 17, 2006 2:47 am

Postby ibm_thinkpad » Mon Jul 10, 2006 11:02 am

Hi Radhoo,

U can try just one of the formats and check if it plays with your code.
Just give me whichever play.

Thanks in advance
ibm_thinkpad
TEK-Newbie
TEK-Newbie
 
Posts: 8
Joined: Thu Jul 06, 2006 9:29 am

PlayWAV

Postby radhoo » Mon Jul 10, 2006 1:49 pm

Some old code, i didnt have the time to check it properly but should get the job done:
Code: Select all
BYTE *bSave;
WAVEFORMATEX wfe;
HWAVEOUT hWaveOut;
DWORD dwLength;
WAVEHDR whdr1;
void LoadWaveFile(TCHAR *szPath)
{
   FILE        *fp;
   int          len;
   BYTE      data[1024];

   if (fp = _tfopen(szPath,L"rb"))
   {
      fread(data, 4, 1, fp);  // strings are case-sensitive
      fread(&len, 4, 1, fp);
      fread(data, 8, 1, fp);  // note: space is required
      fread(&len, 4, 1, fp);
      fread(&wfe, 18, 1, fp);
      fread(data, 4, 1, fp);
      fread(&dwLength, 4, 1, fp);
      bSave = (BYTE *)malloc(dwLength);
      fread(bSave, dwLength, 1, fp);
      fclose(fp);
   }
}
void PlayWave()
{
   waveOutReset(hWaveOut);
   waveOutUnprepareHeader(hWaveOut , &whdr1 , sizeof(WAVEHDR));
   
   whdr1.lpData = (LPSTR)bSave;
   whdr1.dwBufferLength = dwLength;
   whdr1.dwBytesRecorded = 0;
   whdr1.dwFlags = WHDR_BEGINLOOP | WHDR_ENDLOOP;
   whdr1.dwLoops = 1;
   whdr1.lpNext = NULL;
   whdr1.dwUser = 0;
   whdr1.reserved = 0; 

   //play to speaker
   waveOutOpen(&hWaveOut , WAVE_MAPPER , &wfe ,(DWORD)g_hWnd , 0 , CALLBACK_WINDOW);

   waveOutPrepareHeader(hWaveOut , &whdr1 , sizeof(WAVEHDR));
   waveOutWrite(hWaveOut , &whdr1 , sizeof(WAVEHDR));
//   free(memSave);               
}


Radu
radhoo
TEK-Insider
TEK-Insider
 
Posts: 640
Joined: Fri Mar 17, 2006 2:47 am

Postby ibm_thinkpad » Mon Jul 10, 2006 2:15 pm

Hi Radhoo,

Thanks for the speedy reply.

That code is useful but it is for opening a file. I just have to play the characters in the string that i have.

How do i converts the characters into streams?
ibm_thinkpad
TEK-Newbie
TEK-Newbie
 
Posts: 8
Joined: Thu Jul 06, 2006 9:29 am

Postby radhoo » Mon Jul 10, 2006 2:22 pm

Well... to adapt that code do the following:

Instead of using LoadWaveFile, put your stream data in this structure:

Code: Select all
bSave = (BYTE *)malloc(dwLength);
      fread(bSave, dwLength, 1, fp);
      fclose(fp);
using memcpy.

Then be sure to correctly populate the fields of the WAVEFORMATEX wfe; structure. Here you need to know the sample rate (11025,22050 Hz etc,...) and the bit depth.

Radu
radhoo
TEK-Insider
TEK-Insider
 
Posts: 640
Joined: Fri Mar 17, 2006 2:47 am

Postby ibm_thinkpad » Wed Jul 12, 2006 12:28 pm

Hi Radhoo,

thank you very much for the help...

I tried it and I get jumbled up noises. The sound is actually encoded using Truespeech, so i will need a codec to decode it and then I have to play it :(
ibm_thinkpad
TEK-Newbie
TEK-Newbie
 
Posts: 8
Joined: Thu Jul 06, 2006 9:29 am

Postby radhoo » Wed Jul 12, 2006 2:20 pm

Dont worry, it shouldnt be that hard. Come back with questions when you'll need us.

Radu
radhoo
TEK-Insider
TEK-Insider
 
Posts: 640
Joined: Fri Mar 17, 2006 2:47 am

Postby temp123 » Sun Aug 20, 2006 9:35 pm

Hi Radhoo,

I just want the default phone speakers to be used while I play a media file. It is played on the external loud speakers, but i want that to be played on the default phone speakers. I tried with RIL API to set that. But it fails on Sprint 6700 device. Is there a way to set that media file to be played on the phone speakers. I tried your sample applications. It works great.
Can you help ?

With Regards,
TeMp123
temp123
TEK-Seeker
 
Posts: 37
Joined: Mon Jul 24, 2006 9:21 pm

Postby radhoo » Sun Aug 20, 2006 9:40 pm

You're not the only one with this request. Dozens of programmers doing voip software have raised this question.

The answer to yours for the moment is no. Im sorry, but i hope we can give better news later.

Cheers,
Radu
radhoo
TEK-Insider
TEK-Insider
 
Posts: 640
Joined: Fri Mar 17, 2006 2:47 am

Postby temp123 » Fri Aug 25, 2006 5:30 am

Hi,

Thanks for the reply. In future If i get the answer I will update you.

Thanks,
Wiith Regards,
Temp123
temp123
TEK-Seeker
 
Posts: 37
Joined: Mon Jul 24, 2006 9:21 pm

voice routing

Postby qcorporation » Sun Sep 03, 2006 11:27 pm

Hi Radhoo,
Sorry for dropping off on that conversation earlier about voice routing. I had to put that task on the back-burner to deal with more pressing matters.

Now that I'm revisiting the issue, how would someone be able to route voice properly, or rather what API calls could be used, to allow the earpiece to be "muted" during an active call.

Thanks for the earlier answers, you're site is great!
Q.
qcorporation
TEK-Newbie
TEK-Newbie
 
Posts: 6
Joined: Wed Jul 05, 2006 2:22 pm

Postby radhoo » Mon Sep 04, 2006 11:47 am

how would someone be able to route voice properly, or rather what API calls could be used, to allow the earpiece to be "muted" during an active call.


muting the speaker...

the simple approach is to modify the audio gain. RIL_SetAudioGain. So this would change the volume bar (you can tap on the speaker icon while in a call and you get a single slider instead of the usual 2 sliders). This wont mute the speaker perfectly, it would just lower its volume. again, its all about what you are trying to do.

the not so simple approach is to route the voice from one device to another. so if while in a call you are routing the voice to go from the system's audio to the loudspeaker instead of going from the audio-modem to the 'earpiece' speaker, you're phone speaker will get muted. still, there might be side effects depending on each hardware platform.

The code for routing the voice cant be posted here, as Teksoft sells it as a library.

Cheers,
Radu
radhoo
TEK-Insider
TEK-Insider
 
Posts: 640
Joined: Fri Mar 17, 2006 2:47 am

muting the speaker

Postby qcorporation » Mon Sep 04, 2006 2:16 pm

Hi Radu,

Thanks for the post.
I've tried the SetAudioGain before in the past without any luck.

To give you some background, on CDMA devices there seems to be no official "hold" of an active call. The resident dailler on the device performs a "quasi" hold (i'm guessing here) where it mutes the incoming and outgoing audio streams. This gives a fake impression that the remote party is really on hold. For specific devices i'm able to write to a register to get the muting but this is device specific.
I wanted to mimic that quasi hold state in a general sense in my phone application.

The Audio Gateway seems to do voice routing to the bluetooth headset, i'm wondering if there's any way I'll be able to see how that works and apply it to my specific situation.

Many thanks for the guidance. Wish me luck

Cheers,
Q.
qcorporation
TEK-Newbie
TEK-Newbie
 
Posts: 6
Joined: Wed Jul 05, 2006 2:22 pm

Postby radhoo » Mon Sep 04, 2006 8:16 pm

Hi Q.,

On 2003 devices, the Audio gateway, is in fact a driver loaded by devices.exe at system startup. Some implementations that I've seen have this driver as a file: audiogw.dll in the windows folder.

It is true that you can control the voice routing from there. We have developed our own version of this driver so we can customize its functionality but then we saw that for the voice routing the AudioGW is using the Audio Driver. So using the AudioGW for voice routing is just the longer path for getting to the same result as of working with the Audio Driver directly. I dont say its not good, but keep in mind that this interactions (Controlling the voice routing) are highly dependant on the hardware implementations, and its usually a good idea to keep things as simple as possible (my advise: skip the AudioGW and use the Audio Driver directly).

It would be nice for things to be as simple as wishing you good luck, its just that we've checked those possibilities already and we saw what can and what cannot be done.

Again, if interested, you can contact Teksoft at sales@teksoftco.com for details on the library that controls the voice routing.

Radu
radhoo
TEK-Insider
TEK-Insider
 
Posts: 640
Joined: Fri Mar 17, 2006 2:47 am

Postby temp123 » Tue Nov 07, 2006 7:13 pm

Hi,

I found that in some of the devices using RIL you can activate different sets of speakers. Also in case if one wants to mute the speaker, just change the audio device and the speaker will be muted.

Thanks,
With Regards,
Nirav
temp123
TEK-Seeker
 
Posts: 37
Joined: Mon Jul 24, 2006 9:21 pm

Postby radhoo » Wed Nov 08, 2006 11:04 am

That's correct. One can use "RIL_SetAudioDevices" for the purpose that you have mentioned.
radhoo
TEK-Insider
TEK-Insider
 
Posts: 640
Joined: Fri Mar 17, 2006 2:47 am

Postby temp123 » Wed Mar 21, 2007 6:47 am

Any news about the PPC 6700 speaker issue. Can it be played on Cell speakers rather than loud speakers ?
temp123
TEK-Seeker
 
Posts: 37
Joined: Mon Jul 24, 2006 9:21 pm

Postby admin » Wed Mar 21, 2007 1:32 pm

temp123, there is a similar thread (with source code) here:

http://www.teksoftco.com/forum/viewtopic.php?t=778


Mr. A
admin
Editors
 
Posts: 314
Joined: Sat Mar 04, 2006 3:37 pm

Postby fcch » Sat Jul 28, 2007 9:28 am

radhoo wrote:You're not the only one with this request. Dozens of programmers doing voip software have raised this question.

The answer to yours for the moment is no. Im sorry, but i hope we can give better news later.

Cheers,
Radu



Does anyone have the solution to play the voip sound to the speakerphone?

FCCH
fcch
TEK-Newbie
TEK-Newbie
 
Posts: 6
Joined: Sat Jul 28, 2007 8:21 am

Postby rui luis » Sat Jul 28, 2007 2:23 pm

this all sound very interesting, do you guys can tell me if its possible to build an aplication that when we receive a phone call the ppc answers it with a prerecorded message or music before we pick-up the ppc phone?

thanks
rui luis
TEK-Newbie
TEK-Newbie
 
Posts: 6
Joined: Wed Jul 25, 2007 9:29 pm

Postby radhoo » Tue Sep 04, 2007 10:18 am

rui luis wrote:this all sound very interesting, do you guys can tell me if its possible to build an aplication that when we receive a phone call the ppc answers it with a prerecorded message or music before we pick-up the ppc phone?

thanks

Hello Luis,

Everything that happens before you pickup the phone is handled by the phone operator.

It is barely possible that after the phone connection is established to send some sounds, but indirectly, by using the speaker-microphone acoustic link (bad quality).

Regards,
Radu
radhoo
TEK-Insider
TEK-Insider
 
Posts: 640
Joined: Fri Mar 17, 2006 2:47 am


Return to Developers

Who is online

Users browsing this forum: No registered users and 0 guests