multimediacommsengine/mmcesrv/mmcemediamanager/inc/mcemessagesdpcodec.h
branchrcs
changeset 49 64c62431ac08
equal deleted inserted replaced
44:fb024d5e35fa 49:64c62431ac08
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     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".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef CMCEMESSAGESDPCODEC_H
       
    22 #define CMCEMESSAGESDPCODEC_H
       
    23 
       
    24 #include "mcemediasdpcodec.h"
       
    25 #include "mcecommediastream.h"
       
    26 #include "mcecommsrpsource.h"
       
    27 #include "mcecommsrpsink.h"
       
    28 #include <sdpmediafield.h>
       
    29 
       
    30 class CMceComMessageStream;
       
    31 //class CMceComAudioCodec;
       
    32 
       
    33 
       
    34 #define MCE_SDP_STRING_MESSAGEL()\
       
    35         SdpCodecStringPool::StringPoolL().OpenFStringL(KMceMediaMessage)
       
    36 
       
    37 struct TParsedHeader
       
    38     {
       
    39     TBuf8<256> iNameValue;
       
    40     TBuf8<50> iTypeValue;
       
    41     TPtrC8 iHash;
       
    42     TInt64  iSize;
       
    43     TBuf8<32> iFileTransferId;
       
    44     };
       
    45 
       
    46 /**
       
    47  * 
       
    48  *
       
    49  * @lib 
       
    50  */
       
    51 class CMceMessageSdpCodec: public CMceMediaSdpCodec
       
    52     {
       
    53 
       
    54     public://constructor and destructor
       
    55     
       
    56         /**
       
    57         * Constructor
       
    58         */
       
    59         static CMceMessageSdpCodec* NewL();
       
    60         
       
    61         /**
       
    62         * Destructor
       
    63         */
       
    64         ~CMceMessageSdpCodec();
       
    65         
       
    66 
       
    67     public: //from CMceSdpCodec
       
    68         
       
    69         /**
       
    70         * Returns ETrue, if media is encoded by this codec
       
    71         * @return ETrue, if media is encoded by this codec
       
    72         */
       
    73         TBool Encodes( const CMceComMediaStream& aStream ) const;
       
    74         
       
    75         
       
    76     public: //from CMceMediaSdpCodec
       
    77     
       
    78 
       
    79         /**
       
    80         * Returns codecs
       
    81         * @param aStream media stream
       
    82         * @param return codecs
       
    83         * @leave if stream type does not macth codecs
       
    84         */
       
    85         const RPointerArray<CMceComCodec>& CodecsL( CMceComMediaStream& aStream ) const;
       
    86 
       
    87         /**
       
    88         * Encodes rtpmap -attribute
       
    89         * @param aCodec codec encoded to rtpmap
       
    90         * @leave system wide error
       
    91         */
       
    92         CSdpFmtAttributeField* EncodeRtpmapAttributeLC( CMceComCodec& aCodec ) const;
       
    93         
       
    94         /**
       
    95         * Encodes media related attributes
       
    96         * @param aCodec the codec
       
    97         * @param aMediaLine media line
       
    98         * @param aRtpmap rtpmap attribute
       
    99         * @leave system wide error
       
   100         */
       
   101         void EncodeMediaAttributesL( CMceComCodec& aCodec, 
       
   102                                      CSdpMediaField& aMediaLine, 
       
   103                                      CSdpFmtAttributeField& aRtpmap ) const;
       
   104         
       
   105         /**
       
   106         * Encodes message media related attributes
       
   107         * @param aStream for media stream
       
   108         * @param aMediaLine media line        
       
   109         * @leave system wide error
       
   110         */
       
   111         void EncodeMessageMediaAttributesL( CMceComMessageStream& aStream, 
       
   112                 CSdpMediaField& aMediaLine);
       
   113 
       
   114         /**
       
   115         * Decodes media related attributes
       
   116         * @param aMediaLine media line
       
   117         * @param aCodec the codec
       
   118         * @leave system wide error
       
   119         */
       
   120        	void DecodeMediaAttributesL( CSdpMediaField& aMediaLine, 
       
   121                                      CMceComCodec& aCodec,
       
   122                                      CSdpFmtAttributeField& aRtpmap ) const;
       
   123 
       
   124         /**
       
   125         * Creates media stream based on sdp type
       
   126         * @param aType the sdp type sendrecv, sendonly or receive only
       
   127         * @return media stream
       
   128         * @leave system wide error
       
   129         */
       
   130         CMceComMediaStream* CreateStreamLC( TInt aType ) const;
       
   131         
       
   132         /**
       
   133         * Updates media based on received offer
       
   134         * @param aStream media stream
       
   135         * @param aDirection the direction 
       
   136         * @leave system wide error
       
   137         */
       
   138         void UpdateStreamL( CMceComMediaStream& aStream, TInt aDirection ) const;
       
   139         
       
   140         /**
       
   141         * Creates codec based on rtpmap line
       
   142         * @param aRtpmap rtpmap line
       
   143         * @return codec or NULL, if not supported
       
   144         * @leave system wide error
       
   145         */
       
   146         CMceComCodec* CreateCodecLC( CSdpFmtAttributeField& aRtpmap ) const;
       
   147         
       
   148         /**
       
   149         * Creates codec based on payload type
       
   150         * @param aPayload payload
       
   151         * @param aMediaLine media line
       
   152         * @return codec or NULL, if not supported
       
   153         * @leave system wide error
       
   154         */
       
   155         CMceComCodec* CreateCodecLC( TUint aPayload, CSdpMediaField& aMediaLine ) const;
       
   156         
       
   157         /**
       
   158         * Decodes session level media attributes
       
   159         * @param aStream media stream
       
   160         * @param aSdpDocument sdp document
       
   161         * @return codec or NULL, if not supported
       
   162         * @leave system wide error
       
   163         */
       
   164         void DecodeSessionMediaAttributesL( CMceComMediaStream& aStream, 
       
   165                                             CSdpDocument& aSdpDocument ) const;
       
   166         
       
   167         
       
   168          
       
   169     private:
       
   170                                  
       
   171 
       
   172         /**
       
   173         * C++ Constructor
       
   174         * @param aMedia media
       
   175         */
       
   176         CMceMessageSdpCodec( RStringF aMedia );
       
   177 
       
   178         /**
       
   179         * Creates uplink audio stream with mic and rtp sink
       
   180         * @return uplink audio stream
       
   181         */
       
   182         CMceComMessageStream* CreateUplinkStreamL() const;
       
   183         
       
   184         /**
       
   185         * Creates downlink audio stream with rtp source and speaker
       
   186         * @return downlink audio stream
       
   187         */
       
   188         CMceComMessageStream* CreateDownlinkStreamL() const;
       
   189         
       
   190         /**
       
   191          * Creates fmtlist that can be used as media field fmt list -attribute
       
   192          * @param aCodecs codecs
       
   193          * @return fmtp list
       
   194          */
       
   195         HBufC8* CreateFormatListL( CMceComCodec::TIterator& aCodecs ) const;
       
   196         
       
   197         /**
       
   198          * Decodes media line's format list to payload type array
       
   199          * @param aMediaLine Media line
       
   200          * @param aPayloadTypes payload types as an array
       
   201          */
       
   202         void DecodeFormatListL( CSdpMediaField& aMedia, 
       
   203                         RArray<TUint>& aPayloadTypes ) const;
       
   204         
       
   205         /**
       
   206         * Decodes media line's format list to payload type array
       
   207         * @param aMediaLine Media line
       
   208         * @param aPayloadTypes payload types as an array
       
   209         * @return  system wide error
       
   210         */
       
   211         TInt DecodeFormatList( CSdpMediaField& aMedia, 
       
   212                                RArray<TUint>& aPayloadTypes ) const;
       
   213         
       
   214         /**
       
   215          * Decodes static payloads if payload wasn't defined as rtpmap
       
   216          * @param aMediaLine Media line
       
   217          * @param aStream stream
       
   218          * @param aPayloadTypes payload types as an array
       
   219          * @param aRole role of negotiation
       
   220          * @return number of lines decoded
       
   221          */
       
   222         TInt DecodeStaticPayloadsL( CSdpMediaField& aMediaLine,
       
   223                 CMceComMediaStream& aStream,
       
   224                 RArray<TUint>& aPayloadTypes,
       
   225                 TMceNegotiationRole aRole ) const;
       
   226         
       
   227         /**
       
   228          * If the path attribute is set for the message streams then this funtion
       
   229          * extracts the host and port informaiotn and sets accordinlgy to the 
       
   230          * media stream
       
   231          */
       
   232         void SetHostAddrFromPathAttrL(const TUriC8& aMsrpUri, 
       
   233                 CSdpMediaField& aMediaLine);
       
   234         
       
   235         /**
       
   236          * Set MSRP path SDP attribute  to the media line
       
   237          */
       
   238         void SetPathAttributeL(CMceComMessageStream& aMsgStream, 
       
   239                 CMceComMsrpSource* msrpSource, 
       
   240                 CMceComMsrpSink* msrpSink,
       
   241                 CSdpMediaField& aMediaLine);
       
   242         
       
   243         /**
       
   244          * Set MSRP SDP AcceptTypes attribte to the media line 
       
   245          */
       
   246         void SetAcceptTypesAttributeL(CMceComMsrpSource* msrpSource, CMceComMsrpSink* msrpSink, 
       
   247                      CSdpMediaField& aMediaLine);
       
   248         
       
   249         /**
       
   250          * Set MSRP SDP AcceptWrappedTypes attribte to the media line
       
   251          */
       
   252         void SetAcceptWrappedAttributeL(CMceComMsrpSource* msrpSource, CMceComMsrpSink* msrpSink,
       
   253                      CSdpMediaField& aMediaLine);
       
   254         
       
   255         /*
       
   256          * Set file share attribure
       
   257          */
       
   258         void SetFileShareAttributeL(CMceComMsrpSource* msrpSource, CMceComMsrpSink* msrpSink,
       
   259                      CSdpMediaField& aMediaLine);
       
   260         
       
   261         /*
       
   262          * Parsing remotesdplines
       
   263          */
       
   264         TInt ParseSomeHeader(const TDesC8& aHeaderToParse, TParsedHeader& aParsedHeader) const;
       
   265         
       
   266         /**
       
   267          * Creates File-Selector attributes and appends it to media line
       
   268          * 
       
   269          */
       
   270         
       
   271         void EncodeFileAttributeL( CMceComMediaStream& aStream,
       
   272                                    CSdpMediaField& aMediaLine ) const;
       
   273         
       
   274         /**
       
   275          * Sets the MSRP connection usage for the MSRP based m-lines
       
   276          */
       
   277         void SetConnectionAttributeL(CMceComMessageStream& aStream,
       
   278                 CSdpMediaField& aMediaLine);
       
   279         
       
   280         void DecodeClientAttributesL( CSdpMediaField& aMediaLine, 
       
   281                                       CMceComMediaStream& aStream ) const; 
       
   282         
       
   283     private:        
       
   284         RStringF iFileSelectorStr;
       
   285         RStringF iFileTransferidStr;    
       
   286         RStringF iFileDispositionStr;
       
   287         RStringF iAcceptWrappedTypesStr;
       
   288         RStringF iPathStr;
       
   289         RStringF iAcceptTypesStr;
       
   290         RStringF iNetType;
       
   291         RStringF iAddressType;
       
   292         RStringF iConnectionStr;
       
   293     };
       
   294 
       
   295 
       
   296 
       
   297 #endif //CMceMessageSdpCodec_H
       
   298