×
Namespaces

Variants
Actions

Symbian RTP/RTCP API

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Code ExampleArticle
Created: ltomuta (17 Jun 2007)
Last edited: hamishwillee (31 May 2013)

Note.pngNote: This API is not part of the public SDK. It can be found in the SDK API Plug-in.

APIPurpose

The Real-time Transport Protocol (or RTP) defines a standardized packet format for delivering audio and video over the Internet. The RTP as such is agnostic to the payload and can be used to transfer any type of data.

Use cases

It was originally designed as a multicast protocol, but has since been applied in many unicast applications. It is frequently used in streaming media systems (in conjunction with RTSP) as well as videoconferencing and push to talk systems (in conjunction with H.323 or SIP), making it the technical foundation of the Voice over IP industry. It goes along with the RTCP and it's built on top of the User Datagram Protocol (UDP). Applications using RTP are less sensitive to packet loss, but typically very sensitive to delays, so UDP is a better choice than TCP for such applications.

Example code

Attached is the example application which sends APS buffer over WLAN using the RTP protocol and establishes a full duplex communication: File:RTPexample.zip

The steps to test this application in full duplex mode are:

  1. Install the application in two devices supporting WLAN.
    Follow the steps below in both the devices.
  2. Call initialize device from the application menu which by default sets the codec to G711. You can also select different codecs before calling initialize device.
  3. Call Establish connection. Choose the WLAN network. It gives the IP address assigned to the devices.
  4. Call SetIPaddress in one device and give the IP of the other and vice versa.
  5. Call start streaming on both phones.

Header Files:

#include <rtpapi.h> 
#include <rtpheader.h>

Link against:

LIBRARY rtpservice.lib

code snippets:

// ----------------------------------------------------------------------------
// CRTPEngine::StartRTPConnection
// Initializes the RTP streams.
// ----------------------------------------------------------------------------
//
void CRTPEngine::StartRTPConnectionL(TUint aAddr)
{
 
iErrorNotify=0;
TUint localPort = 5000;
 
TUint remotePort = 5000;
 
 
TInetAddr addr1;
addr1.SetAddress(aAddr);
addr1.SetPort(remotePort);
iRtpSession = CRtpAPI::NewL(*this);
 
iParam.iCName.Set(KName);
iParam.iUserName.Set(KName);
iParam.iEmail.Set(KName);
iParam.iPhoneNumber.Set(KName);
iParam.iLocation.Set(KName);
iParam.iSwToolName.Set(KName);
iParam.iNoticeStatus.Set(KName);
iParam.iPrivate.Set(KName);
 
TInetAddr localAddr;
localAddr.SetPort(localPort);
 
// Open RTP session
TInt error = iRtpSession->OpenL( iParam, NULL,
&iSocketServer,&iConnection);
 
 
iTimeStamp = 1;
 
// Create new RTP session
TCreateSessionParams sessionParam = TCreateSessionParams();
sessionParam.iPriority = TCreateSessionParams::EPriorityStandard;
 
iRtpId = iRtpSession->CreateSessionL( sessionParam, localPort, EFalse,
NULL );
 
 
// Set remote address
TInt err1 = iRtpSession->SetRemoteAddress(iRtpId, addr1 );
 
// Register for RTP callback
err1 = iRtpSession->RegisterRtpObserver(iRtpId, *this);
 
TRcvStreamParams aRcvParams;
 
// Create RTP receive stream
iReceivedStreamId = iRtpSession->CreateReceiveStreamL(iRtpId,RcvParams);
 
 
// Start RTP send stream
TTranStreamParams aTransmitParams;
aTransmitParams.iPayloadType = NULL;
 
iTransmitStreamId = iRtpSession->CreateTransmitStreamL(iRtpId,
aTransmitParams, iSsrcId);
 
iSendHeader = TRtpSendHeader();
 
// Start RTP session
err1 = iRtpSession->StartSession(iRtpId);
 
}
// ----------------------------------------------------------------------------
// CRTPEngine::RtpPacketReceived
// Receives the incoming RTP packets and sends it to the queue handler.
// ----------------------------------------------------------------------------
//
void CRTPEngine::RtpPacketReceived( TRtpId aStreamId,
 
const TRtpRecvHeader & aHeaderInfo, const TDesC8 & aPayloadData )
{
 
iAPSObserver.PacketReceived(aPayloadData);
 
}


// ----------------------------------------------------------------------------
// CRTPEngine::SendRtpPacketL
// Sends the RTP packets to the remote destination
// ----------------------------------------------------------------------------
//
void CRTPEngine::SendRtpPacketL(TDesC8& aBuffer)
{
 
iTimeStamp = iTimeStamp + 160;
 
iSendHeader.iTimestamp = iTimeStamp;
 
TInt error = iRtpSession->SendRtpPacket(iTransmitStreamId, iSendHeader,
aBuffer);
}
This page was last modified on 31 May 2013, at 02:34.
107 page views in the last 30 days.
×