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

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

Issue 2709723003: Initial implementation of RtpTransportControllerReceive and related interfaces.
Patch Set: Merge remote-tracking branch 'origin/master' into design-RtpTransportReceiveController Created 3 years, 3 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
« no previous file with comments | « webrtc/video/rtp_video_stream_receiver.h ('k') | webrtc/voice_engine/channel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 ProcessThread* process_thread, 91 ProcessThread* process_thread,
92 NackSender* nack_sender, 92 NackSender* nack_sender,
93 KeyFrameRequestSender* keyframe_request_sender, 93 KeyFrameRequestSender* keyframe_request_sender,
94 video_coding::OnCompleteFrameCallback* complete_frame_callback, 94 video_coding::OnCompleteFrameCallback* complete_frame_callback,
95 VCMTiming* timing) 95 VCMTiming* timing)
96 : clock_(Clock::GetRealTimeClock()), 96 : clock_(Clock::GetRealTimeClock()),
97 config_(*config), 97 config_(*config),
98 packet_router_(packet_router), 98 packet_router_(packet_router),
99 process_thread_(process_thread), 99 process_thread_(process_thread),
100 ntp_estimator_(clock_), 100 ntp_estimator_(clock_),
101 rtp_header_parser_(RtpHeaderParser::Create()), 101 rtp_header_extensions_(config_.rtp.extensions),
102 rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_, 102 rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_,
103 this, 103 this,
104 this, 104 this,
105 &rtp_payload_registry_)), 105 &rtp_payload_registry_)),
106 rtp_receive_statistics_(rtp_receive_statistics), 106 rtp_receive_statistics_(rtp_receive_statistics),
107 ulpfec_receiver_(UlpfecReceiver::Create(config->rtp.remote_ssrc, this)), 107 ulpfec_receiver_(UlpfecReceiver::Create(config->rtp.remote_ssrc, this)),
108 receiving_(false), 108 receiving_(false),
109 last_packet_log_ms_(-1), 109 last_packet_log_ms_(-1),
110 rtp_rtcp_(CreateRtpRtcpModule(rtp_receive_statistics_, 110 rtp_rtcp_(CreateRtpRtcpModule(rtp_receive_statistics_,
111 transport, 111 transport,
(...skipping 15 matching lines...) Expand all
127 RTC_DCHECK(config_.rtp.remote_ssrc != 0); 127 RTC_DCHECK(config_.rtp.remote_ssrc != 0);
128 // TODO(pbos): What's an appropriate local_ssrc for receive-only streams? 128 // TODO(pbos): What's an appropriate local_ssrc for receive-only streams?
129 RTC_DCHECK(config_.rtp.local_ssrc != 0); 129 RTC_DCHECK(config_.rtp.local_ssrc != 0);
130 RTC_DCHECK(config_.rtp.remote_ssrc != config_.rtp.local_ssrc); 130 RTC_DCHECK(config_.rtp.remote_ssrc != config_.rtp.local_ssrc);
131 131
132 rtp_rtcp_->SetRTCPStatus(config_.rtp.rtcp_mode); 132 rtp_rtcp_->SetRTCPStatus(config_.rtp.rtcp_mode);
133 rtp_rtcp_->SetSSRC(config_.rtp.local_ssrc); 133 rtp_rtcp_->SetSSRC(config_.rtp.local_ssrc);
134 rtp_rtcp_->SetRemoteSSRC(config_.rtp.remote_ssrc); 134 rtp_rtcp_->SetRemoteSSRC(config_.rtp.remote_ssrc);
135 rtp_rtcp_->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp); 135 rtp_rtcp_->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp);
136 136
137 for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) {
138 EnableReceiveRtpHeaderExtension(config_.rtp.extensions[i].uri,
139 config_.rtp.extensions[i].id);
140 }
141
142 static const int kMaxPacketAgeToNack = 450; 137 static const int kMaxPacketAgeToNack = 450;
143 const int max_reordering_threshold = (config_.rtp.nack.rtp_history_ms > 0) 138 const int max_reordering_threshold = (config_.rtp.nack.rtp_history_ms > 0)
144 ? kMaxPacketAgeToNack 139 ? kMaxPacketAgeToNack
145 : kDefaultMaxReorderingThreshold; 140 : kDefaultMaxReorderingThreshold;
146 rtp_receive_statistics_->SetMaxReorderingThreshold(max_reordering_threshold); 141 rtp_receive_statistics_->SetMaxReorderingThreshold(max_reordering_threshold);
147 142
148 if (config_.rtp.rtx_ssrc) { 143 if (config_.rtp.rtx_ssrc) {
149 // Needed for rtp_payload_registry_.RtxEnabled(). 144 // Needed for rtp_payload_registry_.RtxEnabled().
150 rtp_payload_registry_.SetRtxSsrc(config_.rtp.rtx_ssrc); 145 rtp_payload_registry_.SetRtxSsrc(config_.rtp.rtx_ssrc);
151 } 146 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 269
275 packet_buffer_->InsertPacket(&packet); 270 packet_buffer_->InsertPacket(&packet);
276 return 0; 271 return 0;
277 } 272 }
278 273
279 // TODO(nisse): Try to delete this method. Obstacles: It is used by 274 // TODO(nisse): Try to delete this method. Obstacles: It is used by
280 // ParseAndHandleEncapsulatingHeader, for handling Rtx packets, and 275 // ParseAndHandleEncapsulatingHeader, for handling Rtx packets, and
281 // for callbacks from |ulpfec_receiver_|. 276 // for callbacks from |ulpfec_receiver_|.
282 void RtpVideoStreamReceiver::OnRecoveredPacket(const uint8_t* rtp_packet, 277 void RtpVideoStreamReceiver::OnRecoveredPacket(const uint8_t* rtp_packet,
283 size_t rtp_packet_length) { 278 size_t rtp_packet_length) {
279 RtpPacketReceived packet;
280 if (!packet.Parse(rtp_packet, rtp_packet_length))
281 return;
282 packet.IdentifyExtensions(rtp_header_extensions_);
283 packet.set_payload_type_frequency(kVideoPayloadTypeFrequency);
284
284 RTPHeader header; 285 RTPHeader header;
285 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) { 286 packet.GetHeader(&header);
286 return;
287 }
288 header.payload_type_frequency = kVideoPayloadTypeFrequency;
289 bool in_order = IsPacketInOrder(header); 287 bool in_order = IsPacketInOrder(header);
290 ReceivePacket(rtp_packet, rtp_packet_length, header, in_order); 288 ReceivePacket(rtp_packet, rtp_packet_length, header, in_order);
291 } 289 }
292 290
293 // TODO(pbos): Remove as soon as audio can handle a changing payload type 291 // TODO(pbos): Remove as soon as audio can handle a changing payload type
294 // without this callback. 292 // without this callback.
295 int32_t RtpVideoStreamReceiver::OnInitializeDecoder( 293 int32_t RtpVideoStreamReceiver::OnInitializeDecoder(
296 const int8_t payload_type, 294 const int8_t payload_type,
297 const char payload_name[RTP_PAYLOAD_NAME_SIZE], 295 const char payload_name[RTP_PAYLOAD_NAME_SIZE],
298 const int frequency, 296 const int frequency,
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 "WebRTC.Video.ReceivedFecPacketsInPercent", 640 "WebRTC.Video.ReceivedFecPacketsInPercent",
643 static_cast<int>(counter.num_fec_packets * 100 / counter.num_packets)); 641 static_cast<int>(counter.num_fec_packets * 100 / counter.num_packets));
644 } 642 }
645 if (counter.num_fec_packets > 0) { 643 if (counter.num_fec_packets > 0) {
646 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.RecoveredMediaPacketsInPercentOfFec", 644 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.RecoveredMediaPacketsInPercentOfFec",
647 static_cast<int>(counter.num_recovered_packets * 645 static_cast<int>(counter.num_recovered_packets *
648 100 / counter.num_fec_packets)); 646 100 / counter.num_fec_packets));
649 } 647 }
650 } 648 }
651 649
652 void RtpVideoStreamReceiver::EnableReceiveRtpHeaderExtension(
653 const std::string& extension, int id) {
654 // One-byte-extension local identifiers are in the range 1-14 inclusive.
655 RTC_DCHECK_GE(id, 1);
656 RTC_DCHECK_LE(id, 14);
657 RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension));
658 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension(
659 StringToRtpExtensionType(extension), id));
660 }
661
662 void RtpVideoStreamReceiver::InsertSpsPpsIntoTracker(uint8_t payload_type) { 650 void RtpVideoStreamReceiver::InsertSpsPpsIntoTracker(uint8_t payload_type) {
663 auto codec_params_it = pt_codec_params_.find(payload_type); 651 auto codec_params_it = pt_codec_params_.find(payload_type);
664 if (codec_params_it == pt_codec_params_.end()) 652 if (codec_params_it == pt_codec_params_.end())
665 return; 653 return;
666 654
667 LOG(LS_INFO) << "Found out of band supplied codec parameters for" 655 LOG(LS_INFO) << "Found out of band supplied codec parameters for"
668 << " payload type: " << static_cast<int>(payload_type); 656 << " payload type: " << static_cast<int>(payload_type);
669 657
670 H264SpropParameterSets sprop_decoder; 658 H264SpropParameterSets sprop_decoder;
671 auto sprop_base64_it = 659 auto sprop_base64_it =
672 codec_params_it->second.find(cricket::kH264FmtpSpropParameterSets); 660 codec_params_it->second.find(cricket::kH264FmtpSpropParameterSets);
673 661
674 if (sprop_base64_it == codec_params_it->second.end()) 662 if (sprop_base64_it == codec_params_it->second.end())
675 return; 663 return;
676 664
677 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) 665 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str()))
678 return; 666 return;
679 667
680 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), 668 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(),
681 sprop_decoder.pps_nalu()); 669 sprop_decoder.pps_nalu());
682 } 670 }
683 671
684 } // namespace webrtc 672 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/rtp_video_stream_receiver.h ('k') | webrtc/voice_engine/channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698