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 |
| 11 #include "webrtc/video/rtp_video_stream_receiver.h" | 11 #include "webrtc/video/rtp_video_stream_receiver.h" |
| 12 | 12 |
| 13 #include <algorithm> | |
| 13 #include <utility> | 14 #include <utility> |
| 14 #include <vector> | 15 #include <vector> |
| 15 | 16 |
| 16 #include "webrtc/common_types.h" | 17 #include "webrtc/common_types.h" |
| 17 #include "webrtc/config.h" | 18 #include "webrtc/config.h" |
| 18 #include "webrtc/media/base/mediaconstants.h" | 19 #include "webrtc/media/base/mediaconstants.h" |
| 19 #include "webrtc/modules/pacing/packet_router.h" | 20 #include "webrtc/modules/pacing/packet_router.h" |
| 20 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat or.h" | 21 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat or.h" |
| 21 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" | 22 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" |
| 22 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" | 23 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 new NackModule(clock_, nack_sender, keyframe_request_sender)); | 185 new NackModule(clock_, nack_sender, keyframe_request_sender)); |
| 185 process_thread_->RegisterModule(nack_module_.get(), RTC_FROM_HERE); | 186 process_thread_->RegisterModule(nack_module_.get(), RTC_FROM_HERE); |
| 186 } | 187 } |
| 187 | 188 |
| 188 packet_buffer_ = video_coding::PacketBuffer::Create( | 189 packet_buffer_ = video_coding::PacketBuffer::Create( |
| 189 clock_, kPacketBufferStartSize, kPacketBufferMaxSixe, this); | 190 clock_, kPacketBufferStartSize, kPacketBufferMaxSixe, this); |
| 190 reference_finder_.reset(new video_coding::RtpFrameReferenceFinder(this)); | 191 reference_finder_.reset(new video_coding::RtpFrameReferenceFinder(this)); |
| 191 } | 192 } |
| 192 | 193 |
| 193 RtpVideoStreamReceiver::~RtpVideoStreamReceiver() { | 194 RtpVideoStreamReceiver::~RtpVideoStreamReceiver() { |
| 195 RTC_DCHECK(secondary_sinks_.empty()); | |
| 196 | |
| 194 if (nack_module_) { | 197 if (nack_module_) { |
| 195 process_thread_->DeRegisterModule(nack_module_.get()); | 198 process_thread_->DeRegisterModule(nack_module_.get()); |
| 196 } | 199 } |
| 197 | 200 |
| 198 process_thread_->DeRegisterModule(rtp_rtcp_.get()); | 201 process_thread_->DeRegisterModule(rtp_rtcp_.get()); |
| 199 | 202 |
| 200 packet_router_->RemoveReceiveRtpModule(rtp_rtcp_.get()); | 203 packet_router_->RemoveReceiveRtpModule(rtp_rtcp_.get()); |
| 201 UpdateHistograms(); | 204 UpdateHistograms(); |
| 202 } | 205 } |
| 203 | 206 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 ReceivePacket(packet.data(), packet.size(), header, in_order); | 357 ReceivePacket(packet.data(), packet.size(), header, in_order); |
| 355 // Update receive statistics after ReceivePacket. | 358 // Update receive statistics after ReceivePacket. |
| 356 // Receive statistics will be reset if the payload type changes (make sure | 359 // Receive statistics will be reset if the payload type changes (make sure |
| 357 // that the first packet is included in the stats). | 360 // that the first packet is included in the stats). |
| 358 if (!packet.recovered()) { | 361 if (!packet.recovered()) { |
| 359 // TODO(nisse): We should pass a recovered flag to stats, to aid | 362 // TODO(nisse): We should pass a recovered flag to stats, to aid |
| 360 // fixing bug bugs.webrtc.org/6339. | 363 // fixing bug bugs.webrtc.org/6339. |
| 361 rtp_receive_statistics_->IncomingPacket( | 364 rtp_receive_statistics_->IncomingPacket( |
| 362 header, packet.size(), IsPacketRetransmitted(header, in_order)); | 365 header, packet.size(), IsPacketRetransmitted(header, in_order)); |
| 363 } | 366 } |
| 367 | |
| 368 for (auto* secondary_sink : secondary_sinks_) { | |
| 369 secondary_sink->OnRtpPacket(packet); | |
| 370 } | |
| 364 } | 371 } |
| 365 | 372 |
| 366 int32_t RtpVideoStreamReceiver::RequestKeyFrame() { | 373 int32_t RtpVideoStreamReceiver::RequestKeyFrame() { |
| 367 return rtp_rtcp_->RequestKeyFrame(); | 374 return rtp_rtcp_->RequestKeyFrame(); |
| 368 } | 375 } |
| 369 | 376 |
| 370 bool RtpVideoStreamReceiver::IsUlpfecEnabled() const { | 377 bool RtpVideoStreamReceiver::IsUlpfecEnabled() const { |
| 371 return config_.rtp.ulpfec.ulpfec_payload_type != -1; | 378 return config_.rtp.ulpfec.ulpfec_payload_type != -1; |
| 372 } | 379 } |
| 373 | 380 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 421 | 428 |
| 422 rtc::Optional<int64_t> RtpVideoStreamReceiver::LastReceivedPacketMs() const { | 429 rtc::Optional<int64_t> RtpVideoStreamReceiver::LastReceivedPacketMs() const { |
| 423 return packet_buffer_->LastReceivedPacketMs(); | 430 return packet_buffer_->LastReceivedPacketMs(); |
| 424 } | 431 } |
| 425 | 432 |
| 426 rtc::Optional<int64_t> RtpVideoStreamReceiver::LastReceivedKeyframePacketMs() | 433 rtc::Optional<int64_t> RtpVideoStreamReceiver::LastReceivedKeyframePacketMs() |
| 427 const { | 434 const { |
| 428 return packet_buffer_->LastReceivedKeyframePacketMs(); | 435 return packet_buffer_->LastReceivedKeyframePacketMs(); |
| 429 } | 436 } |
| 430 | 437 |
| 438 void RtpVideoStreamReceiver::AddSecondarySink(RtpPacketSinkInterface* sink) { | |
| 439 RTC_DCHECK(std::find(secondary_sinks_.cbegin(), secondary_sinks_.cend(), | |
| 440 sink) == secondary_sinks_.cend()); | |
| 441 secondary_sinks_.push_back(sink); | |
| 442 } | |
| 443 | |
| 444 void RtpVideoStreamReceiver::RemoveSecondarySink( | |
| 445 const RtpPacketSinkInterface* sink) { | |
| 446 auto it = std::find(secondary_sinks_.begin(), secondary_sinks_.end(), sink); | |
| 447 if (it == secondary_sinks_.end()) { | |
| 448 // We might be rolling-back a call whose setup failed mid-way. In such a | |
| 449 // case, it's simpler to remove "everything" rather than remember what | |
| 450 // has already been added. | |
| 451 LOG(LS_WARNING) << "Removal of unknown sink (" << sink << ")."; | |
|
danilchap
2017/07/25 17:29:54
why stream to text log address of the sink pointer
eladalon
2017/07/26 08:20:29
I thought it might sometimes help, but I agree it'
| |
| 452 return; | |
| 453 } | |
| 454 secondary_sinks_.erase(it); | |
| 455 } | |
| 456 | |
| 431 void RtpVideoStreamReceiver::ReceivePacket(const uint8_t* packet, | 457 void RtpVideoStreamReceiver::ReceivePacket(const uint8_t* packet, |
| 432 size_t packet_length, | 458 size_t packet_length, |
| 433 const RTPHeader& header, | 459 const RTPHeader& header, |
| 434 bool in_order) { | 460 bool in_order) { |
| 435 if (rtp_payload_registry_.IsEncapsulated(header)) { | 461 if (rtp_payload_registry_.IsEncapsulated(header)) { |
| 436 ParseAndHandleEncapsulatingHeader(packet, packet_length, header); | 462 ParseAndHandleEncapsulatingHeader(packet, packet_length, header); |
| 437 return; | 463 return; |
| 438 } | 464 } |
| 439 const uint8_t* payload = packet + header.headerLength; | 465 const uint8_t* payload = packet + header.headerLength; |
| 440 assert(packet_length >= header.headerLength); | 466 assert(packet_length >= header.headerLength); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 680 return; | 706 return; |
| 681 | 707 |
| 682 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) | 708 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) |
| 683 return; | 709 return; |
| 684 | 710 |
| 685 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), | 711 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), |
| 686 sprop_decoder.pps_nalu()); | 712 sprop_decoder.pps_nalu()); |
| 687 } | 713 } |
| 688 | 714 |
| 689 } // namespace webrtc | 715 } // namespace webrtc |
| OLD | NEW |