epoc32/include/mw/sdpfmtattributefield.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/sdpfmtattributefield.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 /*
     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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.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 #include "_sdpdefs.h"
    31 
    32 // FORWARD DECLARATIONS
    33 class RReadStream;
    34 class RWriteStream;
    35 class CSdpAttributeField;
    36 class TSdpRtpmapValue;
    37 
    38 // CLASS DECLARATION
    39 /**
    40  *  @publishedAll
    41  *  @released
    42  *
    43  *	This class encapsulates the attribute field of the Session Description
    44  *  Protocol for media format/payload type level attributes. Media and session
    45  *  level attributes are supported by the CSdpAttributeField class. 
    46  *
    47  *	The normative reference for correct formatting and values is
    48  *	draft-ietf-mmusic-sdp-new-14 unless specified otherwise in
    49  *  member documentation. The implementation supports this normative
    50  *  reference, but does not enforce it fully. 
    51  *
    52  *  @lib sdpcodec.lib
    53  */
    54 class CSdpFmtAttributeField : public CBase
    55 	{
    56     public: // Constructors and destructor
    57         /**
    58          *	Constructs a new media format level attribute field.
    59 		 * 
    60 		 *	@param aText A string containing a correctly 
    61          *         formatted field value terminated by a CRLF.
    62          *  @return a new instance.
    63          */
    64 		IMPORT_C static CSdpFmtAttributeField* DecodeL( const TDesC8& aText );
    65 
    66         /**
    67          *	Constructs a new media format level attribute field  and adds the 
    68          *  pointer to the cleanup stack.
    69 		 *			 
    70          *	@param aText A string containing a correctly 
    71          *         formatted field value terminated by a CRLF.
    72          *	@return a new instance.
    73          */
    74 		IMPORT_C static CSdpFmtAttributeField* DecodeLC( const TDesC8& aText);
    75 
    76         /**
    77          *	Constructs a new media level format attribute field.
    78 		 *
    79          *	@param aAttribute The attribute name. It can be a pre-defined
    80          *         name in the SDP string pool or defined by the client.
    81          *	@param aFormat A valid format/payload identifier 
    82          *         used in the format list of the media description.
    83          *	@param aValue A valid attribute value or an empty 
    84          *         descriptor to omit the value part.
    85          *	@return a new instance.
    86 		 */
    87 		IMPORT_C static CSdpFmtAttributeField* NewL(
    88             RStringF aAttribute, const TDesC8& aFormat, const TDesC8& aValue );
    89 
    90         /**
    91          *	Constructs a new media format level attribute field and adds the 
    92          *  pointer to the cleanup stack.
    93 		 *
    94          *	@param aAttribute The attribute name. It can be a pre-defined 
    95          *         name in the SDP string pool or defined by the client.
    96          *	@param aFormat A valid format/payload identifier 
    97          *         used in the format list of the media description.
    98          *	@param aValue A valid attribute value or an empty 
    99          *         descriptor to omit the value part.
   100          *	@return a new instance.
   101 		 */
   102 		IMPORT_C static CSdpFmtAttributeField* NewLC(
   103             RStringF aAttribute, const TDesC8& aFormat, const TDesC8& aValue );
   104 
   105 		/**
   106 		 *	Deletes the resources held by the instance.
   107 		 */
   108 		IMPORT_C ~CSdpFmtAttributeField();
   109 
   110     public: // New functions
   111 
   112 		/**
   113 		 *	Outputs the field formatted according to SDP syntax and including
   114 		 *  the terminating CRLF.
   115 		 * 
   116 		 *	@param aStream Stream used for output. On return 
   117          *         the stream includes correctly formatted attribute field.
   118 		 */
   119 		IMPORT_C void EncodeL( RWriteStream& aStream ) const;
   120 
   121 		/**
   122 		 *	Creates a new instance that is equal to the target.
   123 		 *
   124 		 *	@return a new instance.
   125 		 */
   126 		IMPORT_C CSdpFmtAttributeField * CloneL() const;
   127 
   128 		/**	
   129 		 *	Compares this instance to another for equality. 
   130 		 *
   131 		 *	@param aObj The instance to compare to.
   132 		 *	@return ETrue if equal, EFalse if not.
   133 		 */
   134 		IMPORT_C TBool operator== ( const CSdpFmtAttributeField& aObj ) const;
   135 
   136 		/**
   137 		 *	Gets the attribute.
   138 		 *	
   139 		 *	@return	The attribute name. The name can be pre-defined 
   140          *          name in the SDP string table or defined by the client.
   141          */
   142 		IMPORT_C RStringF Attribute() const;
   143 
   144 		/**
   145 		 *	Gets the format.
   146 		 *	
   147 		 *	@return	The format.
   148 		 */
   149 		IMPORT_C const TDesC8& Format() const;
   150 
   151 		/**
   152 		 *	Gets the attribute value.
   153 		 *	
   154 		 *	@return The value  or an empty descriptor if there is no value part.
   155 		 */
   156 		IMPORT_C const TDesC8& Value() const;
   157 
   158 		/**
   159 		 *	Sets the attribute, format/payload type and attribute value.
   160 		 *
   161          *	@param aAttribute A valid attribute name. It can be a 
   162          *         pre-defined name in the SDP string pool or defined by 
   163          *         the client.
   164          *	@param aFormat A valid format/payload identifier 
   165          *         used in the formatlist of the media description.
   166          *	@param aValue A valid attribute value or an empty 
   167          *         descriptor to omit the value part.
   168          *  @leave KErrSdpCodecMediaAttributeField if aAttribute is not rtpmap
   169          *         or fmtp attribute.
   170 		 */
   171 		IMPORT_C void SetL(
   172             RStringF aAttribute, const TDesC8& aFormat, const TDesC8& aValue );
   173 
   174     public: // Internal to codec
   175 
   176         /**
   177          *  Externalizes the object to stream
   178          *
   179          *  @param aStream Stream where the object's state will be stored
   180          */
   181 		void ExternalizeL( RWriteStream& aStream ) const;
   182 
   183         /**
   184          *  Creates object from the stream data
   185          *
   186          *  @param aStream Stream where the object's state will be read        
   187          *  @return Initialized object
   188          */
   189 		static CSdpFmtAttributeField* InternalizeL( RReadStream& aStream );
   190 
   191         /**
   192          *  Returns attribute field
   193          *
   194          *  @return Attribute field
   195          */
   196         const CSdpAttributeField* AttributeField() const;
   197 
   198     private: // New methods
   199 
   200         /**
   201          *  Creates object from the stream data.
   202          *	Does the "2nd phase construction" of internalization.
   203          *
   204          *  @param aStream Stream where the object's state will be read
   205          */
   206         void DoInternalizeL( RReadStream& aStream );
   207 
   208         /**
   209          *  Formats value parameters
   210          *
   211          *  @param aField Attribute field object
   212          */
   213         void FormatValueParamsL( CSdpAttributeField* aField );
   214 
   215     private: // Construction and destruction
   216         
   217         /**
   218          *  Constructor
   219          */
   220         CSdpFmtAttributeField();
   221 
   222         /**
   223          *  Second phase construction
   224          *         
   225          *  @param aText A string containing a correctly formatted field value
   226 		 *         terminated by a CRLF.
   227          */
   228         void ConstructL( const TDesC8& aText );
   229 
   230         /**
   231          *  Second phase construction
   232          *
   233          *	@param aAttribute The attribute from the pre-defined SDP string 
   234 		 *         table or defined by the user
   235          *	@param aFormat A valid format/payload identifier used in the format
   236 		 *         list of the media description.
   237          *	@param aValue A valid attribute value or an empty descriptor
   238 		 *         to omit the value part.         
   239 		 */
   240 		void ConstructL(
   241             RStringF aAttribute, const TDesC8& aFormat, const TDesC8& aValue );    
   242 
   243         
   244         /**
   245          *  Decode format parameter from string
   246          *
   247          *	@param aText A text includeing format parameter.
   248 		 */
   249         void DecodeFormatL(const TDesC8& aText);
   250         
   251         __DECLARE_TEST;
   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