Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: webrtc/video/rtp_video_stream_receiver.cc

Issue 2974453002: Protected streams report RTP messages directly to the FlexFec streams (Closed)
Patch Set: CR response (brandtr) Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 const int frequency, 304 const int frequency,
302 const size_t channels, 305 const size_t channels,
303 const uint32_t rate) { 306 const uint32_t rate) {
304 RTC_NOTREACHED(); 307 RTC_NOTREACHED();
305 return 0; 308 return 0;
306 } 309 }
307 310
308 // This method handles both regular RTP packets and packets recovered 311 // This method handles both regular RTP packets and packets recovered
309 // via FlexFEC. 312 // via FlexFEC.
310 void RtpVideoStreamReceiver::OnRtpPacket(const RtpPacketReceived& packet) { 313 void RtpVideoStreamReceiver::OnRtpPacket(const RtpPacketReceived& packet) {
314 // TODO(eladalon): https://bugs.chromium.org/p/webrtc/issues/detail?id=8056
315 // RTC_DCHECK_RUN_ON(&worker_thread_checker_);
316
311 { 317 {
312 rtc::CritScope lock(&receive_cs_); 318 rtc::CritScope lock(&receive_cs_);
313 if (!receiving_) { 319 if (!receiving_) {
314 return; 320 return;
315 } 321 }
316 322
317 if (!packet.recovered()) { 323 if (!packet.recovered()) {
318 int64_t now_ms = clock_->TimeInMilliseconds(); 324 int64_t now_ms = clock_->TimeInMilliseconds();
319 325
320 // Periodically log the RTP header of incoming packets. 326 // Periodically log the RTP header of incoming packets.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 ReceivePacket(packet.data(), packet.size(), header, in_order); 360 ReceivePacket(packet.data(), packet.size(), header, in_order);
355 // Update receive statistics after ReceivePacket. 361 // Update receive statistics after ReceivePacket.
356 // Receive statistics will be reset if the payload type changes (make sure 362 // Receive statistics will be reset if the payload type changes (make sure
357 // that the first packet is included in the stats). 363 // that the first packet is included in the stats).
358 if (!packet.recovered()) { 364 if (!packet.recovered()) {
359 // TODO(nisse): We should pass a recovered flag to stats, to aid 365 // TODO(nisse): We should pass a recovered flag to stats, to aid
360 // fixing bug bugs.webrtc.org/6339. 366 // fixing bug bugs.webrtc.org/6339.
361 rtp_receive_statistics_->IncomingPacket( 367 rtp_receive_statistics_->IncomingPacket(
362 header, packet.size(), IsPacketRetransmitted(header, in_order)); 368 header, packet.size(), IsPacketRetransmitted(header, in_order));
363 } 369 }
370
371 for (RtpPacketSinkInterface* secondary_sink : secondary_sinks_) {
372 secondary_sink->OnRtpPacket(packet);
373 }
364 } 374 }
365 375
366 int32_t RtpVideoStreamReceiver::RequestKeyFrame() { 376 int32_t RtpVideoStreamReceiver::RequestKeyFrame() {
367 return rtp_rtcp_->RequestKeyFrame(); 377 return rtp_rtcp_->RequestKeyFrame();
368 } 378 }
369 379
370 bool RtpVideoStreamReceiver::IsUlpfecEnabled() const { 380 bool RtpVideoStreamReceiver::IsUlpfecEnabled() const {
371 return config_.rtp.ulpfec.ulpfec_payload_type != -1; 381 return config_.rtp.ulpfec.ulpfec_payload_type != -1;
372 } 382 }
373 383
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 431
422 rtc::Optional<int64_t> RtpVideoStreamReceiver::LastReceivedPacketMs() const { 432 rtc::Optional<int64_t> RtpVideoStreamReceiver::LastReceivedPacketMs() const {
423 return packet_buffer_->LastReceivedPacketMs(); 433 return packet_buffer_->LastReceivedPacketMs();
424 } 434 }
425 435
426 rtc::Optional<int64_t> RtpVideoStreamReceiver::LastReceivedKeyframePacketMs() 436 rtc::Optional<int64_t> RtpVideoStreamReceiver::LastReceivedKeyframePacketMs()
427 const { 437 const {
428 return packet_buffer_->LastReceivedKeyframePacketMs(); 438 return packet_buffer_->LastReceivedKeyframePacketMs();
429 } 439 }
430 440
441 void RtpVideoStreamReceiver::AddSecondarySink(RtpPacketSinkInterface* sink) {
442 // TODO(eladalon): https://bugs.chromium.org/p/webrtc/issues/detail?id=8056
443 // RTC_DCHECK_RUN_ON(&worker_thread_checker_);
444 RTC_DCHECK(std::find(secondary_sinks_.cbegin(), secondary_sinks_.cend(),
445 sink) == secondary_sinks_.cend());
446 secondary_sinks_.push_back(sink);
447 }
448
449 void RtpVideoStreamReceiver::RemoveSecondarySink(
450 const RtpPacketSinkInterface* sink) {
451 // TODO(eladalon): https://bugs.chromium.org/p/webrtc/issues/detail?id=8056
452 // RTC_DCHECK_RUN_ON(&worker_thread_checker_);
453 auto it = std::find(secondary_sinks_.begin(), secondary_sinks_.end(), sink);
454 if (it == secondary_sinks_.end()) {
455 // We might be rolling-back a call whose setup failed mid-way. In such a
456 // case, it's simpler to remove "everything" rather than remember what
457 // has already been added.
458 LOG(LS_WARNING) << "Removal of unknown sink.";
459 return;
460 }
461 secondary_sinks_.erase(it);
462 }
463
431 void RtpVideoStreamReceiver::ReceivePacket(const uint8_t* packet, 464 void RtpVideoStreamReceiver::ReceivePacket(const uint8_t* packet,
432 size_t packet_length, 465 size_t packet_length,
433 const RTPHeader& header, 466 const RTPHeader& header,
434 bool in_order) { 467 bool in_order) {
435 if (rtp_payload_registry_.IsEncapsulated(header)) { 468 if (rtp_payload_registry_.IsEncapsulated(header)) {
436 ParseAndHandleEncapsulatingHeader(packet, packet_length, header); 469 ParseAndHandleEncapsulatingHeader(packet, packet_length, header);
437 return; 470 return;
438 } 471 }
439 const uint8_t* payload = packet + header.headerLength; 472 const uint8_t* payload = packet + header.headerLength;
440 assert(packet_length >= header.headerLength); 473 assert(packet_length >= header.headerLength);
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 return; 713 return;
681 714
682 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) 715 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str()))
683 return; 716 return;
684 717
685 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), 718 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(),
686 sprop_decoder.pps_nalu()); 719 sprop_decoder.pps_nalu());
687 } 720 }
688 721
689 } // namespace webrtc 722 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698