Home | History | Annotate | Download | only in src
      1 /* ------------------------------------------------------------------
      2  * Copyright (C) 1998-2009 PacketVideo
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
     13  * express or implied.
     14  * See the License for the specific language governing permissions
     15  * and limitations under the License.
     16  * -------------------------------------------------------------------
     17  */
     18 
     19 /**
     20  *  @file time_comparison_utils.h
     21  *  @brief Provides time comparison utilities
     22  */
     23 
     24 #ifndef TIME_COMPARISON_UTILS_H_INCLUDED
     25 #define TIME_COMPARISON_UTILS_H_INCLUDED
     26 
     27 #ifndef OSCL_BASE_H_INCLUDED
     28 #include "oscl_base.h"
     29 #endif
     30 
     31 #ifndef PVMF_TIMESTAMP_H_INCLUDED
     32 #include "pvmf_timestamp.h"
     33 #endif
     34 
     35 
     36 class PVTimeComparisonUtils
     37 {
     38     public:
     39         typedef enum
     40         {
     41             MEDIA_EARLY_OUTSIDE_WINDOW,
     42             MEDIA_EARLY_WITHIN_WINDOW,
     43             MEDIA_ONTIME_WITHIN_WINDOW,
     44             MEDIA_LATE_WITHIN_WINDOW,
     45             MEDIA_LATE_OUTSIDE_WINDOW
     46         } MediaTimeStatus;
     47 
     48 
     49         /*!*********************************************************************
     50         **
     51         ** Function:    IsEarlier
     52         **
     53         ** Synopsis: This function returns true if TimeA is considered EARLIER than TimeB.
     54         **
     55         ** Arguments :
     56         ** @param  [aTimeA] -- Time stamp to be compared.
     57         ** @param  [aTimeB] -- Time stamp to be compared.
     58         ** @param  [delta]  -- delta is an output parameter and is always
     59         **                     a small positive value representing TimeB-TimeA if TimeA is earlier
     60         **                     than TimeB or TimeA-TimeB if TimeB is earlier than TimeA.
     61 
     62         ** Returns:
     63         ** @return  bool  -- returns true if TimeA is considered EARLIER than TimeB.
     64         **
     65         **
     66         ** Notes:
     67         **
     68         **********************************************************************/
     69 
     70         OSCL_IMPORT_REF static bool IsEarlier(
     71             /*IN*/ uint32 aTimeA,
     72             /*IN*/ uint32 aTimeB,
     73             /*OUT*/ uint32& delta);
     74 
     75         /*!*********************************************************************
     76         **
     77         ** Function:    CheckTimeWindow
     78         **
     79         ** Synopsis: This function would return one of MEDIA_EARLY_OUTSIDE_WINDOW, MEDIA_EARLY_WITHIN_WINDOW,
     80         **           MEDIA_LATE_WITHIN_WINDOW or MEDIA_LATE_OUTSIDE_WINDOW depending on where the TimeStamp
     81         **           is within the window specified by (Clock-LateMargin) to (Clock+EarlyMargin).
     82         **
     83         ** Arguments :
     84         ** @param  [aTimeStamp]    -- Time stamp to be checked.
     85         ** @param  [aClock]        -- present clock value.
     86         ** @param  [aEarlyMargin]  -- early margin of the window
     87         ** @param  [aLateMargin]   -- late margin of the window
     88         ** @param  [aDelta]        -- aDelta is an output parameter and would contain the difference
     89         **                            in timestamp and clock in positive form.
     90 
     91         ** Returns:
     92         ** @return  MediaTimeStatus  -- returns one of the values from MediaTimeStatus enum.
     93         **
     94         **
     95         ** Notes:
     96         **
     97         **********************************************************************/
     98 
     99         OSCL_IMPORT_REF static MediaTimeStatus CheckTimeWindow(
    100             /*IN*/ PVMFTimestamp aTimeStamp,
    101             /*IN*/ uint32 aClock,
    102             /*IN*/ uint32 aEarlyMargin,
    103             /*IN*/ uint32 aLateMargin,
    104             /*OUT*/ uint32 &aDelta);
    105 
    106 };
    107 #endif
    108