multimediacommsengine/mmcefloorctrlengine/inc/fcsession.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     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:    The class provides the FC session information
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef CFCSESSION_H
       
    22 #define CFCSESSION_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include <e32base.h>
       
    26 #include <sdpcodecstringpool.h>
       
    27 
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class MFCPlugIn;
       
    31 class CFCInterface;
       
    32 class CSdpDocument;
       
    33 class CSdpMediaField;
       
    34 class CSdpConnectionField;
       
    35 class SdpCodecStringPool;
       
    36 class CSdpFmtAttributeField;
       
    37 
       
    38 // CLASS DECLARATION
       
    39 
       
    40 /**
       
    41  * Class contains FCSession information of particular FC sesseion service
       
    42  * If the preconditions are not met function leaves with KErrArgument system
       
    43  * error code.
       
    44  * @lib CFCPlugInEngine.lib
       
    45  */
       
    46 class CFCSession: public CBase
       
    47 	{
       
    48 	public:
       
    49 		/** Parameter for Session comparision*/
       
    50 		enum TComparison
       
    51 			{
       
    52 			/** Port Number in SDP */
       
    53 			EPort = 1,
       
    54 			/** PlugIn Name in SDP */
       
    55 			EName = 2
       
    56 			};
       
    57 
       
    58 		/**
       
    59 		* Constructs an object
       
    60 		* @param aPlugIn the plug-in
       
    61 		* @param aIapId the IAP ID
       
    62 		* @param aPort the port
       
    63 		* @returns new instance
       
    64 		*/
       
    65 		static CFCSession* NewL( MFCPlugIn* aPlugIn, 
       
    66 		                         TUint32 aIapId, 
       
    67 		                         TUint32 aPort );
       
    68 
       
    69 		/**
       
    70 		* Constructs an object and adds the pointer to the cleanup stack;
       
    71 		* leaves on failure
       
    72 		* @param aPlugIn the plug-in
       
    73 		* @param aIapId the IAP ID
       
    74 		* @param aPort the port
       
    75 		* @return new instance
       
    76 		*/
       
    77 		static CFCSession* NewLC( MFCPlugIn* aPlugIn, 
       
    78 		                          TUint32 aIapId, 
       
    79 		                          TUint32 aPort );
       
    80 
       
    81 		/**
       
    82 		* Destructor.
       
    83 		*/
       
    84 		~CFCSession();
       
    85 		
       
    86 		/**
       
    87 		* Sets media port defined for the FCSession.
       
    88 		* @param aPort The port
       
    89 		*/
       
    90 		void SetPort( const TUint aPort );
       
    91 
       
    92 		/**
       
    93 		* Gets media port defined for the FCSession
       
    94 		* @return media port
       
    95 		*/
       
    96 		TUint Port() const;
       
    97 
       
    98 		/**
       
    99 		* Gets the negotiated floor control plugIn
       
   100 		* @return negotiated floor control plugIn
       
   101 		*/
       
   102 		const TDesC8& NegotiatedFCPlugIn() const;
       
   103 
       
   104 		/**
       
   105 		* Gets the set of media format level attributes.
       
   106 		* @return RPointerArray<CSdpFmtAttributeField>&: The set of media 
       
   107         *         format level attributes.
       
   108 		*/
       
   109 		RPointerArray<CSdpFmtAttributeField>& FormatAttributeFields();
       
   110 		
       
   111 		/**
       
   112 		* Sets media format level attributes.
       
   113 		* @param aAttributes, The set of media format level attributes.
       
   114 		*        The ownership is transferred.
       
   115 		*/
       
   116 		void SetFormatAttributeFieldsL(RPointerArray<CSdpFmtAttributeField>* aAttributes);
       
   117 		
       
   118    		/**
       
   119 		* Reads & Store remote parameters of FC from offer/answer document.
       
   120 		* @param aSdpDocument, SDP document containing SDP information
       
   121 		*/
       
   122 		void StoreInfoL(const CSdpDocument& aSdpDocument);
       
   123 	
       
   124 		/**
       
   125 		* Adds or modifies the media line for FCSession to SDP document
       
   126 	    * @param aSdpDocument SDP document to be add/modify the media information
       
   127 		*/
       
   128 		void UpdateSDPL( CSdpDocument& aSdpDocument );
       
   129 
       
   130 		/**
       
   131 		*Session is released 
       
   132 		*/
       
   133 		void ReleaseSession();
       
   134 		
       
   135 		/**
       
   136 		* Session is ready to send
       
   137 		* tb_priority might be =0;
       
   138 		* Socket is open, and start to listen
       
   139 		*/
       
   140 		void ConnectionReadyL();
       
   141 		
       
   142 		/**
       
   143 		* Send the Data to the predefined addresses
       
   144 		* tb_priority must > 0
       
   145 		* @param aData, sending via this plugIn
       
   146 		*/
       
   147 		void SendToNetL(HBufC8* aData);
       
   148 		
       
   149 		/**
       
   150 		* Return a pointer to the FC plug-in, ownership is not transfered.
       
   151 		* @return MFCPlugin& The FCPlugin
       
   152 		*/
       
   153 		MFCPlugIn* PlugIn() const;
       
   154 		
       
   155 		/**
       
   156 		* Returns truth value whether or not this the plugin is 
       
   157 		* to be receive data in this sessions port.
       
   158 		*/
       
   159 		TBool IsReceiver();
       
   160 		
       
   161 		/**
       
   162 		* Updates the port and receiver flag. KFCDefaultPort means, that
       
   163 		* the session will not be receiving.
       
   164 		*/
       
   165 		void Update( TUint32 aPort );
       
   166 		
       
   167 		/**
       
   168         * Are the floor control parameters changed
       
   169         */
       
   170 		TBool UpdateNeeded();
       
   171 		
       
   172 	private:
       
   173 		/**
       
   174 		* Default constructor
       
   175 		*/
       
   176 		CFCSession( TUint32 aPort );
       
   177 
       
   178         /**
       
   179         * Symbian 2nd phase constructor.
       
   180         */
       
   181 		void ConstructL( MFCPlugIn* aPlugIn, TUint32 aIapId );
       
   182 		
       
   183 		/**
       
   184 		* Validate media format level attributes.
       
   185 		* @return 0 if iSdpFmtAttributeFields length is 0 or notset
       
   186 		*	      1 if iSdpFmtAttributeFields is set and length is not 0
       
   187 		*/
       
   188 		TBool IsFmtAttributeValid();
       
   189 		
       
   190 		/**
       
   191 		* Finds the index off FC media line in given array.
       
   192 		* @param aMediaFields, the array of media fields.
       
   193 		* @return index in the array, KErrNotFound if not found.
       
   194 		*/
       
   195 		TInt FindMediaField( 
       
   196 		    const RPointerArray< CSdpMediaField >& aMediaFields ) const;
       
   197 		    
       
   198 		/**
       
   199 		* Get the port number from SDP media fields based on the
       
   200 		* media protocol specified by plugin. Returns 0, if there's no
       
   201 		* media line for the protocol.
       
   202 		* @param aMediaFields, media fields
       
   203 		* @return a specific SDP media port based on the media protocol.
       
   204 		*/
       
   205 		TUint DecodeSDPMediaPort( 
       
   206 		    const RPointerArray< CSdpMediaField >& aMediaFields ) const;
       
   207 		
       
   208 		/**
       
   209 		* Get the connectinon address from SDP doc
       
   210 		* @param aSdpDocument, SDP document containing SDP media information
       
   211 		* @return, the connection address
       
   212 		*/
       
   213 		HBufC* DecodeConnectionAddrL( const CSdpConnectionField* aConnectionField ) const;
       
   214 		
       
   215 		/**
       
   216 		* Clean-up method, that can be given to the cleanup stack.
       
   217 		*/
       
   218 		static void ArrayCleanup(TAny* aArray);
       
   219 		
       
   220 		
       
   221 		static void ArrayCleanupAndDelete(TAny* aArray);
       
   222 	
       
   223 		/**
       
   224 		* Sets media format level attributes.
       
   225 		* @param aAttributes, The set of media format level attributes.
       
   226 		*        The ownership is transferred.
       
   227 		*/
       
   228 		void DoSetFormatAttributeFieldsL(RPointerArray<CSdpFmtAttributeField>* aAttributes);
       
   229 		
       
   230 	private:
       
   231 		
       
   232 		TUint iPort;
       
   233 		RPointerArray<CSdpFmtAttributeField>* iSdpFmtAttributeFields;
       
   234 		// The plug-in, owned
       
   235 		CFCInterface* iPlugIn;
       
   236 		TBool iIsReceiver;
       
   237 		TBool iUpdateNeeded;
       
   238 		
       
   239 	private: // For testing purposes
       
   240 		friend class UT_CFCSession;
       
   241 	};
       
   242 
       
   243 #endif // CFCSession_H
       
   244 
       
   245 //  End of File