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

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

Issue 1929313002: Removed all RTP dependencies from ViEChannel and renamed class. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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_stream_receiver.h ('k') | webrtc/video/video_receive_stream.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
11 #include "webrtc/video/rtp_stream_receiver.h" 11 #include "webrtc/video/rtp_stream_receiver.h"
12 12
13 #include <vector> 13 #include <vector>
14 14
15 #include "webrtc/base/logging.h" 15 #include "webrtc/base/logging.h"
16 #include "webrtc/common_types.h"
16 #include "webrtc/config.h" 17 #include "webrtc/config.h"
17 #include "webrtc/modules/pacing/packet_router.h" 18 #include "webrtc/modules/pacing/packet_router.h"
18 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat or.h" 19 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat or.h"
19 #include "webrtc/modules/rtp_rtcp/include/fec_receiver.h" 20 #include "webrtc/modules/rtp_rtcp/include/fec_receiver.h"
20 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" 21 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
21 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" 22 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h"
22 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" 23 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
23 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" 24 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
24 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
25 #include "webrtc/modules/video_coding/video_coding_impl.h" 26 #include "webrtc/modules/video_coding/video_coding_impl.h"
26 #include "webrtc/system_wrappers/include/metrics.h" 27 #include "webrtc/system_wrappers/include/metrics.h"
27 #include "webrtc/system_wrappers/include/tick_util.h" 28 #include "webrtc/system_wrappers/include/tick_util.h"
28 #include "webrtc/system_wrappers/include/timestamp_extrapolator.h" 29 #include "webrtc/system_wrappers/include/timestamp_extrapolator.h"
29 #include "webrtc/system_wrappers/include/trace.h" 30 #include "webrtc/system_wrappers/include/trace.h"
31 #include "webrtc/video/receive_statistics_proxy.h"
30 32
31 namespace webrtc { 33 namespace webrtc {
32 34
33 std::unique_ptr<RtpRtcp> CreateRtpRtcpModule( 35 std::unique_ptr<RtpRtcp> CreateRtpRtcpModule(
34 ReceiveStatistics* receive_statistics, 36 ReceiveStatistics* receive_statistics,
35 Transport* outgoing_transport, 37 Transport* outgoing_transport,
36 RtcpRttStats* rtt_stats, 38 RtcpRttStats* rtt_stats,
37 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer, 39 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
38 RemoteBitrateEstimator* remote_bitrate_estimator, 40 RemoteBitrateEstimator* remote_bitrate_estimator,
39 RtpPacketSender* paced_sender, 41 RtpPacketSender* paced_sender,
(...skipping 18 matching lines...) Expand all
58 configuration.transport_feedback_callback = nullptr; 60 configuration.transport_feedback_callback = nullptr;
59 61
60 std::unique_ptr<RtpRtcp> rtp_rtcp(RtpRtcp::CreateRtpRtcp(configuration)); 62 std::unique_ptr<RtpRtcp> rtp_rtcp(RtpRtcp::CreateRtpRtcp(configuration));
61 rtp_rtcp->SetSendingStatus(false); 63 rtp_rtcp->SetSendingStatus(false);
62 rtp_rtcp->SetSendingMediaStatus(false); 64 rtp_rtcp->SetSendingMediaStatus(false);
63 rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound); 65 rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound);
64 66
65 return rtp_rtcp; 67 return rtp_rtcp;
66 } 68 }
67 69
68
69 static const int kPacketLogIntervalMs = 10000; 70 static const int kPacketLogIntervalMs = 10000;
70 71
71 RtpStreamReceiver::RtpStreamReceiver( 72 RtpStreamReceiver::RtpStreamReceiver(
72 vcm::VideoReceiver* video_receiver, 73 vcm::VideoReceiver* video_receiver,
73 RemoteBitrateEstimator* remote_bitrate_estimator, 74 RemoteBitrateEstimator* remote_bitrate_estimator,
74 Transport* transport, 75 Transport* transport,
75 RtcpRttStats* rtt_stats, 76 RtcpRttStats* rtt_stats,
76 PacedSender* paced_sender, 77 PacedSender* paced_sender,
77 PacketRouter* packet_router) 78 PacketRouter* packet_router,
79 const VideoReceiveStream::Config& config,
80 ReceiveStatisticsProxy* receive_stats_proxy)
78 : clock_(Clock::GetRealTimeClock()), 81 : clock_(Clock::GetRealTimeClock()),
79 video_receiver_(video_receiver), 82 video_receiver_(video_receiver),
80 remote_bitrate_estimator_(remote_bitrate_estimator), 83 remote_bitrate_estimator_(remote_bitrate_estimator),
81 packet_router_(packet_router), 84 packet_router_(packet_router),
82 ntp_estimator_(clock_), 85 ntp_estimator_(clock_),
83 rtp_payload_registry_(RTPPayloadStrategy::CreateStrategy(false)), 86 rtp_payload_registry_(RTPPayloadStrategy::CreateStrategy(false)),
84 rtp_header_parser_(RtpHeaderParser::Create()), 87 rtp_header_parser_(RtpHeaderParser::Create()),
85 rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_, 88 rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_,
86 this, 89 this,
87 this, 90 this,
88 &rtp_payload_registry_)), 91 &rtp_payload_registry_)),
89 rtp_receive_statistics_(ReceiveStatistics::Create(clock_)), 92 rtp_receive_statistics_(ReceiveStatistics::Create(clock_)),
90 fec_receiver_(FecReceiver::Create(this)), 93 fec_receiver_(FecReceiver::Create(this)),
91 receiving_(false), 94 receiving_(false),
92 restored_packet_in_use_(false), 95 restored_packet_in_use_(false),
93 last_packet_log_ms_(-1), 96 last_packet_log_ms_(-1),
94 rtp_rtcp_(CreateRtpRtcpModule(rtp_receive_statistics_.get(), 97 rtp_rtcp_(CreateRtpRtcpModule(rtp_receive_statistics_.get(),
95 transport, 98 transport,
96 rtt_stats, 99 rtt_stats,
97 &rtcp_packet_type_counter_observer_, 100 receive_stats_proxy,
98 remote_bitrate_estimator_, 101 remote_bitrate_estimator_,
99 paced_sender, 102 paced_sender,
100 packet_router)) { 103 packet_router)) {
101 packet_router_->AddRtpModule(rtp_rtcp_.get()); 104 packet_router_->AddRtpModule(rtp_rtcp_.get());
105 rtp_receive_statistics_->RegisterRtpStatisticsCallback(receive_stats_proxy);
106 rtp_receive_statistics_->RegisterRtcpStatisticsCallback(receive_stats_proxy);
107
108 RTC_DCHECK(config.rtp.rtcp_mode != RtcpMode::kOff)
109 << "A stream should not be configured with RTCP disabled. This value is "
110 "reserved for internal usage.";
111 rtp_rtcp_->SetRTCPStatus(config.rtp.rtcp_mode);
102 rtp_rtcp_->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp); 112 rtp_rtcp_->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp);
113
114 static const int kMaxPacketAgeToNack = 450;
115 NACKMethod nack_method =
116 config.rtp.nack.rtp_history_ms > 0 ? kNackRtcp : kNackOff;
117 const int max_reordering_threshold = (nack_method == kNackRtcp)
118 ? kMaxPacketAgeToNack : kDefaultMaxReorderingThreshold;
119 rtp_receiver_->SetNACKStatus(nack_method);
120 rtp_receive_statistics_->SetMaxReorderingThreshold(max_reordering_threshold);
103 } 121 }
104 122
105 RtpStreamReceiver::~RtpStreamReceiver() { 123 RtpStreamReceiver::~RtpStreamReceiver() {
106 packet_router_->RemoveRtpModule(rtp_rtcp_.get()); 124 packet_router_->RemoveRtpModule(rtp_rtcp_.get());
107 UpdateHistograms(); 125 UpdateHistograms();
108 } 126 }
109 127
110 void RtpStreamReceiver::UpdateHistograms() { 128 void RtpStreamReceiver::UpdateHistograms() {
111 FecPacketCounter counter = fec_receiver_->GetPacketCounter(); 129 FecPacketCounter counter = fec_receiver_->GetPacketCounter();
112 if (counter.num_packets > 0) { 130 if (counter.num_packets > 0) {
(...skipping 15 matching lines...) Expand all
128 video_codec.plName, kVideoPayloadTypeFrequency, 0, 146 video_codec.plName, kVideoPayloadTypeFrequency, 0,
129 video_codec.maxBitrate, &old_pltype) != -1) { 147 video_codec.maxBitrate, &old_pltype) != -1) {
130 rtp_payload_registry_.DeRegisterReceivePayload(old_pltype); 148 rtp_payload_registry_.DeRegisterReceivePayload(old_pltype);
131 } 149 }
132 150
133 return rtp_receiver_->RegisterReceivePayload( 151 return rtp_receiver_->RegisterReceivePayload(
134 video_codec.plName, video_codec.plType, kVideoPayloadTypeFrequency, 152 video_codec.plName, video_codec.plType, kVideoPayloadTypeFrequency,
135 0, 0) == 0; 153 0, 0) == 0;
136 } 154 }
137 155
138 void RtpStreamReceiver::SetNackStatus(bool enable,
139 int max_nack_reordering_threshold) {
140 if (!enable) {
141 // Reset the threshold back to the lower default threshold when NACK is
142 // disabled since we no longer will be receiving retransmissions.
143 max_nack_reordering_threshold = kDefaultMaxReorderingThreshold;
144 }
145 rtp_receive_statistics_->SetMaxReorderingThreshold(
146 max_nack_reordering_threshold);
147 rtp_receiver_->SetNACKStatus(enable ? kNackRtcp : kNackOff);
148 }
149
150 void RtpStreamReceiver::SetRtxPayloadType(int payload_type, 156 void RtpStreamReceiver::SetRtxPayloadType(int payload_type,
151 int associated_payload_type) { 157 int associated_payload_type) {
152 rtp_payload_registry_.SetRtxPayloadType(payload_type, 158 rtp_payload_registry_.SetRtxPayloadType(payload_type,
153 associated_payload_type); 159 associated_payload_type);
154 } 160 }
155 161
156 void RtpStreamReceiver::SetUseRtxPayloadMappingOnRestore(bool val) { 162 void RtpStreamReceiver::SetUseRtxPayloadMappingOnRestore(bool val) {
157 rtp_payload_registry_.set_use_rtx_payload_mapping_on_restore(val); 163 rtp_payload_registry_.set_use_rtx_payload_mapping_on_restore(val);
158 } 164 }
159 165
(...skipping 21 matching lines...) Expand all
181 return rtp_receiver_.get(); 187 return rtp_receiver_.get();
182 } 188 }
183 189
184 void RtpStreamReceiver::EnableReceiveRtpHeaderExtension( 190 void RtpStreamReceiver::EnableReceiveRtpHeaderExtension(
185 const std::string& extension, int id) { 191 const std::string& extension, int id) {
186 RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension)); 192 RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension));
187 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( 193 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension(
188 StringToRtpExtensionType(extension), id)); 194 StringToRtpExtensionType(extension), id));
189 } 195 }
190 196
191 void RtpStreamReceiver::RegisterRtcpPacketTypeCounterObserver(
192 RtcpPacketTypeCounterObserver* observer) {
193 rtcp_packet_type_counter_observer_.Set(observer);
194 }
195
196
197 int32_t RtpStreamReceiver::OnReceivedPayloadData( 197 int32_t RtpStreamReceiver::OnReceivedPayloadData(
198 const uint8_t* payload_data, 198 const uint8_t* payload_data,
199 const size_t payload_size, 199 const size_t payload_size,
200 const WebRtcRTPHeader* rtp_header) { 200 const WebRtcRTPHeader* rtp_header) {
201 RTC_DCHECK(video_receiver_); 201 RTC_DCHECK(video_receiver_);
202 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header; 202 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header;
203 rtp_header_with_ntp.ntp_time_ms = 203 rtp_header_with_ntp.ntp_time_ms =
204 ntp_estimator_.Estimate(rtp_header->header.timestamp); 204 ntp_estimator_.Estimate(rtp_header->header.timestamp);
205 if (video_receiver_->IncomingPacket(payload_data, payload_size, 205 if (video_receiver_->IncomingPacket(payload_data, payload_size,
206 rtp_header_with_ntp) != 0) { 206 rtp_header_with_ntp) != 0) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 rtp_payload_registry_.SetIncomingPayloadType(header); 287 rtp_payload_registry_.SetIncomingPayloadType(header);
288 bool ret = ReceivePacket(rtp_packet, rtp_packet_length, header, in_order); 288 bool ret = ReceivePacket(rtp_packet, rtp_packet_length, header, in_order);
289 // Update receive statistics after ReceivePacket. 289 // Update receive statistics after ReceivePacket.
290 // Receive statistics will be reset if the payload type changes (make sure 290 // Receive statistics will be reset if the payload type changes (make sure
291 // that the first packet is included in the stats). 291 // that the first packet is included in the stats).
292 rtp_receive_statistics_->IncomingPacket( 292 rtp_receive_statistics_->IncomingPacket(
293 header, rtp_packet_length, IsPacketRetransmitted(header, in_order)); 293 header, rtp_packet_length, IsPacketRetransmitted(header, in_order));
294 return ret; 294 return ret;
295 } 295 }
296 296
297 int32_t RtpStreamReceiver::RequestKeyFrame() {
298 return rtp_rtcp_->RequestKeyFrame();
299 }
300
301 int32_t RtpStreamReceiver::SliceLossIndicationRequest(
302 const uint64_t picture_id) {
303 return rtp_rtcp_->SendRTCPSliceLossIndication(
304 static_cast<uint8_t>(picture_id));
305 }
306
307 int32_t RtpStreamReceiver::ResendPackets(const uint16_t* sequence_numbers,
308 uint16_t length) {
309 return rtp_rtcp_->SendNACK(sequence_numbers, length);
310 }
311
297 bool RtpStreamReceiver::ReceivePacket(const uint8_t* packet, 312 bool RtpStreamReceiver::ReceivePacket(const uint8_t* packet,
298 size_t packet_length, 313 size_t packet_length,
299 const RTPHeader& header, 314 const RTPHeader& header,
300 bool in_order) { 315 bool in_order) {
301 if (rtp_payload_registry_.IsEncapsulated(header)) { 316 if (rtp_payload_registry_.IsEncapsulated(header)) {
302 return ParseAndHandleEncapsulatingHeader(packet, packet_length, header); 317 return ParseAndHandleEncapsulatingHeader(packet, packet_length, header);
303 } 318 }
304 const uint8_t* payload = packet + header.headerLength; 319 const uint8_t* payload = packet + header.headerLength;
305 assert(packet_length >= header.headerLength); 320 assert(packet_length >= header.headerLength);
306 size_t payload_length = packet_length - header.headerLength; 321 size_t payload_length = packet_length - header.headerLength;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 rtp_receive_statistics_->GetStatistician(header.ssrc); 463 rtp_receive_statistics_->GetStatistician(header.ssrc);
449 if (!statistician) 464 if (!statistician)
450 return false; 465 return false;
451 // Check if this is a retransmission. 466 // Check if this is a retransmission.
452 int64_t min_rtt = 0; 467 int64_t min_rtt = 0;
453 rtp_rtcp_->RTT(rtp_receiver_->SSRC(), nullptr, nullptr, &min_rtt, nullptr); 468 rtp_rtcp_->RTT(rtp_receiver_->SSRC(), nullptr, nullptr, &min_rtt, nullptr);
454 return !in_order && 469 return !in_order &&
455 statistician->IsRetransmitOfOldPacket(header, min_rtt); 470 statistician->IsRetransmitOfOldPacket(header, min_rtt);
456 } 471 }
457 } // namespace webrtc 472 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/rtp_stream_receiver.h ('k') | webrtc/video/video_receive_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698