epoc32/include/mw/sdpmediafield.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@2
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description:
williamr@2
    15
* Name          : SdpMediaField.h
williamr@2
    16
* Part of       : SDP Codec
williamr@2
    17
* Interface     : SDK API, SDP Codec API
williamr@2
    18
* Version       : 1.0
williamr@2
    19
*
williamr@2
    20
*/
williamr@2
    21
williamr@2
    22
williamr@2
    23
williamr@2
    24
#ifndef CSDPMEDIAFIELD_H
williamr@2
    25
#define CSDPMEDIAFIELD_H
williamr@2
    26
williamr@2
    27
//  INCLUDES
williamr@2
    28
#include <e32base.h>
williamr@2
    29
#include <stringpool.h>
williamr@2
    30
williamr@2
    31
// FORWARD DECLARATIONS
williamr@2
    32
class RReadStream;
williamr@2
    33
class RWriteStream;
williamr@2
    34
class CSdpConnectionField;
williamr@2
    35
class CSdpBandwidthField;
williamr@2
    36
class CSdpAttributeField;
williamr@2
    37
class CSdpKeyField;
williamr@2
    38
class CSdpFmtAttributeField;
williamr@2
    39
class CSdpCodecParseUtil;
williamr@2
    40
williamr@2
    41
// CLASS DECLARATION
williamr@2
    42
/**
williamr@2
    43
 *  @publishedAll
williamr@2
    44
 *  @released
williamr@2
    45
 *
williamr@2
    46
 *	This class encapsulates the media description field and related media
williamr@2
    47
 *  specific subfields of the Session Description Protocol.
williamr@2
    48
 *
williamr@2
    49
 *	The normative reference for correct formatting and values is
williamr@2
    50
 *	draft-ietf-mmusic-sdp-new-14 unless specified otherwise in
williamr@2
    51
 *  member documentation. The implementation supports this normative
williamr@2
    52
 *  reference, but does not enforce it fully. 
williamr@2
    53
 *
williamr@2
    54
 *  @lib sdpcodec.lib
williamr@2
    55
 */
williamr@2
    56
class CSdpMediaField : public CBase
williamr@2
    57
	{
williamr@2
    58
williamr@2
    59
	public:
williamr@2
    60
williamr@2
    61
williamr@2
    62
    public: // Constructors and destructor
williamr@2
    63
        /**
williamr@2
    64
         *	Constructs a new media description field.
williamr@2
    65
		 *	
williamr@2
    66
         *	@param aText A correctly formatted media field 
williamr@2
    67
         *         terminated by a CRLF followed by zero or more media 
williamr@2
    68
         *         attribute fields separated by a CRLF.
williamr@2
    69
         *	@param aRecurse If ETrue, attempts to construct also media 
williamr@2
    70
         *         attributes following the CRLF terminating the media field.
williamr@2
    71
         *	@return a new instance.
williamr@2
    72
         */
williamr@2
    73
		IMPORT_C static	CSdpMediaField* DecodeL(const TDesC8& aText,
williamr@2
    74
												TBool aRecurse = ETrue);
williamr@2
    75
williamr@2
    76
        /**
williamr@2
    77
         *	Constructs a new media description field and adds the pointer to 
williamr@2
    78
         *  the cleanup stack.
williamr@2
    79
		 *	
williamr@2
    80
         *	@param aText A correctly formatted media field 
williamr@2
    81
         *         terminated by a CRLF followed by zero or more media 
williamr@2
    82
         *         attribute fields separated by a CRLF.
williamr@2
    83
         *	@param aRecurse If ETrue, attempts to construct also media 
williamr@2
    84
         *         attributes following the CRLF terminating the media field.
williamr@2
    85
		 *  @return a new instance.
williamr@2
    86
         */
williamr@2
    87
		IMPORT_C static	CSdpMediaField* DecodeLC(const TDesC8& aText,
williamr@2
    88
												 TBool aRecurse = ETrue);
williamr@2
    89
williamr@2
    90
        /**
williamr@2
    91
         *	Constructs a new media description field.
williamr@2
    92
		 *  The optional portcount component of the field is initialized to 1.
williamr@2
    93
		 *
williamr@2
    94
		 *	@param aMedia A valid media type name.
williamr@2
    95
         *	@param aPort Port number.
williamr@2
    96
         *	@param aProtocol A valid media protocol name.
williamr@2
    97
         *	@param aFormatList A valid format list.
williamr@2
    98
         *	@return a new instance.
williamr@2
    99
         */
williamr@2
   100
		IMPORT_C static CSdpMediaField* NewL(RStringF aMedia,
williamr@2
   101
											 TUint aPort,
williamr@2
   102
											 RStringF aProtocol,
williamr@2
   103
											 const TDesC8& aFormatList);
williamr@2
   104
williamr@2
   105
		/**
williamr@2
   106
         *	Constructs a new media description field and adds the pointer to 
williamr@2
   107
         *  the cleanup stack.
williamr@2
   108
		 *  The optional portcount component of the field is initialized to 1.
williamr@2
   109
		 *	
williamr@2
   110
		 *	@param aMedia A valid media type name.
williamr@2
   111
         *	@param aPort Port number.
williamr@2
   112
         *	@param aProtocol A valid media protocol name.
williamr@2
   113
         *	@param aFormatList A valid format list.
williamr@2
   114
         *	@return a new instance.
williamr@2
   115
         */
williamr@2
   116
		IMPORT_C static CSdpMediaField* NewLC(RStringF aMedia,
williamr@2
   117
											  TUint aPort,
williamr@2
   118
										      RStringF aProtocol,
williamr@2
   119
										      const TDesC8& aFormatList);
williamr@2
   120
williamr@2
   121
		/**
williamr@2
   122
		 *	Deletes the resources held by the instance.
williamr@2
   123
		 */
williamr@2
   124
		IMPORT_C ~CSdpMediaField();
williamr@2
   125
williamr@2
   126
    public: // New functions
williamr@2
   127
		/**
williamr@2
   128
		 *	Outputs the field formatted according to SDP syntax and including
williamr@2
   129
		 *  the terminating CRLF. Optionally output also the related media 
williamr@2
   130
		 *  level fields. 
williamr@2
   131
		 * 
williamr@2
   132
		 *	@param aStream Stream used for output. On return the
williamr@2
   133
         *         stream includes correctly formatted media field with 
williamr@2
   134
         *         media part fields if aRecurse is defined to ETrue.
williamr@2
   135
		 *	@param aRecurse Flag to specify whether to output media 
williamr@2
   136
		 *         attributes also (ETrue) or only the media field (EFalse).
williamr@2
   137
		 */
williamr@2
   138
		IMPORT_C void 
williamr@2
   139
			EncodeL(RWriteStream& aStream, TBool aRecurse = ETrue) const;
williamr@2
   140
williamr@2
   141
		/**
williamr@2
   142
		 *	Creates a new instance that is equal to the target.
williamr@2
   143
		 *  Optionally also related subfields are cloned.
williamr@2
   144
		 *
williamr@2
   145
		 *	@param aRecurse Flag to specify whether to clone subfields
williamr@2
   146
		 *         also (ETrue) or only the media field (EFalse).
williamr@2
   147
		 *	@return a new instance.
williamr@2
   148
		 */
williamr@2
   149
		IMPORT_C CSdpMediaField * CloneL(TBool aRecurse = ETrue) const;
williamr@2
   150
williamr@2
   151
		/**	
williamr@2
   152
		 *	Compares this instance to another for equality. Subfields are
williamr@2
   153
		 *  included in the comparison if present.
williamr@2
   154
		 *
williamr@2
   155
		 *	@param aObj The instance to compare to.
williamr@2
   156
		 *	@return ETrue if equal, EFalse if not.
williamr@2
   157
		 */
williamr@2
   158
		IMPORT_C TBool operator == (const CSdpMediaField& aObj) const;
williamr@2
   159
williamr@2
   160
		/**
williamr@2
   161
		 *	Checks the consistency between the media field and it's subfields.
williamr@2
   162
		 *  In particular, this function checks that each format specific 
williamr@2
   163
		 *  attribute is related to a format in the format list of the
williamr@2
   164
		 *  media field.
williamr@2
   165
		 *
williamr@2
   166
		 *	@return	ETrue if media description is consistent and EFalse if not.
williamr@2
   167
		 */
williamr@2
   168
		IMPORT_C TBool IsValid() const;
williamr@2
   169
williamr@2
   170
		/**
williamr@2
   171
		 *	Gets the media type.
williamr@2
   172
		 *
williamr@2
   173
		 *	@return The media type.
williamr@2
   174
		 */
williamr@2
   175
		IMPORT_C RStringF Media() const;
williamr@2
   176
williamr@2
   177
		/**
williamr@2
   178
		 *	Sets the media type.
williamr@2
   179
		 *
williamr@2
   180
		 *	@param aMedia The media type.
williamr@2
   181
		 *  @leave KErrSdpCodecMediaField if aMedia is not valid character
williamr@2
   182
		 */
williamr@2
   183
		IMPORT_C void SetMediaL(RStringF aMedia);
williamr@2
   184
williamr@2
   185
		/**
williamr@2
   186
		 *	Gets the media protocol.
williamr@2
   187
		 *
williamr@2
   188
		 *	@return The media protocol.
williamr@2
   189
		 */
williamr@2
   190
		IMPORT_C RStringF Protocol() const;
williamr@2
   191
williamr@2
   192
		/**
williamr@2
   193
		 *	Sets the media protocol.
williamr@2
   194
		 *
williamr@2
   195
		 *	@param aProtocol The media protocol.
williamr@2
   196
		 *  @leave KErrSdpCodecMediaField if 
williamr@2
   197
		 *		   aProtocol containing two elements divided by slash are not 
williamr@2
   198
         *         valid tokens.
williamr@2
   199
		 */
williamr@2
   200
		IMPORT_C void SetProtocolL(RStringF aProtocol);
williamr@2
   201
williamr@2
   202
		/**
williamr@2
   203
		 *	Gets the port number.
williamr@2
   204
		 *
williamr@2
   205
		 *	@return The port number.
williamr@2
   206
		 */
williamr@2
   207
		IMPORT_C TUint Port() const;
williamr@2
   208
williamr@2
   209
		/**
williamr@2
   210
		 *	Sets the port number.
williamr@2
   211
		 *
williamr@2
   212
		 *	@param aPort The port number.
williamr@2
   213
		 *  @leave KErrSdpCodecMediaField if port is not valid number as 
williamr@2
   214
         *         defined in draft-ietf-mmusic-sdp-new-14
williamr@2
   215
		 */
williamr@2
   216
		IMPORT_C void SetPortL(TUint aPort);
williamr@2
   217
williamr@2
   218
		/**
williamr@2
   219
		 *	Gets the port count.
williamr@2
   220
		 *
williamr@2
   221
		 *	@return The port count.
williamr@2
   222
		 */
williamr@2
   223
		IMPORT_C TUint PortCount() const;
williamr@2
   224
williamr@2
   225
		/**
williamr@2
   226
		 *	Sets the port count.
williamr@2
   227
		 *
williamr@2
   228
		 *	@param aCount The port count that must be greater than zero.
williamr@2
   229
		 *  @leave KErrSdpCodecMediaField if aCount equals to zero.
williamr@2
   230
		 */
williamr@2
   231
		IMPORT_C void SetPortCountL(TUint aCount);
williamr@2
   232
williamr@2
   233
		/**
williamr@2
   234
		 *	Gets the format list.
williamr@2
   235
		 *
williamr@2
   236
		 *	@return The format list.
williamr@2
   237
		 */
williamr@2
   238
		IMPORT_C const TDesC8& FormatList() const;
williamr@2
   239
williamr@2
   240
		/**
williamr@2
   241
		 *	Sets the format list.
williamr@2
   242
		 *  The format list should contain one or more format tokens separated
williamr@2
   243
		 *  by a single whitespace character.
williamr@2
   244
		 *
williamr@2
   245
		 *	@param aValue A valid format list.
williamr@2
   246
		 *  @leave KErrSdpCodecMediaField if aValue contains invalid tokens
williamr@2
   247
		 */
williamr@2
   248
		IMPORT_C void SetFormatListL(const TDesC8& aValue);
williamr@2
   249
williamr@2
   250
		/**
williamr@2
   251
		 *	Return the media level info field value.
williamr@2
   252
		 *
williamr@2
   253
		 *	@return The value or an empty descriptor if not present.
williamr@2
   254
		 */
williamr@2
   255
		IMPORT_C const TDesC8& Info() const;
williamr@2
   256
williamr@2
   257
		/**
williamr@2
   258
		 *	Sets the media level info field value.
williamr@2
   259
		 *
williamr@2
   260
		 *	@param aValue A valid info field value.
williamr@2
   261
		 *	@leave KErrSdpCodecMediaInfoField if aValue is not KNullDesC8 or 
williamr@2
   262
         *         aValue includes invalid byte strings (´\0´, ´\n´, ´\r´).
williamr@2
   263
		 */
williamr@2
   264
		IMPORT_C void SetInfoL(const TDesC8& aValue);
williamr@2
   265
williamr@2
   266
		/**
williamr@2
   267
		 *	Gets the media level encryption key field.
williamr@2
   268
		 *	Note, that the ownership is not transferred and
williamr@2
   269
		 *	the instance must not be deleted by the caller.
williamr@2
   270
		 *
williamr@2
   271
		 *	@return Encryption key field or null if not present.
williamr@2
   272
		 */
williamr@2
   273
		IMPORT_C CSdpKeyField* Key();
williamr@2
   274
williamr@2
   275
		/**
williamr@2
   276
		 *	Gets the media level encryption key field.
williamr@2
   277
		 *
williamr@2
   278
		 *	@return Encryption key field or null if not present.
williamr@2
   279
		 */
williamr@2
   280
		IMPORT_C const CSdpKeyField* Key() const;
williamr@2
   281
williamr@2
   282
		/**
williamr@2
   283
		 *	Sets or removes the media level encryption key field.
williamr@2
   284
		 *
williamr@2
   285
		 *	@param aObj The new key field or null if field is 
williamr@2
   286
         *         to be removed. Ownership of the referenced object
williamr@2
   287
		 *         is transferred to the media field instance.
williamr@2
   288
		 */
williamr@2
   289
		IMPORT_C void SetKey(CSdpKeyField* aObj);
williamr@2
   290
williamr@2
   291
		/**
williamr@2
   292
		 *	Gets the set of media format level attributes.
williamr@2
   293
		 *  This array is used directly for element insertion and removal.
williamr@2
   294
		 *
williamr@2
   295
		 *	The objects referenced from the array are owned by the media
williamr@2
   296
		 *  field instance and must not be deleted. An object can be
williamr@2
   297
		 *  removed from the media description by setting the corresponding
williamr@2
   298
		 *  element to zero. By doing so, the calling party receives ownership
williamr@2
   299
		 *  of the removed object.
williamr@2
   300
		 *
williamr@2
   301
		 *	@return The set of media format level attributes.
williamr@2
   302
		 */
williamr@2
   303
		IMPORT_C RPointerArray<CSdpFmtAttributeField>& FormatAttributeFields();
williamr@2
   304
williamr@2
   305
		/**
williamr@2
   306
		 *	Gets the set of media level, format independent attributes.
williamr@2
   307
		 *  This array is used directly for element insertion and removal.
williamr@2
   308
		 *
williamr@2
   309
		 *	The objects referenced from the array are owned by the media
williamr@2
   310
		 *  field instance and must not be deleted. An object can be
williamr@2
   311
		 *  removed from the media description by setting the corresponding
williamr@2
   312
		 *  element to zero. By doing so, the calling party receives ownership
williamr@2
   313
		 *  of the removed object.
williamr@2
   314
		 *
williamr@2
   315
		 *	@return The set of media level attributes.
williamr@2
   316
		 */
williamr@2
   317
		IMPORT_C RPointerArray<CSdpAttributeField>& AttributeFields();
williamr@2
   318
williamr@2
   319
		/**
williamr@2
   320
		 *	Gets the set of media level bandwidth fields.
williamr@2
   321
		 *  This array is used directly for element insertion and removal.
williamr@2
   322
		 *
williamr@2
   323
		 *	The objects referenced from the array are owned by the media
williamr@2
   324
		 *  field instance and must not be deleted. An object can be
williamr@2
   325
		 *  removed from the media description by setting the corresponding
williamr@2
   326
		 *  element to zero. By doing so, the calling party receives ownership
williamr@2
   327
		 *  of the removed object.
williamr@2
   328
		 *
williamr@2
   329
		 *	@return The set of media level bandwidth fields.
williamr@2
   330
		 */
williamr@2
   331
		IMPORT_C RPointerArray<CSdpBandwidthField>& BandwidthFields();
williamr@2
   332
williamr@2
   333
		/**
williamr@2
   334
		 *	Gets the set of media level connection fields.
williamr@2
   335
		 *  This array is used directly for element insertion and removal.
williamr@2
   336
		 *
williamr@2
   337
		 *	The objects referenced from the array are owned by the media
williamr@2
   338
		 *  field instance and must not be deleted. An object can be
williamr@2
   339
		 *  removed from the media description by setting the corresponding
williamr@2
   340
		 *  element to zero. By doing so, the calling party receives ownership
williamr@2
   341
		 *  of the removed object.
williamr@2
   342
		 *
williamr@2
   343
		 *	@return The set of media level connection fields.
williamr@2
   344
		 */
williamr@2
   345
		IMPORT_C RPointerArray<CSdpConnectionField>& ConnectionFields();
williamr@2
   346
williamr@2
   347
		/**
williamr@2
   348
		 *	Removes a specific format from the media description.
williamr@2
   349
		 *  The function will remove the named format from the format list if
williamr@2
   350
		 *  found and then delete all format level attributes of type 
williamr@2
   351
		 *  CSdpFmtAttributeField related to the removed format. 
williamr@2
   352
		 *
williamr@2
   353
		 *	@param aFormat The name of the format to remove.
williamr@2
   354
		 */
williamr@2
   355
		IMPORT_C void RemoveFormatL(const TDesC8& aFormat);
williamr@2
   356
williamr@2
   357
		/**
williamr@2
   358
		 *	Removes all formats except one from the media description.
williamr@2
   359
		 *  The function will set the format list to only contain the one
williamr@2
   360
		 *  format to keep and then delete all format level attributes that
williamr@2
   361
		 *  are related to the removed formats. If the format is not found
williamr@2
   362
		 *  from the format list, it is added there. If there are no format
williamr@2
   363
		 *  level attributes for the specified format, the format level
williamr@2
   364
		 *  attribute set will be empty.
williamr@2
   365
		 *
williamr@2
   366
		 *	@param aFormat The name of the format to keep after 
williamr@2
   367
		 *         removing all others.
williamr@2
   368
		 */
williamr@2
   369
		IMPORT_C void KeepFormatL(const TDesC8& aFormat);
williamr@2
   370
williamr@2
   371
		/**
williamr@2
   372
		 *	Sets this media description into rejected state.
williamr@2
   373
		 *  The rejected state is defined by the offer/answer model in
williamr@2
   374
		 *  RFC3264. The function sets the port number to 0 and removes
williamr@2
   375
		 *  all formats except one. The remaining format is determined
williamr@2
   376
		 *  by the implementation.
williamr@2
   377
		 */
williamr@2
   378
		IMPORT_C void RejectMedia();
williamr@2
   379
williamr@2
   380
    public:
williamr@2
   381
		/**
williamr@2
   382
		 *	Shows if contact is present
williamr@2
   383
		 *
williamr@2
   384
		 *	@return ETrue if contact present, otherwise EFalse
williamr@2
   385
		 */
williamr@2
   386
		TBool IsContactPresent() const;
williamr@2
   387
		
williamr@2
   388
		/**
williamr@2
   389
         *  Externalizes the object to stream
williamr@2
   390
         *
williamr@2
   391
         *  @param aStream Stream where the object's state will be stored
williamr@2
   392
         */
williamr@2
   393
		void ExternalizeL(RWriteStream& aStream) const;
williamr@2
   394
		
williamr@2
   395
		/**
williamr@2
   396
         *  Creates object from the stream data
williamr@2
   397
         *
williamr@2
   398
         *  @param aStream Stream where the object's state will be read	
williamr@2
   399
         *  @return Initialized object
williamr@2
   400
         */
williamr@2
   401
		static CSdpMediaField* InternalizeL(RReadStream& aStream);
williamr@2
   402
williamr@2
   403
	private:
williamr@2
   404
		CSdpMediaField();
williamr@2
   405
		void ConstructL();
williamr@2
   406
		void ConstructL(TBool aRecurse);
williamr@2
   407
		void ConstructL(RStringF aMedia, TUint aPort, RStringF aProtocol, 
williamr@2
   408
						const TDesC8& aFormatList);
williamr@2
   409
williamr@2
   410
		void ConstructL(const CSdpMediaField& aSdpMediaField);
williamr@2
   411
		void DoInternalizeL(RReadStream& aStream);
williamr@2
   412
		void ParseL (const TDesC8& aText);
williamr@2
   413
		void ParseMediaL();
williamr@2
   414
		void ParseInformationL();
williamr@2
   415
		void ParseConnectionL();
williamr@2
   416
		void ParseBandwithL();
williamr@2
   417
		void ParseEncryptionKeyL();
williamr@2
   418
		void ParseAttributeFieldsL();
williamr@2
   419
		TDesC8& GetTokenFromStreamL(RReadStream& aStream);
williamr@2
   420
williamr@2
   421
williamr@2
   422
		CSdpMediaField(const CSdpMediaField&); // Hidden.
williamr@2
   423
		CSdpMediaField& operator = (const CSdpMediaField&); // Hidden
williamr@2
   424
williamr@2
   425
    private: // Data
williamr@2
   426
		HBufC8* iInfo;
williamr@2
   427
		CSdpKeyField* iSdpKeyField;
williamr@2
   428
		RArray<TPtrC8> iElementArray;
williamr@2
   429
		RStringPool iPool;
williamr@2
   430
		TBool iRecurse;
williamr@2
   431
		RStringF iMedia;
williamr@2
   432
		RStringF iProtocol;
williamr@2
   433
		TUint iPort;
williamr@2
   434
		TUint iPortCount;
williamr@2
   435
		HBufC8* iFormatList;
williamr@2
   436
		RPointerArray<CSdpBandwidthField>* iBandwidthFields;
williamr@2
   437
		RPointerArray<CSdpAttributeField>* iAttributeFields;
williamr@2
   438
		RPointerArray<CSdpConnectionField>* iConnectionFields;
williamr@2
   439
		RPointerArray<CSdpFmtAttributeField>* iFmtAttrFields;
williamr@2
   440
		HBufC8* iToken;
williamr@2
   441
		CSdpCodecParseUtil* iSdpCodecParseUtil;
williamr@2
   442
	};
williamr@2
   443
williamr@2
   444
#endif // CSDPMEDIAFIELD_H