2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Name : SdpFmtAttributeField.h
17 * Interface : SDK API, SDP Codec API
24 #ifndef CSDPFMTATTRIBUTEFIELD_H
25 #define CSDPFMTATTRIBUTEFIELD_H
29 #include <stringpool.h>
31 // FORWARD DECLARATIONS
34 class CSdpAttributeField;
35 class TSdpRtpmapValue;
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.
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.
53 class CSdpFmtAttributeField : public CBase
55 public: // Constructors and destructor
57 * Constructs a new media format level attribute field.
59 * @param aText A string containing a correctly
60 * formatted field value terminated by a CRLF.
61 * @return a new instance.
63 IMPORT_C static CSdpFmtAttributeField* DecodeL( const TDesC8& aText );
66 * Constructs a new media format level attribute field and adds the
67 * pointer to the cleanup stack.
69 * @param aText A string containing a correctly
70 * formatted field value terminated by a CRLF.
71 * @return a new instance.
73 IMPORT_C static CSdpFmtAttributeField* DecodeLC( const TDesC8& aText);
76 * Constructs a new media level format attribute field.
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.
86 IMPORT_C static CSdpFmtAttributeField* NewL(
87 RStringF aAttribute, const TDesC8& aFormat, const TDesC8& aValue );
90 * Constructs a new media format level attribute field and adds the
91 * pointer to the cleanup stack.
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.
101 IMPORT_C static CSdpFmtAttributeField* NewLC(
102 RStringF aAttribute, const TDesC8& aFormat, const TDesC8& aValue );
105 * Deletes the resources held by the instance.
107 IMPORT_C ~CSdpFmtAttributeField();
109 public: // New functions
112 * Outputs the field formatted according to SDP syntax and including
113 * the terminating CRLF.
115 * @param aStream Stream used for output. On return
116 * the stream includes correctly formatted attribute field.
118 IMPORT_C void EncodeL( RWriteStream& aStream ) const;
121 * Creates a new instance that is equal to the target.
123 * @return a new instance.
125 IMPORT_C CSdpFmtAttributeField * CloneL() const;
128 * Compares this instance to another for equality.
130 * @param aObj The instance to compare to.
131 * @return ETrue if equal, EFalse if not.
133 IMPORT_C TBool operator== ( const CSdpFmtAttributeField& aObj ) const;
136 * Gets the attribute.
138 * @return The attribute name. The name can be pre-defined
139 * name in the SDP string table or defined by the client.
141 IMPORT_C RStringF Attribute() const;
146 * @return The format.
148 IMPORT_C const TDesC8& Format() const;
151 * Gets the attribute value.
153 * @return The value or an empty descriptor if there is no value part.
155 IMPORT_C const TDesC8& Value() const;
158 * Sets the attribute, format/payload type and attribute value.
160 * @param aAttribute A valid attribute name. It can be a
161 * pre-defined name in the SDP string pool or defined by
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
171 RStringF aAttribute, const TDesC8& aFormat, const TDesC8& aValue );
173 public: // Internal to codec
176 * Externalizes the object to stream
178 * @param aStream Stream where the object's state will be stored
180 void ExternalizeL( RWriteStream& aStream ) const;
183 * Creates object from the stream data
185 * @param aStream Stream where the object's state will be read
186 * @return Initialized object
188 static CSdpFmtAttributeField* InternalizeL( RReadStream& aStream );
191 * Returns attribute field
193 * @return Attribute field
195 const CSdpAttributeField* AttributeField() const;
197 private: // New methods
200 * Creates object from the stream data.
201 * Does the "2nd phase construction" of internalization.
203 * @param aStream Stream where the object's state will be read
205 void DoInternalizeL( RReadStream& aStream );
208 * Formats value parameters
210 * @param aField Attribute field object
212 void FormatValueParamsL( CSdpAttributeField* aField );
214 private: // Construction and destruction
219 CSdpFmtAttributeField();
222 * Second phase construction
224 * @param aText A string containing a correctly formatted field value
225 * terminated by a CRLF.
227 void ConstructL( const TDesC8& aText );
230 * Second phase construction
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.
240 RStringF aAttribute, const TDesC8& aFormat, const TDesC8& aValue );
244 * Decode format parameter from string
246 * @param aText A text includeing format parameter.
248 void DecodeFormatL(const TDesC8& aText);
250 void __DbgTestInvariant() const;
256 CSdpAttributeField* iAttributeField;
257 /** Pointer to the format part*/
259 /** Pointer to the format parameters*/
263 #endif // CSDPFMTATTRIBUTEFIELD_H