The problem:
We are using the SipXtapi lib to dial-out to a SIP-to-PSTN gateway. During the setup of the call we're receiving a 183+SDP from the gateway. This enables us to listen to the dial-tone. (the one you usually hear before somebody picks up the phone). This dial tone is generated by the gateway (or somewhere further up in the network). After the 183+SDP we're correctly receiving and sending media. After a few seconds we receive a 180(RINGING) and the media is still being send and received. When the call is answered on the PSTN side we're receiving a 200+SDP. All goes well so far, but imediately after receiving the 200+SDP the SipX library stops sending media to the gateway.
Simplified schematic drawing:
A B
0.0s INVITE
----------------->
0.1s 100(TRYING)
<-----------------
0.1s 183 + SDP
<-----------------
MEDIA
<----------------> //both ways (silence from gw-side)
3.0s 180(RINGING)
<-----------------
MEDIA
<----------------> //both ways (dial tone from gw-side)
200 + SDP
5.0s <-----------------
ACK
5.1s ----------------->
5.1s MEDIA
<----------------- //one way (audio from PSTN)
A = SipX client
B = SIP-to-PSTN gateway
We noticed this behavior when using the PlaceCall sample application.
The analysis:
When the 200 + SDP message is received by the voice client, SipXCallLib executes the method SipConnection::processInviteResponseNormal, then the MpRtpOutputAudioConnection::handleStopSendRtp method is called (from MpCallFlowGraph) to stop the channel that is reproducing the ring tone. And then the method MpRtpOutputAudioConnection::handleStartSendRtp is called in order to start the outgoing audio channel which must send audio to the other endpoint.
The problem is that MpRtpOutputAudioConnection::handleStopSendRtp is adding to the queue a message to deselect codecs and MpRtpOutputAudioConnection::handleStartSendRtp does not put a message in the queue, instead it calls to the handler function directly
The solution:
in file sipXmediaLib\src\mp\MpRtpOutputAudioConnection.cpp in the method handleStartSendRtp delete ln 233 and 234 (written below)
SdpCodec* codecs[] = {pPrimaryCodec, pDtmfCodec};
mpEncode->handleSelectCodecs(sizeof(codecs)/sizeof(SdpCodec*), codecs);
And add a line to enqueue the message to the encoder
mpEncode->selectCodecs(pPrimaryCodec, pDtmfCodec);
PS:
I don't know if these 2.9 is the real version, I've checked out the code from:
http://scm.sipfoundry.org/rep/sipX/branches/sipXtapi/
and in a log from PlaceCall I've found: sipXtapi SDK 2.9.1.0 Rls (built 0000-00-00)
This is the first time I works with SipX so maybe something is wrong on the description of the solution. Please tell me if something is wrong.
It should be better, because it avoids a one frame delay in in selectCodecs/deselectCodecs processing.