• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 A_JITTER_CALCULATOR_H_
18 
19 #define A_JITTER_CALCULATOR_H_
20 
21 #include <stdint.h>
22 #include <utils/RefBase.h>
23 
24 namespace android {
25 
26 class JitterCalc : public RefBase {
27 private:
28     // Time Stamp per Second
29     const int32_t mClockRate;
30 
31     uint32_t mFirstTimeStamp;
32     uint32_t mLastTimeStamp;
33     int64_t mFirstArrivalTimeUs;
34     int64_t mLastArrivalTimeUs;
35 
36     int32_t mBaseJitterUs;
37     int32_t mInterArrivalJitterUs;
38 
39 public:
40     JitterCalc(int32_t clockRate);
41 
42     void init(uint32_t rtpTime, int64_t arrivalTimeUs, int32_t base, int32_t inter);
43     void putInterArrivalData(int64_t rtpTime, int64_t arrivalTime);
44     void putBaseData(int64_t rtpTime, int64_t arrivalTimeUs);
45     int32_t getBaseJitterMs();
46     int32_t getInterArrivalJitterMs();
47 };
48 
49 }   // namespace android
50 
51 #endif  // A_JITTER_CALCULATOR_H_
52