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 : SdpDocument.h
17 * Interface : SDK API, SDP Codec API
24 #ifndef CSDPDOCUMENT_H
25 #define CSDPDOCUMENT_H
30 #include <stringpool.h>
32 // FORWARD DECLARATIONS
38 class CSdpOriginField;
41 class CSdpConnectionField;
42 class CSdpBandwidthField;
44 class CSdpAttributeField;
47 class CSdpCodecParseUtil;
54 * This class encapsulates the Session Description Protocol (SDP) document.
55 * The SDP document is a collection of SDP fields and related values
56 * describing a session.
58 * The normative reference for correct formatting and values is
59 * draft-ietf-mmusic-sdp-new-14 unless specified otherwise in
60 * member documentation. The implementation supports this normative
61 * reference, but does not enforce it fully.
65 class CSdpDocument : public CBase
67 public: // Constructors and destructor
69 * Constructs a new SDP document.
71 * @param aText A string containing a correctly formatted SDP document.
72 * @return a new instance.
74 IMPORT_C static CSdpDocument* DecodeL(const TDesC8& aText);
77 * Constructs a new SDP document and adds the pointer to the cleanup stack.
79 * @param aText A string containing a correctly formatted SDP document.
80 * @return a new instance.
82 IMPORT_C static CSdpDocument* DecodeLC(const TDesC8& aText);
85 * Constructs a new, empty SDP document.
86 * The instance will have the following initial values:
91 * @return a new instance.
93 IMPORT_C static CSdpDocument* NewL();
96 * Constructs a new, empty SDP document document and adds the pointer to
98 * The instance will have the following initial values:
103 * @return a new instance.
105 IMPORT_C static CSdpDocument* NewLC();
108 * Deletes the resources held by the instance.
110 IMPORT_C ~CSdpDocument();
114 * Externalizes the object state in an internal, memory optimized format.
116 * @param aStream The output stream.
118 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
121 * Internalizes the object state from an internal, memory optimized format.
123 * @param aStream The input stream.
124 * @return A new SDP document internalized from the input stream.
126 IMPORT_C static CSdpDocument* InternalizeL(RReadStream& aStream);
129 * Outputs the SDP document formatted according to SDP syntax.
130 * It is possible to output the document even though it is
131 * incomplete in the sense that all mandatory SDP fields are
132 * not present.When creating an SDP document to be used e.g.
133 * as part of SIP signalling, caller should first ensure the
134 * validity of the document using the IsValid() function.
136 * @param aStream Stream used for output. On return the
137 * stream includes correctly formatted SDP description.
139 IMPORT_C void EncodeL(RWriteStream& aStream) const;
142 * Creates a new instance that is equal to the target.
144 * @return a new instance.
146 IMPORT_C CSdpDocument* CloneL() const;
149 * Checks if the instance represents a valid SDP document.
151 * @return ETrue if SDP document is valid and EFalse if not.
153 IMPORT_C TBool IsValid() const;
156 * Gets the SDP version used in the version field.
157 * Note, that the current implementation supports only version number 0.
159 * @return The SDP version number.
161 IMPORT_C TUint SdpVersion() const;
164 * Gets a reference to the session origin field.
165 * Note, that the ownership is not transferred and
166 * the instance must not be deleted by the caller.
168 * @return The origin field or zero if not present.
170 IMPORT_C CSdpOriginField* OriginField();
173 * Gets a reference to the session origin field.
175 * @return The origin field or zero if not present.
177 IMPORT_C const CSdpOriginField* OriginField() const;
180 * Sets or removes the session origin field.
181 * Note, that the ownership of the argument is
182 * transferred to the SDP document object.
184 * @param aObj New origin field or null to remove the field.
186 IMPORT_C void SetOriginField(CSdpOriginField* aObj);
189 * Gets the session name field value.
191 * @return The session name or empty descriptor if not present.
193 IMPORT_C const TDesC8& SessionName() const;
196 * Sets the session name field value.
198 * @param aValue Valid session name value.
199 * Note that an empty value is not accepted.
200 * @leave KErrSdpCodecSessionField if
201 * aValue is not empty or aValue includes invalid byte strings
202 * (´\0´, ´\n´, ´\r´).
204 IMPORT_C void SetSessionNameL(const TDesC8& aValue);
207 * Gets the session information field value.
209 * @return Info field value or an empty descriptor if not present.
211 IMPORT_C const TDesC8& Info() const;
214 * Sets or removes the session information field value.
216 * @param New field value or an empty descriptor to remove the field.
217 * @leave KErrSdpCodecInfoField if aValue is not empty or aValue includes
218 * invalid byte strings (´\0´, ´\n´, ´\r´).
220 IMPORT_C void SetInfoL(const TDesC8& aValue);
223 * Gets the session URI field value.
224 * Note, that the ownership is not transferred and
225 * the instance must not be deleted by the caller.
227 * @return CUri8*: Session URI or zero if the field is not present.
229 IMPORT_C CUri8* Uri();
232 * Gets the session URI field value.
234 * @return Session URI or zero if the field is not present.
236 IMPORT_C const CUri8* Uri() const;
239 * Sets or removes the session level URI field.
240 * Note, that the ownership of the argument is
241 * transferred to the SDP document object.
243 * @param New value of the field or zero to remove the field.
245 IMPORT_C void SetUri(CUri8* aValue);
248 * Gets the set of session level email field values. This array is used to
249 * add and remove fields into the document.
250 * Note, that only correctly formatted email field values should be placed
251 * into the array. Empty values in the array will be ignored.
253 * @return Email fields in array or empty array if no email fields.
255 IMPORT_C CDesC8Array& EmailFields();
258 * Gets the set of session level phone field values. This array is used to
259 * add and remove fields into the document.
260 * Note, that only correctly formatted phone field values should be placed
261 * into the array. Empty values in the array will be ignored.
263 * @return Phone fields in array or empty array if no phone fields.
265 IMPORT_C CDesC8Array& PhoneFields();
268 * Gets the session level connection field.
269 * Note, that the ownership is not transferred and the instance must not be
270 * deleted by the caller.
272 * @return Connection field or zero if not present.
274 IMPORT_C CSdpConnectionField* ConnectionField();
277 * Gets the session level connection field.
279 * @return Connection field or zero if not present.
281 IMPORT_C const CSdpConnectionField* ConnectionField() const;
284 * Sets or removes the session level connection field.
285 * Note, that the ownership of the argument is
286 * transferred to the SDP document object.
288 * @param New connection field or zero to remove the field.
290 IMPORT_C void SetConnectionField(CSdpConnectionField* aObj);
293 * Gets the possibly empty set of session level bandwidth fields.
294 * This array is used directly for element insertion and removal.
295 * The array may contain zero references and these are ignored.
297 * The objects referenced from the array are owned by the document
298 * instance and must not be deleted. An object can be removed from
299 * the document by setting the corresponding element to zero. By
300 * doing so, the calling party receives ownership of the removed object.
302 * @return Set of bandwidth fields.
304 IMPORT_C RPointerArray<CSdpBandwidthField>& BandwidthFields();
307 * Gets the set of session level time description fields.
308 * This array is used directly for element insertion and removal.
309 * There must be at least one time description field in a valid SDP
310 * document.The array may contain zero references and these are ignored.
312 * The objects referenced from the array are owned by the document
313 * instance and must not be deleted. An object can be removed from the
314 * document by setting the corresponding element to zero. By doing so,
315 * the calling party receives ownership of the removed object.
317 * @return Set of time fields.
319 IMPORT_C RPointerArray<CSdpTimeField>& TimeFields();
322 * Gets the zone adjustments field value.
324 * @return The field value or an empty descriptor if the
325 * field is not present.
327 IMPORT_C const TDesC8& ZoneAdjustments() const;
330 * Sets the zone adjustments field value.
332 * @param aValue A valid field value or an empty descriptor
333 * if field is not present.
335 IMPORT_C void SetZoneAdjustmentsL(const TDesC8& aValue);
338 * Gets the session level encryption key field.
339 * Note, that the ownership is not transferred and
340 * the instance must not be deleted by the caller.
342 * @return The encryption key or zero if not present.
344 IMPORT_C CSdpKeyField* Key();
347 * Gets the session level encryption key field.
349 * @return The encryption key or zero if not present.
351 IMPORT_C const CSdpKeyField* Key() const;
354 * Sets or removes the encryption key field.
355 * Note, that the ownership of the argument is
356 * transferred to the SDP document object.
358 * @param aObj New value of the field or zero to remove the field.
360 IMPORT_C void SetKey(CSdpKeyField* aObj);
363 * Gets the possibly empty set of session level attribute fields.
364 * This array is used directly for element insertion and removal.
365 * The array may contain zero references and these are ignored.
367 * The objects referenced from the array are owned by the document
368 * instance and must not be deleted. An object can be removed from the
369 * document by setting the corresponding element to zero. By doing so,
370 * the calling party receives ownership of the removed object.
372 * @return Set of session level attributes.
374 IMPORT_C RPointerArray<CSdpAttributeField>& AttributeFields();
377 * Gets the possibly empty set of media description fields.
378 * This array is used directly for element insertion and removal.
379 * Note, that media level attributes and fields are managed
380 * through the corresponding media field instance and not through
381 * the document instance.
382 * The array may contain zero references and these are ignored.
384 * The objects referenced from the array are owned by the document
385 * instance and must not be deleted. An object can be removed from the
386 * document by setting the corresponding element to zero. By doing so,
387 * the calling party receives ownership of the removed object.
389 * @return Set of media description fields.
391 IMPORT_C RPointerArray<CSdpMediaField>& MediaFields();
396 void ConstructL(const CSdpDocument& aSdpDocument);
397 void DoInternalizeL(RReadStream& aStream);
399 void ParseL (const TDesC8& aText);
400 void ParseSessionVersionL();
401 void ParseSessionOwnerL();
402 void ParseSessionNameL();
403 void ParseSessionInformationL();
407 void ParseConnectionL();
408 void ParseBandwidthL();
409 void ParseTimeFieldL();
410 void ParseZoneAdjustmentL();
411 void ParseEncryptionKeyL();
412 void ParseAttributeFieldL();
413 void ParseMediaLevelL ();
414 void ExternalizeDesCArrayL(CDesC8ArraySeg& aArray,
415 RWriteStream& aStream) const;
416 void EncodeDesCArrayL(CDesC8ArraySeg& aArray,TInt aIndex,
417 RWriteStream& aStream) const;
419 TDesC8& GetTokenFromStreamL(RReadStream& aStream);
421 CSdpDocument(const CSdpDocument&); // Hidden.
422 CSdpDocument& operator = (const CSdpDocument&); // Hidden
427 HBufC8* iSessionName;
428 HBufC8* iZoneAdjustments;
429 CSdpKeyField* iSdpKeyField;
430 CSdpOriginField* iSdpOriginField;
431 CSdpConnectionField* iSdpConnectionField;
433 RPointerArray<CSdpTimeField>* iTimeFields;
434 RPointerArray<CSdpBandwidthField>* iBandwidthFields;
435 RPointerArray<CSdpAttributeField>* iAttributeFields;
436 RPointerArray<CSdpMediaField>* iMediaFields;
438 CDesC8ArraySeg* iEmailFields;
439 CDesC8ArraySeg* iPhoneFields;
442 CSdpCodecParseUtil* iSdpCodecParseUtil;
445 #endif // CSDPDOCUMENT_H