realtimenetprots/sipfw/SDP/api/SdpFmtAttributeField.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Name          : SdpFmtAttributeField.h
       
    16 * Part of       : SDP Codec
       
    17 * Interface     : SDK API, SDP Codec API
       
    18 * Version       : 1.0
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 #ifndef CSDPFMTATTRIBUTEFIELD_H
       
    25 #define CSDPFMTATTRIBUTEFIELD_H
       
    26 
       
    27 //  INCLUDES
       
    28 #include <e32base.h>
       
    29 #include <stringpool.h>
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class RReadStream;
       
    33 class RWriteStream;
       
    34 class CSdpAttributeField;
       
    35 class TSdpRtpmapValue;
       
    36 
       
    37 // CLASS DECLARATION
       
    38 /**
       
    39  *  @publishedAll
       
    40  *  @released
       
    41  *
       
    42  *	This class encapsulates the attribute field of the Session Description
       
    43  *  Protocol for media format/payload type level attributes. Media and session
       
    44  *  level attributes are supported by the CSdpAttributeField class. 
       
    45  *
       
    46  *	The normative reference for correct formatting and values is
       
    47  *	draft-ietf-mmusic-sdp-new-14 unless specified otherwise in
       
    48  *  member documentation. The implementation supports this normative
       
    49  *  reference, but does not enforce it fully. 
       
    50  *
       
    51  *  @lib sdpcodec.lib
       
    52  */
       
    53 class CSdpFmtAttributeField : public CBase
       
    54 	{
       
    55     public: // Constructors and destructor
       
    56         /**
       
    57          *	Constructs a new media format level attribute field.
       
    58 		 * 
       
    59 		 *	@param aText A string containing a correctly 
       
    60          *         formatted field value terminated by a CRLF.
       
    61          *  @return a new instance.
       
    62          */
       
    63 		IMPORT_C static CSdpFmtAttributeField* DecodeL( const TDesC8& aText );
       
    64 
       
    65         /**
       
    66          *	Constructs a new media format level attribute field  and adds the 
       
    67          *  pointer to the cleanup stack.
       
    68 		 *			 
       
    69          *	@param aText A string containing a correctly 
       
    70          *         formatted field value terminated by a CRLF.
       
    71          *	@return a new instance.
       
    72          */
       
    73 		IMPORT_C static CSdpFmtAttributeField* DecodeLC( const TDesC8& aText);
       
    74 
       
    75         /**
       
    76          *	Constructs a new media level format attribute field.
       
    77 		 *
       
    78          *	@param aAttribute The attribute name. It can be a pre-defined
       
    79          *         name in the SDP string pool or defined by the client.
       
    80          *	@param aFormat A valid format/payload identifier 
       
    81          *         used in the format list of the media description.
       
    82          *	@param aValue A valid attribute value or an empty 
       
    83          *         descriptor to omit the value part.
       
    84          *	@return a new instance.
       
    85 		 */
       
    86 		IMPORT_C static CSdpFmtAttributeField* NewL(
       
    87             RStringF aAttribute, const TDesC8& aFormat, const TDesC8& aValue );
       
    88 
       
    89         /**
       
    90          *	Constructs a new media format level attribute field and adds the 
       
    91          *  pointer to the cleanup stack.
       
    92 		 *
       
    93          *	@param aAttribute The attribute name. It can be a pre-defined 
       
    94          *         name in the SDP string pool or defined by the client.
       
    95          *	@param aFormat A valid format/payload identifier 
       
    96          *         used in the format list of the media description.
       
    97          *	@param aValue A valid attribute value or an empty 
       
    98          *         descriptor to omit the value part.
       
    99          *	@return a new instance.
       
   100 		 */
       
   101 		IMPORT_C static CSdpFmtAttributeField* NewLC(
       
   102             RStringF aAttribute, const TDesC8& aFormat, const TDesC8& aValue );
       
   103 
       
   104 		/**
       
   105 		 *	Deletes the resources held by the instance.
       
   106 		 */
       
   107 		IMPORT_C ~CSdpFmtAttributeField();
       
   108 
       
   109     public: // New functions
       
   110 
       
   111 		/**
       
   112 		 *	Outputs the field formatted according to SDP syntax and including
       
   113 		 *  the terminating CRLF.
       
   114 		 * 
       
   115 		 *	@param aStream Stream used for output. On return 
       
   116          *         the stream includes correctly formatted attribute field.
       
   117 		 */
       
   118 		IMPORT_C void EncodeL( RWriteStream& aStream ) const;
       
   119 
       
   120 		/**
       
   121 		 *	Creates a new instance that is equal to the target.
       
   122 		 *
       
   123 		 *	@return a new instance.
       
   124 		 */
       
   125 		IMPORT_C CSdpFmtAttributeField * CloneL() const;
       
   126 
       
   127 		/**	
       
   128 		 *	Compares this instance to another for equality. 
       
   129 		 *
       
   130 		 *	@param aObj The instance to compare to.
       
   131 		 *	@return ETrue if equal, EFalse if not.
       
   132 		 */
       
   133 		IMPORT_C TBool operator== ( const CSdpFmtAttributeField& aObj ) const;
       
   134 
       
   135 		/**
       
   136 		 *	Gets the attribute.
       
   137 		 *	
       
   138 		 *	@return	The attribute name. The name can be pre-defined 
       
   139          *          name in the SDP string table or defined by the client.
       
   140          */
       
   141 		IMPORT_C RStringF Attribute() const;
       
   142 
       
   143 		/**
       
   144 		 *	Gets the format.
       
   145 		 *	
       
   146 		 *	@return	The format.
       
   147 		 */
       
   148 		IMPORT_C const TDesC8& Format() const;
       
   149 
       
   150 		/**
       
   151 		 *	Gets the attribute value.
       
   152 		 *	
       
   153 		 *	@return The value  or an empty descriptor if there is no value part.
       
   154 		 */
       
   155 		IMPORT_C const TDesC8& Value() const;
       
   156 
       
   157 		/**
       
   158 		 *	Sets the attribute, format/payload type and attribute value.
       
   159 		 *
       
   160          *	@param aAttribute A valid attribute name. It can be a 
       
   161          *         pre-defined name in the SDP string pool or defined by 
       
   162          *         the client.
       
   163          *	@param aFormat A valid format/payload identifier 
       
   164          *         used in the formatlist of the media description.
       
   165          *	@param aValue A valid attribute value or an empty 
       
   166          *         descriptor to omit the value part.
       
   167          *  @leave KErrSdpCodecMediaAttributeField if aAttribute is not rtpmap
       
   168          *         or fmtp attribute.
       
   169 		 */
       
   170 		IMPORT_C void SetL(
       
   171             RStringF aAttribute, const TDesC8& aFormat, const TDesC8& aValue );
       
   172 
       
   173     public: // Internal to codec
       
   174 
       
   175         /**
       
   176          *  Externalizes the object to stream
       
   177          *
       
   178          *  @param aStream Stream where the object's state will be stored
       
   179          */
       
   180 		void ExternalizeL( RWriteStream& aStream ) const;
       
   181 
       
   182         /**
       
   183          *  Creates object from the stream data
       
   184          *
       
   185          *  @param aStream Stream where the object's state will be read        
       
   186          *  @return Initialized object
       
   187          */
       
   188 		static CSdpFmtAttributeField* InternalizeL( RReadStream& aStream );
       
   189 
       
   190         /**
       
   191          *  Returns attribute field
       
   192          *
       
   193          *  @return Attribute field
       
   194          */
       
   195         const CSdpAttributeField* AttributeField() const;
       
   196 
       
   197     private: // New methods
       
   198 
       
   199         /**
       
   200          *  Creates object from the stream data.
       
   201          *	Does the "2nd phase construction" of internalization.
       
   202          *
       
   203          *  @param aStream Stream where the object's state will be read
       
   204          */
       
   205         void DoInternalizeL( RReadStream& aStream );
       
   206 
       
   207         /**
       
   208          *  Formats value parameters
       
   209          *
       
   210          *  @param aField Attribute field object
       
   211          */
       
   212         void FormatValueParamsL( CSdpAttributeField* aField );
       
   213 
       
   214     private: // Construction and destruction
       
   215         
       
   216         /**
       
   217          *  Constructor
       
   218          */
       
   219         CSdpFmtAttributeField();
       
   220 
       
   221         /**
       
   222          *  Second phase construction
       
   223          *         
       
   224          *  @param aText A string containing a correctly formatted field value
       
   225 		 *         terminated by a CRLF.
       
   226          */
       
   227         void ConstructL( const TDesC8& aText );
       
   228 
       
   229         /**
       
   230          *  Second phase construction
       
   231          *
       
   232          *	@param aAttribute The attribute from the pre-defined SDP string 
       
   233 		 *         table or defined by the user
       
   234          *	@param aFormat A valid format/payload identifier used in the format
       
   235 		 *         list of the media description.
       
   236          *	@param aValue A valid attribute value or an empty descriptor
       
   237 		 *         to omit the value part.         
       
   238 		 */
       
   239 		void ConstructL(
       
   240             RStringF aAttribute, const TDesC8& aFormat, const TDesC8& aValue );    
       
   241 
       
   242         
       
   243         /**
       
   244          *  Decode format parameter from string
       
   245          *
       
   246          *	@param aText A text includeing format parameter.
       
   247 		 */
       
   248         void DecodeFormatL(const TDesC8& aText);
       
   249         
       
   250 		void __DbgTestInvariant() const;
       
   251 
       
   252 
       
   253     private:
       
   254 
       
   255         RStringPool iPool;
       
   256         CSdpAttributeField* iAttributeField;       
       
   257 		/** Pointer to the format part*/
       
   258 		TPtrC8 iFormat;
       
   259         /** Pointer to the format parameters*/
       
   260 		TPtrC8 iValuePart;
       
   261 	};
       
   262 
       
   263 #endif // CSDPFMTATTRIBUTEFIELD_H