| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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_RTCP_SENDER_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_ |
| 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_ |
| 13 | 13 |
| 14 #include <map> | 14 #include <map> |
| 15 #include <memory> | 15 #include <memory> |
| 16 #include <set> | 16 #include <set> |
| 17 #include <sstream> | 17 #include <sstream> |
| 18 #include <string> | 18 #include <string> |
| 19 #include <vector> | 19 #include <vector> |
| 20 | 20 |
| 21 #include "webrtc/api/call/transport.h" | 21 #include "webrtc/api/call/transport.h" |
| 22 #include "webrtc/base/constructormagic.h" | 22 #include "webrtc/base/constructormagic.h" |
| 23 #include "webrtc/base/criticalsection.h" | 23 #include "webrtc/base/criticalsection.h" |
| 24 #include "webrtc/base/optional.h" |
| 24 #include "webrtc/base/random.h" | 25 #include "webrtc/base/random.h" |
| 25 #include "webrtc/base/thread_annotations.h" | 26 #include "webrtc/base/thread_annotations.h" |
| 26 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" | 27 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" |
| 27 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" | 28 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" |
| 28 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" | 29 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" |
| 29 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 30 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" | 31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" |
| 31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/dlrr.h" | 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/dlrr.h" |
| 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h" | 33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h" |
| 33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h" | 34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 uint16_t length); | 144 uint16_t length); |
| 144 int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric); | 145 int32_t SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric); |
| 145 | 146 |
| 146 void SendRtcpXrReceiverReferenceTime(bool enable); | 147 void SendRtcpXrReceiverReferenceTime(bool enable); |
| 147 | 148 |
| 148 bool RtcpXrReceiverReferenceTime() const; | 149 bool RtcpXrReceiverReferenceTime() const; |
| 149 | 150 |
| 150 void SetCsrcs(const std::vector<uint32_t>& csrcs); | 151 void SetCsrcs(const std::vector<uint32_t>& csrcs); |
| 151 | 152 |
| 152 void SetTargetBitrate(unsigned int target_bitrate); | 153 void SetTargetBitrate(unsigned int target_bitrate); |
| 154 void SetVideoBitrateAllocation(const BitrateAllocation& bitrate); |
| 153 bool SendFeedbackPacket(const rtcp::TransportFeedback& packet); | 155 bool SendFeedbackPacket(const rtcp::TransportFeedback& packet); |
| 154 | 156 |
| 155 private: | 157 private: |
| 156 class RtcpContext; | 158 class RtcpContext; |
| 157 | 159 |
| 158 // Determine which RTCP messages should be sent and setup flags. | 160 // Determine which RTCP messages should be sent and setup flags. |
| 159 void PrepareReport(const FeedbackState& feedback_state) | 161 void PrepareReport(const FeedbackState& feedback_state) |
| 160 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); | 162 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 161 | 163 |
| 162 bool AddReportBlock(const FeedbackState& feedback_state, | 164 bool AddReportBlock(const FeedbackState& feedback_state, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 173 std::unique_ptr<rtcp::RtcpPacket> BuildPLI(const RtcpContext& context) | 175 std::unique_ptr<rtcp::RtcpPacket> BuildPLI(const RtcpContext& context) |
| 174 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); | 176 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 175 std::unique_ptr<rtcp::RtcpPacket> BuildREMB(const RtcpContext& context) | 177 std::unique_ptr<rtcp::RtcpPacket> BuildREMB(const RtcpContext& context) |
| 176 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); | 178 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 177 std::unique_ptr<rtcp::RtcpPacket> BuildTMMBR(const RtcpContext& context) | 179 std::unique_ptr<rtcp::RtcpPacket> BuildTMMBR(const RtcpContext& context) |
| 178 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); | 180 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 179 std::unique_ptr<rtcp::RtcpPacket> BuildTMMBN(const RtcpContext& context) | 181 std::unique_ptr<rtcp::RtcpPacket> BuildTMMBN(const RtcpContext& context) |
| 180 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); | 182 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 181 std::unique_ptr<rtcp::RtcpPacket> BuildAPP(const RtcpContext& context) | 183 std::unique_ptr<rtcp::RtcpPacket> BuildAPP(const RtcpContext& context) |
| 182 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); | 184 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 183 std::unique_ptr<rtcp::RtcpPacket> BuildVoIPMetric(const RtcpContext& context) | 185 std::unique_ptr<rtcp::RtcpPacket> BuildExtendedReports( |
| 186 const RtcpContext& context) |
| 184 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); | 187 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 185 std::unique_ptr<rtcp::RtcpPacket> BuildBYE(const RtcpContext& context) | 188 std::unique_ptr<rtcp::RtcpPacket> BuildBYE(const RtcpContext& context) |
| 186 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); | 189 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 187 std::unique_ptr<rtcp::RtcpPacket> BuildFIR(const RtcpContext& context) | 190 std::unique_ptr<rtcp::RtcpPacket> BuildFIR(const RtcpContext& context) |
| 188 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); | 191 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 189 std::unique_ptr<rtcp::RtcpPacket> BuildSLI(const RtcpContext& context) | 192 std::unique_ptr<rtcp::RtcpPacket> BuildSLI(const RtcpContext& context) |
| 190 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); | 193 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 191 std::unique_ptr<rtcp::RtcpPacket> BuildRPSI(const RtcpContext& context) | 194 std::unique_ptr<rtcp::RtcpPacket> BuildRPSI(const RtcpContext& context) |
| 192 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); | 195 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 193 std::unique_ptr<rtcp::RtcpPacket> BuildNACK(const RtcpContext& context) | 196 std::unique_ptr<rtcp::RtcpPacket> BuildNACK(const RtcpContext& context) |
| 194 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); | 197 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 195 std::unique_ptr<rtcp::RtcpPacket> BuildReceiverReferenceTime( | |
| 196 const RtcpContext& context) | |
| 197 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); | |
| 198 std::unique_ptr<rtcp::RtcpPacket> BuildDlrr(const RtcpContext& context) | |
| 199 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); | |
| 200 | 198 |
| 201 private: | 199 private: |
| 202 const bool audio_; | 200 const bool audio_; |
| 203 Clock* const clock_; | 201 Clock* const clock_; |
| 204 Random random_ GUARDED_BY(critical_section_rtcp_sender_); | 202 Random random_ GUARDED_BY(critical_section_rtcp_sender_); |
| 205 RtcpMode method_ GUARDED_BY(critical_section_rtcp_sender_); | 203 RtcpMode method_ GUARDED_BY(critical_section_rtcp_sender_); |
| 206 | 204 |
| 207 RtcEventLog* const event_log_; | 205 RtcEventLog* const event_log_; |
| 208 Transport* const transport_; | 206 Transport* const transport_; |
| 209 | 207 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 uint32_t app_name_ GUARDED_BY(critical_section_rtcp_sender_); | 248 uint32_t app_name_ GUARDED_BY(critical_section_rtcp_sender_); |
| 251 std::unique_ptr<uint8_t[]> app_data_ | 249 std::unique_ptr<uint8_t[]> app_data_ |
| 252 GUARDED_BY(critical_section_rtcp_sender_); | 250 GUARDED_BY(critical_section_rtcp_sender_); |
| 253 uint16_t app_length_ GUARDED_BY(critical_section_rtcp_sender_); | 251 uint16_t app_length_ GUARDED_BY(critical_section_rtcp_sender_); |
| 254 | 252 |
| 255 // True if sending of XR Receiver reference time report is enabled. | 253 // True if sending of XR Receiver reference time report is enabled. |
| 256 bool xr_send_receiver_reference_time_enabled_ | 254 bool xr_send_receiver_reference_time_enabled_ |
| 257 GUARDED_BY(critical_section_rtcp_sender_); | 255 GUARDED_BY(critical_section_rtcp_sender_); |
| 258 | 256 |
| 259 // XR VoIP metric | 257 // XR VoIP metric |
| 260 RTCPVoIPMetric xr_voip_metric_ GUARDED_BY(critical_section_rtcp_sender_); | 258 rtc::Optional<RTCPVoIPMetric> xr_voip_metric_ |
| 259 GUARDED_BY(critical_section_rtcp_sender_); |
| 261 | 260 |
| 262 RtcpPacketTypeCounterObserver* const packet_type_counter_observer_; | 261 RtcpPacketTypeCounterObserver* const packet_type_counter_observer_; |
| 263 RtcpPacketTypeCounter packet_type_counter_ | 262 RtcpPacketTypeCounter packet_type_counter_ |
| 264 GUARDED_BY(critical_section_rtcp_sender_); | 263 GUARDED_BY(critical_section_rtcp_sender_); |
| 265 | 264 |
| 266 RTCPUtility::NackStats nack_stats_ GUARDED_BY(critical_section_rtcp_sender_); | 265 RTCPUtility::NackStats nack_stats_ GUARDED_BY(critical_section_rtcp_sender_); |
| 267 | 266 |
| 268 void SetFlag(RTCPPacketType type, bool is_volatile) | 267 rtc::Optional<BitrateAllocation> video_bitrate_allocation_ |
| 268 GUARDED_BY(critical_section_rtcp_sender_); |
| 269 |
| 270 void SetFlag(uint32_t type, bool is_volatile) |
| 269 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); | 271 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 270 void SetFlags(const std::set<RTCPPacketType>& types, bool is_volatile) | 272 void SetFlags(const std::set<RTCPPacketType>& types, bool is_volatile) |
| 271 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); | 273 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 272 bool IsFlagPresent(RTCPPacketType type) const | 274 bool IsFlagPresent(uint32_t type) const |
| 273 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); | 275 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 274 bool ConsumeFlag(RTCPPacketType type, bool forced = false) | 276 bool ConsumeFlag(uint32_t type, bool forced = false) |
| 275 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); | 277 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 276 bool AllVolatileFlagsConsumed() const | 278 bool AllVolatileFlagsConsumed() const |
| 277 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); | 279 EXCLUSIVE_LOCKS_REQUIRED(critical_section_rtcp_sender_); |
| 278 struct ReportFlag { | 280 struct ReportFlag { |
| 279 ReportFlag(RTCPPacketType type, bool is_volatile) | 281 ReportFlag(uint32_t type, bool is_volatile) |
| 280 : type(type), is_volatile(is_volatile) {} | 282 : type(type), is_volatile(is_volatile) {} |
| 281 bool operator<(const ReportFlag& flag) const { return type < flag.type; } | 283 bool operator<(const ReportFlag& flag) const { return type < flag.type; } |
| 282 bool operator==(const ReportFlag& flag) const { return type == flag.type; } | 284 bool operator==(const ReportFlag& flag) const { return type == flag.type; } |
| 283 const RTCPPacketType type; | 285 const uint32_t type; |
| 284 const bool is_volatile; | 286 const bool is_volatile; |
| 285 }; | 287 }; |
| 286 | 288 |
| 287 std::set<ReportFlag> report_flags_ GUARDED_BY(critical_section_rtcp_sender_); | 289 std::set<ReportFlag> report_flags_ GUARDED_BY(critical_section_rtcp_sender_); |
| 288 | 290 |
| 289 typedef std::unique_ptr<rtcp::RtcpPacket> (RTCPSender::*BuilderFunc)( | 291 typedef std::unique_ptr<rtcp::RtcpPacket> (RTCPSender::*BuilderFunc)( |
| 290 const RtcpContext&); | 292 const RtcpContext&); |
| 291 std::map<RTCPPacketType, BuilderFunc> builders_; | 293 // Map from RTCPPacketType to builder. |
| 294 std::map<uint32_t, BuilderFunc> builders_; |
| 292 | 295 |
| 293 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTCPSender); | 296 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTCPSender); |
| 294 }; | 297 }; |
| 295 } // namespace webrtc | 298 } // namespace webrtc |
| 296 | 299 |
| 297 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_ | 300 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_ |
| OLD | NEW |