Note: We no longer publish the latest version of our code here. We primarily use a kumc-bmi github organization. The heron ETL repository, in particular, is not public. Peers in the informatics community should see MultiSiteDev for details on requesting access.

source: webrtc/webrtc/modules/video_coding/main/test/jitter_estimate_test.h @ 0:4bda6873e34c

pub_scrub_3792 tip
Last change on this file since 0:4bda6873e34c was 0:4bda6873e34c, checked in by Michael Prittie <mprittie@…>, 6 years ago

Scrubbed password for publication.

File size: 2.8 KB
Line 
1/*
2 *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 *
4 *  Use of this source code is governed by a BSD-style license
5 *  that can be found in the LICENSE file in the root of the source
6 *  tree. An additional intellectual property rights grant can be found
7 *  in the file PATENTS.  All contributing project authors may
8 *  be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef WEBRTC_MODULES_VIDEO_CODING_TEST_JITTER_ESTIMATE_TEST_H_
12#define WEBRTC_MODULES_VIDEO_CODING_TEST_JITTER_ESTIMATE_TEST_H_
13
14#include "webrtc/typedefs.h"
15#include "jitter_buffer.h"
16#include "jitter_estimator.h"
17#include <stdlib.h>
18#include <math.h>
19
20double const pi = 4*std::atan(1.0);
21
22class GaussDist
23{
24public:
25    GaussDist(double m, double v): _mu(m), _sigma(sqrt(v)) {}
26
27    double RandValue() // returns a single normally distributed number
28    {
29        double r1 = (std::rand() + 1.0)/(RAND_MAX + 1.0); // gives equal distribution in (0, 1]
30        double r2 = (std::rand() + 1.0)/(RAND_MAX + 1.0);
31        return _mu + _sigma * sqrt(-2*std::log(r1))*std::cos(2*pi*r2);
32    }
33
34    double GetAverage()
35    {
36        return _mu;
37    }
38
39    double GetVariance()
40    {
41        return _sigma*_sigma;
42    }
43
44    void SetParams(double m, double v)
45    {
46        _mu = m;
47        _sigma = sqrt(v);
48    }
49
50private:
51    double _mu, _sigma;
52};
53
54class JitterEstimateTestWrapper : public webrtc::VCMJitterEstimator
55{
56public:
57    JitterEstimateTestWrapper() : VCMJitterEstimator() {}
58    double GetTheta() { return _theta[0]; }
59    double GetVarNoise() { return _varNoise; }
60};
61
62class FrameSample
63{
64public:
65    FrameSample() {FrameSample(0, 0, 0, false, false);}
66    FrameSample(unsigned int ts, int64_t wallClk, unsigned int fs, bool _keyFrame, bool _resent):
67      timestamp90Khz(ts), wallClockMs(wallClk), frameSize(fs), keyFrame(_keyFrame), resent(_resent) {}
68
69    unsigned int timestamp90Khz;
70    int64_t wallClockMs;
71    unsigned int frameSize;
72    bool keyFrame;
73    bool resent;
74};
75
76class JitterEstimateTest
77{
78public:
79    JitterEstimateTest(unsigned int frameRate);
80    FrameSample GenerateFrameSample();
81    void SetCapacity(unsigned int c);
82    void SetRate(unsigned int r);
83    void SetJitter(double m, double v);
84    void SetFrameSizeStats(double m, double v);
85    void SetKeyFrameRate(int rate);
86    void SetLossRate(double rate);
87
88private:
89    double RandUniform() { return (std::rand() + 1.0)/(RAND_MAX + 1.0); }
90    unsigned int _frameRate;
91    unsigned int _capacity;
92    unsigned int _rate;
93    GaussDist _jitter;
94    //GaussDist _noResend;
95    GaussDist _deltaFrameSize;
96    unsigned int _prevTimestamp;
97    int64_t _prevWallClock;
98    unsigned int _nextDelay;
99    double _keyFrameRate;
100    unsigned int _counter;
101    unsigned int _seed;
102    double _lossrate;
103};
104
105#endif // WEBRTC_MODULES_VIDEO_CODING_TEST_JITTER_ESTIMATE_TEST_H_
Note: See TracBrowser for help on using the repository browser.