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 : 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"
32 // FORWARD DECLARATIONS
35 class CSdpFmtAttributeField;
36 class CSdpAttributeFieldPtrs;
43 * This class encapsulates the attribute field of Session Description Protocol
44 * for media and session level attributes. Media format/payload type level
45 * attributes are supported by the CSdpFmtAttributeField class.
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.
54 class CSdpAttributeField : public CBase
56 public: // Constructors and destructor
59 * Constructs a new attribute field.
61 * @param aText A string containing a correctly
62 * formatted field value terminated by a CRLF.
63 * @return a new instance.
65 IMPORT_C static CSdpAttributeField* DecodeL( const TDesC8& aText );
68 * Constructs a new attribute field and adds the pointer to the
71 * @param aTest A string containing a correctly
72 * formatted field value terminated by a CRLF.
73 * @return a new instance.
75 IMPORT_C static CSdpAttributeField* DecodeLC( const TDesC8& aText );
78 * Constructs a new attribute field.
80 * @param aAttribute The attribute name. It can be a pre-
81 * defined name in the SDP string pool or defined by the
83 * @param aValue A valid attribute value or an empty
84 * descriptor to omit the value part.
85 * @return a new instance.
87 IMPORT_C static CSdpAttributeField* NewL(
88 RStringF aAttribute, const TDesC8& aValue );
91 * Constructs a new attribute field and adds the pointer to the
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 aValue A valid attribute value or an empty
97 * descriptor to omit the value part.
98 * @return a new instance.
100 IMPORT_C static CSdpAttributeField* NewLC(
101 RStringF aAttribute, const TDesC8& aValue );
104 * Deletes the resources held by the instance.
106 IMPORT_C ~CSdpAttributeField();
108 public: // New functions
111 * Outputs the field formatted according to SDP syntax and including
112 * the terminating CRLF.
114 * @param aStream Stream used for output. On return the
115 * stream includes correctly formatted attribute field.
117 IMPORT_C void EncodeL( RWriteStream& aStream ) const;
120 * Creates a new instance that is equal to the target.
122 * @return a new instance.
124 IMPORT_C CSdpAttributeField* CloneL() const;
127 * Compares this instance to another for equality.
129 * @param aObj: The instance to compare to.
130 * @return ETrue if equal, EFalse if not.
132 IMPORT_C TBool operator == ( const CSdpAttributeField& aObj ) const;
135 * Gets the attribute name.
137 * @return The attribute name. The name can be pre-defined
138 * name in the SDP string table or defined by the client.
140 IMPORT_C RStringF Attribute() const;
143 * Gets the attribute.
145 * @return The value or an empty descriptor if there is no value part.
147 IMPORT_C const TDesC8& Value() const;
150 * Sets the attribute and attribute value.
152 * @param aAttribute A valid attribute name. It can be a
153 * pre-defined name in the SDP string pool or
154 * defined by the client.
155 * @param aValue A valid attribute value or an empty
156 * descriptor to omit the value part.
157 * @leave KErrSdpCodecAttributeField if the attribute part is not
158 * pre-defined EAttributeFmtp or EAttributeRtpmap.
160 IMPORT_C void SetL( RStringF aAttribute, const TDesC8& aValue );
163 * Assigns attribute to the format level attribute.
164 * In the final output the attribute will placed after format level
167 * @param aFmtAttribute A format level
168 * attribute this attribute is assigned to.
170 IMPORT_C void AssignTo(const CSdpFmtAttributeField& aFmtAttribute);
173 * Test if the attribute belongs to the given format level attribute.
174 * Note, that the check can be true for the media level paremeter if
175 * it appears after the last format level attribute.
177 * @param aFmtAttribute: A format level
178 * attribute this attribute belongs to.
179 * @return ETrue if attribute belongs to the format level attribute,
182 IMPORT_C TBool BelongsTo(const CSdpFmtAttributeField& aFmtAttribute) const;
184 public: // Internal to codec
187 * Externalizes the object to stream
189 * @param aStream Stream where the object's state will be stored
191 void ExternalizeL( RWriteStream& aStream ) const;
194 * Creates object from the stream data
196 * @param aStream Stream where the object's state will be read
197 * @return Initialized object
199 static CSdpAttributeField* InternalizeL( RReadStream& aStream );
202 * Informs if the attribute belongs to any format level attribute.
204 * @return ETrue if attribute belongs to any format level
205 * attribute, EFalse otherwise.
207 TBool IsFmtAttribute();
209 private: // Constructors
214 CSdpAttributeField();
217 * Second phase constructor
219 * @param aText Text string ending to LF character
221 void ConstructL( const TDesC8& aText );
224 * Second phase constructor
226 * @param aAttribute Attribute identifier
227 * @param aValue Value of the attribute of KNullDesC8
229 void ConstructL( RStringF aAttribute, const TDesC8& aValue );
234 * Verifies that attribute is valid property attribute and initializes
235 * the member variables of class accordingly
237 * @param aAttribute Attribute in descriptor
239 void FormatProperyAttributeL( const TDesC8& aAttribute );
242 * Verifies that attribute is valid value attribute and initializes
243 * the member variables of class accordingly
245 * @param aArray Array of the attributes
247 void FormatValueAttributeL( const TDesC8& aAttribute,
248 const TDesC8& aValue );
251 * Verifies that the value is valid for the attribute
253 * @param aAttribute The attribute
254 * @param aArray Array containing the values (and attribute)
256 void VerifyValueAttributeL( SdpCodecStringConstants::TStrings aString,
257 const TDesC8& aValue );
260 * Forms attribute and value strings out of the token array
261 * and pushes both (aAttribute & aValue) into cleanup stack
263 * @param aArray Token array
264 * @param aAttribute Attribute string (in cleanup stack)
265 * @param aValue Value string (in cleanup stack)
267 void CreateAttributeAndValueStringsLC( RArray<TPtrC8>& aArray,
272 * Checks if the value is among the valid orient attributes
274 * @param aValue Value string
276 void CheckValidOrientL( const TDesC8& aValue );
279 * Checks if the value is valid language attribute as
280 * specified in RFC 3066
282 * @param aValue Value string
284 void CheckValidLangStrL( const TDesC8& aValue );
287 * Checks if the value is valid framerate attribute
289 * @param aValue Value string
291 void CheckValidFrameRateL( const TDesC8& aValue );
294 * Checks if the value is among valid uri value for control attribute
296 * @param aValue Value string
298 void CheckValidControlL( const TDesC8& aValue );
301 * Checks if the value is valid value for group attribute as
302 * specified in RFC 3388
304 * @param aValue Value string
306 void CheckValidGroupL( const TDesC8& aValue );
309 * Checks if the value is valid value for des attribute as
310 * specified in RFC 3312
312 * @param aValue Value string
314 void CheckValidDesL( const TDesC8& aValue );
317 * Checks if the value is valid value for curr and conf attribute as
318 * specified in RFC 3312
320 * @param aValue Value string
322 void CheckValidCurrAndConfL( const TDesC8& aValue );
325 * Checks if value is included in the list of predefined values
327 * @param aItemsCount Predefined values count
328 * @param aValuesList List of predefined values
329 * @param aValue Value string
331 void ValidValueInListL( TInt aItemsCount,
332 const TText8* const aValuesList[],
333 const TDesC8& aValue );
336 * Checks if the value is valid value for range attribute as
337 * specified in RFC 2326
339 * @param aValue Value string
341 void CheckValidRangeL( const TDesC8& aValue );
345 * Checks if the value is valid rtpmap string
347 * @param aValue Value string
349 void CheckValidRtpmapL( const TDesC8& aValue );
352 * Checks if the value is valid fmtp string
354 * @param aValue Value string
356 void CheckValidFmtpL( const TDesC8& aValue );
359 * Set attribute and values. Attribute is not one of predefined ones.
361 * @param aAttribute Attribute string (in cleanup stack)
362 * @param aValue Value string
364 void SetNotPredefinedAttributeL( const TDesC8& aAttribute,
365 const TDesC8& aValue );
367 void CreateAttributeFieldPtrsL();
369 inline CSdpAttributeFieldPtrs& AttributeFieldPtrs();
371 inline const CSdpAttributeFieldPtrs& AttributeFieldPtrs() const;
373 void __DbgTestInvariant() const;
384 // Flag indicating if the attribute is a property attribute
385 TBool iPropertyAttribute;
391 #endif // CSDPATTRIBUTEFIELD_H