epoc32/include/mw/sdpdocument.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/sdpdocument.h@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
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@2
     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
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.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          : SdpDocument.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 CSDPDOCUMENT_H
williamr@2
    25
#define CSDPDOCUMENT_H
williamr@2
    26
williamr@2
    27
//  INCLUDES
williamr@2
    28
#include <e32base.h>
williamr@2
    29
#include <badesca.h>
williamr@2
    30
#include "_sdpdefs.h"
williamr@2
    31
#include <stringpool.h>
williamr@2
    32
williamr@2
    33
// FORWARD DECLARATIONS
williamr@2
    34
class SdpUtil;
williamr@2
    35
class RReadStream;
williamr@2
    36
class RWriteStream;
williamr@2
    37
class CUri8;
williamr@2
    38
class CDesC8Array;
williamr@2
    39
class CSdpOriginField;
williamr@2
    40
class CSdpEmailField;
williamr@2
    41
class CSdpPhoneField;
williamr@2
    42
class CSdpConnectionField;
williamr@2
    43
class CSdpBandwidthField;
williamr@2
    44
class CSdpTimeField;
williamr@2
    45
class CSdpAttributeField;
williamr@2
    46
class CSdpMediaField;
williamr@2
    47
class CSdpKeyField;
williamr@2
    48
class CSdpCodecParseUtil;
williamr@2
    49
williamr@2
    50
// CLASS DECLARATION
williamr@2
    51
/**
williamr@2
    52
 *  @publishedAll
williamr@2
    53
 *  @released
williamr@2
    54
 *
williamr@2
    55
 *    This class encapsulates the Session Description Protocol (SDP) document.
williamr@2
    56
 *  The SDP document is a collection of SDP fields and related values
williamr@2
    57
 *    describing a session.
williamr@2
    58
 *
williamr@2
    59
 *    The normative reference for correct formatting and values is
williamr@2
    60
 *    draft-ietf-mmusic-sdp-new-14 unless specified otherwise in
williamr@2
    61
 *  member documentation. The implementation supports this normative
williamr@2
    62
 *  reference, but does not enforce it fully. 
williamr@2
    63
 *
williamr@2
    64
 *  @lib sdpcodec.lib
williamr@2
    65
 */
williamr@2
    66
class CSdpDocument : public CBase
williamr@2
    67
    {
williamr@2
    68
    public: // Constructors and destructor
williamr@2
    69
        /**
williamr@2
    70
        * Constructs a new SDP document.
williamr@2
    71
        *    
williamr@2
    72
        * @param aText A string containing a correctly formatted SDP document.
williamr@2
    73
        * @return a new instance.
williamr@2
    74
        */
williamr@2
    75
        IMPORT_C static CSdpDocument* DecodeL(const TDesC8& aText);
williamr@2
    76
williamr@2
    77
        /**
williamr@2
    78
        * Constructs a new SDP document and adds the pointer to the cleanup stack.
williamr@2
    79
        *    
williamr@2
    80
        * @param aText A string containing a correctly formatted SDP document.
williamr@2
    81
        * @return a new instance.
williamr@2
    82
        */
williamr@2
    83
        IMPORT_C static CSdpDocument* DecodeLC(const TDesC8& aText);
williamr@2
    84
            
williamr@2
    85
        /**
williamr@2
    86
        * Constructs a new, empty SDP document.
williamr@2
    87
        * The instance will have the following initial values:
williamr@2
    88
        *      v=0
williamr@2
    89
        *      s=-
williamr@2
    90
        *      t=0 0
williamr@2
    91
        *
williamr@2
    92
        * @return a new instance.
williamr@2
    93
        */
williamr@2
    94
        IMPORT_C static CSdpDocument* NewL();
williamr@2
    95
williamr@2
    96
        /**
williamr@2
    97
        * Constructs a new, empty SDP document document and adds the pointer to 
williamr@2
    98
        * the cleanup stack.
williamr@2
    99
        * The instance will have the following initial values:
williamr@2
   100
        *      v=0
williamr@2
   101
        *      s=-
williamr@2
   102
        *      t=0 0
williamr@2
   103
        *
williamr@2
   104
        * @return a new instance.
williamr@2
   105
        */
williamr@2
   106
        IMPORT_C static CSdpDocument* NewLC();
williamr@2
   107
williamr@2
   108
        /**
williamr@2
   109
        * Deletes the resources held by the instance.
williamr@2
   110
        */
williamr@2
   111
        IMPORT_C ~CSdpDocument();
williamr@2
   112
williamr@2
   113
    public: 
williamr@2
   114
        /**
williamr@2
   115
        * Externalizes the object state in an internal, memory optimized format.
williamr@2
   116
        *
williamr@2
   117
        * @param aStream The output stream.
williamr@2
   118
        */
williamr@2
   119
        IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
williamr@2
   120
williamr@2
   121
        /**
williamr@2
   122
        * Internalizes the object state from an internal, memory optimized format.
williamr@2
   123
        *
williamr@2
   124
        * @param aStream The input stream.
williamr@2
   125
        * @return A new SDP document internalized from the input stream.
williamr@2
   126
        */
williamr@2
   127
        IMPORT_C static CSdpDocument* InternalizeL(RReadStream& aStream);
williamr@2
   128
williamr@2
   129
        /**
williamr@2
   130
        * Outputs the SDP document formatted according to SDP syntax.
williamr@2
   131
        * It is possible to output the document even though it is
williamr@2
   132
        * incomplete in the sense that all mandatory SDP fields are
williamr@2
   133
        * not present.When creating an SDP document to be used e.g.
williamr@2
   134
        * as part of SIP signalling, caller should first ensure the
williamr@2
   135
        * validity of the document using the IsValid() function.
williamr@2
   136
        * 
williamr@2
   137
        * @param aStream Stream used for output. On return the 
williamr@2
   138
        *        stream includes correctly formatted SDP description.
williamr@2
   139
        */
williamr@2
   140
        IMPORT_C void EncodeL(RWriteStream& aStream) const;
williamr@2
   141
williamr@2
   142
        /**
williamr@2
   143
        * Creates a new instance that is equal to the target.
williamr@2
   144
        *
williamr@2
   145
        * @return a new instance.
williamr@2
   146
        */
williamr@2
   147
        IMPORT_C CSdpDocument* CloneL() const;
williamr@2
   148
williamr@2
   149
        /**
williamr@2
   150
        * Checks if the instance represents a valid SDP document.
williamr@2
   151
        *
williamr@2
   152
        * @return ETrue if SDP document is valid and EFalse if not.
williamr@2
   153
        */
williamr@2
   154
        IMPORT_C TBool IsValid() const;
williamr@2
   155
williamr@2
   156
        /**
williamr@2
   157
        * Gets the SDP version used in the version field.
williamr@2
   158
        * Note, that the current implementation supports only version number 0.
williamr@2
   159
        *
williamr@2
   160
        * @return The SDP version number.
williamr@2
   161
        */ 
williamr@2
   162
        IMPORT_C TUint SdpVersion() const;
williamr@2
   163
williamr@2
   164
        /**
williamr@2
   165
        * Gets a reference to the session origin field.
williamr@2
   166
        * Note, that the ownership is not transferred and
williamr@2
   167
        * the instance must not be deleted by the caller.
williamr@2
   168
        *
williamr@2
   169
        * @return The origin field or zero if not present.
williamr@2
   170
        */
williamr@2
   171
        IMPORT_C CSdpOriginField* OriginField();
williamr@2
   172
williamr@2
   173
        /**
williamr@2
   174
        * Gets a reference to the session origin field.
williamr@2
   175
        *
williamr@2
   176
        * @return The origin field or zero if not present.
williamr@2
   177
        */
williamr@2
   178
        IMPORT_C const CSdpOriginField* OriginField() const;
williamr@2
   179
williamr@2
   180
        /**
williamr@2
   181
        * Sets or removes the session origin field.
williamr@2
   182
        * Note, that the ownership of the argument is 
williamr@2
   183
        * transferred to the SDP document object.
williamr@2
   184
        *
williamr@2
   185
        * @param aObj New origin field or null to remove the field.
williamr@2
   186
        */
williamr@2
   187
        IMPORT_C void SetOriginField(CSdpOriginField* aObj);
williamr@2
   188
williamr@2
   189
        /**
williamr@2
   190
        * Gets the session name field value.
williamr@2
   191
        *
williamr@2
   192
        * @return The session name or empty descriptor if not present.
williamr@2
   193
        */
williamr@2
   194
        IMPORT_C const TDesC8& SessionName() const;
williamr@2
   195
williamr@2
   196
        /**
williamr@2
   197
        * Sets the session name field value.
williamr@2
   198
        *
williamr@2
   199
        * @param aValue Valid session name value. 
williamr@2
   200
        *        Note that an empty value is not accepted.
williamr@2
   201
        * @leave KErrSdpCodecSessionField if
williamr@2
   202
        *        aValue is not empty or aValue includes invalid byte strings 
williamr@2
   203
        *        (´\0´, ´\n´, ´\r´).
williamr@2
   204
        */
williamr@2
   205
        IMPORT_C void SetSessionNameL(const TDesC8& aValue);
williamr@2
   206
williamr@2
   207
        /**
williamr@2
   208
        * Gets the session information field value.
williamr@2
   209
        *
williamr@2
   210
        * @return Info field value or an empty descriptor if not present.
williamr@2
   211
        */
williamr@2
   212
        IMPORT_C const TDesC8& Info() const;
williamr@2
   213
williamr@2
   214
        /**
williamr@2
   215
        * Sets or removes the session information field value.
williamr@2
   216
        *
williamr@2
   217
        * @param New field value or an empty descriptor to remove the field.
williamr@2
   218
        * @leave KErrSdpCodecInfoField if aValue is not empty or aValue includes 
williamr@2
   219
        *        invalid byte strings (´\0´, ´\n´, ´\r´).
williamr@2
   220
        */
williamr@2
   221
        IMPORT_C void SetInfoL(const TDesC8& aValue);
williamr@2
   222
williamr@2
   223
        /**
williamr@2
   224
        *    Gets the session URI field value.
williamr@2
   225
        *    Note, that the ownership is not transferred and
williamr@2
   226
        *    the instance must not be deleted by the caller.
williamr@2
   227
        *
williamr@2
   228
        *    @return CUri8*: Session URI or zero if the field is not present.
williamr@2
   229
        */
williamr@2
   230
        IMPORT_C CUri8* Uri();
williamr@2
   231
williamr@2
   232
        /**
williamr@2
   233
        * Gets the session URI field value.
williamr@2
   234
        *
williamr@2
   235
        * @return Session URI or zero if the field is not present.
williamr@2
   236
        */
williamr@2
   237
        IMPORT_C const CUri8* Uri() const;
williamr@2
   238
williamr@2
   239
        /**
williamr@2
   240
        * Sets or removes the session level URI field.
williamr@2
   241
        * Note, that the ownership of the argument is 
williamr@2
   242
        * transferred to the SDP document object.
williamr@2
   243
        *
williamr@2
   244
        * @param New value of the field or zero to remove the field.
williamr@2
   245
        */
williamr@2
   246
        IMPORT_C void SetUri(CUri8* aValue);
williamr@2
   247
williamr@2
   248
        /**
williamr@2
   249
        * Gets the set of session level email field values. This array is used to
williamr@2
   250
        * add and remove fields into the document.
williamr@2
   251
        * Note, that only correctly formatted email field values should be placed
williamr@2
   252
        * into the array. Empty values in the array will be ignored.
williamr@2
   253
        *
williamr@2
   254
        * @return Email fields in array or empty array if no email fields.
williamr@2
   255
        */
williamr@2
   256
        IMPORT_C CDesC8Array& EmailFields();
williamr@2
   257
williamr@2
   258
        /**
williamr@2
   259
        * Gets the set of session level phone field values. This array is used to
williamr@2
   260
        * add and remove fields into the document.
williamr@2
   261
        * Note, that only correctly formatted phone field values should be placed
williamr@2
   262
        * into the array. Empty values in the array will be ignored.
williamr@2
   263
        *  
williamr@2
   264
        * @return Phone fields in array or empty array if no phone fields.
williamr@2
   265
        */
williamr@2
   266
        IMPORT_C CDesC8Array& PhoneFields();
williamr@2
   267
williamr@2
   268
        /**
williamr@2
   269
        * Gets the session level connection field.
williamr@2
   270
        * Note, that the ownership is not transferred and the instance must not be
williamr@2
   271
        * deleted by the caller.
williamr@2
   272
        *
williamr@2
   273
        * @return Connection field or zero if not present.
williamr@2
   274
        */
williamr@2
   275
        IMPORT_C CSdpConnectionField* ConnectionField();
williamr@2
   276
williamr@2
   277
        /**
williamr@2
   278
        * Gets the session level connection field.
williamr@2
   279
        *
williamr@2
   280
        * @return Connection field or zero if not present.
williamr@2
   281
        */
williamr@2
   282
        IMPORT_C const CSdpConnectionField* ConnectionField() const;
williamr@2
   283
williamr@2
   284
        /**
williamr@2
   285
        * Sets or removes the session level connection field.
williamr@2
   286
        * Note, that the ownership of the argument is 
williamr@2
   287
        * transferred to the SDP document object.
williamr@2
   288
        *
williamr@2
   289
        * @param New connection field or zero to remove the field.
williamr@2
   290
        */    
williamr@2
   291
        IMPORT_C void SetConnectionField(CSdpConnectionField* aObj);
williamr@2
   292
williamr@2
   293
        /**
williamr@2
   294
        * Gets the possibly empty set of session level bandwidth fields.
williamr@2
   295
        * This array is used directly for element insertion and removal.
williamr@2
   296
        * The array may contain zero references and these are ignored.
williamr@2
   297
        *
williamr@2
   298
        * The objects referenced from the array are owned by the document
williamr@2
   299
        * instance and must not be deleted. An object can be removed from
williamr@2
   300
        * the document by setting the corresponding element to zero. By
williamr@2
   301
        * doing so, the calling party receives ownership of the removed object.
williamr@2
   302
        *
williamr@2
   303
        * @return Set of bandwidth fields.
williamr@2
   304
        */
williamr@2
   305
        IMPORT_C RPointerArray<CSdpBandwidthField>& BandwidthFields();
williamr@2
   306
williamr@2
   307
        /**
williamr@2
   308
        * Gets the set of session level time description fields.
williamr@2
   309
        * This array is used directly for element insertion and removal.
williamr@2
   310
        * There must be at least one time description field in a valid SDP
williamr@2
   311
        * document.The array may contain zero references and these are ignored.
williamr@2
   312
        *
williamr@2
   313
        * The objects referenced from the array are owned by the document 
williamr@2
   314
        * instance and must not be deleted. An object can be removed from the
williamr@2
   315
        * document by setting the corresponding element to zero. By doing so,
williamr@2
   316
        * the calling party receives ownership of the removed object.  
williamr@2
   317
        *
williamr@2
   318
        * @return Set of time fields.
williamr@2
   319
        */
williamr@2
   320
        IMPORT_C RPointerArray<CSdpTimeField>& TimeFields();
williamr@2
   321
williamr@2
   322
        /** 
williamr@2
   323
        * Gets the zone adjustments field value.
williamr@2
   324
        *
williamr@2
   325
        * @return The field value or an empty descriptor if the
williamr@2
   326
        *         field is not present.
williamr@2
   327
        */
williamr@2
   328
        IMPORT_C const TDesC8& ZoneAdjustments() const;
williamr@2
   329
williamr@2
   330
        /** 
williamr@2
   331
        * Sets the zone adjustments field value.
williamr@2
   332
        *
williamr@2
   333
        * @param aValue A valid field value or an empty descriptor
williamr@2
   334
        *        if field is not present.
williamr@2
   335
        */
williamr@2
   336
        IMPORT_C void SetZoneAdjustmentsL(const TDesC8& aValue);
williamr@2
   337
williamr@2
   338
        /**
williamr@2
   339
        * Gets the session level encryption key field.
williamr@2
   340
        * Note, that the ownership is not transferred and
williamr@2
   341
        * the instance must not be deleted by the caller.
williamr@2
   342
        *
williamr@2
   343
        * @return The encryption key or zero if not present.
williamr@2
   344
        */
williamr@2
   345
        IMPORT_C CSdpKeyField* Key();
williamr@2
   346
williamr@2
   347
        /**
williamr@2
   348
        * Gets the session level encryption key field.
williamr@2
   349
        *
williamr@2
   350
        * @return The encryption key or zero if not present.
williamr@2
   351
        */
williamr@2
   352
        IMPORT_C const CSdpKeyField* Key() const;
williamr@2
   353
williamr@2
   354
        /**
williamr@2
   355
        * Sets or removes the encryption key field.
williamr@2
   356
        * Note, that the ownership of the argument is 
williamr@2
   357
        * transferred to the SDP document object.
williamr@2
   358
        *
williamr@2
   359
        * @param aObj New value of the field or zero to remove the field.
williamr@2
   360
        */
williamr@2
   361
        IMPORT_C void SetKey(CSdpKeyField* aObj);
williamr@2
   362
williamr@2
   363
        /**
williamr@2
   364
        * Gets the possibly empty set of session level attribute fields.
williamr@2
   365
        * This array is used directly for element insertion and removal.
williamr@2
   366
        * The array may contain zero references and these are ignored.
williamr@2
   367
        *
williamr@2
   368
        * The objects referenced from the array are owned by the document
williamr@2
   369
        * instance and must not be deleted. An object can be removed from the
williamr@2
   370
        * document by setting the corresponding element to zero. By doing so,
williamr@2
   371
        * the calling party receives ownership of the removed object.
williamr@2
   372
        *
williamr@2
   373
        * @return Set of session level attributes.
williamr@2
   374
        */
williamr@2
   375
        IMPORT_C RPointerArray<CSdpAttributeField>& AttributeFields();
williamr@2
   376
williamr@2
   377
        /**
williamr@2
   378
        * Gets the possibly empty set of media description fields.
williamr@2
   379
        * This array is used directly for element insertion and removal.
williamr@2
   380
        * Note, that media level attributes and fields are managed 
williamr@2
   381
        * through the corresponding media field instance and not through
williamr@2
   382
        * the document instance.
williamr@2
   383
        * The array may contain zero references and these are ignored.
williamr@2
   384
        *
williamr@2
   385
        * The objects referenced from the array are owned by the document
williamr@2
   386
        * instance and must not be deleted. An object can be removed from the
williamr@2
   387
        * document by setting the corresponding element to zero. By doing so,
williamr@2
   388
        * the calling party receives ownership of the removed object.
williamr@2
   389
        *
williamr@2
   390
        * @return Set of media description fields.
williamr@2
   391
        */
williamr@2
   392
        IMPORT_C RPointerArray<CSdpMediaField>& MediaFields();
williamr@2
   393
williamr@2
   394
    private:
williamr@2
   395
        CSdpDocument();
williamr@2
   396
        void ConstructL();
williamr@2
   397
        void ConstructL(const CSdpDocument& aSdpDocument);
williamr@2
   398
        void DoInternalizeL(RReadStream& aStream);
williamr@2
   399
williamr@2
   400
        void ParseL (const TDesC8& aText);
williamr@2
   401
        void ParseSessionVersionL();
williamr@2
   402
        void ParseSessionOwnerL();
williamr@2
   403
        void ParseSessionNameL();
williamr@2
   404
        void ParseSessionInformationL();
williamr@2
   405
        void ParseUriL();
williamr@2
   406
        void ParseEmailL();
williamr@2
   407
        void ParsePhoneL();
williamr@2
   408
        void ParseConnectionL();
williamr@2
   409
        void ParseBandwidthL();
williamr@2
   410
        void ParseTimeFieldL();
williamr@2
   411
        void ParseZoneAdjustmentL();
williamr@2
   412
        void ParseEncryptionKeyL();
williamr@2
   413
        void ParseAttributeFieldL();
williamr@2
   414
        void ParseMediaLevelL ();
williamr@2
   415
        void ExternalizeDesCArrayL(CDesC8ArraySeg& aArray,
williamr@2
   416
                               RWriteStream& aStream) const;
williamr@2
   417
        void EncodeDesCArrayL(CDesC8ArraySeg& aArray,TInt aIndex,
williamr@2
   418
                                            RWriteStream& aStream) const;
williamr@2
   419
williamr@2
   420
        TDesC8& GetTokenFromStreamL(RReadStream& aStream);
williamr@2
   421
williamr@2
   422
        CSdpDocument(const CSdpDocument&); // Hidden.
williamr@2
   423
        CSdpDocument& operator = (const CSdpDocument&); // Hidden
williamr@2
   424
williamr@2
   425
    private: // Data
williamr@2
   426
            
williamr@2
   427
        HBufC8* iInfo;
williamr@2
   428
        HBufC8* iSessionName;
williamr@2
   429
        HBufC8* iZoneAdjustments;
williamr@2
   430
        CSdpKeyField* iSdpKeyField;
williamr@2
   431
        CSdpOriginField* iSdpOriginField;
williamr@2
   432
        CSdpConnectionField* iSdpConnectionField;
williamr@2
   433
        TUint iSdpVersion;
williamr@2
   434
        RPointerArray<CSdpTimeField>* iTimeFields;
williamr@2
   435
        RPointerArray<CSdpBandwidthField>* iBandwidthFields;
williamr@2
   436
        RPointerArray<CSdpAttributeField>* iAttributeFields;
williamr@2
   437
        RPointerArray<CSdpMediaField>* iMediaFields;
williamr@2
   438
        CUri8* iUri;
williamr@2
   439
        CDesC8ArraySeg* iEmailFields;
williamr@2
   440
        CDesC8ArraySeg* iPhoneFields;
williamr@2
   441
        RStringPool iPool;
williamr@2
   442
        HBufC8* iToken;
williamr@2
   443
        CSdpCodecParseUtil* iSdpCodecParseUtil;
williamr@2
   444
    };
williamr@2
   445
williamr@2
   446
#endif // CSDPDOCUMENT_H