1 /** 2 * Copyright (C) 2022 The Android Open Source Project 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 express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef IMS_MEDIA_TIMER_H 18 #define IMS_MEDIA_TIMER_H 19 20 #include <stdint.h> 21 22 typedef void* hTimerHandler; 23 typedef void (*fn_TimerCb)(hTimerHandler hTimer, void* pUserData); 24 struct IMNtpTime 25 { 26 uint32_t ntpHigh32Bits; 27 uint32_t ntpLow32Bits; 28 }; 29 30 class ImsMediaTimer 31 { 32 public: 33 static hTimerHandler TimerStart( 34 uint32_t nDuration, bool bRepeat, fn_TimerCb pTimerCb, void* pUserData); 35 static bool TimerStop(hTimerHandler hTimer, void** ppUserData); 36 static void SetStartTimeInMicroSeconds(uint64_t time); 37 static uint64_t GetTimeInMicroSeconds(void); 38 static uint32_t GetTimeInMilliSeconds(void); 39 static uint32_t GenerateRandom(uint32_t nRange); 40 static int32_t Atomic_Inc(int32_t* v); 41 static int32_t Atomic_Dec(int32_t* v); 42 static void Sleep(unsigned int t); // milliseconds 43 static void USleep(unsigned int t); // microseconds 44 }; 45 #endif 46