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 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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Name : SdpAttributeField.h
17 * Interface : SDK API, SDP Codec API
24 #ifndef CSDPATTRIBUTEFIELD_H
25 #define CSDPATTRIBUTEFIELD_H
29 #include <stringpool.h>
30 #include "sdpcodecstringconstants.h"
33 // FORWARD DECLARATIONS
36 class CSdpFmtAttributeField;
37 class CSdpAttributeFieldPtrs;
44 * This class encapsulates the attribute field of Session Description Protocol
45 * for media and session level attributes. Media format/payload type level
46 * attributes are supported by the CSdpFmtAttributeField class.
48 * The normative reference for correct formatting and values is
49 * draft-ietf-mmusic-sdp-new-14 unless specified otherwise in
50 * member documentation. The implementation supports this normative
51 * reference, but does not enforce it fully.
55 class CSdpAttributeField : public CBase
57 public: // Constructors and destructor
60 * Constructs a new attribute field.
62 * @param aText A string containing a correctly
63 * formatted field value terminated by a CRLF.
64 * @return a new instance.
66 IMPORT_C static CSdpAttributeField* DecodeL( const TDesC8& aText );
69 * Constructs a new attribute field and adds the pointer to the
72 * @param aTest A string containing a correctly
73 * formatted field value terminated by a CRLF.
74 * @return a new instance.
76 IMPORT_C static CSdpAttributeField* DecodeLC( const TDesC8& aText );
79 * Constructs a new attribute field.
81 * @param aAttribute The attribute name. It can be a pre-
82 * defined name in the SDP string pool or defined by the
84 * @param aValue A valid attribute value or an empty
85 * descriptor to omit the value part.
86 * @return a new instance.
88 IMPORT_C static CSdpAttributeField* NewL(
89 RStringF aAttribute, const TDesC8& aValue );
92 * Constructs a new attribute field and adds the pointer to the
95 * @param aAttribute The attribute name. It can be a pre-defined
96 * name in the SDP string pool or defined by the client.
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 CSdpAttributeField* NewLC(
102 RStringF aAttribute, const TDesC8& aValue );
105 * Deletes the resources held by the instance.
107 IMPORT_C ~CSdpAttributeField();
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 the
116 * 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 CSdpAttributeField* 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 CSdpAttributeField& aObj ) const;
136 * Gets the attribute name.
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;
144 * Gets the attribute.
146 * @return The value or an empty descriptor if there is no value part.
148 IMPORT_C const TDesC8& Value() const;
151 * Sets the attribute and attribute value.
153 * @param aAttribute A valid attribute name. It can be a
154 * pre-defined name in the SDP string pool or
155 * defined by the client.
156 * @param aValue A valid attribute value or an empty
157 * descriptor to omit the value part.
158 * @leave KErrSdpCodecAttributeField if the attribute part is not
159 * pre-defined EAttributeFmtp or EAttributeRtpmap.
161 IMPORT_C void SetL( RStringF aAttribute, const TDesC8& aValue );
164 * Assigns attribute to the format level attribute.
165 * In the final output the attribute will placed after format level
168 * @param aFmtAttribute A format level
169 * attribute this attribute is assigned to.
171 IMPORT_C void AssignTo(const CSdpFmtAttributeField& aFmtAttribute);
174 * Test if the attribute belongs to the given format level attribute.
175 * Note, that the check can be true for the media level paremeter if
176 * it appears after the last format level attribute.
178 * @param aFmtAttribute: A format level
179 * attribute this attribute belongs to.
180 * @return ETrue if attribute belongs to the format level attribute,
183 IMPORT_C TBool BelongsTo(const CSdpFmtAttributeField& aFmtAttribute) const;
185 public: // Internal to codec
188 * Externalizes the object to stream
190 * @param aStream Stream where the object's state will be stored
192 void ExternalizeL( RWriteStream& aStream ) const;
195 * Creates object from the stream data
197 * @param aStream Stream where the object's state will be read
198 * @return Initialized object
200 static CSdpAttributeField* InternalizeL( RReadStream& aStream );
203 * Informs if the attribute belongs to any format level attribute.
205 * @return ETrue if attribute belongs to any format level
206 * attribute, EFalse otherwise.
208 TBool IsFmtAttribute();
210 private: // Constructors
215 CSdpAttributeField();
218 * Second phase constructor
220 * @param aText Text string ending to LF character
222 void ConstructL( const TDesC8& aText );
225 * Second phase constructor
227 * @param aAttribute Attribute identifier
228 * @param aValue Value of the attribute of KNullDesC8
230 void ConstructL( RStringF aAttribute, const TDesC8& aValue );
235 * Verifies that attribute is valid property attribute and initializes
236 * the member variables of class accordingly
238 * @param aAttribute Attribute in descriptor
240 void FormatProperyAttributeL( const TDesC8& aAttribute );
243 * Verifies that attribute is valid value attribute and initializes
244 * the member variables of class accordingly
246 * @param aArray Array of the attributes
248 void FormatValueAttributeL( const TDesC8& aAttribute,
249 const TDesC8& aValue );
252 * Verifies that the value is valid for the attribute
254 * @param aAttribute The attribute
255 * @param aArray Array containing the values (and attribute)
257 void VerifyValueAttributeL( SdpCodecStringConstants::TStrings aString,
258 const TDesC8& aValue );
261 * Forms attribute and value strings out of the token array
262 * and pushes both (aAttribute & aValue) into cleanup stack
264 * @param aArray Token array
265 * @param aAttribute Attribute string (in cleanup stack)
266 * @param aValue Value string (in cleanup stack)
268 void CreateAttributeAndValueStringsLC( RArray<TPtrC8>& aArray,
273 * Checks if the value is among the valid orient attributes
275 * @param aValue Value string
277 void CheckValidOrientL( const TDesC8& aValue );
280 * Checks if the value is valid language attribute as
281 * specified in RFC 3066
283 * @param aValue Value string
285 void CheckValidLangStrL( const TDesC8& aValue );
288 * Checks if the value is valid framerate attribute
290 * @param aValue Value string
292 void CheckValidFrameRateL( const TDesC8& aValue );
295 * Checks if the value is among valid uri value for control attribute
297 * @param aValue Value string
299 void CheckValidControlL( const TDesC8& aValue );
302 * Checks if the value is valid value for group attribute as
303 * specified in RFC 3388
305 * @param aValue Value string
307 void CheckValidGroupL( const TDesC8& aValue );
310 * Checks if the value is valid value for des attribute as
311 * specified in RFC 3312
313 * @param aValue Value string
315 void CheckValidDesL( const TDesC8& aValue );
318 * Checks if the value is valid value for curr and conf attribute as
319 * specified in RFC 3312
321 * @param aValue Value string
323 void CheckValidCurrAndConfL( const TDesC8& aValue );
326 * Checks if value is included in the list of predefined values
328 * @param aItemsCount Predefined values count
329 * @param aValuesList List of predefined values
330 * @param aValue Value string
332 void ValidValueInListL( TInt aItemsCount,
333 const TText8* const aValuesList[],
334 const TDesC8& aValue );
337 * Checks if the value is valid value for range attribute as
338 * specified in RFC 2326
340 * @param aValue Value string
342 void CheckValidRangeL( const TDesC8& aValue );
346 * Checks if the value is valid rtpmap string
348 * @param aValue Value string
350 void CheckValidRtpmapL( const TDesC8& aValue );
353 * Checks if the value is valid fmtp string
355 * @param aValue Value string
357 void CheckValidFmtpL( const TDesC8& aValue );
360 * Set attribute and values. Attribute is not one of predefined ones.
362 * @param aAttribute Attribute string (in cleanup stack)
363 * @param aValue Value string
365 void SetNotPredefinedAttributeL( const TDesC8& aAttribute,
366 const TDesC8& aValue );
368 void CreateAttributeFieldPtrsL();
370 inline CSdpAttributeFieldPtrs& AttributeFieldPtrs();
372 inline const CSdpAttributeFieldPtrs& AttributeFieldPtrs() const;
384 // Flag indicating if the attribute is a property attribute
385 TBool iPropertyAttribute;
391 #endif // CSDPATTRIBUTEFIELD_H