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

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: Appease lint. 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 new NackModule(clock_, nack_sender, keyframe_request_sender)); 186 new NackModule(clock_, nack_sender, keyframe_request_sender));
186 process_thread_->RegisterModule(nack_module_.get(), RTC_FROM_HERE); 187 process_thread_->RegisterModule(nack_module_.get(), RTC_FROM_HERE);
187 } 188 }
188 189
189 packet_buffer_ = video_coding::PacketBuffer::Create( 190 packet_buffer_ = video_coding::PacketBuffer::Create(
190 clock_, kPacketBufferStartSize, kPacketBufferMaxSixe, this); 191 clock_, kPacketBufferStartSize, kPacketBufferMaxSixe, this);
191 reference_finder_.reset(new video_coding::RtpFrameReferenceFinder(this)); 192 reference_finder_.reset(new video_coding::RtpFrameReferenceFinder(this));
192 } 193 }
193 194
194 RtpVideoStreamReceiver::~RtpVideoStreamReceiver() { 195 RtpVideoStreamReceiver::~RtpVideoStreamReceiver() {
196 RTC_DCHECK(secondary_sinks_.empty());
197
195 if (nack_module_) { 198 if (nack_module_) {
196 process_thread_->DeRegisterModule(nack_module_.get()); 199 process_thread_->DeRegisterModule(nack_module_.get());
197 } 200 }
198 201
199 process_thread_->DeRegisterModule(rtp_rtcp_.get()); 202 process_thread_->DeRegisterModule(rtp_rtcp_.get());
200 203
201 packet_router_->RemoveReceiveRtpModule(rtp_rtcp_.get()); 204 packet_router_->RemoveReceiveRtpModule(rtp_rtcp_.get());
202 UpdateHistograms(); 205 UpdateHistograms();
203 } 206 }
204 207
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 const int frequency, 305 const int frequency,
303 const size_t channels, 306 const size_t channels,
304 const uint32_t rate) { 307 const uint32_t rate) {
305 RTC_NOTREACHED(); 308 RTC_NOTREACHED();
306 return 0; 309 return 0;
307 } 310 }
308 311
309 // This method handles both regular RTP packets and packets recovered 312 // This method handles both regular RTP packets and packets recovered
310 // via FlexFEC. 313 // via FlexFEC.
311 void RtpVideoStreamReceiver::OnRtpPacket(const RtpPacketReceived& packet) { 314 void RtpVideoStreamReceiver::OnRtpPacket(const RtpPacketReceived& packet) {
315 // TODO(eladalon): https://bugs.chromium.org/p/webrtc/issues/detail?id=8056
316 // RTC_DCHECK_RUN_ON(&worker_thread_checker_);
317
312 { 318 {
313 rtc::CritScope lock(&receive_cs_); 319 rtc::CritScope lock(&receive_cs_);
314 if (!receiving_) { 320 if (!receiving_) {
315 return; 321 return;
316 } 322 }
317 323
318 if (!packet.recovered()) { 324 if (!packet.recovered()) {
319 int64_t now_ms = clock_->TimeInMilliseconds(); 325 int64_t now_ms = clock_->TimeInMilliseconds();
320 326
321 // Periodically log the RTP header of incoming packets. 327 // Periodically log the RTP header of incoming packets.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 ReceivePacket(packet.data(), packet.size(), header, in_order); 361 ReceivePacket(packet.data(), packet.size(), header, in_order);
356 // Update receive statistics after ReceivePacket. 362 // Update receive statistics after ReceivePacket.
357 // Receive statistics will be reset if the payload type changes (make sure 363 // Receive statistics will be reset if the payload type changes (make sure
358 // that the first packet is included in the stats). 364 // that the first packet is included in the stats).
359 if (!packet.recovered()) { 365 if (!packet.recovered()) {
360 // TODO(nisse): We should pass a recovered flag to stats, to aid 366 // TODO(nisse): We should pass a recovered flag to stats, to aid
361 // fixing bug bugs.webrtc.org/6339. 367 // fixing bug bugs.webrtc.org/6339.
362 rtp_receive_statistics_->IncomingPacket( 368 rtp_receive_statistics_->IncomingPacket(
363 header, packet.size(), IsPacketRetransmitted(header, in_order)); 369 header, packet.size(), IsPacketRetransmitted(header, in_order));
364 } 370 }
371
372 for (RtpPacketSinkInterface* secondary_sink : secondary_sinks_) {
373 secondary_sink->OnRtpPacket(packet);
374 }
365 } 375 }
366 376
367 int32_t RtpVideoStreamReceiver::RequestKeyFrame() { 377 int32_t RtpVideoStreamReceiver::RequestKeyFrame() {
368 return rtp_rtcp_->RequestKeyFrame(); 378 return rtp_rtcp_->RequestKeyFrame();
369 } 379 }
370 380
371 bool RtpVideoStreamReceiver::IsUlpfecEnabled() const { 381 bool RtpVideoStreamReceiver::IsUlpfecEnabled() const {
372 return config_.rtp.ulpfec.ulpfec_payload_type != -1; 382 return config_.rtp.ulpfec.ulpfec_payload_type != -1;
373 } 383 }
374 384
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 432
423 rtc::Optional<int64_t> RtpVideoStreamReceiver::LastReceivedPacketMs() const { 433 rtc::Optional<int64_t> RtpVideoStreamReceiver::LastReceivedPacketMs() const {
424 return packet_buffer_->LastReceivedPacketMs(); 434 return packet_buffer_->LastReceivedPacketMs();
425 } 435 }
426 436
427 rtc::Optional<int64_t> RtpVideoStreamReceiver::LastReceivedKeyframePacketMs() 437 rtc::Optional<int64_t> RtpVideoStreamReceiver::LastReceivedKeyframePacketMs()
428 const { 438 const {
429 return packet_buffer_->LastReceivedKeyframePacketMs(); 439 return packet_buffer_->LastReceivedKeyframePacketMs();
430 } 440 }
431 441
442 void RtpVideoStreamReceiver::AddSecondarySink(RtpPacketSinkInterface* sink) {
443 // TODO(eladalon): https://bugs.chromium.org/p/webrtc/issues/detail?id=8056
444 // RTC_DCHECK_RUN_ON(&worker_thread_checker_);
445 RTC_DCHECK(std::find(secondary_sinks_.cbegin(), secondary_sinks_.cend(),
446 sink) == secondary_sinks_.cend());
447 secondary_sinks_.push_back(sink);
448 }
449
450 void RtpVideoStreamReceiver::RemoveSecondarySink(
451 const RtpPacketSinkInterface* sink) {
452 // TODO(eladalon): https://bugs.chromium.org/p/webrtc/issues/detail?id=8056
453 // RTC_DCHECK_RUN_ON(&worker_thread_checker_);
454 auto it = std::find(secondary_sinks_.begin(), secondary_sinks_.end(), sink);
455 if (it == secondary_sinks_.end()) {
456 // We might be rolling-back a call whose setup failed mid-way. In such a
457 // case, it's simpler to remove "everything" rather than remember what
458 // has already been added.
459 LOG(LS_WARNING) << "Removal of unknown sink.";
460 return;
461 }
462 secondary_sinks_.erase(it);
463 }
464
432 void RtpVideoStreamReceiver::ReceivePacket(const uint8_t* packet, 465 void RtpVideoStreamReceiver::ReceivePacket(const uint8_t* packet,
433 size_t packet_length, 466 size_t packet_length,
434 const RTPHeader& header, 467 const RTPHeader& header,
435 bool in_order) { 468 bool in_order) {
436 if (rtp_payload_registry_.IsEncapsulated(header)) { 469 if (rtp_payload_registry_.IsEncapsulated(header)) {
437 ParseAndHandleEncapsulatingHeader(packet, packet_length, header); 470 ParseAndHandleEncapsulatingHeader(packet, packet_length, header);
438 return; 471 return;
439 } 472 }
440 const uint8_t* payload = packet + header.headerLength; 473 const uint8_t* payload = packet + header.headerLength;
441 assert(packet_length >= header.headerLength); 474 assert(packet_length >= header.headerLength);
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 return; 714 return;
682 715
683 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) 716 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str()))
684 return; 717 return;
685 718
686 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), 719 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(),
687 sprop_decoder.pps_nalu()); 720 sprop_decoder.pps_nalu());
688 } 721 }
689 722
690 } // namespace webrtc 723 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/rtp_video_stream_receiver.h ('k') | webrtc/video/rtp_video_stream_receiver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698