Chromium Code Reviews| 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()); | |
| 116 | 118 |
| 117 // Set default packet size limit. | 119 // Set default packet size limit. |
| 118 // TODO(nisse): Kind-of duplicates | 120 // TODO(nisse): Kind-of duplicates |
| 119 // webrtc::VideoSendStream::Config::Rtp::kDefaultMaxPacketSize. | 121 // webrtc::VideoSendStream::Config::Rtp::kDefaultMaxPacketSize. |
| 120 const size_t kTcpOverIpv4HeaderSize = 40; | 122 const size_t kTcpOverIpv4HeaderSize = 40; |
| 121 SetMaxRtpPacketSize(IP_PACKET_SIZE - kTcpOverIpv4HeaderSize); | 123 SetMaxRtpPacketSize(IP_PACKET_SIZE - kTcpOverIpv4HeaderSize); |
| 124 } | |
| 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.send_payload_type = rtp_sender_.SendPayloadType(); | 323 // This is called also when receiver_only is true. Hence below |
| 322 state.packets_sent = rtp_stats.transmitted.packets + | 324 // checks that rtp_sender_ exists. |
| 323 rtx_stats.transmitted.packets; | 325 if (rtp_sender_) { |
| 324 state.media_bytes_sent = rtp_stats.transmitted.payload_bytes + | 326 StreamDataCounters rtp_stats; |
| 325 rtx_stats.transmitted.payload_bytes; | 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_payload_type = rtp_sender_->SendPayloadType(); | |
| 334 state.send_bitrate = rtp_sender_->BitrateSent(); | |
| 335 } else { | |
| 336 // The default value for RTPSender::payload_type_ is -1, | |
| 337 // use same value if RTPSender is missing. | |
| 338 state.send_payload_type = static_cast<uint8_t>(-1); | |
| 339 state.send_bitrate = 0; | |
| 340 } | |
| 326 state.module = this; | 341 state.module = this; |
| 327 | 342 |
| 328 LastReceivedNTP(&state.last_rr_ntp_secs, | 343 LastReceivedNTP(&state.last_rr_ntp_secs, |
| 329 &state.last_rr_ntp_frac, | 344 &state.last_rr_ntp_frac, |
| 330 &state.remote_sr); | 345 &state.remote_sr); |
| 331 | 346 |
| 332 state.has_last_xr_rr = | 347 state.has_last_xr_rr = |
| 333 rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&state.last_xr_rr); | 348 rtcp_receiver_.LastReceivedXrReferenceTimeInfo(&state.last_xr_rr); |
| 334 | 349 |
| 335 uint32_t tmp; | |
| 336 BitrateSent(&state.send_bitrate, &tmp, &tmp, &tmp); | |
| 337 return state; | 350 return state; |
| 338 } | 351 } |
| 339 | 352 |
| 353 // TODO(nisse): The | |
| 354 // TestWithNewVideoJitterBuffer/EndToEndTest.RembWithSendSideBwe/* tests call | |
| 355 // this method for a receive-only stream, which makes little sense. If that is | |
| 356 // fixed, the rtp_sender_ check can be removed. | |
| 340 int32_t ModuleRtpRtcpImpl::SetSendingStatus(const bool sending) { | 357 int32_t ModuleRtpRtcpImpl::SetSendingStatus(const bool sending) { |
| 341 if (rtcp_sender_.Sending() != sending) { | 358 if (rtcp_sender_.Sending() != sending) { |
| 342 // Sends RTCP BYE when going from true to false | 359 // Sends RTCP BYE when going from true to false |
| 343 if (rtcp_sender_.SetSendingStatus(GetFeedbackState(), sending) != 0) { | 360 if (rtcp_sender_.SetSendingStatus(GetFeedbackState(), sending) != 0) { |
| 344 LOG(LS_WARNING) << "Failed to send RTCP BYE"; | 361 LOG(LS_WARNING) << "Failed to send RTCP BYE"; |
| 345 } | 362 } |
| 346 if (sending) { | 363 if (sending && rtp_sender_) { |
| 347 // Update Rtcp receiver config, to track Rtx config changes from | 364 // Update Rtcp receiver config, to track Rtx config changes from |
| 348 // the SetRtxStatus and SetRtxSsrc methods. | 365 // the SetRtxStatus and SetRtxSsrc methods. |
| 349 SetRtcpReceiverSsrcs(rtp_sender_.SSRC()); | 366 SetRtcpReceiverSsrcs(rtp_sender_->SSRC()); |
| 350 } | 367 } |
| 351 } | 368 } |
| 352 return 0; | 369 return 0; |
| 353 } | 370 } |
| 354 | 371 |
| 355 bool ModuleRtpRtcpImpl::Sending() const { | 372 bool ModuleRtpRtcpImpl::Sending() const { |
| 356 return rtcp_sender_.Sending(); | 373 return rtcp_sender_.Sending(); |
| 357 } | 374 } |
| 358 | 375 |
| 359 void ModuleRtpRtcpImpl::SetSendingMediaStatus(const bool sending) { | 376 void ModuleRtpRtcpImpl::SetSendingMediaStatus(const bool sending) { |
| 360 rtp_sender_.SetSendingMediaStatus(sending); | 377 rtp_sender_->SetSendingMediaStatus(sending); |
|
danilchap
2017/03/16 15:08:42
add if (rtp_sender_) check to protect against rece
nisse-webrtc
2017/03/16 15:14:08
Done.
| |
| 361 } | 378 } |
| 362 | 379 |
| 363 bool ModuleRtpRtcpImpl::SendingMedia() const { | 380 bool ModuleRtpRtcpImpl::SendingMedia() const { |
| 364 return rtp_sender_.SendingMedia(); | 381 return rtp_sender_ ? rtp_sender_->SendingMedia() : false; |
| 365 } | 382 } |
| 366 | 383 |
| 367 bool ModuleRtpRtcpImpl::SendOutgoingData( | 384 bool ModuleRtpRtcpImpl::SendOutgoingData( |
| 368 FrameType frame_type, | 385 FrameType frame_type, |
| 369 int8_t payload_type, | 386 int8_t payload_type, |
| 370 uint32_t time_stamp, | 387 uint32_t time_stamp, |
| 371 int64_t capture_time_ms, | 388 int64_t capture_time_ms, |
| 372 const uint8_t* payload_data, | 389 const uint8_t* payload_data, |
| 373 size_t payload_size, | 390 size_t payload_size, |
| 374 const RTPFragmentationHeader* fragmentation, | 391 const RTPFragmentationHeader* fragmentation, |
| 375 const RTPVideoHeader* rtp_video_header, | 392 const RTPVideoHeader* rtp_video_header, |
| 376 uint32_t* transport_frame_id_out) { | 393 uint32_t* transport_frame_id_out) { |
| 377 rtcp_sender_.SetLastRtpTime(time_stamp, capture_time_ms); | 394 rtcp_sender_.SetLastRtpTime(time_stamp, capture_time_ms); |
| 378 // 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. |
| 379 if (rtcp_sender_.TimeToSendRTCPReport(kVideoFrameKey == frame_type)) { | 396 if (rtcp_sender_.TimeToSendRTCPReport(kVideoFrameKey == frame_type)) { |
| 380 rtcp_sender_.SendRTCP(GetFeedbackState(), kRtcpReport); | 397 rtcp_sender_.SendRTCP(GetFeedbackState(), kRtcpReport); |
| 381 } | 398 } |
| 382 return rtp_sender_.SendOutgoingData( | 399 return rtp_sender_->SendOutgoingData( |
| 383 frame_type, payload_type, time_stamp, capture_time_ms, payload_data, | 400 frame_type, payload_type, time_stamp, capture_time_ms, payload_data, |
| 384 payload_size, fragmentation, rtp_video_header, transport_frame_id_out); | 401 payload_size, fragmentation, rtp_video_header, transport_frame_id_out); |
| 385 } | 402 } |
| 386 | 403 |
| 387 bool ModuleRtpRtcpImpl::TimeToSendPacket(uint32_t ssrc, | 404 bool ModuleRtpRtcpImpl::TimeToSendPacket(uint32_t ssrc, |
| 388 uint16_t sequence_number, | 405 uint16_t sequence_number, |
| 389 int64_t capture_time_ms, | 406 int64_t capture_time_ms, |
| 390 bool retransmission, | 407 bool retransmission, |
| 391 const PacedPacketInfo& pacing_info) { | 408 const PacedPacketInfo& pacing_info) { |
| 392 return rtp_sender_.TimeToSendPacket(ssrc, sequence_number, capture_time_ms, | 409 return rtp_sender_->TimeToSendPacket(ssrc, sequence_number, capture_time_ms, |
| 393 retransmission, pacing_info); | 410 retransmission, pacing_info); |
| 394 } | 411 } |
| 395 | 412 |
| 396 size_t ModuleRtpRtcpImpl::TimeToSendPadding( | 413 size_t ModuleRtpRtcpImpl::TimeToSendPadding( |
| 397 size_t bytes, | 414 size_t bytes, |
| 398 const PacedPacketInfo& pacing_info) { | 415 const PacedPacketInfo& pacing_info) { |
| 399 return rtp_sender_.TimeToSendPadding(bytes, pacing_info); | 416 return rtp_sender_->TimeToSendPadding(bytes, pacing_info); |
| 400 } | 417 } |
| 401 | 418 |
| 402 size_t ModuleRtpRtcpImpl::MaxPayloadSize() const { | 419 size_t ModuleRtpRtcpImpl::MaxPayloadSize() const { |
| 403 return rtp_sender_.MaxPayloadSize(); | 420 return rtp_sender_->MaxPayloadSize(); |
| 404 } | 421 } |
| 405 | 422 |
| 406 size_t ModuleRtpRtcpImpl::MaxRtpPacketSize() const { | 423 size_t ModuleRtpRtcpImpl::MaxRtpPacketSize() const { |
| 407 return rtp_sender_.MaxRtpPacketSize(); | 424 return rtp_sender_->MaxRtpPacketSize(); |
| 408 } | 425 } |
| 409 | 426 |
| 410 void ModuleRtpRtcpImpl::SetMaxRtpPacketSize(size_t rtp_packet_size) { | 427 void ModuleRtpRtcpImpl::SetMaxRtpPacketSize(size_t rtp_packet_size) { |
| 411 RTC_DCHECK_LE(rtp_packet_size, IP_PACKET_SIZE) | 428 RTC_DCHECK_LE(rtp_packet_size, IP_PACKET_SIZE) |
| 412 << "rtp packet size too large: " << rtp_packet_size; | 429 << "rtp packet size too large: " << rtp_packet_size; |
| 413 RTC_DCHECK_GT(rtp_packet_size, packet_overhead_) | 430 RTC_DCHECK_GT(rtp_packet_size, packet_overhead_) |
| 414 << "rtp packet size too small: " << rtp_packet_size; | 431 << "rtp packet size too small: " << rtp_packet_size; |
| 415 | 432 |
| 416 rtcp_sender_.SetMaxRtpPacketSize(rtp_packet_size); | 433 rtcp_sender_.SetMaxRtpPacketSize(rtp_packet_size); |
| 417 rtp_sender_.SetMaxRtpPacketSize(rtp_packet_size); | 434 rtp_sender_->SetMaxRtpPacketSize(rtp_packet_size); |
| 418 } | 435 } |
| 419 | 436 |
| 420 RtcpMode ModuleRtpRtcpImpl::RTCP() const { | 437 RtcpMode ModuleRtpRtcpImpl::RTCP() const { |
| 421 return rtcp_sender_.Status(); | 438 return rtcp_sender_.Status(); |
| 422 } | 439 } |
| 423 | 440 |
| 424 // Configure RTCP status i.e on/off. | 441 // Configure RTCP status i.e on/off. |
| 425 void ModuleRtpRtcpImpl::SetRTCPStatus(const RtcpMode method) { | 442 void ModuleRtpRtcpImpl::SetRTCPStatus(const RtcpMode method) { |
| 426 rtcp_sender_.SetRTCPStatus(method); | 443 rtcp_sender_.SetRTCPStatus(method); |
| 427 } | 444 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 508 bool ModuleRtpRtcpImpl::RtcpXrRrtrStatus() const { | 525 bool ModuleRtpRtcpImpl::RtcpXrRrtrStatus() const { |
| 509 return rtcp_sender_.RtcpXrReceiverReferenceTime(); | 526 return rtcp_sender_.RtcpXrReceiverReferenceTime(); |
| 510 } | 527 } |
| 511 | 528 |
| 512 // TODO(asapersson): Replace this method with the one below. | 529 // TODO(asapersson): Replace this method with the one below. |
| 513 int32_t ModuleRtpRtcpImpl::DataCountersRTP( | 530 int32_t ModuleRtpRtcpImpl::DataCountersRTP( |
| 514 size_t* bytes_sent, | 531 size_t* bytes_sent, |
| 515 uint32_t* packets_sent) const { | 532 uint32_t* packets_sent) const { |
| 516 StreamDataCounters rtp_stats; | 533 StreamDataCounters rtp_stats; |
| 517 StreamDataCounters rtx_stats; | 534 StreamDataCounters rtx_stats; |
| 518 rtp_sender_.GetDataCounters(&rtp_stats, &rtx_stats); | 535 rtp_sender_->GetDataCounters(&rtp_stats, &rtx_stats); |
| 519 | 536 |
| 520 if (bytes_sent) { | 537 if (bytes_sent) { |
| 521 *bytes_sent = rtp_stats.transmitted.payload_bytes + | 538 *bytes_sent = rtp_stats.transmitted.payload_bytes + |
| 522 rtp_stats.transmitted.padding_bytes + | 539 rtp_stats.transmitted.padding_bytes + |
| 523 rtp_stats.transmitted.header_bytes + | 540 rtp_stats.transmitted.header_bytes + |
| 524 rtx_stats.transmitted.payload_bytes + | 541 rtx_stats.transmitted.payload_bytes + |
| 525 rtx_stats.transmitted.padding_bytes + | 542 rtx_stats.transmitted.padding_bytes + |
| 526 rtx_stats.transmitted.header_bytes; | 543 rtx_stats.transmitted.header_bytes; |
| 527 } | 544 } |
| 528 if (packets_sent) { | 545 if (packets_sent) { |
| 529 *packets_sent = rtp_stats.transmitted.packets + | 546 *packets_sent = rtp_stats.transmitted.packets + |
| 530 rtx_stats.transmitted.packets; | 547 rtx_stats.transmitted.packets; |
| 531 } | 548 } |
| 532 return 0; | 549 return 0; |
| 533 } | 550 } |
| 534 | 551 |
| 535 void ModuleRtpRtcpImpl::GetSendStreamDataCounters( | 552 void ModuleRtpRtcpImpl::GetSendStreamDataCounters( |
| 536 StreamDataCounters* rtp_counters, | 553 StreamDataCounters* rtp_counters, |
| 537 StreamDataCounters* rtx_counters) const { | 554 StreamDataCounters* rtx_counters) const { |
| 538 rtp_sender_.GetDataCounters(rtp_counters, rtx_counters); | 555 rtp_sender_->GetDataCounters(rtp_counters, rtx_counters); |
| 539 } | 556 } |
| 540 | 557 |
| 541 void ModuleRtpRtcpImpl::GetRtpPacketLossStats( | 558 void ModuleRtpRtcpImpl::GetRtpPacketLossStats( |
| 542 bool outgoing, | 559 bool outgoing, |
| 543 uint32_t ssrc, | 560 uint32_t ssrc, |
| 544 struct RtpPacketLossStats* loss_stats) const { | 561 struct RtpPacketLossStats* loss_stats) const { |
| 545 if (!loss_stats) return; | 562 if (!loss_stats) return; |
| 546 const PacketLossStats* stats_source = NULL; | 563 const PacketLossStats* stats_source = NULL; |
| 547 if (outgoing) { | 564 if (outgoing) { |
| 548 if (SSRC() == ssrc) { | 565 if (SSRC() == ssrc) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 583 } | 600 } |
| 584 | 601 |
| 585 void ModuleRtpRtcpImpl::SetREMBData(const uint32_t bitrate, | 602 void ModuleRtpRtcpImpl::SetREMBData(const uint32_t bitrate, |
| 586 const std::vector<uint32_t>& ssrcs) { | 603 const std::vector<uint32_t>& ssrcs) { |
| 587 rtcp_sender_.SetREMBData(bitrate, ssrcs); | 604 rtcp_sender_.SetREMBData(bitrate, ssrcs); |
| 588 } | 605 } |
| 589 | 606 |
| 590 int32_t ModuleRtpRtcpImpl::RegisterSendRtpHeaderExtension( | 607 int32_t ModuleRtpRtcpImpl::RegisterSendRtpHeaderExtension( |
| 591 const RTPExtensionType type, | 608 const RTPExtensionType type, |
| 592 const uint8_t id) { | 609 const uint8_t id) { |
| 593 return rtp_sender_.RegisterRtpHeaderExtension(type, id); | 610 return rtp_sender_->RegisterRtpHeaderExtension(type, id); |
| 594 } | 611 } |
| 595 | 612 |
| 596 int32_t ModuleRtpRtcpImpl::DeregisterSendRtpHeaderExtension( | 613 int32_t ModuleRtpRtcpImpl::DeregisterSendRtpHeaderExtension( |
| 597 const RTPExtensionType type) { | 614 const RTPExtensionType type) { |
| 598 return rtp_sender_.DeregisterRtpHeaderExtension(type); | 615 return rtp_sender_->DeregisterRtpHeaderExtension(type); |
| 599 } | 616 } |
| 600 | 617 |
| 601 bool ModuleRtpRtcpImpl::HasBweExtensions() const { | 618 bool ModuleRtpRtcpImpl::HasBweExtensions() const { |
| 602 return rtp_sender_.IsRtpHeaderExtensionRegistered( | 619 return rtp_sender_->IsRtpHeaderExtensionRegistered( |
| 603 kRtpExtensionTransportSequenceNumber) || | 620 kRtpExtensionTransportSequenceNumber) || |
| 604 rtp_sender_.IsRtpHeaderExtensionRegistered( | 621 rtp_sender_->IsRtpHeaderExtensionRegistered( |
| 605 kRtpExtensionAbsoluteSendTime) || | 622 kRtpExtensionAbsoluteSendTime) || |
| 606 rtp_sender_.IsRtpHeaderExtensionRegistered( | 623 rtp_sender_->IsRtpHeaderExtensionRegistered( |
| 607 kRtpExtensionTransmissionTimeOffset); | 624 kRtpExtensionTransmissionTimeOffset); |
| 608 } | 625 } |
| 609 | 626 |
| 610 // (TMMBR) Temporary Max Media Bit Rate. | 627 // (TMMBR) Temporary Max Media Bit Rate. |
| 611 bool ModuleRtpRtcpImpl::TMMBR() const { | 628 bool ModuleRtpRtcpImpl::TMMBR() const { |
| 612 return rtcp_sender_.TMMBR(); | 629 return rtcp_sender_.TMMBR(); |
| 613 } | 630 } |
| 614 | 631 |
| 615 void ModuleRtpRtcpImpl::SetTMMBRStatus(const bool enable) { | 632 void ModuleRtpRtcpImpl::SetTMMBRStatus(const bool enable) { |
| 616 rtcp_sender_.SetTMMBRStatus(enable); | 633 rtcp_sender_.SetTMMBRStatus(enable); |
| 617 } | 634 } |
| 618 | 635 |
| 619 void ModuleRtpRtcpImpl::SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set) { | 636 void ModuleRtpRtcpImpl::SetTmmbn(std::vector<rtcp::TmmbItem> bounding_set) { |
| 620 rtcp_sender_.SetTmmbn(std::move(bounding_set)); | 637 rtcp_sender_.SetTmmbn(std::move(bounding_set)); |
| 621 } | 638 } |
| 622 | 639 |
| 623 // Returns the currently configured retransmission mode. | 640 // Returns the currently configured retransmission mode. |
| 624 int ModuleRtpRtcpImpl::SelectiveRetransmissions() const { | 641 int ModuleRtpRtcpImpl::SelectiveRetransmissions() const { |
| 625 return rtp_sender_.SelectiveRetransmissions(); | 642 return rtp_sender_->SelectiveRetransmissions(); |
| 626 } | 643 } |
| 627 | 644 |
| 628 // Enable or disable a retransmission mode, which decides which packets will | 645 // Enable or disable a retransmission mode, which decides which packets will |
| 629 // be retransmitted if NACKed. | 646 // be retransmitted if NACKed. |
| 630 int ModuleRtpRtcpImpl::SetSelectiveRetransmissions(uint8_t settings) { | 647 int ModuleRtpRtcpImpl::SetSelectiveRetransmissions(uint8_t settings) { |
| 631 return rtp_sender_.SetSelectiveRetransmissions(settings); | 648 return rtp_sender_->SetSelectiveRetransmissions(settings); |
| 632 } | 649 } |
| 633 | 650 |
| 634 // Send a Negative acknowledgment packet. | 651 // Send a Negative acknowledgment packet. |
| 635 int32_t ModuleRtpRtcpImpl::SendNACK(const uint16_t* nack_list, | 652 int32_t ModuleRtpRtcpImpl::SendNACK(const uint16_t* nack_list, |
| 636 const uint16_t size) { | 653 const uint16_t size) { |
| 637 for (int i = 0; i < size; ++i) { | 654 for (int i = 0; i < size; ++i) { |
| 638 receive_loss_stats_.AddLostPacket(nack_list[i]); | 655 receive_loss_stats_.AddLostPacket(nack_list[i]); |
| 639 } | 656 } |
| 640 uint16_t nack_length = size; | 657 uint16_t nack_length = size; |
| 641 uint16_t start_id = 0; | 658 uint16_t start_id = 0; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 692 // Send a full NACK list once within every |wait_time|. | 709 // Send a full NACK list once within every |wait_time|. |
| 693 if (rtt_stats_) { | 710 if (rtt_stats_) { |
| 694 return now - nack_last_time_sent_full_ > wait_time; | 711 return now - nack_last_time_sent_full_ > wait_time; |
| 695 } | 712 } |
| 696 return now - nack_last_time_sent_full_prev_ > wait_time; | 713 return now - nack_last_time_sent_full_prev_ > wait_time; |
| 697 } | 714 } |
| 698 | 715 |
| 699 // Store the sent packets, needed to answer to Negative acknowledgment requests. | 716 // Store the sent packets, needed to answer to Negative acknowledgment requests. |
| 700 void ModuleRtpRtcpImpl::SetStorePacketsStatus(const bool enable, | 717 void ModuleRtpRtcpImpl::SetStorePacketsStatus(const bool enable, |
| 701 const uint16_t number_to_store) { | 718 const uint16_t number_to_store) { |
| 702 rtp_sender_.SetStorePacketsStatus(enable, number_to_store); | 719 rtp_sender_->SetStorePacketsStatus(enable, number_to_store); |
| 703 } | 720 } |
| 704 | 721 |
| 705 bool ModuleRtpRtcpImpl::StorePackets() const { | 722 bool ModuleRtpRtcpImpl::StorePackets() const { |
| 706 return rtp_sender_.StorePackets(); | 723 return rtp_sender_->StorePackets(); |
| 707 } | 724 } |
| 708 | 725 |
| 709 void ModuleRtpRtcpImpl::RegisterRtcpStatisticsCallback( | 726 void ModuleRtpRtcpImpl::RegisterRtcpStatisticsCallback( |
| 710 RtcpStatisticsCallback* callback) { | 727 RtcpStatisticsCallback* callback) { |
| 711 rtcp_receiver_.RegisterRtcpStatisticsCallback(callback); | 728 rtcp_receiver_.RegisterRtcpStatisticsCallback(callback); |
| 712 } | 729 } |
| 713 | 730 |
| 714 RtcpStatisticsCallback* ModuleRtpRtcpImpl::GetRtcpStatisticsCallback() { | 731 RtcpStatisticsCallback* ModuleRtpRtcpImpl::GetRtcpStatisticsCallback() { |
| 715 return rtcp_receiver_.GetRtcpStatisticsCallback(); | 732 return rtcp_receiver_.GetRtcpStatisticsCallback(); |
| 716 } | 733 } |
| 717 | 734 |
| 718 bool ModuleRtpRtcpImpl::SendFeedbackPacket( | 735 bool ModuleRtpRtcpImpl::SendFeedbackPacket( |
| 719 const rtcp::TransportFeedback& packet) { | 736 const rtcp::TransportFeedback& packet) { |
| 720 return rtcp_sender_.SendFeedbackPacket(packet); | 737 return rtcp_sender_.SendFeedbackPacket(packet); |
| 721 } | 738 } |
| 722 | 739 |
| 723 // Send a TelephoneEvent tone using RFC 2833 (4733). | 740 // Send a TelephoneEvent tone using RFC 2833 (4733). |
| 724 int32_t ModuleRtpRtcpImpl::SendTelephoneEventOutband( | 741 int32_t ModuleRtpRtcpImpl::SendTelephoneEventOutband( |
| 725 const uint8_t key, | 742 const uint8_t key, |
| 726 const uint16_t time_ms, | 743 const uint16_t time_ms, |
| 727 const uint8_t level) { | 744 const uint8_t level) { |
| 728 return rtp_sender_.SendTelephoneEvent(key, time_ms, level); | 745 return rtp_sender_->SendTelephoneEvent(key, time_ms, level); |
| 729 } | 746 } |
| 730 | 747 |
| 731 int32_t ModuleRtpRtcpImpl::SetAudioPacketSize( | 748 int32_t ModuleRtpRtcpImpl::SetAudioPacketSize( |
| 732 const uint16_t packet_size_samples) { | 749 const uint16_t packet_size_samples) { |
| 733 return audio_ ? 0 : -1; | 750 return audio_ ? 0 : -1; |
| 734 } | 751 } |
| 735 | 752 |
| 736 int32_t ModuleRtpRtcpImpl::SetAudioLevel( | 753 int32_t ModuleRtpRtcpImpl::SetAudioLevel( |
| 737 const uint8_t level_d_bov) { | 754 const uint8_t level_d_bov) { |
| 738 return rtp_sender_.SetAudioLevel(level_d_bov); | 755 return rtp_sender_->SetAudioLevel(level_d_bov); |
| 739 } | 756 } |
| 740 | 757 |
| 741 int32_t ModuleRtpRtcpImpl::SetKeyFrameRequestMethod( | 758 int32_t ModuleRtpRtcpImpl::SetKeyFrameRequestMethod( |
| 742 const KeyFrameRequestMethod method) { | 759 const KeyFrameRequestMethod method) { |
| 743 key_frame_req_method_ = method; | 760 key_frame_req_method_ = method; |
| 744 return 0; | 761 return 0; |
| 745 } | 762 } |
| 746 | 763 |
| 747 int32_t ModuleRtpRtcpImpl::RequestKeyFrame() { | 764 int32_t ModuleRtpRtcpImpl::RequestKeyFrame() { |
| 748 switch (key_frame_req_method_) { | 765 switch (key_frame_req_method_) { |
| 749 case kKeyFrameReqPliRtcp: | 766 case kKeyFrameReqPliRtcp: |
| 750 return SendRTCP(kRtcpPli); | 767 return SendRTCP(kRtcpPli); |
| 751 case kKeyFrameReqFirRtcp: | 768 case kKeyFrameReqFirRtcp: |
| 752 return SendRTCP(kRtcpFir); | 769 return SendRTCP(kRtcpFir); |
| 753 } | 770 } |
| 754 return -1; | 771 return -1; |
| 755 } | 772 } |
| 756 | 773 |
| 757 void ModuleRtpRtcpImpl::SetUlpfecConfig(int red_payload_type, | 774 void ModuleRtpRtcpImpl::SetUlpfecConfig(int red_payload_type, |
| 758 int ulpfec_payload_type) { | 775 int ulpfec_payload_type) { |
| 759 rtp_sender_.SetUlpfecConfig(red_payload_type, ulpfec_payload_type); | 776 rtp_sender_->SetUlpfecConfig(red_payload_type, ulpfec_payload_type); |
| 760 } | 777 } |
| 761 | 778 |
| 762 bool ModuleRtpRtcpImpl::SetFecParameters( | 779 bool ModuleRtpRtcpImpl::SetFecParameters( |
| 763 const FecProtectionParams& delta_params, | 780 const FecProtectionParams& delta_params, |
| 764 const FecProtectionParams& key_params) { | 781 const FecProtectionParams& key_params) { |
| 765 return rtp_sender_.SetFecParameters(delta_params, key_params); | 782 return rtp_sender_->SetFecParameters(delta_params, key_params); |
| 766 } | 783 } |
| 767 | 784 |
| 768 void ModuleRtpRtcpImpl::SetRemoteSSRC(const uint32_t ssrc) { | 785 void ModuleRtpRtcpImpl::SetRemoteSSRC(const uint32_t ssrc) { |
| 769 // Inform about the incoming SSRC. | 786 // Inform about the incoming SSRC. |
| 770 rtcp_sender_.SetRemoteSSRC(ssrc); | 787 rtcp_sender_.SetRemoteSSRC(ssrc); |
| 771 rtcp_receiver_.SetRemoteSSRC(ssrc); | 788 rtcp_receiver_.SetRemoteSSRC(ssrc); |
| 772 } | 789 } |
| 773 | 790 |
| 774 void ModuleRtpRtcpImpl::BitrateSent(uint32_t* total_rate, | 791 void ModuleRtpRtcpImpl::BitrateSent(uint32_t* total_rate, |
| 775 uint32_t* video_rate, | 792 uint32_t* video_rate, |
| 776 uint32_t* fec_rate, | 793 uint32_t* fec_rate, |
| 777 uint32_t* nack_rate) const { | 794 uint32_t* nack_rate) const { |
| 778 *total_rate = rtp_sender_.BitrateSent(); | 795 *total_rate = rtp_sender_->BitrateSent(); |
| 779 *video_rate = rtp_sender_.VideoBitrateSent(); | 796 *video_rate = rtp_sender_->VideoBitrateSent(); |
| 780 *fec_rate = rtp_sender_.FecOverheadRate(); | 797 *fec_rate = rtp_sender_->FecOverheadRate(); |
| 781 *nack_rate = rtp_sender_.NackOverheadRate(); | 798 *nack_rate = rtp_sender_->NackOverheadRate(); |
| 782 } | 799 } |
| 783 | 800 |
| 784 void ModuleRtpRtcpImpl::OnRequestSendReport() { | 801 void ModuleRtpRtcpImpl::OnRequestSendReport() { |
| 785 SendRTCP(kRtcpSr); | 802 SendRTCP(kRtcpSr); |
| 786 } | 803 } |
| 787 | 804 |
| 788 void ModuleRtpRtcpImpl::OnReceivedNack( | 805 void ModuleRtpRtcpImpl::OnReceivedNack( |
| 789 const std::vector<uint16_t>& nack_sequence_numbers) { | 806 const std::vector<uint16_t>& nack_sequence_numbers) { |
| 807 if (!rtp_sender_) | |
| 808 return; | |
| 809 | |
| 790 for (uint16_t nack_sequence_number : nack_sequence_numbers) { | 810 for (uint16_t nack_sequence_number : nack_sequence_numbers) { |
| 791 send_loss_stats_.AddLostPacket(nack_sequence_number); | 811 send_loss_stats_.AddLostPacket(nack_sequence_number); |
| 792 } | 812 } |
| 793 if (!rtp_sender_.StorePackets() || | 813 if (!rtp_sender_->StorePackets() || |
| 794 nack_sequence_numbers.size() == 0) { | 814 nack_sequence_numbers.size() == 0) { |
| 795 return; | 815 return; |
| 796 } | 816 } |
| 797 // Use RTT from RtcpRttStats class if provided. | 817 // Use RTT from RtcpRttStats class if provided. |
| 798 int64_t rtt = rtt_ms(); | 818 int64_t rtt = rtt_ms(); |
| 799 if (rtt == 0) { | 819 if (rtt == 0) { |
| 800 rtcp_receiver_.RTT(rtcp_receiver_.RemoteSSRC(), NULL, &rtt, NULL, NULL); | 820 rtcp_receiver_.RTT(rtcp_receiver_.RemoteSSRC(), NULL, &rtt, NULL, NULL); |
| 801 } | 821 } |
| 802 rtp_sender_.OnReceivedNack(nack_sequence_numbers, rtt); | 822 rtp_sender_->OnReceivedNack(nack_sequence_numbers, rtt); |
| 803 } | 823 } |
| 804 | 824 |
| 805 void ModuleRtpRtcpImpl::OnReceivedRtcpReportBlocks( | 825 void ModuleRtpRtcpImpl::OnReceivedRtcpReportBlocks( |
| 806 const ReportBlockList& report_blocks) { | 826 const ReportBlockList& report_blocks) { |
| 807 rtp_sender_.OnReceivedRtcpReportBlocks(report_blocks); | 827 if (rtp_sender_) |
| 828 rtp_sender_->OnReceivedRtcpReportBlocks(report_blocks); | |
| 808 } | 829 } |
| 809 | 830 |
| 810 bool ModuleRtpRtcpImpl::LastReceivedNTP( | 831 bool ModuleRtpRtcpImpl::LastReceivedNTP( |
| 811 uint32_t* rtcp_arrival_time_secs, // When we got the last report. | 832 uint32_t* rtcp_arrival_time_secs, // When we got the last report. |
| 812 uint32_t* rtcp_arrival_time_frac, | 833 uint32_t* rtcp_arrival_time_frac, |
| 813 uint32_t* remote_sr) const { | 834 uint32_t* remote_sr) const { |
| 814 // Remote SR: NTP inside the last received (mid 16 bits from sec and frac). | 835 // Remote SR: NTP inside the last received (mid 16 bits from sec and frac). |
| 815 uint32_t ntp_secs = 0; | 836 uint32_t ntp_secs = 0; |
| 816 uint32_t ntp_frac = 0; | 837 uint32_t ntp_frac = 0; |
| 817 | 838 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 835 int64_t ModuleRtpRtcpImpl::RtcpReportInterval() { | 856 int64_t ModuleRtpRtcpImpl::RtcpReportInterval() { |
| 836 if (audio_) | 857 if (audio_) |
| 837 return RTCP_INTERVAL_AUDIO_MS; | 858 return RTCP_INTERVAL_AUDIO_MS; |
| 838 else | 859 else |
| 839 return RTCP_INTERVAL_VIDEO_MS; | 860 return RTCP_INTERVAL_VIDEO_MS; |
| 840 } | 861 } |
| 841 | 862 |
| 842 void ModuleRtpRtcpImpl::SetRtcpReceiverSsrcs(uint32_t main_ssrc) { | 863 void ModuleRtpRtcpImpl::SetRtcpReceiverSsrcs(uint32_t main_ssrc) { |
| 843 std::set<uint32_t> ssrcs; | 864 std::set<uint32_t> ssrcs; |
| 844 ssrcs.insert(main_ssrc); | 865 ssrcs.insert(main_ssrc); |
| 845 if (rtp_sender_.RtxStatus() != kRtxOff) | 866 if (RtxSendStatus() != kRtxOff) |
| 846 ssrcs.insert(rtp_sender_.RtxSsrc()); | 867 ssrcs.insert(rtp_sender_->RtxSsrc()); |
| 847 rtcp_receiver_.SetSsrcs(main_ssrc, ssrcs); | 868 rtcp_receiver_.SetSsrcs(main_ssrc, ssrcs); |
| 848 } | 869 } |
| 849 | 870 |
| 850 void ModuleRtpRtcpImpl::set_rtt_ms(int64_t rtt_ms) { | 871 void ModuleRtpRtcpImpl::set_rtt_ms(int64_t rtt_ms) { |
| 851 rtc::CritScope cs(&critical_section_rtt_); | 872 rtc::CritScope cs(&critical_section_rtt_); |
| 852 rtt_ms_ = rtt_ms; | 873 rtt_ms_ = rtt_ms; |
| 853 } | 874 } |
| 854 | 875 |
| 855 int64_t ModuleRtpRtcpImpl::rtt_ms() const { | 876 int64_t ModuleRtpRtcpImpl::rtt_ms() const { |
| 856 rtc::CritScope cs(&critical_section_rtt_); | 877 rtc::CritScope cs(&critical_section_rtt_); |
| 857 return rtt_ms_; | 878 return rtt_ms_; |
| 858 } | 879 } |
| 859 | 880 |
| 860 void ModuleRtpRtcpImpl::RegisterSendChannelRtpStatisticsCallback( | 881 void ModuleRtpRtcpImpl::RegisterSendChannelRtpStatisticsCallback( |
| 861 StreamDataCountersCallback* callback) { | 882 StreamDataCountersCallback* callback) { |
| 862 rtp_sender_.RegisterRtpStatisticsCallback(callback); | 883 rtp_sender_->RegisterRtpStatisticsCallback(callback); |
| 863 } | 884 } |
| 864 | 885 |
| 865 StreamDataCountersCallback* | 886 StreamDataCountersCallback* |
| 866 ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const { | 887 ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const { |
| 867 return rtp_sender_.GetRtpStatisticsCallback(); | 888 return rtp_sender_->GetRtpStatisticsCallback(); |
| 868 } | 889 } |
| 869 | 890 |
| 870 void ModuleRtpRtcpImpl::SetVideoBitrateAllocation( | 891 void ModuleRtpRtcpImpl::SetVideoBitrateAllocation( |
| 871 const BitrateAllocation& bitrate) { | 892 const BitrateAllocation& bitrate) { |
| 872 rtcp_sender_.SetVideoBitrateAllocation(bitrate); | 893 rtcp_sender_.SetVideoBitrateAllocation(bitrate); |
| 873 } | 894 } |
| 874 } // namespace webrtc | 895 } // namespace webrtc |
| OLD | NEW |