epoc32/include/mw/rtp.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/rtp.h@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef RTP_H
    17 #define RTP_H
    18 
    19 #include <es_sock.h>
    20  
    21 class TRtpEvent;
    22 class RRtpSession;
    23 class RRtpSendPacket;
    24 class RRtpReceivePacket;
    25 class RRtpReceiveSource;
    26 class RRtpSendSource;
    27 class RRtpHeaderExtension;
    28 class RRtpCSRCs;
    29 class CRtpSession;
    30 class CRtpReceiveSource;
    31 class CRtpSendSource;
    32 class TRtpPacket;
    33 
    34 class RRtcpRRPart;
    35 class RRtcpSRPart;
    36 
    37 /**
    38 @publishedAll
    39 @released
    40 
    41 A set of values that defines the event types that may be handled.
    42 
    43 See all variants of the RegisterEventCallbackL() function. 
    44 
    45 @see TRtpEvent
    46 */
    47 enum TRtpEventType
    48 	{
    49 	/** 
    50 	A special event type that is interpreted by all of
    51 	the RegisterEventCallbackL() set of functions to mean that the registered
    52 	callback function is to be called for any event except failure events.
    53     */
    54 	ERtpAnyEvent = 0,
    55 	
    56 	
    57     /**
    58     Defines a base value for session events.
    59    
    60     All session event types have values that are greater than this.
    61     */
    62 	ERtpSessionEventBase = 0x100,
    63 	
    64 	
    65 	/**
    66 	An event type that indicates that a session-level error has occurred.
    67 	
    68 	The event status is a standard Symbian OS error code.
    69 	The callback parameter is used to register interest in only one 
    70 	type of error.
    71 	*/
    72 	ERtpSessionFail      = 0x101, 
    73 	
    74 	
    75 	/**
    76     An event type that indicates that a new stream has been received.
    77 	
    78 	The event status is the	SSRC of the stream.
    79 	*/
    80 	ERtpNewSource        = 0x102,
    81 	
    82 	
    83 	/**
    84 	An event type that indicates that an RTCP RR (Receiver Report) has been
    85 	received.
    86 	
    87 	The event status is the SSRC of the sender.
    88 
    89 	Note - This event type has not been implemented yet.
    90 	*/
    91 	ERtpNewRR            = 0x103,
    92 	
    93 	
    94 	/**
    95 	An event type that indicates that a packet bigger than the expected maximum
    96 	has been received.
    97 	
    98 	When this event occurs, the packet is deleted.
    99 	*/
   100 	ERtpBufferOverflow   = 0x104,
   101 	
   102 	
   103 	/**
   104 	An event type that indicates that a packet has been recived that
   105 	is smaller than its header.
   106 	
   107 	When this event occurs, the packet is deleted.
   108 	*/
   109 	ERtpUndersizedPacket = 0x105,
   110  
   111  	
   112 	/**
   113 	Not an event type, but defines the upper limit for session event
   114 	type values.
   115     */
   116 	ERtpSessionEventEnd  = 0x1ff,
   117 
   118 
   119     /**
   120     Not an event type but defines a base value for send stream events.
   121    
   122     All send stream event types have values that are greater than this.
   123     */
   124 	ERtpSendEventBase    = 0x200,
   125 
   126 
   127 	/**
   128 	An event type that indicates that an error has occurred while sending
   129 	a packet.
   130 	
   131 	The event status is a standard Symbian OS error code. The callback parameter
   132 	is used only to register interest in one type of error.
   133 	*/
   134 	ERtpSendFail         = 0x201, 
   135 	
   136 	
   137 	/**
   138 	An event type that indicates that a send packet operation has succeeded.
   139 	*/
   140 	ERtpSendSucceeded    = 0x202,
   141 	
   142 	
   143 	/**
   144 	Not an event type, but defines the upper limit for send stream event 
   145 	type values.
   146 	*/
   147 	ERtpSendEventEnd     = 0x2ff,
   148 
   149 
   150     /**
   151     Not an event type but defines a base value for receive stream events.
   152    
   153     All receive stream event types have values that are greater than this.
   154     */
   155 	ERtpSourceEventBase  = 0x300,
   156 	
   157 	
   158 	/**
   159 	An event type that indicates that an error has occurred.
   160 	
   161     The event status is a standard Symbian OS error code. The callback parameter
   162     is used only to register interest in one type of error.
   163     */
   164 	ERtpSourceFail       = 0x301,
   165 	
   166 	
   167 	/**
   168 	An event type that indicates that an in-sequence packet has been received.
   169 	*/
   170 	ERtpPacketReceived   = 0x302,
   171 	
   172 	
   173 	/**
   174 	An event type that indicates that the  codec has changed.
   175 	
   176 	The event status is the new payload type.
   177 	*/
   178 	ERtpCodecChange      = 0x303,
   179 	
   180 	
   181 	/**
   182 	An event type that indicates that a marker packet has arrived.
   183 	*/
   184 	ERtpMarker           = 0x304,
   185 	
   186 	
   187 	/**
   188 	An event type that indicates that a misordered packet has arrived.
   189 	*/
   190 	ERtpMisorder         = 0x305,
   191 	
   192 	
   193 	/**
   194 	An event type that indicates that a dropout has been detected.
   195 	*/
   196 	ERtpDropout          = 0x306,
   197 	
   198 	
   199 	/**
   200 	An event type that indicates that a SDES (Source Description) RTCP packet
   201 	has been received.
   202 	
   203 	For SDES events, the callback parameter is used to specify the type of 
   204 	SDES. Use a value from TRtpSendPacketType
   205 	
   206 	The event status is the SSRC of the sender.
   207 
   208 	@see RRtpSession::TRtpSendPacketType
   209 	*/
   210 	ERtpSDES             = 0x307, 
   211 
   212 
   213 	/**
   214 	An event type that indicates that a APP (Application Defined) RTCP packet
   215 	has been received.
   216 	
   217 	The event status is the SSRC of the sender.
   218 
   219 	*/
   220 	ERtpAPP              = 0x308,
   221 	
   222 	
   223 	/**
   224 	An event type that indicates that a SR (Sender Report) RTCP packet
   225 	has been received.
   226 
   227 	The event status is the SSRC of the sender.
   228 	
   229 	*/
   230 	ERtpSR               = 0x309,
   231 	
   232 	
   233 	/**
   234 	An event type that indicates that a RR (Receiver Report) RTCP packet
   235 	has been received.
   236 
   237 	The event status is the SSRC of the sender.
   238 	*/
   239 	ERtpRR               = 0x30a,
   240 
   241 
   242 	/**
   243 	An event type that indicates that a BYE (Goodbye) RTCP packet
   244 	has been received.
   245 
   246 	The event status is the SSRC of the sender.
   247 	*/
   248 	ERtpBYE              = 0x30b,
   249 
   250 	
   251 	/**
   252 	Not an event type, but defines the upper limit for receive stream event 
   253 	type values.
   254 	*/
   255 	ERtpSourceEventEnd   = 0x3ff
   256 	};
   257 
   258 
   259 /**
   260 @publishedAll
   261 @released
   262 
   263 Indicates whether a callback function can be called once, or more than once.
   264 
   265 The appropriate enum value is passed as an argument to the
   266 RegisterEventCallbackL() functions of RRtpSession, RRtpSendSource,
   267 and RRtpReceiveSource, or to the equivalent static functions.
   268 
   269 @see RRtpSession
   270 @see RRtpSendSource
   271 @see RRtpReceiveSource
   272 */
   273 enum TRtpOneShotness 
   274 	{
   275 	/**
   276 	Indicates that the call back function can be called more than once.
   277 	*/
   278 	ERtpNotOneShot = 0,
   279 
   280 	
   281 	/**
   282 	Indicates that the call back function is only called once.
   283 	*/
   284 	ERtpOneShot = 0x40000000
   285 	};
   286 
   287 
   288 
   289 
   290 /**
   291 @publishedAll
   292 */
   293 typedef void (*TRtpCallbackFunction)(TAny* aPtr, const TRtpEvent& aEvent);
   294 
   295 
   296 
   297 /**
   298 @internalComponent
   299 */
   300 const TInt KRtpNoParameter = KRequestPending;
   301 
   302 
   303 //Needed for recv-only option for RTP or RTCP
   304 //This must map to TRtpType
   305 enum TPacketType
   306 	{	
   307 	EPacketRtp,	
   308 	EPacketRtcp
   309 	};
   310 
   311 
   312 
   313 
   314 /**
   315 @publishedAll
   316 @released
   317 
   318 A value that can be passed as the second parameter in a call to either
   319 RRtpSendSource::NewSendPacketL() or RRtpSendSource::NewSendPacketLC()
   320 to indicate that no exension is required for the RTP send packet.
   321 */
   322 const TInt KRtpNoExtension = -1;
   323 
   324 
   325 
   326 /**
   327 @publishedAll
   328 @released
   329 
   330 A handle to an RTP session.
   331 
   332 This is the interface to the socket-level RTP service, and provides additional
   333 facilities such as header parsing, re-ordering out-of-order packets,
   334 demultiplexing multiple sources etc.
   335 
   336 The class abstracts all RTP information going to/from a RTP socket, and its
   337 corresponding RTCP data.
   338 
   339 Each RTP endpoint on a device needs its own RTP session.
   340 
   341 Multiple hosts streaming to a port on this device correspond
   342 to different RRtpReceiveSource objects associated with the session.
   343 
   344 The class behaviour assumes that an active scheduler has already been created
   345 and started; the class does not function correctly if not.
   346 */
   347 class RRtpSession
   348 	{
   349  public:
   350     /**
   351     A set of bit values passed as a parameter to RRtpSession::SendRTCPPacketL()
   352     to specify the SDES (Source Description) items that are to be sent with
   353     the packet. One or more of these may be set.
   354     
   355     @see RRtpSession::SendRTCPPacketL()
   356 	*/
   357 	enum TRtpSendPacketType
   358 		{
   359         /**
   360         Canonical End-Point Identifier SDES Item.
   361         */
   362 		ERtcpPacketCNAME = 1, 
   363 		
   364 		/**
   365         User Name SDES Item.
   366 	    */
   367 		ERtcpPacketNAME  = 2, 
   368 		
   369 	    /**
   370         Electronic Mail Address SDES Item.
   371 	    */
   372 		ERtcpPacketEMAIL = 4, 
   373 		
   374         /**
   375 	    Phone Number SDES Item.
   376 	    */		
   377 		ERtcpPacketPHONE = 8, 
   378 		
   379 		/**
   380 	    Geographic User Location SDES Item.
   381 	    */
   382 		ERtcpPacketLOC   = 16,
   383 		
   384 		/**
   385         Application or Tool Name SDES Item 
   386 	    */
   387 		ERtcpPacketTOOL  = 32,
   388 		
   389 		/**
   390 	    Notice/Status SDES Item 
   391 	    */
   392 		ERtcpPacketNOTE  = 64,
   393 		
   394 		/**
   395 	    Private Extensions SDES Item 
   396 	    */
   397 		ERtcpPacketPRIV  = 128
   398 		};
   399 
   400 	inline RRtpSession();
   401 	inline TBool IsOpen() const;
   402 
   403 	IMPORT_C void OpenL(RSocketServ& aServer, TSockAddr& aLocalAddr,
   404 						TSockAddr& aRemoteAddr,
   405 						TInt aMaxRXSize, RConnection& aConnection, TInt aPriority = EPriorityNormal, 
   406 						const TDesC8& aCNAME = KNullDesC8);
   407 
   408 	
   409 	IMPORT_C void OpenL(RSocketServ& aServer, TSockAddr& aLocalAddr,
   410 						TSockAddr& aRemoteAddr,
   411 						TInt aMaxRXSize, TInt aPriority = EPriorityNormal, 
   412 						const TDesC8& aCNAME = KNullDesC8);
   413 
   414     /**
   415 	@publishedPartner
   416 	@released
   417    	
   418     Opens the session and initialises it.
   419 
   420     No events will be generated until after control returns to the
   421     active scheduler. The client has this time to initialise the
   422     object by adding event callbacks.
   423 
   424     @param aSocket     The connected socket.
   425     @param aMaxRXSize  The maximum size of a received packet.
   426     @param aRtcpSocket The RTCP socket.
   427     @param aPriority   The priority to be used for internal active objects
   428     @param aCNAME      The CNAME. A sensible default is supplied if none is
   429                        provided.
   430     */
   431 	IMPORT_C void OpenL(RSocket& aSocket, TInt aMaxRXSize, 
   432 						RSocket& aRtcpSocket,
   433 						TInt aPriority = EPriorityNormal, 
   434 						const TDesC8& aCNAME = KNullDesC8);
   435 
   436 	IMPORT_C void OpenL(RSocket& aSocket, TInt aMaxRXSize,
   437 						TInt aPriority = EPriorityNormal);
   438 
   439 	IMPORT_C void Close();
   440 
   441 	IMPORT_C void SetMaxRXSize(TInt aMaxRXSize);
   442 
   443 	IMPORT_C TInt MaxRXSize();
   444     
   445     
   446     /** 
   447 	@publishedPartner
   448 	@released
   449 	
   450     Sets the estimated bandwidth used by the session.
   451     
   452     This is used to decide when to send RTCP status packets.
   453     The default	value is read from a resource file and should be a reasonably
   454 	sensible default based on the maximum bandwidth of the handset.
   455 	
   456 	@param aBandwidth The bandwidth in bps.
   457     */
   458 	IMPORT_C void SetBandwidth(TUint aBandwidth);
   459 
   460 
   461     /**
   462 	@publishedPartner
   463 	@released
   464    	
   465    	Supplies information about the profile-specific RTP
   466     timestamps. 
   467     
   468     This is used to generate the RTP timestamps in RTCP packets.
   469     It is not used to generate timestamps in RTP packets as they must
   470     accurately relate to the time of the sample.
   471    	
   472    	@param aNow        The time now in RTP format
   473 	@param aConversion The number of nanoseconds per RTP timer tick.
   474     */
   475 	IMPORT_C void SetRTPTimeConversion(TUint aNow, TUint aConversion);
   476 	IMPORT_C RRtpReceiveSource NewReceiveSourceL();
   477 	IMPORT_C RRtpReceiveSource NewReceiveSourceLC();
   478 
   479     /**
   480     Registers a callback for the specified event.
   481 
   482 	Some compilers may not support templated member functions. A static version
   483 	of this function is available that offers the same behaviour:
   484     RegisterEventCallbackL(RRtpSession,TRtpEventType,void (*aCallback)(T*, const TRtpEvent&),T*,TRtpOneShotness,TInt)
   485 
   486     @param aType      The type of event.
   487     @param aCallback  The callback function. The function is templated, and is
   488                       prototyped to take a pointer to an object of the template
   489                       type and a const reference to a TRtpEvent. The function
   490                       returns void.
   491 	@param aPtr       A pointer that is passed to the callback function when
   492 	                  that function is called.
   493 	@param aOneShot   Indicates whether the callback function is only
   494 	                  called once, or can be called more than once.
   495 	@param aParameter A parameter to be passed to the registration function.
   496 	                  The meaning of this depends entirely on the event type.
   497 	                  The parameter is optional - the other overload of this
   498 	                  function is available for registrations that don't need
   499                       to pass a parameter.                      
   500 	*/
   501 	template <class T> inline void 
   502 		RegisterEventCallbackL(TRtpEventType aType, 
   503 							   void (*aCallback)(T*, const TRtpEvent&), 
   504 							   T* aPtr, 
   505 							   TRtpOneShotness aOneShot,
   506 							   TInt aParameter)
   507 			{
   508 			PrivRegisterEventCallbackL(
   509 				aType|aOneShot, 
   510 				reinterpret_cast<TRtpCallbackFunction>(aCallback),
   511 				static_cast<TAny*>(aPtr), aParameter);
   512 			}
   513 
   514     /**
   515     Registers a callback for the specified event.
   516 
   517 	Some compilers may not support templated member functions. A static version
   518 	of this function is available that offers the same behaviour:
   519 	RegisterEventCallbackL(RRtpSession,TRtpEventType,void (*aCallback)(T*, const TRtpEvent&),T*,TRtpOneShotness)
   520 
   521     @param aType      The type of event.
   522     @param aCallback  The callback function. The function is templated, and is
   523                       prototyped to take a pointer to an object of the template
   524                       type and a const reference to a TRtpEvent. The function
   525                       returns void.
   526 	@param aPtr       A pointer that is passed to the callback function when
   527 	                  that function is called.
   528 	@param aOneShot   Indicates whether the callback function is only
   529 	                  called once, or can be called more than once. If not
   530 	                  specified, the default is to allow the callback function
   531 	                  to be called more than once.
   532 	*/
   533 	template <class T> inline void 
   534 		RegisterEventCallbackL(TRtpEventType aType, 
   535 							   void (*aCallback)(T*, const TRtpEvent&), 
   536 							   T* aPtr, 
   537 							   TRtpOneShotness aOneShot = ERtpNotOneShot)
   538 			{
   539 			PrivRegisterEventCallbackL(
   540 				aType|aOneShot, 
   541 				reinterpret_cast<TRtpCallbackFunction>(aCallback),
   542 				static_cast<TAny*>(aPtr));
   543 			}
   544 
   545 
   546 	/**
   547 	@publishedPartner
   548 	@released
   549 	
   550 	Gets an array contining the most recent RR (Receiver Report) from
   551 	all hosts who are reporting on our send stream.
   552 	
   553 	@return The array of RRs.
   554 	*/
   555 	IMPORT_C RRtcpRRPart GetRRs();
   556 
   557 
   558 	/**
   559 	@publishedPartner
   560 	@released
   561 	
   562 	Gets the data associated with the specified RTCP SDES (Source Description)
   563 	item.
   564 
   565 	Note a that the PRIV (Private Extensions) SDES item is not supported
   566 	by this mechanism.
   567 	
   568 	@param aType  The value identifying the RTCP SDES item.
   569 	
   570 	@param aValue A descriptor reference to the SDES item data. 
   571 	
   572 	@return KErrNotFound if the item type was not found in the most recent RTCP packet
   573 			KErrNone if the operation is successful
   574 	*/
   575 	IMPORT_C TInt GetSDES(const TInt aType, TDes8& aValue);
   576 
   577 	
   578 	/**
   579 	@publishedPartner
   580 	@released
   581 	
   582 	Sets the data associated with the specified RTCP SDES (Source Description)
   583 	item for sending in the next SDES packet only.
   584 
   585 	The function Leaves if duplicate values are set for the same CNAME.
   586 	
   587 	Note a that the PRIV (Private Extensions) SDES item is not supported
   588 	by this mechanism.
   589 	
   590 	NOTE - This call cannot be used to set a different CNAME for this session.
   591 	The default CNAME is send with every SDES packets.
   592 	
   593 	@param aType  The value identfying the RTCP SDES item.
   594 	@param aValue The SDES item data.
   595 
   596 	@return KErrTooBig if the length of the aValue is more than KMaxSdesItemLength(=255)
   597 			KErrNone if the operation is successful
   598 	*/
   599 	IMPORT_C TInt SetSDESL(TInt aType, const TDesC8& aValue);
   600 
   601 	/**
   602 	@publishedPartner
   603 	@released
   604 	
   605 	Sets the data associated with the PRIV (Private Extensions) SDES item.
   606 	
   607 	@param aPrefix The value identfying the RTCP SDES item.
   608 	@param aValue The SDES item data.
   609 
   610   	@return KErrTooBig if the length of the aValue and aPrefix combined is more 
   611 	                   than KMaxSdesItemLength(=255)
   612 			KErrNone if the operation is successful
   613 	*/
   614 	IMPORT_C TInt SetPRIVL(const TDesC8& aPrefix, const TDesC8& aValue);
   615 
   616     
   617 	/**
   618 	@publishedPartner
   619 	@released
   620 	Sends an APP (Application Defined) RTCP Packet.
   621 	
   622 	The packet is sent immediately.
   623 	
   624 	If used with RTCP auto-send, the function disrupts the auto-send
   625 	intervals. Note however that Symbian reserves the right to fix this.
   626 	
   627 	@param aApp A handle to a RTCP APP (Application Defined) packet,
   628 	            for experimental extensions to RTCP.
   629 	*/
   630 	IMPORT_C void SendAPPL(const TDesC8& aName, const TDesC8& aAppData = KNullDesC8, TUint8 aSubType = 0);
   631 
   632 
   633 	/**
   634 	@publishedPartner
   635 	@released
   636 	
   637 	Enables or disables the automatic sending of RTCP SR (Sender Report),
   638 	RR (Receiver Report), and SDES (Source Description) packets.
   639 	
   640 	Note that if automatic sending is not enabled and RTCP sending is required,
   641 	then explicit calls to SendRTCPPacketL() will be required.
   642 	
   643 	@param aAutoSend ETrue, if RTCP packets need to be send automatically
   644 	                 EFalse otherwise.
   645 	
   646 	@see RRtpSession::SendRTCPPacketL()
   647 	*/
   648 	IMPORT_C void SetRTCPAutoSend(TBool aAutoSend);
   649 
   650 
   651 	/** 
   652 	@publishedPartner
   653 	@released
   654 	
   655 	Gets the RTCP Auto Send status. 
   656 
   657 	@return True, if RTCP SR, RR and SDES packets are automatically sent,
   658 	        false otherwise
   659 	
   660 	@see RRtpSession::SetRTCPAutoSend()
   661 	*/
   662 	IMPORT_C TBool RTCPAutoSend() const;
   663 
   664 	/** 
   665 	@publishedPartner
   666 	@released
   667 	
   668 	Sets the RTCP Auto Send interval.
   669 	This disables the RFC based calculation of RTCP intervals.
   670 	To re-enable auto calculation, set the interval to zero.
   671 
   672   	@param aInterval Time interval after which an RTCP auto-send will take place
   673 	*/
   674 	IMPORT_C void SetRtcpInterval(TTimeIntervalMicroSeconds32& aInterval);
   675 	
   676 	/** 
   677 	@publishedPartner
   678 	@released	
   679 	Enables Receive only option for rtp or rtcp
   680 
   681 	@param aRtpOrRtcp Takes the values from the enum TPacketType
   682 
   683 	@see RRtpSession::DontReceive()
   684 	*/
   685 	IMPORT_C void DontReceive(TInt aRtpOrRtcp);
   686 	
   687 	/** 
   688 	@publishedPartner
   689 	@released
   690     Sends an RTCP packet now. 
   691 
   692 	Calling this function doesn't make much sense if auto-send is
   693 	on, as it will result in packets being sent at rather
   694 	incoherent intervals.
   695 
   696 	@param aPacketType  Zero or more of the bit values defined by
   697 	                    the TRtpSendPacketType enum. The packet sent will
   698 	                    contain a SR (Sender Report) or RR (Receiver Report),
   699 	                    depending on whether any packets have actually been
   700 	                    sent, together with all SDES (Source Description) items
   701 	                    specified by this parameter.
   702 
   703     @see TRtpSendPacketType
   704 	*/
   705 	IMPORT_C void SendRTCPPacketL(TDesC8& aPacket);
   706 
   707 	
   708 	/**
   709 	@publishedPartner
   710 	@released
   711 	Creates a new send stream, and returns the send stream handle.
   712 
   713 	Only one send stream per session is permitted, which means that you must not
   714 	call this function if the send stream has already been created.
   715 
   716 	As the send stream is an active object, it cannot handle request
   717 	completion events until control returns to the active scheduler.
   718 	Typically, clients will want to add event registrations before that.
   719 
   720 	The Code panics if the SendSource has alredy been opened.
   721 
   722 	@return The send stream handle.
   723 
   724 	This function may leave if memory is not enough.
   725 	*/
   726 	IMPORT_C RRtpSendSource NewSendSourceL(); 
   727 
   728 
   729 	/**
   730 	@publishedPartner
   731 	@released
   732 	
   733 	Gets the handle to the send stream object associated with this session.
   734 
   735 	The send stream object is the one created in a previous call
   736 	to NewSendSourceL(). If the send stream object has not been created, then
   737 	the returned handle will refer to a closed send stream.
   738 
   739     @return The handle to the send stream object.
   740     
   741     @see RRtpSendSource NewSendSourceL()
   742     */
   743 	IMPORT_C RRtpSendSource SendSource(); 
   744 
   745 
   746     /**
   747 	@publishedPartner
   748 	@released
   749     
   750     Sets the number of sequential packets that must be received
   751 	before a stream is considered good.
   752 	
   753 	Sets the maximum number of dropped packets to be considered a
   754 	dropout, as opposed to an ended and restarted stream.
   755 	
   756 	Sets the maximum number of packets by which a packet can be delayed 
   757 	before it is considered dropped.
   758 			
   759 	@param aMaxMisorder The maximum number of packets.
   760 		
   761 	@param aMaxDropout The number of sequential packets.
   762 		
   763 	@param aMinSequential The number of sequential packets.
   764 	@post The session will be 'restarted', 
   765 			i.e. it resets the sequence number sequence and resets all RTCP statistics.
   766 	*/
   767 	IMPORT_C void SetRtpStreamParameters(TInt aMinSequential, TInt aMaxMisorder, TInt aMaxDropout);
   768 
   769 	inline TBool operator == (RRtpSession aThat) const;
   770 	inline TBool operator != (RRtpSession aThat) const;
   771 
   772 	/**
   773 	@publishedPartner
   774 	@released
   775 
   776     The event manager contains a number of callback registrations, each of which 
   777 	binds a function and pointer (normally an object) to a particular kind of
   778     event. Registrations can be bound to all events on a stream.
   779 
   780 	If a function is registered for a particular event, it will be called when 
   781 	that event occurs. One callback function can be associated with more than 1
   782 	callback registration. Callback functions take a pointer argument
   783 	which was supplied as part of the registration
   784 
   785     @param aType Event type
   786 		
   787 	@param aCallback Callback object
   788 		
   789 	@param aPtr Pointer to data that needs to be passed to the callback function
   790 
   791   	@param aParameter Parameter to be passed to internal callback subsystem
   792 	*/
   793 	IMPORT_C void PrivRegisterEventCallbackL(TUint aType, 
   794 										  TRtpCallbackFunction aCallback, 
   795 										  TAny* aPtr, 
   796 										  TInt aParameter);
   797 
   798 	/**
   799 	@publishedPartner
   800 	@released
   801 
   802     The event manager contains a number of callback registrations, each of which 
   803 	binds a function and pointer (normally an object) to a particular kind of
   804     event. Registrations can be bound to all events on a stream.
   805 
   806 	If a function is registered for a particular event, it will be called when 
   807 	that event occurs. One callback function can be associated with more than 1
   808 	callback registration. Callback functions take a pointer argument
   809 	which was supplied as part of the registration
   810 
   811     @param aType Event type
   812 		
   813 	@param aCallback Callback object
   814 		
   815 	@param aPtr Pointer to data that needs to be passed to the callback function
   816 	*/
   817 	IMPORT_C void PrivRegisterEventCallbackL(TUint aType, 
   818 										  TRtpCallbackFunction aCallback, 
   819 										  TAny* aPtr);
   820 
   821  private:
   822 	friend class TRtpEvent;
   823 	CRtpSession* iPtr;
   824 	// Note: Comments that start with //\ are pseudo-variables used to get
   825 	// Doxygen collaboration diagrams to look right. Ignore them.
   826 	//\ RRtpSendSource sndSource_1_01;
   827 	//\ RRtpReceiveSource rcvSource_1_n;
   828 	//\ TRtpCallback callbacks_1_n;
   829 	//\ TRtpEvent events_1_n;
   830 	};
   831 
   832 
   833 
   834 
   835 /**
   836 @publishedAll
   837 @released
   838 
   839 A handle to a send stream.
   840 
   841 Use this class to manage the creation and sending of packets. 
   842 A session can have only one send stream.
   843 
   844 Only one packet can be sent at any one time.
   845 Once a packet has been sent, the packet cannot be closed and no further packets
   846 can be sent until an event signalling the completion of the send operation has
   847 occurred. This will be one of the events defined by the enum values:
   848 ERtpSendSucceeded and ERtpSendFail.
   849 
   850 A client must monitor these events so that it can schedule the sending of
   851 subsequent packets.
   852 It does this by implementing and registering callback functions that 
   853 handle these events.
   854 
   855 @see TRtpEventType
   856 */
   857 class RRtpSendSource
   858 	{
   859  public:
   860 	inline RRtpSendSource();
   861 	inline TBool IsOpen() const;
   862 	IMPORT_C void Close();
   863 
   864 	IMPORT_C void Cancel();
   865     
   866 	template <class T> inline void 
   867 		RegisterEventCallbackL(TRtpEventType aType, 
   868 							   void (*aCallback)(T*, const TRtpEvent&), 
   869 							   T* aPtr, 
   870 							   TRtpOneShotness aOneShot,
   871 							   TInt aParameter)
   872 	{
   873 	PrivRegisterEventCallbackL(aType|aOneShot,
   874 				reinterpret_cast<TRtpCallbackFunction>(aCallback),
   875 				static_cast<TAny*>(aPtr), aParameter);
   876 	}
   877 
   878 
   879 	template <class T> inline void 
   880 		RegisterEventCallbackL(TRtpEventType aType, 
   881 							   void (*aCallback)(T*, const TRtpEvent&), 
   882 							   T* aPtr, 
   883 							   TRtpOneShotness aOneShot = ERtpNotOneShot)
   884 	{
   885 	PrivRegisterEventCallbackL(aType|aOneShot,
   886 				reinterpret_cast<TRtpCallbackFunction>(aCallback),
   887 				static_cast<TAny*>(aPtr));
   888 	}
   889 
   890 
   891 	
   892 	IMPORT_C RRtpSendPacket NewSendPacketL(TInt aPayloadSize = 0, 
   893 										   TInt aHeaderExtensionSize = 
   894 										   KRtpNoExtension);
   895 	
   896 	IMPORT_C RRtpSendPacket NewSendPacketLC(TInt aPayloadSize = 0, 
   897 											TInt aHeaderExtensionSize = 
   898 											KRtpNoExtension);
   899 
   900 	IMPORT_C TBool IsSending();
   901 	IMPORT_C void SetPayloadType(TUint aPayloadType);
   902 	IMPORT_C void SetDefaultPayloadSize(TInt aPayloadSize);
   903 	/**
   904 	@publishedPartner
   905 	@released
   906 	
   907 	Sends a Bye RTCP packet.
   908 	
   909 	@param aReason The reason for sending the Bye RTCP packet.
   910 	*/
   911 	IMPORT_C void ByeL(TDesC8& aReason);
   912 	IMPORT_C TUint32 GetLocalSSRC();
   913 
   914 	IMPORT_C void SetAlignment(TInt aAlignment);
   915 	IMPORT_C TInt Alignment() const;
   916 
   917 	inline TBool operator == (RRtpSendSource aThat) const;
   918 	inline TBool operator != (RRtpSendSource aThat) const;
   919 	
   920 	/**
   921 	@publishedPartner
   922 	@released
   923 
   924     The event manager contains a number of callback registrations, each of which 
   925 	binds a function and pointer (normally an object) to a particular kind of
   926     event. Registrations can be bound to all events on a stream.
   927 
   928 	If a function is registered for a particular event, it will be called when 
   929 	that event occurs. One callback function can be associated with more than 1
   930 	callback registration. Callback functions take a pointer argument
   931 	which was supplied as part of the registration
   932 
   933     @param aType Event type
   934 		
   935 	@param aCallback Callback object
   936 		
   937 	@param aPtr Pointer to data that needs to be passed to the callback function
   938 
   939   	@param aParameter Parameter to be passed to internal callback subsystem
   940 	*/
   941 	IMPORT_C void PrivRegisterEventCallbackL(TUint aType, 
   942 										  TRtpCallbackFunction aCallback, 
   943 										  TAny* aPtr, 
   944 										  TInt aParameter);
   945 
   946 	/**
   947 	@publishedPartner
   948 	@released
   949 
   950     The event manager contains a number of callback registrations, each of which 
   951 	binds a function and pointer (normally an object) to a particular kind of
   952     event. Registrations can be bound to all events on a stream.
   953 
   954 	If a function is registered for a particular event, it will be called when 
   955 	that event occurs. One callback function can be associated with more than 1
   956 	callback registration. Callback functions take a pointer argument
   957 	which was supplied as part of the registration
   958 
   959     @param aType Event type
   960 		
   961 	@param aCallback Callback object
   962 		
   963 	@param aPtr Pointer to data that needs to be passed to the callback function
   964 	*/
   965 	IMPORT_C void PrivRegisterEventCallbackL(TUint aType, 
   966 										  TRtpCallbackFunction aCallback, 
   967 										  TAny* aPtr);
   968  private:
   969 	friend class RRtpSession;
   970 	friend class TRtpEvent;
   971 	CRtpSendSource* iPtr;
   972 	// Note: Comments that start with //\ are pseudo-variables used to get
   973 	// Doxygen collaboration diagrams to look right. Ignore them.
   974 	//\ TRtpCallback callbacks_1_n;
   975 	//\ TRtpEvent events_1_n;
   976 	//\ TRtpSendPacket packets_1_n;
   977 	};
   978 
   979 
   980 
   981 
   982 /**
   983 @publishedAll
   984 @released
   985 
   986 A handle to a receive stream.
   987 
   988 An object of this type represents the stream of data on a single SSRC and
   989 delivers the RTP packets and RTCP information in the order they
   990 arrive.
   991 
   992 Note that RTP does not guarantee the order of delivery, which means that the 
   993 client may want to buffer the data.
   994 */
   995 class RRtpReceiveSource 
   996 	{
   997  public:
   998 	RRtpReceiveSource();
   999 	inline TBool IsOpen() const;
  1000 
  1001 	IMPORT_C void Close();
  1002 
  1003 	
  1004 	template <class T> inline void 
  1005 		RegisterEventCallbackL(TRtpEventType aType, 
  1006 							   void (*aCallback)(T*, const TRtpEvent&), 
  1007 							   T* aPtr, 
  1008 							   TRtpOneShotness aOneShot,
  1009 							   TInt aParameter)
  1010 	{
  1011 	PrivRegisterEventCallbackL(aType|aOneShot, 
  1012 			reinterpret_cast<TRtpCallbackFunction>(aCallback),
  1013 			static_cast<TAny*>(aPtr), aParameter);
  1014 	}
  1015 
  1016 
  1017 	template <class T> inline void 
  1018 		RegisterEventCallbackL(TRtpEventType aType, 
  1019 							   void (*aCallback)(T*, const TRtpEvent&), 
  1020 							   T* aPtr, 
  1021 							   TRtpOneShotness aOneShot = ERtpNotOneShot)	
  1022 	{
  1023 	PrivRegisterEventCallbackL(aType|aOneShot, 
  1024 				reinterpret_cast<TRtpCallbackFunction>(aCallback),
  1025 				static_cast<TAny*>(aPtr));
  1026 	}
  1027 
  1028 	/**
  1029 	@publishedPartner
  1030 	@released
  1031 	
  1032 	Gets the data associated with the specified RTCP SDES (Source Description)
  1033 	item.
  1034 
  1035 	Note a that the PRIV (Private Extensions) SDES item is not supported
  1036 	by this mechanism.
  1037 
  1038 	@param aType  The value identifying the RTCP SDES item.
  1039 	
  1040 	@return A descriptor reference to the SDES item data. 
  1041 	*/
  1042 	IMPORT_C TInt GetSDES(const TInt aType, TDes8& aValue);
  1043 
  1044 
  1045 	/**
  1046 	@publishedPartner
  1047 	@released
  1048 	
  1049 	Gets the most recent SR ((Sender Report) from this SSRC.
  1050  
  1051     @return A handle to the SR.
  1052     */
  1053 	IMPORT_C RRtcpSRPart GetSR();
  1054 
  1055 
  1056 	/**
  1057 	@publishedPartner
  1058 	@released
  1059 	
  1060 	Gets the reason for a BYE packet.
  1061 	
  1062 	@return A descriptor contaning the BYE message. This is
  1063 	        KNullDesC if the source has not sent a BYE packet.
  1064     */
  1065 	IMPORT_C TDesC8& GetByeReason();
  1066 
  1067 
  1068 	/**
  1069 	@publishedPartner
  1070 	@released
  1071 	
  1072 	Parameters from the last APP (Application Defined) packet.
  1073 
  1074   	@param aName  Four-bytes application name
  1075 	@param aAppData  Applciation specific data
  1076 	@param aSubType  Application defined sub-type of the APP packet
  1077 	*/
  1078 	IMPORT_C void GetLastApp(TPtrC8& aName, TPtrC8& aAppData, TUint& aSubType);
  1079 
  1080 	IMPORT_C RRtpReceivePacket Packet();
  1081 
  1082 	/**
  1083 	@publishedPartner
  1084 	@released
  1085 	
  1086 	Gets the SSRC of the remote end
  1087 
  1088 	@return The SSRC of the remote end
  1089 	*/
  1090 	IMPORT_C TUint SSRC() const;
  1091 
  1092 	inline TBool operator == (RRtpReceiveSource aThat) const;
  1093 	inline TBool operator != (RRtpReceiveSource aThat) const;
  1094 
  1095 	/**
  1096 	@publishedPartner
  1097 	@released
  1098 
  1099     The event manager contains a number of callback registrations, each of which 
  1100 	binds a function and pointer (normally an object) to a particular kind of
  1101     event. Registrations can be bound to all events on a stream.
  1102 
  1103 	If a function is registered for a particular event, it will be called when 
  1104 	that event occurs. One callback function can be associated with more than 1
  1105 	callback registration. Callback functions take a pointer argument
  1106 	which was supplied as part of the registration
  1107 
  1108     @param aType Event type
  1109 		
  1110 	@param aCallback Callback object
  1111 		
  1112 	@param aPtr Pointer to data that needs to be passed to the callback function
  1113 
  1114   	@param aParameter Parameter to be passed to internal callback subsystem
  1115 	*/
  1116 	IMPORT_C void PrivRegisterEventCallbackL(TUint aType, 
  1117 										  TRtpCallbackFunction aCallback, 
  1118 										  TAny* aPtr, TInt aParameter);
  1119 
  1120 	/**
  1121 	@publishedPartner
  1122 	@released
  1123 
  1124     The event manager contains a number of callback registrations, each of which 
  1125 	binds a function and pointer (normally an object) to a particular kind of
  1126     event. Registrations can be bound to all events on a stream.
  1127 
  1128 	If a function is registered for a particular event, it will be called when 
  1129 	that event occurs. One callback function can be associated with more than 1
  1130 	callback registration. Callback functions take a pointer argument
  1131 	which was supplied as part of the registration
  1132 
  1133     @param aType Event type
  1134 		
  1135 	@param aCallback Callback object
  1136 		
  1137 	@param aPtr Pointer to data that needs to be passed to the callback function
  1138 	*/
  1139 
  1140 	IMPORT_C void PrivRegisterEventCallbackL(TUint aType, 
  1141 										  TRtpCallbackFunction aCallback, 
  1142 										  TAny* aPtr);
  1143  private:
  1144 	friend class RRtpSession;
  1145 	friend class TRtpEvent;
  1146 	CRtpReceiveSource* iPtr;
  1147 	// Note: Comments that start with //\ are pseudo-variables used to get
  1148 	// Doxygen collaboration diagrams to look right. Ignore them.
  1149 	//\ TRtpCallback callbacks_1_n;
  1150 	//\ TRtpEvent events_1_n;
  1151 	//\ TRtpReceivePacket packets_1_n;
  1152 	};
  1153 
  1154 
  1155 
  1156 
  1157 /**
  1158 @publishedAll
  1159 @released
  1160 
  1161 A handle to an RTP packet.
  1162 
  1163 The packet is accessed through the interface provided by this handle.
  1164 */
  1165 class RRtpPacket
  1166 	{
  1167  public:
  1168 	inline RRtpPacket();
  1169 	inline TBool IsOpen() const;
  1170 
  1171 	IMPORT_C void Close();
  1172 	IMPORT_C TPtrC8 Payload() const;
  1173 	IMPORT_C TUint SequenceNumber() const;
  1174 	IMPORT_C TUint Timestamp() const;
  1175 	IMPORT_C TUint SSRC() const;
  1176 	IMPORT_C RRtpCSRCs CSRCs() const;
  1177 	IMPORT_C TBool ExtensionPresent() const;
  1178 	IMPORT_C RRtpHeaderExtension Extension() const; 
  1179 	IMPORT_C TBool Marker() const;
  1180 	IMPORT_C TUint PayloadType() const;
  1181 	IMPORT_C TUint Flags() const;
  1182 
  1183 	inline TBool operator == (RRtpPacket aThat) const;
  1184 	inline TBool operator != (RRtpPacket aThat) const;
  1185 
  1186  protected:
  1187 	TRtpPacket* iPtr;
  1188 	// Note: Comments that start with //\ are pseudo-variables used to get
  1189 	// Doxygen collaboration diagrams to look right. Ignore them.
  1190 	//\ RRtpHeaderExtension extension_1_01;
  1191 	//\ RRtpCSRCs csrcs_1_01;
  1192 	};
  1193 
  1194 
  1195 
  1196 
  1197 /**
  1198 @publishedAll
  1199 @released
  1200 
  1201 A handle to an RTP packet to be sent (an RTP send packet).
  1202 
  1203 @see RRtpSendSource
  1204 */
  1205 class RRtpSendPacket : public RRtpPacket
  1206 	{
  1207  public:
  1208 	IMPORT_C void Send();
  1209 	IMPORT_C TDes8& WritePayload();
  1210 	IMPORT_C void SetTimestamp(TUint aTimestamp);
  1211 	IMPORT_C void SetMarker(TBool aMark);
  1212 	IMPORT_C void SetPayloadType(TUint aPayloadType);
  1213 	IMPORT_C void SetFlags(TUint aFlags);
  1214 
  1215 	friend class RRtpSendSource;
  1216 	};
  1217 
  1218 
  1219 
  1220 
  1221 /**
  1222 @publishedAll
  1223 @released
  1224 
  1225 A handle to an RTP packet received from another source.
  1226 */
  1227 class RRtpReceivePacket : public RRtpPacket
  1228 	{
  1229 	friend class RRtpReceiveSource;
  1230 	friend class TRtpReceivePacket;
  1231 	};
  1232 
  1233 
  1234 
  1235 
  1236 /**
  1237 @publishedAll
  1238 @released
  1239 
  1240 An RTP event.
  1241 
  1242 An event is generated when anything happens that a client might want
  1243 to know about. The class encapulates two pieces of information:
  1244 1. An event type as defined by a TRtpEventType value.
  1245 2. Additional information whose meaning is dependent on the event type.
  1246 
  1247 Additional information may be implicitly associated with the event, but still
  1248 needs to be fetched from another object, for example, when processing
  1249 an ERtpPacketReceived event, the packet (represented by a RRtpReceivePacket
  1250 handle) must be obtained from the receive stream (represented by a
  1251 RRtpReceiveStream handle).
  1252 
  1253 Events are always associated with either an RTP session, a send stream or
  1254 a receive stream, and this class has functions for getting the corresponding
  1255 handle.
  1256 
  1257 @see RRtpSession
  1258 @see RRtpSendSource
  1259 @see RRtpReceiveSource
  1260 */
  1261 class TRtpEvent
  1262 	{
  1263  public:
  1264 	IMPORT_C TRtpEvent(TRtpEventType aType, TInt aStatus, TAny* aData);
  1265 	IMPORT_C RRtpSession Session() const;
  1266 	IMPORT_C RRtpSendSource SendSource() const;
  1267 	IMPORT_C RRtpReceiveSource ReceiveSource() const;
  1268 	IMPORT_C TBool IsSessionEvent() const;
  1269 	IMPORT_C TBool IsSendSourceEvent() const;
  1270 	IMPORT_C TBool IsReceiveSourceEvent() const;
  1271         
  1272 	inline TRtpEventType Type() const;
  1273 	inline TInt Status() const;
  1274  private:
  1275 	TRtpEventType iType;
  1276 	TInt iStatus;
  1277 	TAny* iData;
  1278 	};
  1279 
  1280 
  1281 
  1282 
  1283 /**
  1284 @publishedAll
  1285 @released
  1286 
  1287 Reresents an RTP packet's header extension.
  1288 
  1289 The format of a header extension is profile-defined.
  1290 */
  1291 class RRtpHeaderExtension
  1292 	{
  1293  public:
  1294 	IMPORT_C TUint16 Type() const;
  1295 	IMPORT_C void SetType(TUint16 aType);
  1296 	IMPORT_C TPtrC8 Data();
  1297  private:
  1298 	friend class RRtpPacket;
  1299 	TRtpPacket* iPtr;
  1300 	};
  1301 
  1302 
  1303 
  1304 
  1305 /**
  1306 @publishedAll
  1307 @released
  1308 
  1309 A handle representing the list of CSRCs in an RTP packet.
  1310 */
  1311 class RRtpCSRCs
  1312 	{
  1313  public:
  1314 	IMPORT_C TInt Count() const;
  1315 	IMPORT_C TUint operator [](TUint aIndex) const;
  1316  private:
  1317 	friend class RRtpPacket;
  1318 	
  1319 	TRtpPacket* iPtr;
  1320 	};
  1321 
  1322 
  1323 /**
  1324 @publishedPartner
  1325 
  1326 A set of panic codes.
  1327 
  1328 in release mode, different panic codes, such as
  1329 KERN-EXEC 3 may be generated instead.
  1330 */
  1331 enum TRtpPanicCode
  1332 	{
  1333 	ERtpPacketIsClosed = 1, 
  1334 	ERtpPayloadTypeOutOfRange = 2,
  1335 	ERtpSessionIsClosed = 3,
  1336 	ERtpSourceIsClosed = 4,
  1337 	ERtpNoExtension = 5,
  1338 	ERtpLeaveInResponseToError = 6,
  1339 	ERtpCantSend2PacketsAtOnce = 7,
  1340 	ERtpWrongEventType = 8,
  1341 	ERtpWrongParameter = 9,
  1342 	ERtpSendSourceAlreadyOpen = 10,
  1343 	ERtpSessionAlreadyOpen = 11,
  1344 	//
  1345 	ERtpCoreController = 100,
  1346 	};
  1347 
  1348 GLREF_C void Panic(TRtpPanicCode aPanicCode);
  1349 
  1350 #include "rtp.inl"
  1351 
  1352 #endif // RTP_H