TTerminal.FilePlaybackTerminal
(1)
TTerminal.MediaStreamTerminal
(1)
TAPIaroundTheWorld
(1)
SelectedModem.GetDefaultStaticTerminal
(1)
ActiveCall.UnselectTerminalOnCall
(1)
ActiveCall.SelectTerminalOnCall
(1)
TapiCallMediaEventArgs
(1)
PlaybackTerminal.MediaPlayList
(1)

Enable SpeakerPhone in TAPI3

Asked By Jeff Faull
04-Feb-10 12:30 PM
I'm working on an alternative and augmentative communication (AAC) program and I'm attempting to add the ability to make and receive voice calls. I am using Julmar's ITapi3 wrapper in C#. I have managed to send and receive calls and send text to speech on demand. My issue is that I am unable to hear the other party.



In my mind the simplest solution would be to enable the speakerphone on the modem (in my case LSI softmodem H50113) but I have been unable to accomplish this. Alternatively I can use another terminal in my application but I have been unable to figure out how to switch terminals.



As an example to create a call:



_activeCall = _selectedModem.CreateCall(_dialNumber, AddressType, MediaType);

_playbackTerminal = _activeCall.RequestTerminal(TTerminal.FilePlaybackTerminal, TAPIMEDIATYPES.AUDIO, TERMINAL_DIRECTION.TD_CAPTURE);

_playbackTerminal.MediaPlayList = new[] { "test.wav" };

_activeCall.SelectTerminalOnCall(_playbackTerminal);

_activeCall.Connect(false);



This works well but if I then create a new terminal with the intention of listening I am unable to switch. The code below gives me the error, "The operation is not supported at this time." when I try to start the terminal.



case TERMINAL_MEDIA_STATE.TMS_IDLE:

_activeCall.UnselectTerminalOnCall(_playbackTerminal);

_playbackTerminal.Dispose();

_listenTerminal = _activeCall.RequestTerminal(TTerminal.MediaStreamTerminal, TAPIMEDIATYPES.AUDIO, TERMINAL_DIRECTION.TD_RENDER);

_activeCall.SelectTerminalOnCall(_listenTerminal);

_listenTerminal.Start();

break;



Any help/ideas appreciated

No sound

Jeff Faull replied to Jeff Faull
05-Feb-10 09:50 AM
After another day of trial and error I think I'm closer however I'm still having problems. I select and can use one terminal for file playback with no problems.



_playbackTerminal = _activeCall.RequestTerminal(TTerminal.FilePlaybackTerminal, TAPIMEDIATYPES.AUDIO, TERMINAL_DIRECTION.TD_CAPTURE);

_playbackTerminal.MediaPlayList = new[] { IdleWav };

_activeCall.SelectTerminalOnCall(_playbackTerminal);



I also select the static terminal for the speakers.



_speakerTerminal = _selectedModem.GetDefaultStaticTerminal(TAPIMEDIATYPES.AUDIO, TERMINAL_DIRECTION.TD_RENDER);

foreach (var stream in _activeCall.Streams.Where(stream => stream.MediaType == TAPIMEDIATYPES.AUDIO).Where(stream => stream.Direction == TERMINAL_DIRECTION.TD_RENDER))

{

stream.SelectTerminal(_speakerTerminal);

}



I keep getting the CME_FAIL event with the following trace:

ITapiTrace Verbose: 0 : Processing TapiCallMediaEventArgs: Event=CME_STREAM_FAIL, Call=TCall: 0 CS_CONNECTED, Cause=CMC_UNKNOWN, Stream=TStream: Wave MSP Render Stream AUDIO TD_RENDER, Terminal=TTerminal Speakers (2- High Definition Au AUDIO TD_RENDER TS_INUSE, Err=JulMar.Tapi3.TapiException (0x80004005): The operation failed - E_FAIL

ITapiTrace Verbose: 0 : TAPIEVENT: 0x10 IDispatch=0x7838C88

ITapiTrace Verbose: 0 : Processing TapiCallMediaEventArgs: Event=CME_STREAM_FAIL, Call=TCall: 0 CS_CONNECTED, Cause=CMC_BAD_DEVICE, Stream=TStream: Wave MSP Render Stream AUDIO TD_RENDER, Terminal=TTerminal Speakers (2- High Definition Au AUDIO TD_RENDER TS_INUSE, Err=JulMar.Tapi3.TapiException (0x80040006): The device is already in use.



I'm assuming this has to do with a half-duplex issue but I'm at a loss for how to fix it.

Jeff,to check whether speakerphone changes do want you wantyou may want to try

Andreas Marschall [exMVP TAPI] replied to Jeff Faull
05-Feb-10 03:57 AM
Jeff,
to check whether speakerphone changes do want you want
you may want to try JulMar's Phone.exe: www.julmar.com/tapi
It is a TAPI2 test tool (incl. open source) that supports TAPI2 line and
phone devices.
The speakerphone stuff can be accessed via the "Phone" button after "Start
Sessioi".

--
Best Regards
Andreas Marschall
Microsoft MVP for TAPI / Windows SDK / Visual C++ 2003-2008
TAPI / TSP Developer and Tester
My TAPI and TSPI FAQ:
http://www.I-B-A-M.de/Andreas_Marschall's_TAPI_and_TSPI_FAQ.htm
My Toto® Tools (a collection of free, mostly TAPI related tools):
http://www.i-b-a-m.de/Andreas_Marschall's_Toto_Tools.htm
TAPI development around the world (Frappr! map):
http://www.frappr.com/TAPIaroundTheWorld
* Please post all messages and replies to the newsgroup so all may
* benefit from the discussion.  Private mail is usually not replied to.
* This posting is provided "AS IS" with no warranties, and confers no
rights.

The operation failed for an unspecified reason.

Jeff Faull replied to Andreas Marschall [exMVP TAPI]
05-Feb-10 10:06 AM
Thanks for the response. I have tried that. If I make a call and hit Speaker under Speakerphone I get a 0x9000001c error which according to MSDN means "The operation failed for an unspecified reason." I'm not sure what, if anything, that tells me.
If I call into Phone.exe it works...sort of
Jeff Faull replied to Jeff Faull
05-Feb-10 10:37 AM
If I call into Phone.exe and answer the call the sound is piped through my speakers even though Handset and Speakerphone show OnHook.
I'd like your opinion
Jeff Faull replied to Andreas Marschall [exMVP TAPI]
05-Feb-10 01:20 PM
I've gotten it working but it feels hacky and results in quite a bit of lag. I can select either the Speakers or the FilePlayback terminals via:

_speakerTerminal = _selectedModem.GetDefaultStaticTerminal(TAPIMEDIATYPES.AUDIO, TERMINAL_DIRECTION.TD_RENDER);

or

_playbackTerminal = _activeCall.RequestTerminal(TTerminal.FilePlaybackTerminal, TAPIMEDIATYPES.AUDIO, TERMINAL_DIRECTION.TD_CAPTURE);

I can only have on selected on the terminal at a time. I'm assuming this is because the modem is half-duplex. I can switch back and forth from listening to talking by unselecting the current terminal and select the other like:

_activeCall.UnselectTerminalOnCall(_playbackTerminal);

_activeCall.SelectTerminalOnCall(_speakerTerminal);

or vice versa but this causes deadtime between each switch. Is this the only way to accomplish this or am I suffering from a conceptual error?
Post Question To EggHeadCafe