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/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.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: 4.4 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_RTP_RTCP_TEST_BWESTANDALONE_TESTLOADGENERATOR_H_
12#define WEBRTC_MODULES_RTP_RTCP_TEST_BWESTANDALONE_TESTLOADGENERATOR_H_
13
14#include <stdlib.h>
15
16#include "webrtc/modules/interface/module_common_types.h"
17#include "webrtc/typedefs.h"
18
19class TestSenderReceiver;
20namespace webrtc {
21class CriticalSectionWrapper;
22class EventWrapper;
23class ThreadWrapper;
24}
25
26class TestLoadGenerator
27{
28public:
29    TestLoadGenerator (TestSenderReceiver *sender, int32_t rtpSampleRate = 90000);
30    virtual ~TestLoadGenerator ();
31
32    int32_t SetBitrate (int32_t newBitrateKbps);
33    virtual int32_t Start (const char *threadName = NULL);
34    virtual int32_t Stop ();
35    virtual bool GeneratorLoop () = 0;
36
37protected:
38    virtual int generatePayload ( uint32_t timestamp ) = 0;
39    int generatePayload ();
40    int sendPayload (const uint32_t timeStamp,
41        const uint8_t* payloadData,
42        const uint32_t payloadSize,
43        const webrtc::FrameType frameType = webrtc::kVideoFrameDelta);
44
45    webrtc::CriticalSectionWrapper* _critSect;
46    webrtc::EventWrapper *_eventPtr;
47    webrtc::ThreadWrapper* _genThread;
48    int32_t _bitrateKbps;
49    TestSenderReceiver *_sender;
50    bool _running;
51    int32_t _rtpSampleRate;
52};
53
54
55class CBRGenerator : public TestLoadGenerator
56{
57public:
58    CBRGenerator (TestSenderReceiver *sender, int32_t payloadSizeBytes, int32_t bitrateKbps, int32_t rtpSampleRate = 90000);
59    virtual ~CBRGenerator ();
60
61    virtual int32_t Start () {return (TestLoadGenerator::Start("CBRGenerator"));};
62
63    virtual bool GeneratorLoop ();
64
65protected:
66    virtual int generatePayload ( uint32_t timestamp );
67
68    int32_t _payloadSizeBytes;
69    uint8_t *_payload;
70};
71
72
73class CBRFixFRGenerator : public TestLoadGenerator // constant bitrate and fixed frame rate
74{
75public:
76    CBRFixFRGenerator (TestSenderReceiver *sender, int32_t bitrateKbps, int32_t rtpSampleRate = 90000,
77        int32_t frameRateFps = 30, double spread = 0.0);
78    virtual ~CBRFixFRGenerator ();
79
80    virtual int32_t Start () {return (TestLoadGenerator::Start("CBRFixFRGenerator"));};
81
82    virtual bool GeneratorLoop ();
83
84protected:
85    virtual int32_t nextPayloadSize ();
86    virtual int generatePayload ( uint32_t timestamp );
87
88    int32_t _payloadSizeBytes;
89    uint8_t *_payload;
90    int32_t _payloadAllocLen;
91    int32_t _frameRateFps;
92    double      _spreadFactor;
93};
94
95class PeriodicKeyFixFRGenerator : public CBRFixFRGenerator // constant bitrate and fixed frame rate with periodically large frames
96{
97public:
98    PeriodicKeyFixFRGenerator (TestSenderReceiver *sender, int32_t bitrateKbps, int32_t rtpSampleRate = 90000,
99        int32_t frameRateFps = 30, double spread = 0.0, double keyFactor = 4.0, uint32_t keyPeriod = 300);
100    virtual ~PeriodicKeyFixFRGenerator () {}
101
102protected:
103    virtual int32_t nextPayloadSize ();
104
105    double          _keyFactor;
106    uint32_t    _keyPeriod;
107    uint32_t    _frameCount;
108};
109
110// Probably better to inherit CBRFixFRGenerator from CBRVarFRGenerator, but since
111// the fix FR version already existed this was easier.
112class CBRVarFRGenerator : public CBRFixFRGenerator // constant bitrate and variable frame rate
113{
114public:
115    CBRVarFRGenerator(TestSenderReceiver *sender, int32_t bitrateKbps, const uint8_t* frameRates,
116        uint16_t numFrameRates, int32_t rtpSampleRate = 90000, double avgFrPeriodMs = 5.0,
117        double frSpreadFactor = 0.05, double spreadFactor = 0.0);
118
119    ~CBRVarFRGenerator();
120
121protected:
122    virtual void ChangeFrameRate();
123    virtual int32_t nextPayloadSize ();
124
125    double       _avgFrPeriodMs;
126    double       _frSpreadFactor;
127    uint8_t* _frameRates;
128    uint16_t _numFrameRates;
129    int64_t  _frChangeTimeMs;
130};
131
132class CBRFrameDropGenerator : public CBRFixFRGenerator // constant bitrate and variable frame rate
133{
134public:
135    CBRFrameDropGenerator(TestSenderReceiver *sender, int32_t bitrateKbps,
136                    int32_t rtpSampleRate = 90000, double spreadFactor = 0.0);
137
138    ~CBRFrameDropGenerator();
139
140protected:
141    virtual int32_t nextPayloadSize();
142
143    double       _accBits;
144};
145
146#endif // WEBRTC_MODULES_RTP_RTCP_TEST_BWESTANDALONE_TESTLOADGENERATOR_H_
Note: See TracBrowser for help on using the repository browser.