1.1 --- a/epoc32/include/sdpmediafield.h Tue Mar 16 16:12:26 2010 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,445 +0,0 @@
1.4 -/*
1.5 -* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 -* All rights reserved.
1.7 -* This component and the accompanying materials are made available
1.8 -* 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
1.9 -* which accompanies this distribution, and is available
1.10 -* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 -*
1.12 -* Initial Contributors:
1.13 -* Nokia Corporation - initial contribution.
1.14 -*
1.15 -* Contributors:
1.16 -*
1.17 -* Description:
1.18 -* Name : SdpMediaField.h
1.19 -* Part of : SDP Codec
1.20 -* Interface : SDK API, SDP Codec API
1.21 -* Version : 1.0
1.22 -*
1.23 -*/
1.24 -
1.25 -
1.26 -
1.27 -#ifndef CSDPMEDIAFIELD_H
1.28 -#define CSDPMEDIAFIELD_H
1.29 -
1.30 -// INCLUDES
1.31 -#include <e32base.h>
1.32 -#include "_sdpdefs.h"
1.33 -#include <stringpool.h>
1.34 -
1.35 -// FORWARD DECLARATIONS
1.36 -class RReadStream;
1.37 -class RWriteStream;
1.38 -class CSdpConnectionField;
1.39 -class CSdpBandwidthField;
1.40 -class CSdpAttributeField;
1.41 -class CSdpKeyField;
1.42 -class CSdpFmtAttributeField;
1.43 -class CSdpCodecParseUtil;
1.44 -
1.45 -// CLASS DECLARATION
1.46 -/**
1.47 - * @publishedAll
1.48 - * @released
1.49 - *
1.50 - * This class encapsulates the media description field and related media
1.51 - * specific subfields of the Session Description Protocol.
1.52 - *
1.53 - * The normative reference for correct formatting and values is
1.54 - * draft-ietf-mmusic-sdp-new-14 unless specified otherwise in
1.55 - * member documentation. The implementation supports this normative
1.56 - * reference, but does not enforce it fully.
1.57 - *
1.58 - * @lib sdpcodec.lib
1.59 - */
1.60 -class CSdpMediaField : public CBase
1.61 - {
1.62 -
1.63 - public:
1.64 -
1.65 -
1.66 - public: // Constructors and destructor
1.67 - /**
1.68 - * Constructs a new media description field.
1.69 - *
1.70 - * @param aText A correctly formatted media field
1.71 - * terminated by a CRLF followed by zero or more media
1.72 - * attribute fields separated by a CRLF.
1.73 - * @param aRecurse If ETrue, attempts to construct also media
1.74 - * attributes following the CRLF terminating the media field.
1.75 - * @return a new instance.
1.76 - */
1.77 - IMPORT_C static CSdpMediaField* DecodeL(const TDesC8& aText,
1.78 - TBool aRecurse = ETrue);
1.79 -
1.80 - /**
1.81 - * Constructs a new media description field and adds the pointer to
1.82 - * the cleanup stack.
1.83 - *
1.84 - * @param aText A correctly formatted media field
1.85 - * terminated by a CRLF followed by zero or more media
1.86 - * attribute fields separated by a CRLF.
1.87 - * @param aRecurse If ETrue, attempts to construct also media
1.88 - * attributes following the CRLF terminating the media field.
1.89 - * @return a new instance.
1.90 - */
1.91 - IMPORT_C static CSdpMediaField* DecodeLC(const TDesC8& aText,
1.92 - TBool aRecurse = ETrue);
1.93 -
1.94 - /**
1.95 - * Constructs a new media description field.
1.96 - * The optional portcount component of the field is initialized to 1.
1.97 - *
1.98 - * @param aMedia A valid media type name.
1.99 - * @param aPort Port number.
1.100 - * @param aProtocol A valid media protocol name.
1.101 - * @param aFormatList A valid format list.
1.102 - * @return a new instance.
1.103 - */
1.104 - IMPORT_C static CSdpMediaField* NewL(RStringF aMedia,
1.105 - TUint aPort,
1.106 - RStringF aProtocol,
1.107 - const TDesC8& aFormatList);
1.108 -
1.109 - /**
1.110 - * Constructs a new media description field and adds the pointer to
1.111 - * the cleanup stack.
1.112 - * The optional portcount component of the field is initialized to 1.
1.113 - *
1.114 - * @param aMedia A valid media type name.
1.115 - * @param aPort Port number.
1.116 - * @param aProtocol A valid media protocol name.
1.117 - * @param aFormatList A valid format list.
1.118 - * @return a new instance.
1.119 - */
1.120 - IMPORT_C static CSdpMediaField* NewLC(RStringF aMedia,
1.121 - TUint aPort,
1.122 - RStringF aProtocol,
1.123 - const TDesC8& aFormatList);
1.124 -
1.125 - /**
1.126 - * Deletes the resources held by the instance.
1.127 - */
1.128 - IMPORT_C ~CSdpMediaField();
1.129 -
1.130 - public: // New functions
1.131 - /**
1.132 - * Outputs the field formatted according to SDP syntax and including
1.133 - * the terminating CRLF. Optionally output also the related media
1.134 - * level fields.
1.135 - *
1.136 - * @param aStream Stream used for output. On return the
1.137 - * stream includes correctly formatted media field with
1.138 - * media part fields if aRecurse is defined to ETrue.
1.139 - * @param aRecurse Flag to specify whether to output media
1.140 - * attributes also (ETrue) or only the media field (EFalse).
1.141 - */
1.142 - IMPORT_C void
1.143 - EncodeL(RWriteStream& aStream, TBool aRecurse = ETrue) const;
1.144 -
1.145 - /**
1.146 - * Creates a new instance that is equal to the target.
1.147 - * Optionally also related subfields are cloned.
1.148 - *
1.149 - * @param aRecurse Flag to specify whether to clone subfields
1.150 - * also (ETrue) or only the media field (EFalse).
1.151 - * @return a new instance.
1.152 - */
1.153 - IMPORT_C CSdpMediaField * CloneL(TBool aRecurse = ETrue) const;
1.154 -
1.155 - /**
1.156 - * Compares this instance to another for equality. Subfields are
1.157 - * included in the comparison if present.
1.158 - *
1.159 - * @param aObj The instance to compare to.
1.160 - * @return ETrue if equal, EFalse if not.
1.161 - */
1.162 - IMPORT_C TBool operator == (const CSdpMediaField& aObj) const;
1.163 -
1.164 - /**
1.165 - * Checks the consistency between the media field and it's subfields.
1.166 - * In particular, this function checks that each format specific
1.167 - * attribute is related to a format in the format list of the
1.168 - * media field.
1.169 - *
1.170 - * @return ETrue if media description is consistent and EFalse if not.
1.171 - */
1.172 - IMPORT_C TBool IsValid() const;
1.173 -
1.174 - /**
1.175 - * Gets the media type.
1.176 - *
1.177 - * @return The media type.
1.178 - */
1.179 - IMPORT_C RStringF Media() const;
1.180 -
1.181 - /**
1.182 - * Sets the media type.
1.183 - *
1.184 - * @param aMedia The media type.
1.185 - * @leave KErrSdpCodecMediaField if aMedia is not valid character
1.186 - */
1.187 - IMPORT_C void SetMediaL(RStringF aMedia);
1.188 -
1.189 - /**
1.190 - * Gets the media protocol.
1.191 - *
1.192 - * @return The media protocol.
1.193 - */
1.194 - IMPORT_C RStringF Protocol() const;
1.195 -
1.196 - /**
1.197 - * Sets the media protocol.
1.198 - *
1.199 - * @param aProtocol The media protocol.
1.200 - * @leave KErrSdpCodecMediaField if
1.201 - * aProtocol containing two elements divided by slash are not
1.202 - * valid tokens.
1.203 - */
1.204 - IMPORT_C void SetProtocolL(RStringF aProtocol);
1.205 -
1.206 - /**
1.207 - * Gets the port number.
1.208 - *
1.209 - * @return The port number.
1.210 - */
1.211 - IMPORT_C TUint Port() const;
1.212 -
1.213 - /**
1.214 - * Sets the port number.
1.215 - *
1.216 - * @param aPort The port number.
1.217 - * @leave KErrSdpCodecMediaField if port is not valid number as
1.218 - * defined in draft-ietf-mmusic-sdp-new-14
1.219 - */
1.220 - IMPORT_C void SetPortL(TUint aPort);
1.221 -
1.222 - /**
1.223 - * Gets the port count.
1.224 - *
1.225 - * @return The port count.
1.226 - */
1.227 - IMPORT_C TUint PortCount() const;
1.228 -
1.229 - /**
1.230 - * Sets the port count.
1.231 - *
1.232 - * @param aCount The port count that must be greater than zero.
1.233 - * @leave KErrSdpCodecMediaField if aCount equals to zero.
1.234 - */
1.235 - IMPORT_C void SetPortCountL(TUint aCount);
1.236 -
1.237 - /**
1.238 - * Gets the format list.
1.239 - *
1.240 - * @return The format list.
1.241 - */
1.242 - IMPORT_C const TDesC8& FormatList() const;
1.243 -
1.244 - /**
1.245 - * Sets the format list.
1.246 - * The format list should contain one or more format tokens separated
1.247 - * by a single whitespace character.
1.248 - *
1.249 - * @param aValue A valid format list.
1.250 - * @leave KErrSdpCodecMediaField if aValue contains invalid tokens
1.251 - */
1.252 - IMPORT_C void SetFormatListL(const TDesC8& aValue);
1.253 -
1.254 - /**
1.255 - * Return the media level info field value.
1.256 - *
1.257 - * @return The value or an empty descriptor if not present.
1.258 - */
1.259 - IMPORT_C const TDesC8& Info() const;
1.260 -
1.261 - /**
1.262 - * Sets the media level info field value.
1.263 - *
1.264 - * @param aValue A valid info field value.
1.265 - * @leave KErrSdpCodecMediaInfoField if aValue is not KNullDesC8 or
1.266 - * aValue includes invalid byte strings (´\0´, ´\n´, ´\r´).
1.267 - */
1.268 - IMPORT_C void SetInfoL(const TDesC8& aValue);
1.269 -
1.270 - /**
1.271 - * Gets the media level encryption key field.
1.272 - * Note, that the ownership is not transferred and
1.273 - * the instance must not be deleted by the caller.
1.274 - *
1.275 - * @return Encryption key field or null if not present.
1.276 - */
1.277 - IMPORT_C CSdpKeyField* Key();
1.278 -
1.279 - /**
1.280 - * Gets the media level encryption key field.
1.281 - *
1.282 - * @return Encryption key field or null if not present.
1.283 - */
1.284 - IMPORT_C const CSdpKeyField* Key() const;
1.285 -
1.286 - /**
1.287 - * Sets or removes the media level encryption key field.
1.288 - *
1.289 - * @param aObj The new key field or null if field is
1.290 - * to be removed. Ownership of the referenced object
1.291 - * is transferred to the media field instance.
1.292 - */
1.293 - IMPORT_C void SetKey(CSdpKeyField* aObj);
1.294 -
1.295 - /**
1.296 - * Gets the set of media format level attributes.
1.297 - * This array is used directly for element insertion and removal.
1.298 - *
1.299 - * The objects referenced from the array are owned by the media
1.300 - * field instance and must not be deleted. An object can be
1.301 - * removed from the media description by setting the corresponding
1.302 - * element to zero. By doing so, the calling party receives ownership
1.303 - * of the removed object.
1.304 - *
1.305 - * @return The set of media format level attributes.
1.306 - */
1.307 - IMPORT_C RPointerArray<CSdpFmtAttributeField>& FormatAttributeFields();
1.308 -
1.309 - /**
1.310 - * Gets the set of media level, format independent attributes.
1.311 - * This array is used directly for element insertion and removal.
1.312 - *
1.313 - * The objects referenced from the array are owned by the media
1.314 - * field instance and must not be deleted. An object can be
1.315 - * removed from the media description by setting the corresponding
1.316 - * element to zero. By doing so, the calling party receives ownership
1.317 - * of the removed object.
1.318 - *
1.319 - * @return The set of media level attributes.
1.320 - */
1.321 - IMPORT_C RPointerArray<CSdpAttributeField>& AttributeFields();
1.322 -
1.323 - /**
1.324 - * Gets the set of media level bandwidth fields.
1.325 - * This array is used directly for element insertion and removal.
1.326 - *
1.327 - * The objects referenced from the array are owned by the media
1.328 - * field instance and must not be deleted. An object can be
1.329 - * removed from the media description by setting the corresponding
1.330 - * element to zero. By doing so, the calling party receives ownership
1.331 - * of the removed object.
1.332 - *
1.333 - * @return The set of media level bandwidth fields.
1.334 - */
1.335 - IMPORT_C RPointerArray<CSdpBandwidthField>& BandwidthFields();
1.336 -
1.337 - /**
1.338 - * Gets the set of media level connection fields.
1.339 - * This array is used directly for element insertion and removal.
1.340 - *
1.341 - * The objects referenced from the array are owned by the media
1.342 - * field instance and must not be deleted. An object can be
1.343 - * removed from the media description by setting the corresponding
1.344 - * element to zero. By doing so, the calling party receives ownership
1.345 - * of the removed object.
1.346 - *
1.347 - * @return The set of media level connection fields.
1.348 - */
1.349 - IMPORT_C RPointerArray<CSdpConnectionField>& ConnectionFields();
1.350 -
1.351 - /**
1.352 - * Removes a specific format from the media description.
1.353 - * The function will remove the named format from the format list if
1.354 - * found and then delete all format level attributes of type
1.355 - * CSdpFmtAttributeField related to the removed format.
1.356 - *
1.357 - * @param aFormat The name of the format to remove.
1.358 - */
1.359 - IMPORT_C void RemoveFormatL(const TDesC8& aFormat);
1.360 -
1.361 - /**
1.362 - * Removes all formats except one from the media description.
1.363 - * The function will set the format list to only contain the one
1.364 - * format to keep and then delete all format level attributes that
1.365 - * are related to the removed formats. If the format is not found
1.366 - * from the format list, it is added there. If there are no format
1.367 - * level attributes for the specified format, the format level
1.368 - * attribute set will be empty.
1.369 - *
1.370 - * @param aFormat The name of the format to keep after
1.371 - * removing all others.
1.372 - */
1.373 - IMPORT_C void KeepFormatL(const TDesC8& aFormat);
1.374 -
1.375 - /**
1.376 - * Sets this media description into rejected state.
1.377 - * The rejected state is defined by the offer/answer model in
1.378 - * RFC3264. The function sets the port number to 0 and removes
1.379 - * all formats except one. The remaining format is determined
1.380 - * by the implementation.
1.381 - */
1.382 - IMPORT_C void RejectMedia();
1.383 -
1.384 - public:
1.385 - /**
1.386 - * Shows if contact is present
1.387 - *
1.388 - * @return ETrue if contact present, otherwise EFalse
1.389 - */
1.390 - TBool IsContactPresent() const;
1.391 -
1.392 - /**
1.393 - * Externalizes the object to stream
1.394 - *
1.395 - * @param aStream Stream where the object's state will be stored
1.396 - */
1.397 - void ExternalizeL(RWriteStream& aStream) const;
1.398 -
1.399 - /**
1.400 - * Creates object from the stream data
1.401 - *
1.402 - * @param aStream Stream where the object's state will be read
1.403 - * @return Initialized object
1.404 - */
1.405 - static CSdpMediaField* InternalizeL(RReadStream& aStream);
1.406 -
1.407 - private:
1.408 - CSdpMediaField();
1.409 - void ConstructL();
1.410 - void ConstructL(TBool aRecurse);
1.411 - void ConstructL(RStringF aMedia, TUint aPort, RStringF aProtocol,
1.412 - const TDesC8& aFormatList);
1.413 -
1.414 - void ConstructL(const CSdpMediaField& aSdpMediaField);
1.415 - void DoInternalizeL(RReadStream& aStream);
1.416 - void ParseL (const TDesC8& aText);
1.417 - void ParseMediaL();
1.418 - void ParseInformationL();
1.419 - void ParseConnectionL();
1.420 - void ParseBandwithL();
1.421 - void ParseEncryptionKeyL();
1.422 - void ParseAttributeFieldsL();
1.423 - TDesC8& GetTokenFromStreamL(RReadStream& aStream);
1.424 -
1.425 -
1.426 - CSdpMediaField(const CSdpMediaField&); // Hidden.
1.427 - CSdpMediaField& operator = (const CSdpMediaField&); // Hidden
1.428 -
1.429 - private: // Data
1.430 - HBufC8* iInfo;
1.431 - CSdpKeyField* iSdpKeyField;
1.432 - RArray<TPtrC8> iElementArray;
1.433 - RStringPool iPool;
1.434 - TBool iRecurse;
1.435 - RStringF iMedia;
1.436 - RStringF iProtocol;
1.437 - TUint iPort;
1.438 - TUint iPortCount;
1.439 - HBufC8* iFormatList;
1.440 - RPointerArray<CSdpBandwidthField>* iBandwidthFields;
1.441 - RPointerArray<CSdpAttributeField>* iAttributeFields;
1.442 - RPointerArray<CSdpConnectionField>* iConnectionFields;
1.443 - RPointerArray<CSdpFmtAttributeField>* iFmtAttrFields;
1.444 - HBufC8* iToken;
1.445 - CSdpCodecParseUtil* iSdpCodecParseUtil;
1.446 - };
1.447 -
1.448 -#endif // CSDPMEDIAFIELD_H