mmsharing/livecommsui/lcui/tsrc/mustester/Stubs/mceclientstub/inc/mcecodec.h
branchRCL_3
changeset 33 bc78a40cd63c
parent 32 73a1feb507fb
child 35 6c57ef9392d2
equal deleted inserted replaced
32:73a1feb507fb 33:bc78a40cd63c
     1 /*
       
     2 * Copyright (c) 2006 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 #ifndef MCECODEC_H
       
    20 #define MCECODEC_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include "mcedefs.h"
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class RReadStream;
       
    28 class RWriteStream;
       
    29 class CMceComCodec;
       
    30 
       
    31 class CMceMediaStream;
       
    32 class TMceEvent;
       
    33 class TMceMediaId;
       
    34 class TMceFactory;
       
    35 
       
    36 // DATA TYPES
       
    37 typedef TUint TMceCodecType;
       
    38 
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43 * Base class for codecs.
       
    44 *
       
    45 * It defines setters and getters for generic codec attributes.
       
    46 *
       
    47 * In some systems certain device resources cannot be shared. For example
       
    48 * speaker of the device might not be able to play simultaneously several
       
    49 * differently encoded audio streams. Or only one client at the time
       
    50 * could use the camera of the device. Codec states can be used to overcome
       
    51 * situations where single codec would occupy some resource for excessive
       
    52 * period of time or permanently. 
       
    53 *
       
    54 * Codec can be in one of the three states:
       
    55 *
       
    56 * When codec is in state EEnabled, resources, associated with the codec,
       
    57 * are reserved for the codec and in some cases cannot be used by other
       
    58 * software components. Precondition for reserving resources for the codec
       
    59 * is that associated device resource (e.g. speaker sink of downlink or
       
    60 * camera source of uplink) is also enabled.
       
    61 *
       
    62 * When codec is in state EStandby, resources are not reserved for the codec
       
    63 * and therefore can be used by other software components. If the stream 
       
    64 * (uplink or downlink), into which this codec is attached, encounters data
       
    65 * encoded with the codec, codec in state EStandby is tried to be enabled.
       
    66 * If enabling succeeds, codec state changes to EEnabled and associated
       
    67 * resources are reserved.
       
    68 *
       
    69 * When codec is in state EDisabled, resources are not reserved for the codec
       
    70 * and are not even tried to be reserved.    
       
    71 *
       
    72 * @lib mceclient.lib
       
    73 */
       
    74 class CMceCodec : public CBase
       
    75     {
       
    76     
       
    77     public:  // Codec states
       
    78     
       
    79         enum TState
       
    80             {
       
    81             EDisabled, 
       
    82             EStandby,
       
    83             EEnabled
       
    84             };
       
    85     
       
    86 	public:  // Constructors and destructor
       
    87 	        
       
    88 	    /**
       
    89 	    * Destructor.
       
    90 	    */
       
    91 	    virtual ~CMceCodec();
       
    92 
       
    93 	public: // New functions
       
    94 	         
       
    95 	    /**
       
    96 	    * Sets bitrate used with codec for encoding.
       
    97 	    * @param aBitrate bitrate value for encoding
       
    98 	    * @return KErrNotSupported if codec doesn't support bitrate
       
    99 	    *         value issued
       
   100 	    */
       
   101 	    virtual TInt SetBitrate( TUint aBitrate ) = 0;
       
   102 	    
       
   103 	    /**
       
   104 	    * Sets bitrates allowed with codec.
       
   105 	    * @param aBitrates allowed bitrate values
       
   106 	    * @return KErrNotSupported if codec doesn't support bitrate
       
   107 	    *         values issued
       
   108 	    */
       
   109 	    virtual TInt SetAllowedBitrates( TUint aBitrates ) = 0;
       
   110 	    
       
   111 	    /**
       
   112 	    * Sets the codec specific mode.
       
   113 	    * @param aCodecMode mode of the codec 
       
   114 	    * @return KErrNotSupported if codec doesnt' support codec mode
       
   115 	    *         value issued
       
   116 	    */
       
   117 	    virtual TInt SetCodecMode( TUint aCodecMode ) = 0;
       
   118 	    
       
   119 	    /**
       
   120 	    * Sets the payload type.
       
   121 	    * @param aPayloadType type identifier of the payload
       
   122 	    * @return KErrNotSupported if codec doesn't support payload type issued
       
   123 	    */
       
   124 	    virtual TInt SetPayloadType( TUint8 aPayloadType ) = 0;
       
   125 	    
       
   126 	
       
   127 	public: // New functions          
       
   128 
       
   129         /**
       
   130         * Sets the state of the codec.
       
   131         * @param aState desired codec state
       
   132         */
       
   133         IMPORT_C void SetStateL( CMceCodec::TState aState );
       
   134 
       
   135         /**
       
   136         * Sets the timer period in seconds from starting of inactivity
       
   137         * to automatically changing to state CMceCodec::EStandby .
       
   138         * @param aTimerValue timer period in seconds
       
   139         */
       
   140         IMPORT_C void SetStandByTimerL( TUint32 aTimerValue );
       
   141 
       
   142         /**
       
   143 	    * Sets MMF priority value for the codec.
       
   144 	    * @param aPriority priority of the codec
       
   145 	    */
       
   146         IMPORT_C void SetMMFPriorityL( TInt aPriority );
       
   147         
       
   148         /**
       
   149 	    * Sets MMF priority preference value for the codec.
       
   150 	    * @param aPriorityPreference priority preference of the codec
       
   151 	    */
       
   152         IMPORT_C void SetMMFPriorityPreferenceL( TInt aPriorityPreference );
       
   153         
       
   154         /**
       
   155         * Set keep alive packets send timer value.
       
   156         * @param aTimerValue timer value in ms for keep alive packets
       
   157         * @return One of the standard system-wide error codes.
       
   158         */
       
   159         IMPORT_C void SetKeepAliveTimerL( TUint8 aTimerValue );
       
   160 
       
   161         /**
       
   162         * Set keep alive packets payload type.
       
   163         * @param aKeepAlivePT payload type for keep alive packets
       
   164         * @return One of the standard system-wide error codes.
       
   165         */
       
   166         IMPORT_C void SetKeepAlivePayloadTypeL( TUint8 aKeepAlivePT );
       
   167 
       
   168         /**
       
   169         * Set keep alive packets payload data.
       
   170         * @param aData payload data for keep alive packets
       
   171         * @return One of the standard system-wide error codes.
       
   172         */
       
   173         IMPORT_C void SetKeepAliveDataL( const TDesC8& aData );        
       
   174         
       
   175 
       
   176     public: // Getters
       
   177 
       
   178         /**
       
   179 	    * Gets the state of the codec
       
   180 	    * @return state of the codec
       
   181 	    */	
       
   182 	    IMPORT_C CMceCodec::TState State() const;
       
   183 	     
       
   184         /**
       
   185 	    * Media id of the codec.
       
   186 	    * @return media id
       
   187 	    */
       
   188 		//IMPORT_C TMceMediaId Id() const;
       
   189 		
       
   190 		/**
       
   191 	    * Type of the codec
       
   192 	    * @return codec type
       
   193 	    */
       
   194 		IMPORT_C TMceCodecType Type() const;
       
   195     	    
       
   196 	    /**
       
   197 	    * Gets codec fourCC.
       
   198 	    * @return fourCC value
       
   199 	    */        
       
   200 	    IMPORT_C TUint32 FourCC() const;
       
   201 
       
   202 	    /**
       
   203 	    * Gets current bitrate.
       
   204 	    * @return bitrate value
       
   205 	    */
       
   206 	    IMPORT_C TUint Bitrate() const;
       
   207 
       
   208 	    /**
       
   209 	    * Gets allowed bitrate values.
       
   210 	    * @return bitrate values
       
   211 	    */
       
   212 	    IMPORT_C TUint AllowedBitrates() const;
       
   213 	    
       
   214 	    /**
       
   215 	    * Gets current frame size of the codec.
       
   216 	    * @return size of single frame used by the codec
       
   217 	    */        
       
   218 	    IMPORT_C TUint FrameSize() const;
       
   219 
       
   220 	    /**
       
   221 	    * Gets the codec mode.
       
   222 	    * @return codec mode
       
   223 	    */
       
   224 	    IMPORT_C TUint CodecMode() const;
       
   225 	    	    
       
   226 	    /**
       
   227 	    * Gets the payload type identifier.
       
   228 	    * @return payload type used
       
   229 	    */
       
   230 	    IMPORT_C TUint8 PayloadType() const;
       
   231 	    
       
   232 	    /**
       
   233 	    * Gets the sdp name.
       
   234 	    * @return sdp name of the codec
       
   235 	    */
       
   236 	    IMPORT_C const TDesC8& SdpName() const;
       
   237 
       
   238 		/**
       
   239 	    * Gets MMF priority
       
   240 	    * @return MMF priority
       
   241 	    */
       
   242 		IMPORT_C TInt MMFPriority() const;
       
   243 		
       
   244 		/**
       
   245 	    * Gets MMF priority preference
       
   246 	    * @return current MMFPriorityPreference
       
   247 	    */
       
   248 		IMPORT_C TInt MMFPriorityPreference() const;
       
   249 		
       
   250 		/**
       
   251         * Gets keep alive packets send timer value.
       
   252         * @return keep alive packets send timer value (ms).
       
   253         */
       
   254         IMPORT_C TUint8 KeepAliveTimer() const;
       
   255 
       
   256         /**
       
   257         * Gets keep alive packets payload type.
       
   258         * @return keep alive packets payload type.
       
   259         */
       
   260         IMPORT_C TUint8 KeepAlivePayloadType() const;
       
   261 
       
   262         /**
       
   263         * Gets keep alive packets payload data.
       
   264         * @return keep alive packets payload data.
       
   265         */
       
   266         IMPORT_C const TDesC8& KeepAliveData() const;     
       
   267         
       
   268 
       
   269 	public: // Preference manipulation    
       
   270 	    
       
   271 	    /**
       
   272 	    * Gets the preference value.
       
   273 	    * @return preference value of the codec
       
   274 	    */
       
   275 	    IMPORT_C TInt Preference() const; 
       
   276 	    
       
   277 	    /**
       
   278 	    * Sets the preference value used in media negotiation.
       
   279 	    * Codec with preference value 0 is considered as the most preferenced
       
   280 	    * codec. Preference of codecs with the same preference value is
       
   281 	    * determined by order they were added to the stream. 
       
   282 	    * @param aPreference preference value of the codec
       
   283 	    */
       
   284 	    IMPORT_C void SetPreferenceL( TInt aPeference );
       
   285 	    	    
       
   286 	
       
   287 	public: // Internal
       
   288 	 
       
   289 	    /**
       
   290 	    * Initializes the codec.
       
   291 	    * @param aParent the parent
       
   292 	    */
       
   293 	    virtual void InitializeL( CMceMediaStream& aParent );           
       
   294 	    
       
   295 	  
       
   296 	                
       
   297 	protected: // New functions
       
   298 	    
       
   299 	    /**
       
   300 	    * Sets the sdp name.
       
   301 	    * @param aSdpName sdp name for the codec
       
   302 	    */
       
   303 	    virtual void SetSdpNameL( const TDesC8& aSdpName ) = 0;
       
   304 
       
   305 	    /**
       
   306 	    * C++ default constructor.
       
   307 	    */
       
   308 	    CMceCodec();
       
   309 		
       
   310 	protected: // Data
       
   311 		
       
   312 		/**
       
   313 		* Codec type.
       
   314 		*/
       
   315 		TMceCodecType iType;
       
   316 
       
   317 	protected: // NOT owned data
       
   318 			
       
   319 	    /**
       
   320 	    * Parent stream, not owned.
       
   321 	    */
       
   322 		CMceMediaStream* iStream;
       
   323 
       
   324     private: // Reserved for future use
       
   325     
       
   326         TAny* iReserved;       
       
   327 
       
   328     public: // stub data
       
   329     
       
   330         /**
       
   331          * type of session
       
   332          */
       
   333         //TMceMediaId iID;
       
   334     	
       
   335     	/**
       
   336          * Fmtp attribute
       
   337          */
       
   338         HBufC8* iFmtpAttr;
       
   339 
       
   340     	/**
       
   341         * Sdp name used in SDP messages
       
   342         */
       
   343     	TBuf8<KMceMaxSdpNameLength> iSdpName;		
       
   344 
       
   345     	/**
       
   346         * Payload type
       
   347         */
       
   348     	TUint8 iPayloadType;
       
   349 
       
   350         /**
       
   351          * Is enabled
       
   352          */
       
   353         TBool iIsEnabled;
       
   354         
       
   355        	/**
       
   356         * Stream's bit rate
       
   357         */
       
   358     	TUint iBitrate;
       
   359 
       
   360     	/**
       
   361         * Stream's allowed bit rates
       
   362         */
       
   363     	TUint32 iAllowedBitrates;
       
   364 
       
   365     	/**
       
   366         * Codec mode ( e.g. PCMU, PCMA, Bandwidth efficient, octet aligned )
       
   367         */
       
   368     	TUint32 iCodecMode;		
       
   369     	
       
   370     	/**
       
   371     	* Codec FourCC
       
   372     	*/
       
   373     	TUint32 iFourCC;
       
   374 
       
   375     	/**
       
   376         * Codecs frame size
       
   377         */
       
   378     	TUint iFrameSize;
       
   379     	
       
   380     	/**
       
   381         * 
       
   382         */
       
   383         TInt iMMFPriority;
       
   384         
       
   385         /**
       
   386         * 
       
   387         */
       
   388         TInt iMMFPriorityPreference;
       
   389         
       
   390     	/**
       
   391         * 
       
   392         */
       
   393         TUint8 iKeepAliveTimer;
       
   394         
       
   395     	/**
       
   396         * Codecs frame size
       
   397         */
       
   398     	TUint8 iKeepAlivePayloadType;
       
   399 
       
   400         /**
       
   401         * 
       
   402         */
       
   403         TBuf8<10> iKeepAliveData;
       
   404         
       
   405         TInt iPreference;
       
   406 	
       
   407     };
       
   408 
       
   409 
       
   410 #endif
       
   411 
       
   412 // End of File