OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_PLAYOUT_DELAY_ORACLE_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_PLAYOUT_DELAY_ORACLE_H_ |
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_PLAYOUT_DELAY_ORACLE_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_PLAYOUT_DELAY_ORACLE_H_ |
13 | 13 |
14 #include "webrtc/base/basictypes.h" | 14 #include "webrtc/base/basictypes.h" |
15 #include "webrtc/base/criticalsection.h" | 15 #include "webrtc/base/criticalsection.h" |
16 #include "webrtc/base/thread_checker.h" | |
17 #include "webrtc/base/thread_annotations.h" | 16 #include "webrtc/base/thread_annotations.h" |
18 #include "webrtc/modules/include/module_common_types.h" | 17 #include "webrtc/modules/include/module_common_types.h" |
19 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 18 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
20 | 19 |
21 namespace webrtc { | 20 namespace webrtc { |
22 | 21 |
23 // This class tracks the application requests to limit minimum and maximum | 22 // This class tracks the application requests to limit minimum and maximum |
24 // playout delay and makes a decision on whether the current RTP frame | 23 // playout delay and makes a decision on whether the current RTP frame |
25 // should include the playout out delay extension header. | 24 // should include the playout out delay extension header. |
26 // | 25 // |
(...skipping 11 matching lines...) Expand all Loading... |
38 | 37 |
39 // Returns true if the current frame should include the playout delay | 38 // Returns true if the current frame should include the playout delay |
40 // extension | 39 // extension |
41 bool send_playout_delay() const { | 40 bool send_playout_delay() const { |
42 rtc::CritScope lock(&crit_sect_); | 41 rtc::CritScope lock(&crit_sect_); |
43 return send_playout_delay_; | 42 return send_playout_delay_; |
44 } | 43 } |
45 | 44 |
46 // Returns current minimum playout delay in milliseconds. | 45 // Returns current minimum playout delay in milliseconds. |
47 int min_playout_delay_ms() const { | 46 int min_playout_delay_ms() const { |
48 RTC_DCHECK_RUN_ON(&thread_checker_); | 47 rtc::CritScope lock(&crit_sect_); |
49 return min_playout_delay_ms_; | 48 return min_playout_delay_ms_; |
50 } | 49 } |
51 | 50 |
52 // Returns current maximum playout delay in milliseconds. | 51 // Returns current maximum playout delay in milliseconds. |
53 int max_playout_delay_ms() const { | 52 int max_playout_delay_ms() const { |
54 RTC_DCHECK_RUN_ON(&thread_checker_); | 53 rtc::CritScope lock(&crit_sect_); |
55 return max_playout_delay_ms_; | 54 return max_playout_delay_ms_; |
56 } | 55 } |
57 | 56 |
58 // Updates the application requested playout delay, current ssrc | 57 // Updates the application requested playout delay, current ssrc |
59 // and the current sequence number. | 58 // and the current sequence number. |
60 void UpdateRequest(uint32_t ssrc, | 59 void UpdateRequest(uint32_t ssrc, |
61 PlayoutDelay playout_delay, | 60 PlayoutDelay playout_delay, |
62 uint16_t seq_num); | 61 uint16_t seq_num); |
63 | 62 |
64 void OnReceivedRtcpReportBlocks(const ReportBlockList& report_blocks); | 63 void OnReceivedRtcpReportBlocks(const ReportBlockList& report_blocks); |
65 | 64 |
66 private: | 65 private: |
67 // The playout delay information is updated from the encoder thread or | 66 // The playout delay information is updated from the encoder thread(s). |
68 // a thread controlled by application in case of external encoder. | |
69 // The sequence number feedback is updated from the worker thread. | 67 // The sequence number feedback is updated from the worker thread. |
70 // Guards access to data across the two threads. | 68 // Guards access to data across multiple threads. |
71 rtc::CriticalSection crit_sect_; | 69 rtc::CriticalSection crit_sect_; |
72 // The current highest sequence number on which playout delay has been sent. | 70 // The current highest sequence number on which playout delay has been sent. |
73 int64_t high_sequence_number_ GUARDED_BY(crit_sect_); | 71 int64_t high_sequence_number_ GUARDED_BY(crit_sect_); |
74 // Indicates whether the playout delay should go on the next frame. | 72 // Indicates whether the playout delay should go on the next frame. |
75 bool send_playout_delay_ GUARDED_BY(crit_sect_); | 73 bool send_playout_delay_ GUARDED_BY(crit_sect_); |
76 // Sender ssrc. | 74 // Sender ssrc. |
77 uint32_t ssrc_ GUARDED_BY(crit_sect_); | 75 uint32_t ssrc_ GUARDED_BY(crit_sect_); |
78 | |
79 // Data in this section is accessed on the sending/encoder thread alone. | |
80 rtc::ThreadChecker thread_checker_; | |
81 // Sequence number unwrapper. | 76 // Sequence number unwrapper. |
82 SequenceNumberUnwrapper unwrapper_ GUARDED_BY(thread_checker_); | 77 SequenceNumberUnwrapper unwrapper_ GUARDED_BY(crit_sect_); |
83 // Min playout delay value on the next frame if |send_playout_delay_| is set. | 78 // Min playout delay value on the next frame if |send_playout_delay_| is set. |
84 int min_playout_delay_ms_ GUARDED_BY(thread_checker_); | 79 int min_playout_delay_ms_ GUARDED_BY(crit_sect_); |
85 // Max playout delay value on the next frame if |send_playout_delay_| is set. | 80 // Max playout delay value on the next frame if |send_playout_delay_| is set. |
86 int max_playout_delay_ms_ GUARDED_BY(thread_checker_); | 81 int max_playout_delay_ms_ GUARDED_BY(crit_sect_); |
87 | 82 |
88 RTC_DISALLOW_COPY_AND_ASSIGN(PlayoutDelayOracle); | 83 RTC_DISALLOW_COPY_AND_ASSIGN(PlayoutDelayOracle); |
89 }; | 84 }; |
90 | 85 |
91 } // namespace webrtc | 86 } // namespace webrtc |
92 | 87 |
93 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_PLAYOUT_DELAY_ORACLE_H_ | 88 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_PLAYOUT_DELAY_ORACLE_H_ |
OLD | NEW |