Sending and Receiving Non-RTP Data

This topic explains how to send and receive non-RTP data packets on the RTP and RTCP sockets.

Exchanging non-RTP data on an RTP socket is one of the techniques you can use to implement NAT traversal (maintaining client-to-client network connections through Network Address Translation gateways).

Sending non-RTP data

The RRtpSession::SendDataL() method does not attach the RTP or RTCP header to the data.

// initialise the data 
const TInt KNonRtpBufferMaxLength = 100;
TBuf8<KNonRtpBufferMaxLength> nonRtpData;
nonRtpData.SetLength(KNonRtpBufferMaxLength);
nonRtpData.Fill('Z');
  
TRequestStatus stat;
iServer->rtpSession.SendDataL(ETrue,nonRtpData, stat);
  
User::WaitForRequest(stat);

Receiving non-RTP data

By default, when receiving data identified as non-RTP, the RTP stack discards it.

To receive non-RTP data, you need to register for the ENonRtpDataReceived and ENonRtcpDataReceived events. When you register for one of these events, the RTP stack no longer discards the non-RTP data but does not process the data either. To retrieve the data, call the following functions:

  • NonRtpDataL() provides the non-RTP data received by the RTP socket.

    
    const TDesC8& des = iServer->rtpSession.NonRtpDataL();
    
  • NonRtcpDataL() provides the non-RTP data received by the RTCP socket.

    
    const TDesC8& des = iServer->rtpSession.NonRtcpDataL();
    

To stop receiving non-RTP data, call the DisableNonRtpData() method. The RTP stack cancels your registration to the non-RTP data events and discards the non-RTP packets.