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