forked from YiyiLee/webrtc-perf-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0005-reduce-the-calling-frequency-of-the-timer-thread.patch
122 lines (110 loc) · 4.58 KB
/
0005-reduce-the-calling-frequency-of-the-timer-thread.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
From af557888d99a0784a9a6c725e22cf7968d88b865 Mon Sep 17 00:00:00 2001
From: slee <[email protected]>
Date: Fri, 7 Jun 2013 11:51:20 +0800
Subject: [PATCH 05/10] reduce-the-calling-frequency-of-the-timer-thread
---
.../video_coding/main/source/video_coding_impl.cc | 30 ++++++++++++++--------
.../video_coding/main/source/video_coding_impl.h | 2 +-
2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/media/webrtc/trunk/webrtc/modules/video_coding/main/source/video_coding_impl.cc b/media/webrtc/trunk/webrtc/modules/video_coding/main/source/video_coding_impl.cc
index 8fba7de..86f823f 100644
--- a/media/webrtc/trunk/webrtc/modules/video_coding/main/source/video_coding_impl.cc
+++ b/media/webrtc/trunk/webrtc/modules/video_coding/main/source/video_coding_impl.cc
@@ -30,11 +30,17 @@ VCMProcessTimer::Period() const
}
WebRtc_UWord32
-VCMProcessTimer::TimeUntilProcess() const
+VCMProcessTimer::TimeUntilProcess(WebRtc_UWord64 now) const
{
+ if (now == 0) {
+ now = _clock->MillisecondTimestamp();
+ }
+#ifdef DEBUG
+ assert(now - _latestMs >= 0);
+#endif
return static_cast<WebRtc_UWord32>(
VCM_MAX(static_cast<WebRtc_Word64>(_periodMs) -
- (_clock->MillisecondTimestamp() - _latestMs), 0));
+ static_cast<WebRtc_Word64>(now - _latestMs), 0));
}
void
@@ -136,8 +142,10 @@ VideoCodingModuleImpl::Process()
{
WebRtc_Word32 returnValue = VCM_OK;
+ WebRtc_UWord64 now = clock_->MillisecondTimestamp();
+
// Receive-side statistics
- if (_receiveStatsTimer.TimeUntilProcess() == 0)
+ if (_receiveStatsTimer.TimeUntilProcess(now) == 0)
{
_receiveStatsTimer.Processed();
if (_receiveStatsCallback != NULL)
@@ -150,7 +158,7 @@ VideoCodingModuleImpl::Process()
}
// Send-side statistics
- if (_sendStatsTimer.TimeUntilProcess() == 0)
+ if (_sendStatsTimer.TimeUntilProcess(now) == 0)
{
_sendStatsTimer.Processed();
if (_sendStatsCallback != NULL)
@@ -169,7 +177,7 @@ VideoCodingModuleImpl::Process()
}
// Packet retransmission requests
- if (_retransmissionTimer.TimeUntilProcess() == 0)
+ if (_retransmissionTimer.TimeUntilProcess(now) == 0)
{
_retransmissionTimer.Processed();
if (_packetRequestCallback != NULL)
@@ -189,7 +197,7 @@ VideoCodingModuleImpl::Process()
}
// Key frame requests
- if (_keyRequestTimer.TimeUntilProcess() == 0)
+ if (_keyRequestTimer.TimeUntilProcess(now) == 0)
{
_keyRequestTimer.Processed();
if (_scheduleKeyRequest && _frameTypeCallback != NULL)
@@ -201,7 +209,6 @@ VideoCodingModuleImpl::Process()
}
}
}
-
return returnValue;
}
@@ -232,19 +239,20 @@ VideoCodingModuleImpl::ChangeUniqueId(const WebRtc_Word32 id)
WebRtc_Word32
VideoCodingModuleImpl::TimeUntilNextProcess()
{
+ WebRtc_UWord64 now = clock_->MillisecondTimestamp();
WebRtc_UWord32 timeUntilNextProcess = VCM_MIN(
- _receiveStatsTimer.TimeUntilProcess(),
- _sendStatsTimer.TimeUntilProcess());
+ _receiveStatsTimer.TimeUntilProcess(now),
+ _sendStatsTimer.TimeUntilProcess(now));
if ((_receiver.NackMode() != kNoNack) ||
(_dualReceiver.State() != kPassive))
{
// We need a Process call more often if we are relying on
// retransmissions
timeUntilNextProcess = VCM_MIN(timeUntilNextProcess,
- _retransmissionTimer.TimeUntilProcess());
+ _retransmissionTimer.TimeUntilProcess(now));
}
timeUntilNextProcess = VCM_MIN(timeUntilNextProcess,
- _keyRequestTimer.TimeUntilProcess());
+ _keyRequestTimer.TimeUntilProcess(now));
return timeUntilNextProcess;
}
diff --git a/media/webrtc/trunk/webrtc/modules/video_coding/main/source/video_coding_impl.h b/media/webrtc/trunk/webrtc/modules/video_coding/main/source/video_coding_impl.h
index 80e3c81..5d3c6fa 100644
--- a/media/webrtc/trunk/webrtc/modules/video_coding/main/source/video_coding_impl.h
+++ b/media/webrtc/trunk/webrtc/modules/video_coding/main/source/video_coding_impl.h
@@ -37,7 +37,7 @@ public:
_periodMs(periodMs),
_latestMs(_clock->MillisecondTimestamp()) {}
WebRtc_UWord32 Period() const;
- WebRtc_UWord32 TimeUntilProcess() const;
+ WebRtc_UWord32 TimeUntilProcess(WebRtc_UWord64 now = 0) const;
void Processed();
private:
--
1.7.12.4 (Apple Git-37)