mmserv/voipaudioservices/inc/JitterBuffer.h
changeset 53 eabc8c503852
parent 0 71ca22bcf22a
equal deleted inserted replaced
48:a493a607b5bf 53:eabc8c503852
     9  * Initial Contributors:
     9  * Initial Contributors:
    10  * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11  *
    11  *
    12  * Contributors:
    12  * Contributors:
    13  *
    13  *
    14  * Description:  Jitter buffer for audio frames.
    14  * Description: Jitter buffer for audio frames.
    15  *  Interface   : VoIPJitterBuffer.lib
    15  * Interface  : VoIPJitterBuffer.lib
    16  *
    16  *
    17  */
    17  */
    18 
    18 
    19 #ifndef __VOIPJITTERBUFFER_H
    19 #ifndef VOIPJITTERBUFFER_H
    20 #define __VOIPJITTERBUFFER_H
    20 #define VOIPJITTERBUFFER_H
    21 
    21 
    22 // DATA TYPES
    22 // DATA TYPES
    23 
    23 
    24 // FORWARD DECLARATIONS
    24 // FORWARD DECLARATIONS
    25 class CMccCnGenerator;
    25 class CMccCnGenerator;
    31 
    31 
    32 /**
    32 /**
    33  *  Jitter buffer.
    33  *  Jitter buffer.
    34  *
    34  *
    35  *  @lib VoIPJitterBuffer.lib
    35  *  @lib VoIPJitterBuffer.lib
    36  *  @since Series 60 5.0
       
    37  */
    36  */
    38 class CVoIPJitterBuffer : public CActive
    37 class CVoIPJitterBuffer : public CActive
    39     {
    38     {
    40 private:
    39 private:
    41     /**
    40     /**
    52      * Transition states during JB playback
    51      * Transition states during JB playback
    53      */
    52      */
    54     enum TJBTransitionState
    53     enum TJBTransitionState
    55         {
    54         {
    56         EWait,
    55         EWait,
    57         //    ENeedData,
    56         //ENeedData,
    58         EEmptyData
    57         EEmptyData
    59         };
    58         };
    60 
    59 
    61 public:
    60 public:
    62     // Constructors and destructor
    61     // Constructors and destructor
    75     // Methods
    74     // Methods
    76 
    75 
    77     /**
    76     /**
    78      * SetupL
    77      * SetupL
    79      * Sets codec information and initializes JB.
    78      * Sets codec information and initializes JB.
    80      * @since Series 60 5.0
    79      *
    81      * @param TFourCC - codec's fourcc
    80      * @param TFourCC - codec's fourcc
    82      * @param TVoIPJBConfig& - JB configuraion parameters
    81      * @param TVoIPJBConfig& - JB configuraion parameters
    83      * @return void
    82      * @return void
    84      */
    83      */
    85     IMPORT_C void SetupL(const TFourCC aCodec, const TVoIPJBConfig& aJBConfig);
    84     IMPORT_C void SetupL(const TFourCC aCodec, const TVoIPJBConfig& aJBConfig);
    86 
    85 
    87     /**
    86     /**
    88      * ResetBuffer
    87      * ResetBuffer
    89      * Resets JB to its original state with no data.
    88      * Resets JB to its original state with no data.
    90      * @since Series 60 5.0
    89      *
    91      * @param TBool - ETrue == tone is to be played
    90      * @param TBool - ETrue == tone is to be played
    92      * @return void
    91      * @return void
    93      */
    92      */
    94     IMPORT_C void ResetBuffer(TBool aPlayTone = ETrue);
    93     IMPORT_C void ResetBuffer(TBool aPlayTone = ETrue);
    95 
    94 
    96     /**
    95     /**
    97      * Delay Down
    96      * Delay Down
    98      *
    97      *
    99      * @since Series 60 5.0
       
   100      * @param none
    98      * @param none
   101      * @return void
    99      * @return void
   102      */
   100      */
   103     IMPORT_C void DelayDown();
   101     IMPORT_C void DelayDown();
   104 
   102 
   105     /**
   103     /**
   106      * Delay Up
   104      * Delay Up
   107      *
   105      *
   108      * @since Series 60 5.0
       
   109      * @param none
   106      * @param none
   110      * @return void
   107      * @return void
   111      */
   108      */
   112     IMPORT_C void DelayUp();
   109     IMPORT_C void DelayUp();
   113 
   110 
   114     /**
   111     /**
   115      * Play
   112      * Play
   116      *
   113      *
   117      * @since Series 60 5.0
       
   118      * @param none
   114      * @param none
   119      * @return void
   115      * @return void
   120      */
   116      */
   121     IMPORT_C void Play();
   117     IMPORT_C void Play();
   122 
   118 
   123     /**
   119     /**
   124      * Pause
   120      * Pause
   125      *
   121      *
   126      * @since Series 60 5.0
       
   127      * @param none
   122      * @param none
   128      * @return void
   123      * @return void
   129      */
   124      */
   130     IMPORT_C void Pause();
   125     IMPORT_C void Pause();
   131 
   126 
   132     /**
   127     /**
   133      * Stop
   128      * Stop
   134      *
   129      *
   135      * @since Series 60 5.0
       
   136      * @param none
   130      * @param none
   137      * @return void
   131      * @return void
   138      */
   132      */
   139     IMPORT_C void Stop();
   133     IMPORT_C void Stop();
   140 
   134 
   141     /**
   135     /**
   142      * FillBuffer
   136      * FillBuffer
   143      * Retrieves next frame from JB queue.
   137      * Retrieves next frame from JB queue.
   144      * @since Series 60 5.0
   138      *
   145      * @param CMMFBuffer* - buffer to be filled with data from the JB
   139      * @param CMMFBuffer* - buffer to be filled with data from the JB
   146      * @return TInt
   140      * @return TInt
   147      */
   141      */
   148     IMPORT_C TInt FillBuffer(CMMFBuffer* aBuffer);
   142     IMPORT_C TInt FillBuffer(CMMFBuffer* aBuffer);
   149 
   143 
   150     /**
   144     /**
   151      * EmptyBufferL
   145      * EmptyBufferL
   152      * Queues received frame in JB.
   146      * Queues received frame in JB.
   153      * @since Series 60 5.0
   147      *
   154      * @param CMMFBuffer* - buffer to be queued in the JB
   148      * @param CMMFBuffer* - buffer to be queued in the JB
   155      * @return TInt
   149      * @return TInt
   156      */
   150      */
   157     IMPORT_C TInt EmptyBuffer(CMMFBuffer* aBuffer);
   151     IMPORT_C TInt EmptyBuffer(CMMFBuffer* aBuffer);
   158 
   152 
   186 private:
   180 private:
   187     // Internal helper methods
   181     // Internal helper methods
   188 
   182 
   189     /**
   183     /**
   190      * Play current frame from JB.
   184      * Play current frame from JB.
   191      * @since Series 60 5.0
   185      *
   192      * @param none
   186      * @param none
   193      * @return void
   187      * @return void
   194      */
   188      */
   195     void PlayBuffer();
   189     void PlayBuffer();
   196 
   190 
   197     /**
   191     /**
   198      * TransitionState
   192      * TransitionState
   199      * @since Series 60 5.0
   193      *
   200      * @param TJBTransitionState
   194      * @param TJBTransitionState
   201      * @param TUint32
   195      * @param TUint32
   202      * @return void
   196      * @return void
   203      */
   197      */
   204     void TransitionState(TJBTransitionState aTransitionState,
   198     void TransitionState(TJBTransitionState aTransitionState,
   205             TUint32 aStateChangeDelay = 0);
   199             TUint32 aStateChangeDelay = 0);
   206 
   200 
   207     /**
   201     /**
   208      * Calculates the time interval at which data rate should be slowed down
   202      * Calculates the time interval at which data rate should be slowed down
   209      * when subsequent EmptyBufferL calls are coming too fast.
   203      * when subsequent EmptyBufferL calls are coming too fast.
   210      * @since Series 60 5.0
   204      *
   211      * @param none
   205      * @param none
   212      * @return Suggested delay in microseconds.
   206      * @return Suggested delay in microseconds.
   213      */
   207      */
   214     TUint32 DetermineEmptyBufferDelay();
   208     TUint32 DetermineEmptyBufferDelay();
   215 
   209 
   238     TUint32 iSampleInterval;
   232     TUint32 iSampleInterval;
   239     TUint32 iEmptyBufferDelayThreshold;
   233     TUint32 iEmptyBufferDelayThreshold;
   240 
   234 
   241     // Current request size of the buffer
   235     // Current request size of the buffer
   242     TInt iRequestSize;
   236     TInt iRequestSize;
   243 
       
   244     };
   237     };
   245 
   238 
   246 #endif  //__VOIPJITTERBUFFER_H
   239 #endif //VOIPJITTERBUFFER_H
   247 
   240 
   248 // End of file
   241 // End of file