multimediacommscontroller/mmccsubcontroller/inc/mccrtpmediaclock.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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 C_MCCRTPMEDIACLOCK_H
       
    22 #define C_MCCRTPMEDIACLOCK_H
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <e32cmn.h>
       
    26 
       
    27 
       
    28 const TUint K8Khz( 8000 );
       
    29 const TInt K20ms( 20 );
       
    30 
       
    31 /**
       
    32  * Mcc media clock registration info class
       
    33  * 
       
    34  * @lib N/A
       
    35  * @since Series 60 3.2
       
    36  */
       
    37 NONSHARABLE_CLASS( TMccRegInfo )
       
    38     {
       
    39     public:
       
    40     inline TMccRegInfo() :
       
    41             iSamplingFreq( K8Khz ),
       
    42             iHwFrametime( K20ms ),
       
    43             iKey( 0 )
       
    44             { };
       
    45     
       
    46     TUint32 iKey;
       
    47     TUint iSamplingFreq;
       
    48     TInt iHwFrametime;
       
    49     };
       
    50     
       
    51 /**
       
    52  * Media clock provides common RTP timestamp space.
       
    53  *  
       
    54  * Clock that forms common timeline for all media formats using 
       
    55  * same SSRC. Typical client for media clock is 
       
    56  * one of supported payload formatters.
       
    57  *
       
    58  * @lib    mmccsubcontroller.lib
       
    59  * @since  S60 v3.2
       
    60  */
       
    61 NONSHARABLE_CLASS( CMccRtpMediaClock ) : public CBase
       
    62     {
       
    63 public:
       
    64 
       
    65     static CMccRtpMediaClock* NewL();
       
    66 
       
    67     virtual ~CMccRtpMediaClock();
       
    68 
       
    69     /**
       
    70      * Method for client registration. Media clock's client must be registered
       
    71      * in order to use media clock services. If client has changed its
       
    72      * parameters after first registration, new registration is needed.
       
    73      *
       
    74      * @since   S60 3.2
       
    75      * @param   aSamplingFreq   Used sampling frequency.
       
    76      * @param   aHwFrametime    Used frame time.
       
    77      * @return  key             Unique key for client to use media clock
       
    78      */
       
    79     virtual TUint32 RegisterMediaFormat( TUint aSamplingFreq,
       
    80                                  TInt aHwFrametime );
       
    81 
       
    82     /**
       
    83      * Client can query next rtp time stamp. NOT for keep alive packets!
       
    84      *
       
    85      * @since   S60 3.2
       
    86      * @param   aKey            key got from registration
       
    87      * @param   aTimeStamp      time stamp is returned
       
    88      * @return  KErrNone if ok, else KErrNotFound
       
    89      */
       
    90     virtual TInt GetTimeStamp( TUint32 aKey, TUint32& aTimeStamp ); 
       
    91                       
       
    92     /**
       
    93      * Latest consumed rtp time stamp can be queried through this method.
       
    94      * Designed for keep alive packets.
       
    95      *
       
    96      * @since   S60 3.2
       
    97      * @param   aTimeStamp      latest consumed rtp time stamp is returned
       
    98      * @return  void
       
    99      */
       
   100     virtual void GetLatestConsumedTS( TUint32& aTimeStamp );
       
   101     
       
   102     /**
       
   103      * Unregisters a media format with given key. Does nothing if given
       
   104      * key is not found from registry.
       
   105      *
       
   106      * @since S60 v3.2
       
   107      * @param aKey              Registration key from RegisterMediaFormat.
       
   108      * @return void
       
   109      */
       
   110     virtual void UnregisterMediaFormat( TUint32 aKey );
       
   111     
       
   112     /**
       
   113      * Checks whether 'timebased' or 'callback' increment has been used
       
   114      */
       
   115     virtual TBool TimeBasedIncrement() const;
       
   116     
       
   117 private:
       
   118 
       
   119     CMccRtpMediaClock();
       
   120 
       
   121     void ConstructL();
       
   122     
       
   123     /**
       
   124      * Calculates new rtp time stamp.
       
   125      *
       
   126      * @since   S60 3.2
       
   127      * @return  new rtp time stamp
       
   128      */
       
   129     TUint32 TimeStampIncrement(); 
       
   130      
       
   131     /**
       
   132      * Check clients key to verify registration and to set variables
       
   133      *
       
   134      * @since   S60 3.2
       
   135      * @param   aKey     client's unique key
       
   136      * @param   aCell    
       
   137      * @return  System wide error code
       
   138      */
       
   139     TInt CheckKey( TUint32 aKey, TInt& aCell );
       
   140     
       
   141 
       
   142 private: // data
       
   143 
       
   144     /**
       
   145      * Used sampling frequency
       
   146      */
       
   147     TUint iSamplingFreq; 
       
   148     
       
   149     /**
       
   150      * Used frame time
       
   151      */
       
   152     TInt iHwFrametime;
       
   153     
       
   154     /**
       
   155      * current rtp time stamp
       
   156      */
       
   157     TUint32 iCurRtpTS;
       
   158     
       
   159     /**
       
   160      * Currently used registeration key 
       
   161      */ 
       
   162     TUint32 iUsedKey;
       
   163     
       
   164     /**
       
   165      * Array to maintain registration info
       
   166      */
       
   167     RArray<TMccRegInfo> iRegister;
       
   168     
       
   169     /**
       
   170      * Previous time when time stamp was updated
       
   171      */
       
   172     TTime iPreviousTimestamp;
       
   173     
       
   174     /**
       
   175      * Whether 'timebased' or 'callback' increment has been used
       
   176      */
       
   177     TBool iTimeBasedIncrement;
       
   178     
       
   179     };
       
   180 
       
   181 
       
   182 #endif // C_MCCRTPMEDIACLOCK_H