| 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 | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 63 | 63 | 
| 64 // Deprecated. | 64 // Deprecated. | 
| 65 int32_t RtpRtcp::SetFecParameters(const FecProtectionParams* delta_params, | 65 int32_t RtpRtcp::SetFecParameters(const FecProtectionParams* delta_params, | 
| 66                                   const FecProtectionParams* key_params) { | 66                                   const FecProtectionParams* key_params) { | 
| 67   RTC_DCHECK(delta_params); | 67   RTC_DCHECK(delta_params); | 
| 68   RTC_DCHECK(key_params); | 68   RTC_DCHECK(key_params); | 
| 69   return SetFecParameters(*delta_params, *key_params) ? 0 : -1; | 69   return SetFecParameters(*delta_params, *key_params) ? 0 : -1; | 
| 70 } | 70 } | 
| 71 | 71 | 
| 72 ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const Configuration& configuration) | 72 ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const Configuration& configuration) | 
| 73     : rtp_sender_(configuration.audio, | 73     : rtcp_sender_(configuration.audio, | 
| 74                   configuration.clock, |  | 
| 75                   configuration.outgoing_transport, |  | 
| 76                   configuration.paced_sender, |  | 
| 77                   configuration.flexfec_sender, |  | 
| 78                   configuration.transport_sequence_number_allocator, |  | 
| 79                   configuration.transport_feedback_callback, |  | 
| 80                   configuration.send_bitrate_observer, |  | 
| 81                   configuration.send_frame_count_observer, |  | 
| 82                   configuration.send_side_delay_observer, |  | 
| 83                   configuration.event_log, |  | 
| 84                   configuration.send_packet_observer, |  | 
| 85                   configuration.retransmission_rate_limiter, |  | 
| 86                   configuration.overhead_observer), |  | 
| 87       rtcp_sender_(configuration.audio, |  | 
| 88                    configuration.clock, | 74                    configuration.clock, | 
| 89                    configuration.receive_statistics, | 75                    configuration.receive_statistics, | 
| 90                    configuration.rtcp_packet_type_counter_observer, | 76                    configuration.rtcp_packet_type_counter_observer, | 
| 91                    configuration.event_log, | 77                    configuration.event_log, | 
| 92                    configuration.outgoing_transport), | 78                    configuration.outgoing_transport), | 
| 93       rtcp_receiver_(configuration.clock, | 79       rtcp_receiver_(configuration.clock, | 
| 94                      configuration.receiver_only, | 80                      configuration.receiver_only, | 
| 95                      configuration.rtcp_packet_type_counter_observer, | 81                      configuration.rtcp_packet_type_counter_observer, | 
| 96                      configuration.bandwidth_callback, | 82                      configuration.bandwidth_callback, | 
| 97                      configuration.intra_frame_callback, | 83                      configuration.intra_frame_callback, | 
| 98                      configuration.transport_feedback_callback, | 84                      configuration.transport_feedback_callback, | 
| 99                      configuration.bitrate_allocation_observer, | 85                      configuration.bitrate_allocation_observer, | 
| 100                      this), | 86                      this), | 
| 101       clock_(configuration.clock), | 87       clock_(configuration.clock), | 
| 102       audio_(configuration.audio), | 88       audio_(configuration.audio), | 
| 103       last_process_time_(configuration.clock->TimeInMilliseconds()), | 89       last_process_time_(configuration.clock->TimeInMilliseconds()), | 
| 104       last_bitrate_process_time_(configuration.clock->TimeInMilliseconds()), | 90       last_bitrate_process_time_(configuration.clock->TimeInMilliseconds()), | 
| 105       last_rtt_process_time_(configuration.clock->TimeInMilliseconds()), | 91       last_rtt_process_time_(configuration.clock->TimeInMilliseconds()), | 
| 106       packet_overhead_(28),  // IPV4 UDP. | 92       packet_overhead_(28),  // IPV4 UDP. | 
| 107       nack_last_time_sent_full_(0), | 93       nack_last_time_sent_full_(0), | 
| 108       nack_last_time_sent_full_prev_(0), | 94       nack_last_time_sent_full_prev_(0), | 
| 109       nack_last_seq_number_sent_(0), | 95       nack_last_seq_number_sent_(0), | 
| 110       key_frame_req_method_(kKeyFrameReqPliRtcp), | 96       key_frame_req_method_(kKeyFrameReqPliRtcp), | 
| 111       remote_bitrate_(configuration.remote_bitrate_estimator), | 97       remote_bitrate_(configuration.remote_bitrate_estimator), | 
| 112       rtt_stats_(configuration.rtt_stats), | 98       rtt_stats_(configuration.rtt_stats), | 
| 113       rtt_ms_(0) { | 99       rtt_ms_(0) { | 
| 114   // Make sure rtcp sender use same timestamp offset as rtp sender. | 100   if (!configuration.receiver_only) { | 
| 115   rtcp_sender_.SetTimestampOffset(rtp_sender_.TimestampOffset()); | 101     rtp_sender_.reset(new RTPSender( | 
|  | 102         configuration.audio, | 
|  | 103         configuration.clock, | 
|  | 104         configuration.outgoing_transport, | 
|  | 105         configuration.paced_sender, | 
|  | 106         configuration.flexfec_sender, | 
|  | 107         configuration.transport_sequence_number_allocator, | 
|  | 108         configuration.transport_feedback_callback, | 
|  | 109         configuration.send_bitrate_observer, | 
|  | 110         configuration.send_frame_count_observer, | 
|  | 111         configuration.send_side_delay_observer, | 
|  | 112         configuration.event_log, | 
|  | 113         configuration.send_packet_observer, | 
|  | 114         configuration.retransmission_rate_limiter, | 
|  | 115         configuration.overhead_observer)); | 
|  | 116     // Make sure rtcp sender use same timestamp offset as rtp sender. | 
|  | 117     rtcp_sender_.SetTimestampOffset(rtp_sender_->TimestampOffset()); | 
|  | 118   } | 
| 116 | 119 | 
| 117   // Set default packet size limit. | 120   // Set default packet size limit. | 
| 118   // TODO(nisse): Kind-of duplicates | 121   // TODO(nisse): Kind-of duplicates | 
| 119   // webrtc::VideoSendStream::Config::Rtp::kDefaultMaxPacketSize. | 122   // webrtc::VideoSendStream::Config::Rtp::kDefaultMaxPacketSize. | 
| 120   const size_t kTcpOverIpv4HeaderSize = 40; | 123   const size_t kTcpOverIpv4HeaderSize = 40; | 
| 121   SetMaxRtpPacketSize(IP_PACKET_SIZE - kTcpOverIpv4HeaderSize); | 124   SetMaxRtpPacketSize(IP_PACKET_SIZE - kTcpOverIpv4HeaderSize); | 
| 122 } | 125 } | 
| 123 | 126 | 
| 124 // Returns the number of milliseconds until the module want a worker thread | 127 // Returns the number of milliseconds until the module want a worker thread | 
| 125 // to call Process. | 128 // to call Process. | 
| 126 int64_t ModuleRtpRtcpImpl::TimeUntilNextProcess() { | 129 int64_t ModuleRtpRtcpImpl::TimeUntilNextProcess() { | 
| 127   const int64_t now = clock_->TimeInMilliseconds(); | 130   const int64_t now = clock_->TimeInMilliseconds(); | 
| 128   const int64_t kRtpRtcpMaxIdleTimeProcessMs = 5; | 131   const int64_t kRtpRtcpMaxIdleTimeProcessMs = 5; | 
| 129   return kRtpRtcpMaxIdleTimeProcessMs - (now - last_process_time_); | 132   return kRtpRtcpMaxIdleTimeProcessMs - (now - last_process_time_); | 
| 130 } | 133 } | 
| 131 | 134 | 
| 132 // Process any pending tasks such as timeouts (non time critical events). | 135 // Process any pending tasks such as timeouts (non time critical events). | 
| 133 void ModuleRtpRtcpImpl::Process() { | 136 void ModuleRtpRtcpImpl::Process() { | 
| 134   const int64_t now = clock_->TimeInMilliseconds(); | 137   const int64_t now = clock_->TimeInMilliseconds(); | 
| 135   last_process_time_ = now; | 138   last_process_time_ = now; | 
| 136 | 139 | 
| 137   const int64_t kRtpRtcpBitrateProcessTimeMs = 10; | 140   if (rtp_sender_) { | 
| 138   if (now >= last_bitrate_process_time_ + kRtpRtcpBitrateProcessTimeMs) { | 141     const int64_t kRtpRtcpBitrateProcessTimeMs = 10; | 
| 139     rtp_sender_.ProcessBitrate(); | 142     if (now >= last_bitrate_process_time_ + kRtpRtcpBitrateProcessTimeMs) { | 
| 140     last_bitrate_process_time_ = now; | 143       rtp_sender_->ProcessBitrate(); | 
|  | 144       last_bitrate_process_time_ = now; | 
|  | 145     } | 
| 141   } | 146   } | 
| 142 |  | 
| 143   const int64_t kRtpRtcpRttProcessTimeMs = 1000; | 147   const int64_t kRtpRtcpRttProcessTimeMs = 1000; | 
| 144   bool process_rtt = now >= last_rtt_process_time_ + kRtpRtcpRttProcessTimeMs; | 148   bool process_rtt = now >= last_rtt_process_time_ + kRtpRtcpRttProcessTimeMs; | 
| 145   if (rtcp_sender_.Sending()) { | 149   if (rtcp_sender_.Sending()) { | 
| 146     // Process RTT if we have received a receiver report and we haven't | 150     // Process RTT if we have received a receiver report and we haven't | 
| 147     // processed RTT for at least |kRtpRtcpRttProcessTimeMs| milliseconds. | 151     // processed RTT for at least |kRtpRtcpRttProcessTimeMs| milliseconds. | 
| 148     if (rtcp_receiver_.LastReceivedReceiverReport() > | 152     if (rtcp_receiver_.LastReceivedReceiverReport() > | 
| 149         last_rtt_process_time_ && process_rtt) { | 153         last_rtt_process_time_ && process_rtt) { | 
| 150       std::vector<RTCPReportBlock> receive_blocks; | 154       std::vector<RTCPReportBlock> receive_blocks; | 
| 151       rtcp_receiver_.StatisticsReceived(&receive_blocks); | 155       rtcp_receiver_.StatisticsReceived(&receive_blocks); | 
| 152       int64_t max_rtt = 0; | 156       int64_t max_rtt = 0; | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 204 | 208 | 
| 205   if (rtcp_sender_.TimeToSendRTCPReport()) | 209   if (rtcp_sender_.TimeToSendRTCPReport()) | 
| 206     rtcp_sender_.SendRTCP(GetFeedbackState(), kRtcpReport); | 210     rtcp_sender_.SendRTCP(GetFeedbackState(), kRtcpReport); | 
| 207 | 211 | 
| 208   if (TMMBR() && rtcp_receiver_.UpdateTmmbrTimers()) { | 212   if (TMMBR() && rtcp_receiver_.UpdateTmmbrTimers()) { | 
| 209     rtcp_receiver_.NotifyTmmbrUpdated(); | 213     rtcp_receiver_.NotifyTmmbrUpdated(); | 
| 210   } | 214   } | 
| 211 } | 215 } | 
| 212 | 216 | 
| 213 void ModuleRtpRtcpImpl::SetRtxSendStatus(int mode) { | 217 void ModuleRtpRtcpImpl::SetRtxSendStatus(int mode) { | 
| 214   rtp_sender_.SetRtxStatus(mode); | 218   rtp_sender_->SetRtxStatus(mode); | 
| 215 } | 219 } | 
| 216 | 220 | 
| 217 int ModuleRtpRtcpImpl::RtxSendStatus() const { | 221 int ModuleRtpRtcpImpl::RtxSendStatus() const { | 
| 218   return rtp_sender_.RtxStatus(); | 222   return rtp_sender_ ? rtp_sender_->RtxStatus() : kRtxOff; | 
| 219 } | 223 } | 
| 220 | 224 | 
| 221 void ModuleRtpRtcpImpl::SetRtxSsrc(uint32_t ssrc) { | 225 void ModuleRtpRtcpImpl::SetRtxSsrc(uint32_t ssrc) { | 
| 222   rtp_sender_.SetRtxSsrc(ssrc); | 226   rtp_sender_->SetRtxSsrc(ssrc); | 
| 223 } | 227 } | 
| 224 | 228 | 
| 225 void ModuleRtpRtcpImpl::SetRtxSendPayloadType(int payload_type, | 229 void ModuleRtpRtcpImpl::SetRtxSendPayloadType(int payload_type, | 
| 226                                               int associated_payload_type) { | 230                                               int associated_payload_type) { | 
| 227   rtp_sender_.SetRtxPayloadType(payload_type, associated_payload_type); | 231   rtp_sender_->SetRtxPayloadType(payload_type, associated_payload_type); | 
| 228 } | 232 } | 
| 229 | 233 | 
| 230 rtc::Optional<uint32_t> ModuleRtpRtcpImpl::FlexfecSsrc() const { | 234 rtc::Optional<uint32_t> ModuleRtpRtcpImpl::FlexfecSsrc() const { | 
| 231   return rtp_sender_.FlexfecSsrc(); | 235   return rtp_sender_->FlexfecSsrc(); | 
| 232 } | 236 } | 
| 233 | 237 | 
| 234 int32_t ModuleRtpRtcpImpl::IncomingRtcpPacket( | 238 int32_t ModuleRtpRtcpImpl::IncomingRtcpPacket( | 
| 235     const uint8_t* rtcp_packet, | 239     const uint8_t* rtcp_packet, | 
| 236     const size_t length) { | 240     const size_t length) { | 
| 237   return rtcp_receiver_.IncomingPacket(rtcp_packet, length) ? 0 : -1; | 241   return rtcp_receiver_.IncomingPacket(rtcp_packet, length) ? 0 : -1; | 
| 238 } | 242 } | 
| 239 | 243 | 
| 240 int32_t ModuleRtpRtcpImpl::RegisterSendPayload( | 244 int32_t ModuleRtpRtcpImpl::RegisterSendPayload( | 
| 241     const CodecInst& voice_codec) { | 245     const CodecInst& voice_codec) { | 
| 242   return rtp_sender_.RegisterPayload( | 246   return rtp_sender_->RegisterPayload( | 
| 243       voice_codec.plname, voice_codec.pltype, voice_codec.plfreq, | 247       voice_codec.plname, voice_codec.pltype, voice_codec.plfreq, | 
| 244       voice_codec.channels, (voice_codec.rate < 0) ? 0 : voice_codec.rate); | 248       voice_codec.channels, (voice_codec.rate < 0) ? 0 : voice_codec.rate); | 
| 245 } | 249 } | 
| 246 | 250 | 
| 247 int32_t ModuleRtpRtcpImpl::RegisterSendPayload(const VideoCodec& video_codec) { | 251 int32_t ModuleRtpRtcpImpl::RegisterSendPayload(const VideoCodec& video_codec) { | 
| 248   return rtp_sender_.RegisterPayload(video_codec.plName, video_codec.plType, | 252   return rtp_sender_->RegisterPayload(video_codec.plName, video_codec.plType, | 
| 249                                      90000, 0, 0); | 253                                      90000, 0, 0); | 
| 250 } | 254 } | 
| 251 | 255 | 
| 252 void ModuleRtpRtcpImpl::RegisterVideoSendPayload(int payload_type, | 256 void ModuleRtpRtcpImpl::RegisterVideoSendPayload(int payload_type, | 
| 253                                                  const char* payload_name) { | 257                                                  const char* payload_name) { | 
| 254   RTC_CHECK_EQ( | 258   RTC_CHECK_EQ( | 
| 255       0, rtp_sender_.RegisterPayload(payload_name, payload_type, 90000, 0, 0)); | 259       0, rtp_sender_->RegisterPayload(payload_name, payload_type, 90000, 0, 0)); | 
| 256 } | 260 } | 
| 257 | 261 | 
| 258 int32_t ModuleRtpRtcpImpl::DeRegisterSendPayload(const int8_t payload_type) { | 262 int32_t ModuleRtpRtcpImpl::DeRegisterSendPayload(const int8_t payload_type) { | 
| 259   return rtp_sender_.DeRegisterSendPayload(payload_type); | 263   return rtp_sender_->DeRegisterSendPayload(payload_type); | 
| 260 } | 264 } | 
| 261 | 265 | 
| 262 uint32_t ModuleRtpRtcpImpl::StartTimestamp() const { | 266 uint32_t ModuleRtpRtcpImpl::StartTimestamp() const { | 
| 263   return rtp_sender_.TimestampOffset(); | 267   return rtp_sender_->TimestampOffset(); | 
| 264 } | 268 } | 
| 265 | 269 | 
| 266 // Configure start timestamp, default is a random number. | 270 // Configure start timestamp, default is a random number. | 
| 267 void ModuleRtpRtcpImpl::SetStartTimestamp(const uint32_t timestamp) { | 271 void ModuleRtpRtcpImpl::SetStartTimestamp(const uint32_t timestamp) { | 
| 268   rtcp_sender_.SetTimestampOffset(timestamp); | 272   rtcp_sender_.SetTimestampOffset(timestamp); | 
| 269   rtp_sender_.SetTimestampOffset(timestamp); | 273   rtp_sender_->SetTimestampOffset(timestamp); | 
| 270 } | 274 } | 
| 271 | 275 | 
| 272 uint16_t ModuleRtpRtcpImpl::SequenceNumber() const { | 276 uint16_t ModuleRtpRtcpImpl::SequenceNumber() const { | 
| 273   return rtp_sender_.SequenceNumber(); | 277   return rtp_sender_->SequenceNumber(); | 
| 274 } | 278 } | 
| 275 | 279 | 
| 276 // Set SequenceNumber, default is a random number. | 280 // Set SequenceNumber, default is a random number. | 
| 277 void ModuleRtpRtcpImpl::SetSequenceNumber(const uint16_t seq_num) { | 281 void ModuleRtpRtcpImpl::SetSequenceNumber(const uint16_t seq_num) { | 
| 278   rtp_sender_.SetSequenceNumber(seq_num); | 282   rtp_sender_->SetSequenceNumber(seq_num); | 
| 279 } | 283 } | 
| 280 | 284 | 
| 281 void ModuleRtpRtcpImpl::SetRtpState(const RtpState& rtp_state) { | 285 void ModuleRtpRtcpImpl::SetRtpState(const RtpState& rtp_state) { | 
| 282   rtp_sender_.SetRtpState(rtp_state); | 286   rtp_sender_->SetRtpState(rtp_state); | 
| 283   rtcp_sender_.SetTimestampOffset(rtp_state.start_timestamp); | 287   rtcp_sender_.SetTimestampOffset(rtp_state.start_timestamp); | 
| 284 } | 288 } | 
| 285 | 289 | 
| 286 void ModuleRtpRtcpImpl::SetRtxState(const RtpState& rtp_state) { | 290 void ModuleRtpRtcpImpl::SetRtxState(const RtpState& rtp_state) { | 
| 287   rtp_sender_.SetRtxRtpState(rtp_state); | 291   rtp_sender_->SetRtxRtpState(rtp_state); | 
| 288 } | 292 } | 
| 289 | 293 | 
| 290 RtpState ModuleRtpRtcpImpl::GetRtpState() const { | 294 RtpState ModuleRtpRtcpImpl::GetRtpState() const { | 
| 291   return rtp_sender_.GetRtpState(); | 295   return rtp_sender_->GetRtpState(); | 
| 292 } | 296 } | 
| 293 | 297 | 
| 294 RtpState ModuleRtpRtcpImpl::GetRtxState() const { | 298 RtpState ModuleRtpRtcpImpl::GetRtxState() const { | 
| 295   return rtp_sender_.GetRtxRtpState(); | 299   return rtp_sender_->GetRtxRtpState(); | 
| 296 } | 300 } | 
| 297 | 301 | 
| 298 uint32_t ModuleRtpRtcpImpl::SSRC() const { | 302 uint32_t ModuleRtpRtcpImpl::SSRC() const { | 
| 299   return rtp_sender_.SSRC(); | 303   return rtcp_sender_.SSRC(); | 
| 300 } | 304 } | 
| 301 | 305 | 
| 302 void ModuleRtpRtcpImpl::SetSSRC(const uint32_t ssrc) { | 306 void ModuleRtpRtcpImpl::SetSSRC(const uint32_t ssrc) { | 
| 303   rtp_sender_.SetSSRC(ssrc); | 307   if (rtp_sender_) { | 
|  | 308     rtp_sender_->SetSSRC(ssrc); | 
|  | 309   } | 
| 304   rtcp_sender_.SetSSRC(ssrc); | 310   rtcp_sender_.SetSSRC(ssrc); | 
| 305   SetRtcpReceiverSsrcs(ssrc); | 311   SetRtcpReceiverSsrcs(ssrc); | 
| 306 } | 312 } | 
| 307 | 313 | 
| 308 void ModuleRtpRtcpImpl::SetCsrcs(const std::vector<uint32_t>& csrcs) { | 314 void ModuleRtpRtcpImpl::SetCsrcs(const std::vector<uint32_t>& csrcs) { | 
| 309   rtcp_sender_.SetCsrcs(csrcs); | 315   rtcp_sender_.SetCsrcs(csrcs); | 
| 310   rtp_sender_.SetCsrcs(csrcs); | 316   rtp_sender_->SetCsrcs(csrcs); | 
| 311 } | 317 } | 
| 312 | 318 | 
| 313 // TODO(pbos): Handle media and RTX streams separately (separate RTCP | 319 // TODO(pbos): Handle media and RTX streams separately (separate RTCP | 
| 314 // feedbacks). | 320 // feedbacks). | 
| 315 RTCPSender::FeedbackState ModuleRtpRtcpImpl::GetFeedbackState() { | 321 RTCPSender::FeedbackState ModuleRtpRtcpImpl::GetFeedbackState() { | 
| 316   StreamDataCounters rtp_stats; |  | 
| 317   StreamDataCounters rtx_stats; |  | 
| 318   rtp_sender_.GetDataCounters(&rtp_stats, &rtx_stats); |  | 
| 319 |  | 
| 320   RTCPSender::FeedbackState state; | 322   RTCPSender::FeedbackState state; | 
| 321   state.packets_sent = rtp_stats.transmitted.packets + | 323   // This is called also when receiver_only is true. Hence below | 
| 322                        rtx_stats.transmitted.packets; | 324   // checks that rtp_sender_ exists. | 
| 323   state.media_bytes_sent = rtp_stats.transmitted.payload_bytes + | 325   if (rtp_sender_) { | 
| 324                            rtx_stats.transmitted.payload_bytes; | 326     StreamDataCounters rtp_stats; | 
|  | 327     StreamDataCounters rtx_stats; | 
|  | 328     rtp_sender_->GetDataCounters(&rtp_stats, &rtx_stats); | 
|  | 329     state.packets_sent = rtp_stats.transmitted.packets + | 
|  | 330                          rtx_stats.transmitted.packets; | 
|  | 331     state.media_bytes_sent = rtp_stats.transmitted.payload_bytes + | 
|  | 332                              rtx_stats.transmitted.payload_bytes; | 
|  | 333     state.send_bitrate = rtp_sender_->BitrateSent(); | 
|  | 334   } | 
| 325   state.module = this; | 335   state.module = this; | 
| 326 | 336 | 
| 327   LastReceivedNTP(&state.last_rr_ntp_secs, | 337   LastReceivedNTP(&state.last_rr_ntp_secs, | 
| 328                   &state.last_rr_ntp_frac, | 338                   &state.last_rr_ntp_frac, | 
| 329                   &state.remote_sr); | 339                   &state.remote_sr); | 
| 330 | 340 | 
| 331   state.has_last_xr_rr = | 341   state.has_last_xr_rr = | 
| 332       rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&state.last_xr_rr); | 342       rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&state.last_xr_rr); | 
| 333 | 343 | 
| 334   uint32_t tmp; |  | 
| 335   BitrateSent(&state.send_bitrate, &tmp, &tmp, &tmp); |  | 
| 336   return state; | 344   return state; | 
| 337 } | 345 } | 
| 338 | 346 | 
|  | 347 // TODO(nisse): This method shouldn't be called for a receive-only | 
|  | 348 // stream. Delete rtp_sender_ check as soon as all applications are | 
|  | 349 // updated. | 
| 339 int32_t ModuleRtpRtcpImpl::SetSendingStatus(const bool sending) { | 350 int32_t ModuleRtpRtcpImpl::SetSendingStatus(const bool sending) { | 
| 340   if (rtcp_sender_.Sending() != sending) { | 351   if (rtcp_sender_.Sending() != sending) { | 
| 341     // Sends RTCP BYE when going from true to false | 352     // Sends RTCP BYE when going from true to false | 
| 342     if (rtcp_sender_.SetSendingStatus(GetFeedbackState(), sending) != 0) { | 353     if (rtcp_sender_.SetSendingStatus(GetFeedbackState(), sending) != 0) { | 
| 343       LOG(LS_WARNING) << "Failed to send RTCP BYE"; | 354       LOG(LS_WARNING) << "Failed to send RTCP BYE"; | 
| 344     } | 355     } | 
| 345     if (sending) { | 356     if (sending && rtp_sender_) { | 
| 346       // Update Rtcp receiver config, to track Rtx config changes from | 357       // Update Rtcp receiver config, to track Rtx config changes from | 
| 347       // the SetRtxStatus and SetRtxSsrc methods. | 358       // the SetRtxStatus and SetRtxSsrc methods. | 
| 348       SetRtcpReceiverSsrcs(rtp_sender_.SSRC()); | 359       SetRtcpReceiverSsrcs(rtp_sender_->SSRC()); | 
| 349     } | 360     } | 
| 350   } | 361   } | 
| 351   return 0; | 362   return 0; | 
| 352 } | 363 } | 
| 353 | 364 | 
| 354 bool ModuleRtpRtcpImpl::Sending() const { | 365 bool ModuleRtpRtcpImpl::Sending() const { | 
| 355   return rtcp_sender_.Sending(); | 366   return rtcp_sender_.Sending(); | 
| 356 } | 367 } | 
| 357 | 368 | 
|  | 369 // TODO(nisse): This method shouldn't be called for a receive-only | 
|  | 370 // stream. Delete rtp_sender_ check as soon as all applications are | 
|  | 371 // updated. | 
| 358 void ModuleRtpRtcpImpl::SetSendingMediaStatus(const bool sending) { | 372 void ModuleRtpRtcpImpl::SetSendingMediaStatus(const bool sending) { | 
| 359   rtp_sender_.SetSendingMediaStatus(sending); | 373   if (rtp_sender_) { | 
|  | 374     rtp_sender_->SetSendingMediaStatus(sending); | 
|  | 375   } else { | 
|  | 376     RTC_DCHECK(!sending); | 
|  | 377   } | 
| 360 } | 378 } | 
| 361 | 379 | 
| 362 bool ModuleRtpRtcpImpl::SendingMedia() const { | 380 bool ModuleRtpRtcpImpl::SendingMedia() const { | 
| 363   return rtp_sender_.SendingMedia(); | 381   return rtp_sender_ ? rtp_sender_->SendingMedia() : false; | 
| 364 } | 382 } | 
| 365 | 383 | 
| 366 bool ModuleRtpRtcpImpl::SendOutgoingData( | 384 bool ModuleRtpRtcpImpl::SendOutgoingData( | 
| 367     FrameType frame_type, | 385     FrameType frame_type, | 
| 368     int8_t payload_type, | 386     int8_t payload_type, | 
| 369     uint32_t time_stamp, | 387     uint32_t time_stamp, | 
| 370     int64_t capture_time_ms, | 388     int64_t capture_time_ms, | 
| 371     const uint8_t* payload_data, | 389     const uint8_t* payload_data, | 
| 372     size_t payload_size, | 390     size_t payload_size, | 
| 373     const RTPFragmentationHeader* fragmentation, | 391     const RTPFragmentationHeader* fragmentation, | 
| 374     const RTPVideoHeader* rtp_video_header, | 392     const RTPVideoHeader* rtp_video_header, | 
| 375     uint32_t* transport_frame_id_out) { | 393     uint32_t* transport_frame_id_out) { | 
| 376   rtcp_sender_.SetLastRtpTime(time_stamp, capture_time_ms); | 394   rtcp_sender_.SetLastRtpTime(time_stamp, capture_time_ms); | 
| 377   // Make sure an RTCP report isn't queued behind a key frame. | 395   // Make sure an RTCP report isn't queued behind a key frame. | 
| 378   if (rtcp_sender_.TimeToSendRTCPReport(kVideoFrameKey == frame_type)) { | 396   if (rtcp_sender_.TimeToSendRTCPReport(kVideoFrameKey == frame_type)) { | 
| 379       rtcp_sender_.SendRTCP(GetFeedbackState(), kRtcpReport); | 397       rtcp_sender_.SendRTCP(GetFeedbackState(), kRtcpReport); | 
| 380   } | 398   } | 
| 381   return rtp_sender_.SendOutgoingData( | 399   return rtp_sender_->SendOutgoingData( | 
| 382       frame_type, payload_type, time_stamp, capture_time_ms, payload_data, | 400       frame_type, payload_type, time_stamp, capture_time_ms, payload_data, | 
| 383       payload_size, fragmentation, rtp_video_header, transport_frame_id_out); | 401       payload_size, fragmentation, rtp_video_header, transport_frame_id_out); | 
| 384 } | 402 } | 
| 385 | 403 | 
| 386 bool ModuleRtpRtcpImpl::TimeToSendPacket(uint32_t ssrc, | 404 bool ModuleRtpRtcpImpl::TimeToSendPacket(uint32_t ssrc, | 
| 387                                          uint16_t sequence_number, | 405                                          uint16_t sequence_number, | 
| 388                                          int64_t capture_time_ms, | 406                                          int64_t capture_time_ms, | 
| 389                                          bool retransmission, | 407                                          bool retransmission, | 
| 390                                          const PacedPacketInfo& pacing_info) { | 408                                          const PacedPacketInfo& pacing_info) { | 
| 391   return rtp_sender_.TimeToSendPacket(ssrc, sequence_number, capture_time_ms, | 409   return rtp_sender_->TimeToSendPacket(ssrc, sequence_number, capture_time_ms, | 
| 392                                       retransmission, pacing_info); | 410                                       retransmission, pacing_info); | 
| 393 } | 411 } | 
| 394 | 412 | 
| 395 size_t ModuleRtpRtcpImpl::TimeToSendPadding( | 413 size_t ModuleRtpRtcpImpl::TimeToSendPadding( | 
| 396     size_t bytes, | 414     size_t bytes, | 
| 397     const PacedPacketInfo& pacing_info) { | 415     const PacedPacketInfo& pacing_info) { | 
| 398   return rtp_sender_.TimeToSendPadding(bytes, pacing_info); | 416   return rtp_sender_->TimeToSendPadding(bytes, pacing_info); | 
| 399 } | 417 } | 
| 400 | 418 | 
| 401 size_t ModuleRtpRtcpImpl::MaxPayloadSize() const { | 419 size_t ModuleRtpRtcpImpl::MaxPayloadSize() const { | 
| 402   return rtp_sender_.MaxPayloadSize(); | 420   return rtp_sender_->MaxPayloadSize(); | 
| 403 } | 421 } | 
| 404 | 422 | 
| 405 size_t ModuleRtpRtcpImpl::MaxRtpPacketSize() const { | 423 size_t ModuleRtpRtcpImpl::MaxRtpPacketSize() const { | 
| 406   return rtp_sender_.MaxRtpPacketSize(); | 424   return rtp_sender_->MaxRtpPacketSize(); | 
| 407 } | 425 } | 
| 408 | 426 | 
| 409 void ModuleRtpRtcpImpl::SetMaxRtpPacketSize(size_t rtp_packet_size) { | 427 void ModuleRtpRtcpImpl::SetMaxRtpPacketSize(size_t rtp_packet_size) { | 
| 410   RTC_DCHECK_LE(rtp_packet_size, IP_PACKET_SIZE) | 428   RTC_DCHECK_LE(rtp_packet_size, IP_PACKET_SIZE) | 
| 411       << "rtp packet size too large: " << rtp_packet_size; | 429       << "rtp packet size too large: " << rtp_packet_size; | 
| 412   RTC_DCHECK_GT(rtp_packet_size, packet_overhead_) | 430   RTC_DCHECK_GT(rtp_packet_size, packet_overhead_) | 
| 413       << "rtp packet size too small: " << rtp_packet_size; | 431       << "rtp packet size too small: " << rtp_packet_size; | 
| 414 | 432 | 
| 415   rtcp_sender_.SetMaxRtpPacketSize(rtp_packet_size); | 433   rtcp_sender_.SetMaxRtpPacketSize(rtp_packet_size); | 
| 416   rtp_sender_.SetMaxRtpPacketSize(rtp_packet_size); | 434   if (rtp_sender_) | 
|  | 435     rtp_sender_->SetMaxRtpPacketSize(rtp_packet_size); | 
| 417 } | 436 } | 
| 418 | 437 | 
| 419 RtcpMode ModuleRtpRtcpImpl::RTCP() const { | 438 RtcpMode ModuleRtpRtcpImpl::RTCP() const { | 
| 420   return rtcp_sender_.Status(); | 439   return rtcp_sender_.Status(); | 
| 421 } | 440 } | 
| 422 | 441 | 
| 423 // Configure RTCP status i.e on/off. | 442 // Configure RTCP status i.e on/off. | 
| 424 void ModuleRtpRtcpImpl::SetRTCPStatus(const RtcpMode method) { | 443 void ModuleRtpRtcpImpl::SetRTCPStatus(const RtcpMode method) { | 
| 425   rtcp_sender_.SetRTCPStatus(method); | 444   rtcp_sender_.SetRTCPStatus(method); | 
| 426 } | 445 } | 
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 507 bool ModuleRtpRtcpImpl::RtcpXrRrtrStatus() const { | 526 bool ModuleRtpRtcpImpl::RtcpXrRrtrStatus() const { | 
| 508   return rtcp_sender_.RtcpXrReceiverReferenceTime(); | 527   return rtcp_sender_.RtcpXrReceiverReferenceTime(); | 
| 509 } | 528 } | 
| 510 | 529 | 
| 511 // TODO(asapersson): Replace this method with the one below. | 530 // TODO(asapersson): Replace this method with the one below. | 
| 512 int32_t ModuleRtpRtcpImpl::DataCountersRTP( | 531 int32_t ModuleRtpRtcpImpl::DataCountersRTP( | 
| 513     size_t* bytes_sent, | 532     size_t* bytes_sent, | 
| 514     uint32_t* packets_sent) const { | 533     uint32_t* packets_sent) const { | 
| 515   StreamDataCounters rtp_stats; | 534   StreamDataCounters rtp_stats; | 
| 516   StreamDataCounters rtx_stats; | 535   StreamDataCounters rtx_stats; | 
| 517   rtp_sender_.GetDataCounters(&rtp_stats, &rtx_stats); | 536   rtp_sender_->GetDataCounters(&rtp_stats, &rtx_stats); | 
| 518 | 537 | 
| 519   if (bytes_sent) { | 538   if (bytes_sent) { | 
| 520     *bytes_sent = rtp_stats.transmitted.payload_bytes + | 539     *bytes_sent = rtp_stats.transmitted.payload_bytes + | 
| 521                   rtp_stats.transmitted.padding_bytes + | 540                   rtp_stats.transmitted.padding_bytes + | 
| 522                   rtp_stats.transmitted.header_bytes + | 541                   rtp_stats.transmitted.header_bytes + | 
| 523                   rtx_stats.transmitted.payload_bytes + | 542                   rtx_stats.transmitted.payload_bytes + | 
| 524                   rtx_stats.transmitted.padding_bytes + | 543                   rtx_stats.transmitted.padding_bytes + | 
| 525                   rtx_stats.transmitted.header_bytes; | 544                   rtx_stats.transmitted.header_bytes; | 
| 526   } | 545   } | 
| 527   if (packets_sent) { | 546   if (packets_sent) { | 
| 528     *packets_sent = rtp_stats.transmitted.packets + | 547     *packets_sent = rtp_stats.transmitted.packets + | 
| 529                     rtx_stats.transmitted.packets; | 548                     rtx_stats.transmitted.packets; | 
| 530   } | 549   } | 
| 531   return 0; | 550   return 0; | 
| 532 } | 551 } | 
| 533 | 552 | 
| 534 void ModuleRtpRtcpImpl::GetSendStreamDataCounters( | 553 void ModuleRtpRtcpImpl::GetSendStreamDataCounters( | 
| 535     StreamDataCounters* rtp_counters, | 554     StreamDataCounters* rtp_counters, | 
| 536     StreamDataCounters* rtx_counters) const { | 555     StreamDataCounters* rtx_counters) const { | 
| 537   rtp_sender_.GetDataCounters(rtp_counters, rtx_counters); | 556   rtp_sender_->GetDataCounters(rtp_counters, rtx_counters); | 
| 538 } | 557 } | 
| 539 | 558 | 
| 540 void ModuleRtpRtcpImpl::GetRtpPacketLossStats( | 559 void ModuleRtpRtcpImpl::GetRtpPacketLossStats( | 
| 541     bool outgoing, | 560     bool outgoing, | 
| 542     uint32_t ssrc, | 561     uint32_t ssrc, | 
| 543     struct RtpPacketLossStats* loss_stats) const { | 562     struct RtpPacketLossStats* loss_stats) const { | 
| 544   if (!loss_stats) return; | 563   if (!loss_stats) return; | 
| 545   const PacketLossStats* stats_source = NULL; | 564   const PacketLossStats* stats_source = NULL; | 
| 546   if (outgoing) { | 565   if (outgoing) { | 
| 547     if (SSRC() == ssrc) { | 566     if (SSRC() == ssrc) { | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 582 } | 601 } | 
| 583 | 602 | 
| 584 void ModuleRtpRtcpImpl::SetREMBData(const uint32_t bitrate, | 603 void ModuleRtpRtcpImpl::SetREMBData(const uint32_t bitrate, | 
| 585                                     const std::vector<uint32_t>& ssrcs) { | 604                                     const std::vector<uint32_t>& ssrcs) { | 
| 586   rtcp_sender_.SetREMBData(bitrate, ssrcs); | 605   rtcp_sender_.SetREMBData(bitrate, ssrcs); | 
| 587 } | 606 } | 
| 588 | 607 | 
| 589 int32_t ModuleRtpRtcpImpl::RegisterSendRtpHeaderExtension( | 608 int32_t ModuleRtpRtcpImpl::RegisterSendRtpHeaderExtension( | 
| 590     const RTPExtensionType type, | 609     const RTPExtensionType type, | 
| 591     const uint8_t id) { | 610     const uint8_t id) { | 
| 592   return rtp_sender_.RegisterRtpHeaderExtension(type, id); | 611   return rtp_sender_->RegisterRtpHeaderExtension(type, id); | 
| 593 } | 612 } | 
| 594 | 613 | 
| 595 int32_t ModuleRtpRtcpImpl::DeregisterSendRtpHeaderExtension( | 614 int32_t ModuleRtpRtcpImpl::DeregisterSendRtpHeaderExtension( | 
| 596     const RTPExtensionType type) { | 615     const RTPExtensionType type) { | 
| 597   return rtp_sender_.DeregisterRtpHeaderExtension(type); | 616   return rtp_sender_->DeregisterRtpHeaderExtension(type); | 
| 598 } | 617 } | 
| 599 | 618 | 
| 600 bool ModuleRtpRtcpImpl::HasBweExtensions() const { | 619 bool ModuleRtpRtcpImpl::HasBweExtensions() const { | 
| 601   return rtp_sender_.IsRtpHeaderExtensionRegistered( | 620   return rtp_sender_->IsRtpHeaderExtensionRegistered( | 
| 602              kRtpExtensionTransportSequenceNumber) || | 621              kRtpExtensionTransportSequenceNumber) || | 
| 603          rtp_sender_.IsRtpHeaderExtensionRegistered( | 622          rtp_sender_->IsRtpHeaderExtensionRegistered( | 
| 604              kRtpExtensionAbsoluteSendTime) || | 623              kRtpExtensionAbsoluteSendTime) || | 
| 605          rtp_sender_.IsRtpHeaderExtensionRegistered( | 624          rtp_sender_->IsRtpHeaderExtensionRegistered( | 
| 606              kRtpExtensionTransmissionTimeOffset); | 625              kRtpExtensionTransmissionTimeOffset); | 
| 607 } | 626 } | 
| 608 | 627 | 
| 609 // (TMMBR) Temporary Max Media Bit Rate. | 628 // (TMMBR) Temporary Max Media Bit Rate. | 
| 610 bool ModuleRtpRtcpImpl::TMMBR() const { | 629 bool ModuleRtpRtcpImpl::TMMBR() const { | 
| 611   return rtcp_sender_.TMMBR(); | 630   return rtcp_sender_.TMMBR(); | 
| 612 } | 631 } | 
| 613 | 632 | 
| 614 void ModuleRtpRtcpImpl::SetTMMBRStatus(const bool enable) { | 633 void ModuleRtpRtcpImpl::SetTMMBRStatus(const bool enable) { | 
| 615   rtcp_sender_.SetTMMBRStatus(enable); | 634   rtcp_sender_.SetTMMBRStatus(enable); | 
| 616 } | 635 } | 
| 617 | 636 | 
| 618 void ModuleRtpRtcpImpl::SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set) { | 637 void ModuleRtpRtcpImpl::SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set) { | 
| 619   rtcp_sender_.SetTmmbn(std::move(bounding_set)); | 638   rtcp_sender_.SetTmmbn(std::move(bounding_set)); | 
| 620 } | 639 } | 
| 621 | 640 | 
| 622 // Returns the currently configured retransmission mode. | 641 // Returns the currently configured retransmission mode. | 
| 623 int ModuleRtpRtcpImpl::SelectiveRetransmissions() const { | 642 int ModuleRtpRtcpImpl::SelectiveRetransmissions() const { | 
| 624   return rtp_sender_.SelectiveRetransmissions(); | 643   return rtp_sender_->SelectiveRetransmissions(); | 
| 625 } | 644 } | 
| 626 | 645 | 
| 627 // Enable or disable a retransmission mode, which decides which packets will | 646 // Enable or disable a retransmission mode, which decides which packets will | 
| 628 // be retransmitted if NACKed. | 647 // be retransmitted if NACKed. | 
| 629 int ModuleRtpRtcpImpl::SetSelectiveRetransmissions(uint8_t settings) { | 648 int ModuleRtpRtcpImpl::SetSelectiveRetransmissions(uint8_t settings) { | 
| 630   return rtp_sender_.SetSelectiveRetransmissions(settings); | 649   return rtp_sender_->SetSelectiveRetransmissions(settings); | 
| 631 } | 650 } | 
| 632 | 651 | 
| 633 // Send a Negative acknowledgment packet. | 652 // Send a Negative acknowledgment packet. | 
| 634 int32_t ModuleRtpRtcpImpl::SendNACK(const uint16_t* nack_list, | 653 int32_t ModuleRtpRtcpImpl::SendNACK(const uint16_t* nack_list, | 
| 635                                     const uint16_t size) { | 654                                     const uint16_t size) { | 
| 636   for (int i = 0; i < size; ++i) { | 655   for (int i = 0; i < size; ++i) { | 
| 637     receive_loss_stats_.AddLostPacket(nack_list[i]); | 656     receive_loss_stats_.AddLostPacket(nack_list[i]); | 
| 638   } | 657   } | 
| 639   uint16_t nack_length = size; | 658   uint16_t nack_length = size; | 
| 640   uint16_t start_id = 0; | 659   uint16_t start_id = 0; | 
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 691   // Send a full NACK list once within every |wait_time|. | 710   // Send a full NACK list once within every |wait_time|. | 
| 692   if (rtt_stats_) { | 711   if (rtt_stats_) { | 
| 693     return now - nack_last_time_sent_full_ > wait_time; | 712     return now - nack_last_time_sent_full_ > wait_time; | 
| 694   } | 713   } | 
| 695   return now - nack_last_time_sent_full_prev_ > wait_time; | 714   return now - nack_last_time_sent_full_prev_ > wait_time; | 
| 696 } | 715 } | 
| 697 | 716 | 
| 698 // Store the sent packets, needed to answer to Negative acknowledgment requests. | 717 // Store the sent packets, needed to answer to Negative acknowledgment requests. | 
| 699 void ModuleRtpRtcpImpl::SetStorePacketsStatus(const bool enable, | 718 void ModuleRtpRtcpImpl::SetStorePacketsStatus(const bool enable, | 
| 700                                               const uint16_t number_to_store) { | 719                                               const uint16_t number_to_store) { | 
| 701   rtp_sender_.SetStorePacketsStatus(enable, number_to_store); | 720   rtp_sender_->SetStorePacketsStatus(enable, number_to_store); | 
| 702 } | 721 } | 
| 703 | 722 | 
| 704 bool ModuleRtpRtcpImpl::StorePackets() const { | 723 bool ModuleRtpRtcpImpl::StorePackets() const { | 
| 705   return rtp_sender_.StorePackets(); | 724   return rtp_sender_->StorePackets(); | 
| 706 } | 725 } | 
| 707 | 726 | 
| 708 void ModuleRtpRtcpImpl::RegisterRtcpStatisticsCallback( | 727 void ModuleRtpRtcpImpl::RegisterRtcpStatisticsCallback( | 
| 709     RtcpStatisticsCallback* callback) { | 728     RtcpStatisticsCallback* callback) { | 
| 710   rtcp_receiver_.RegisterRtcpStatisticsCallback(callback); | 729   rtcp_receiver_.RegisterRtcpStatisticsCallback(callback); | 
| 711 } | 730 } | 
| 712 | 731 | 
| 713 RtcpStatisticsCallback* ModuleRtpRtcpImpl::GetRtcpStatisticsCallback() { | 732 RtcpStatisticsCallback* ModuleRtpRtcpImpl::GetRtcpStatisticsCallback() { | 
| 714   return rtcp_receiver_.GetRtcpStatisticsCallback(); | 733   return rtcp_receiver_.GetRtcpStatisticsCallback(); | 
| 715 } | 734 } | 
| 716 | 735 | 
| 717 bool ModuleRtpRtcpImpl::SendFeedbackPacket( | 736 bool ModuleRtpRtcpImpl::SendFeedbackPacket( | 
| 718     const rtcp::TransportFeedback& packet) { | 737     const rtcp::TransportFeedback& packet) { | 
| 719   return rtcp_sender_.SendFeedbackPacket(packet); | 738   return rtcp_sender_.SendFeedbackPacket(packet); | 
| 720 } | 739 } | 
| 721 | 740 | 
| 722 // Send a TelephoneEvent tone using RFC 2833 (4733). | 741 // Send a TelephoneEvent tone using RFC 2833 (4733). | 
| 723 int32_t ModuleRtpRtcpImpl::SendTelephoneEventOutband( | 742 int32_t ModuleRtpRtcpImpl::SendTelephoneEventOutband( | 
| 724     const uint8_t key, | 743     const uint8_t key, | 
| 725     const uint16_t time_ms, | 744     const uint16_t time_ms, | 
| 726     const uint8_t level) { | 745     const uint8_t level) { | 
| 727   return rtp_sender_.SendTelephoneEvent(key, time_ms, level); | 746   return rtp_sender_->SendTelephoneEvent(key, time_ms, level); | 
| 728 } | 747 } | 
| 729 | 748 | 
| 730 int32_t ModuleRtpRtcpImpl::SetAudioPacketSize( | 749 int32_t ModuleRtpRtcpImpl::SetAudioPacketSize( | 
| 731     const uint16_t packet_size_samples) { | 750     const uint16_t packet_size_samples) { | 
| 732   return audio_ ? 0 : -1; | 751   return audio_ ? 0 : -1; | 
| 733 } | 752 } | 
| 734 | 753 | 
| 735 int32_t ModuleRtpRtcpImpl::SetAudioLevel( | 754 int32_t ModuleRtpRtcpImpl::SetAudioLevel( | 
| 736     const uint8_t level_d_bov) { | 755     const uint8_t level_d_bov) { | 
| 737   return rtp_sender_.SetAudioLevel(level_d_bov); | 756   return rtp_sender_->SetAudioLevel(level_d_bov); | 
| 738 } | 757 } | 
| 739 | 758 | 
| 740 int32_t ModuleRtpRtcpImpl::SetKeyFrameRequestMethod( | 759 int32_t ModuleRtpRtcpImpl::SetKeyFrameRequestMethod( | 
| 741     const KeyFrameRequestMethod method) { | 760     const KeyFrameRequestMethod method) { | 
| 742   key_frame_req_method_ = method; | 761   key_frame_req_method_ = method; | 
| 743   return 0; | 762   return 0; | 
| 744 } | 763 } | 
| 745 | 764 | 
| 746 int32_t ModuleRtpRtcpImpl::RequestKeyFrame() { | 765 int32_t ModuleRtpRtcpImpl::RequestKeyFrame() { | 
| 747   switch (key_frame_req_method_) { | 766   switch (key_frame_req_method_) { | 
| 748     case kKeyFrameReqPliRtcp: | 767     case kKeyFrameReqPliRtcp: | 
| 749       return SendRTCP(kRtcpPli); | 768       return SendRTCP(kRtcpPli); | 
| 750     case kKeyFrameReqFirRtcp: | 769     case kKeyFrameReqFirRtcp: | 
| 751       return SendRTCP(kRtcpFir); | 770       return SendRTCP(kRtcpFir); | 
| 752   } | 771   } | 
| 753   return -1; | 772   return -1; | 
| 754 } | 773 } | 
| 755 | 774 | 
| 756 void ModuleRtpRtcpImpl::SetUlpfecConfig(int red_payload_type, | 775 void ModuleRtpRtcpImpl::SetUlpfecConfig(int red_payload_type, | 
| 757                                         int ulpfec_payload_type) { | 776                                         int ulpfec_payload_type) { | 
| 758   rtp_sender_.SetUlpfecConfig(red_payload_type, ulpfec_payload_type); | 777   rtp_sender_->SetUlpfecConfig(red_payload_type, ulpfec_payload_type); | 
| 759 } | 778 } | 
| 760 | 779 | 
| 761 bool ModuleRtpRtcpImpl::SetFecParameters( | 780 bool ModuleRtpRtcpImpl::SetFecParameters( | 
| 762     const FecProtectionParams& delta_params, | 781     const FecProtectionParams& delta_params, | 
| 763     const FecProtectionParams& key_params) { | 782     const FecProtectionParams& key_params) { | 
| 764   return rtp_sender_.SetFecParameters(delta_params, key_params); | 783   return rtp_sender_->SetFecParameters(delta_params, key_params); | 
| 765 } | 784 } | 
| 766 | 785 | 
| 767 void ModuleRtpRtcpImpl::SetRemoteSSRC(const uint32_t ssrc) { | 786 void ModuleRtpRtcpImpl::SetRemoteSSRC(const uint32_t ssrc) { | 
| 768   // Inform about the incoming SSRC. | 787   // Inform about the incoming SSRC. | 
| 769   rtcp_sender_.SetRemoteSSRC(ssrc); | 788   rtcp_sender_.SetRemoteSSRC(ssrc); | 
| 770   rtcp_receiver_.SetRemoteSSRC(ssrc); | 789   rtcp_receiver_.SetRemoteSSRC(ssrc); | 
| 771 } | 790 } | 
| 772 | 791 | 
| 773 void ModuleRtpRtcpImpl::BitrateSent(uint32_t* total_rate, | 792 void ModuleRtpRtcpImpl::BitrateSent(uint32_t* total_rate, | 
| 774                                     uint32_t* video_rate, | 793                                     uint32_t* video_rate, | 
| 775                                     uint32_t* fec_rate, | 794                                     uint32_t* fec_rate, | 
| 776                                     uint32_t* nack_rate) const { | 795                                     uint32_t* nack_rate) const { | 
| 777   *total_rate = rtp_sender_.BitrateSent(); | 796   *total_rate = rtp_sender_->BitrateSent(); | 
| 778   *video_rate = rtp_sender_.VideoBitrateSent(); | 797   *video_rate = rtp_sender_->VideoBitrateSent(); | 
| 779   *fec_rate = rtp_sender_.FecOverheadRate(); | 798   *fec_rate = rtp_sender_->FecOverheadRate(); | 
| 780   *nack_rate = rtp_sender_.NackOverheadRate(); | 799   *nack_rate = rtp_sender_->NackOverheadRate(); | 
| 781 } | 800 } | 
| 782 | 801 | 
| 783 void ModuleRtpRtcpImpl::OnRequestSendReport() { | 802 void ModuleRtpRtcpImpl::OnRequestSendReport() { | 
| 784   SendRTCP(kRtcpSr); | 803   SendRTCP(kRtcpSr); | 
| 785 } | 804 } | 
| 786 | 805 | 
| 787 void ModuleRtpRtcpImpl::OnReceivedNack( | 806 void ModuleRtpRtcpImpl::OnReceivedNack( | 
| 788     const std::vector<uint16_t>& nack_sequence_numbers) { | 807     const std::vector<uint16_t>& nack_sequence_numbers) { | 
|  | 808   if (!rtp_sender_) | 
|  | 809     return; | 
|  | 810 | 
| 789   for (uint16_t nack_sequence_number : nack_sequence_numbers) { | 811   for (uint16_t nack_sequence_number : nack_sequence_numbers) { | 
| 790     send_loss_stats_.AddLostPacket(nack_sequence_number); | 812     send_loss_stats_.AddLostPacket(nack_sequence_number); | 
| 791   } | 813   } | 
| 792   if (!rtp_sender_.StorePackets() || | 814   if (!rtp_sender_->StorePackets() || | 
| 793       nack_sequence_numbers.size() == 0) { | 815       nack_sequence_numbers.size() == 0) { | 
| 794     return; | 816     return; | 
| 795   } | 817   } | 
| 796   // Use RTT from RtcpRttStats class if provided. | 818   // Use RTT from RtcpRttStats class if provided. | 
| 797   int64_t rtt = rtt_ms(); | 819   int64_t rtt = rtt_ms(); | 
| 798   if (rtt == 0) { | 820   if (rtt == 0) { | 
| 799     rtcp_receiver_.RTT(rtcp_receiver_.RemoteSSRC(), NULL, &rtt, NULL, NULL); | 821     rtcp_receiver_.RTT(rtcp_receiver_.RemoteSSRC(), NULL, &rtt, NULL, NULL); | 
| 800   } | 822   } | 
| 801   rtp_sender_.OnReceivedNack(nack_sequence_numbers, rtt); | 823   rtp_sender_->OnReceivedNack(nack_sequence_numbers, rtt); | 
| 802 } | 824 } | 
| 803 | 825 | 
| 804 void ModuleRtpRtcpImpl::OnReceivedRtcpReportBlocks( | 826 void ModuleRtpRtcpImpl::OnReceivedRtcpReportBlocks( | 
| 805     const ReportBlockList& report_blocks) { | 827     const ReportBlockList& report_blocks) { | 
| 806   rtp_sender_.OnReceivedRtcpReportBlocks(report_blocks); | 828   if (rtp_sender_) | 
|  | 829     rtp_sender_->OnReceivedRtcpReportBlocks(report_blocks); | 
| 807 } | 830 } | 
| 808 | 831 | 
| 809 bool ModuleRtpRtcpImpl::LastReceivedNTP( | 832 bool ModuleRtpRtcpImpl::LastReceivedNTP( | 
| 810     uint32_t* rtcp_arrival_time_secs,  // When we got the last report. | 833     uint32_t* rtcp_arrival_time_secs,  // When we got the last report. | 
| 811     uint32_t* rtcp_arrival_time_frac, | 834     uint32_t* rtcp_arrival_time_frac, | 
| 812     uint32_t* remote_sr) const { | 835     uint32_t* remote_sr) const { | 
| 813   // Remote SR: NTP inside the last received (mid 16 bits from sec and frac). | 836   // Remote SR: NTP inside the last received (mid 16 bits from sec and frac). | 
| 814   uint32_t ntp_secs = 0; | 837   uint32_t ntp_secs = 0; | 
| 815   uint32_t ntp_frac = 0; | 838   uint32_t ntp_frac = 0; | 
| 816 | 839 | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 834 int64_t ModuleRtpRtcpImpl::RtcpReportInterval() { | 857 int64_t ModuleRtpRtcpImpl::RtcpReportInterval() { | 
| 835   if (audio_) | 858   if (audio_) | 
| 836     return RTCP_INTERVAL_AUDIO_MS; | 859     return RTCP_INTERVAL_AUDIO_MS; | 
| 837   else | 860   else | 
| 838     return RTCP_INTERVAL_VIDEO_MS; | 861     return RTCP_INTERVAL_VIDEO_MS; | 
| 839 } | 862 } | 
| 840 | 863 | 
| 841 void ModuleRtpRtcpImpl::SetRtcpReceiverSsrcs(uint32_t main_ssrc) { | 864 void ModuleRtpRtcpImpl::SetRtcpReceiverSsrcs(uint32_t main_ssrc) { | 
| 842   std::set<uint32_t> ssrcs; | 865   std::set<uint32_t> ssrcs; | 
| 843   ssrcs.insert(main_ssrc); | 866   ssrcs.insert(main_ssrc); | 
| 844   if (rtp_sender_.RtxStatus() != kRtxOff) | 867   if (RtxSendStatus() != kRtxOff) | 
| 845     ssrcs.insert(rtp_sender_.RtxSsrc()); | 868     ssrcs.insert(rtp_sender_->RtxSsrc()); | 
| 846   rtcp_receiver_.SetSsrcs(main_ssrc, ssrcs); | 869   rtcp_receiver_.SetSsrcs(main_ssrc, ssrcs); | 
| 847 } | 870 } | 
| 848 | 871 | 
| 849 void ModuleRtpRtcpImpl::set_rtt_ms(int64_t rtt_ms) { | 872 void ModuleRtpRtcpImpl::set_rtt_ms(int64_t rtt_ms) { | 
| 850   rtc::CritScope cs(&critical_section_rtt_); | 873   rtc::CritScope cs(&critical_section_rtt_); | 
| 851   rtt_ms_ = rtt_ms; | 874   rtt_ms_ = rtt_ms; | 
| 852 } | 875 } | 
| 853 | 876 | 
| 854 int64_t ModuleRtpRtcpImpl::rtt_ms() const { | 877 int64_t ModuleRtpRtcpImpl::rtt_ms() const { | 
| 855   rtc::CritScope cs(&critical_section_rtt_); | 878   rtc::CritScope cs(&critical_section_rtt_); | 
| 856   return rtt_ms_; | 879   return rtt_ms_; | 
| 857 } | 880 } | 
| 858 | 881 | 
| 859 void ModuleRtpRtcpImpl::RegisterSendChannelRtpStatisticsCallback( | 882 void ModuleRtpRtcpImpl::RegisterSendChannelRtpStatisticsCallback( | 
| 860     StreamDataCountersCallback* callback) { | 883     StreamDataCountersCallback* callback) { | 
| 861   rtp_sender_.RegisterRtpStatisticsCallback(callback); | 884   rtp_sender_->RegisterRtpStatisticsCallback(callback); | 
| 862 } | 885 } | 
| 863 | 886 | 
| 864 StreamDataCountersCallback* | 887 StreamDataCountersCallback* | 
| 865     ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const { | 888     ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const { | 
| 866   return rtp_sender_.GetRtpStatisticsCallback(); | 889   return rtp_sender_->GetRtpStatisticsCallback(); | 
| 867 } | 890 } | 
| 868 | 891 | 
| 869 void ModuleRtpRtcpImpl::SetVideoBitrateAllocation( | 892 void ModuleRtpRtcpImpl::SetVideoBitrateAllocation( | 
| 870     const BitrateAllocation& bitrate) { | 893     const BitrateAllocation& bitrate) { | 
| 871   rtcp_sender_.SetVideoBitrateAllocation(bitrate); | 894   rtcp_sender_.SetVideoBitrateAllocation(bitrate); | 
| 872 } | 895 } | 
| 873 }  // namespace webrtc | 896 }  // namespace webrtc | 
| OLD | NEW | 
|---|