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

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

Issue 2681673004: Replace RtpStreamReceiver::DeliverRtp with OnRtpPacket. (Closed)
Patch Set: Created 3 years, 10 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_stream_receiver.h" 11 #include "webrtc/video/rtp_stream_receiver.h"
12 12
13 #include <vector> 13 #include <vector>
14 #include <utility> 14 #include <utility>
15 15
16 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
17 #include "webrtc/base/logging.h" 17 #include "webrtc/base/logging.h"
18 #include "webrtc/common_types.h" 18 #include "webrtc/common_types.h"
19 #include "webrtc/config.h" 19 #include "webrtc/config.h"
20 #include "webrtc/media/base/mediaconstants.h" 20 #include "webrtc/media/base/mediaconstants.h"
21 #include "webrtc/modules/pacing/packet_router.h" 21 #include "webrtc/modules/pacing/packet_router.h"
22 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat or.h" 22 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat or.h"
23 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" 23 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
24 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" 24 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h"
25 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" 25 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
26 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" 26 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
27 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 27 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
28 #include "webrtc/modules/rtp_rtcp/include/ulpfec_receiver.h" 28 #include "webrtc/modules/rtp_rtcp/include/ulpfec_receiver.h"
29 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h"
29 #include "webrtc/modules/video_coding/frame_object.h" 30 #include "webrtc/modules/video_coding/frame_object.h"
30 #include "webrtc/modules/video_coding/h264_sprop_parameter_sets.h" 31 #include "webrtc/modules/video_coding/h264_sprop_parameter_sets.h"
31 #include "webrtc/modules/video_coding/h264_sps_pps_tracker.h" 32 #include "webrtc/modules/video_coding/h264_sps_pps_tracker.h"
32 #include "webrtc/modules/video_coding/packet_buffer.h" 33 #include "webrtc/modules/video_coding/packet_buffer.h"
33 #include "webrtc/modules/video_coding/video_coding_impl.h" 34 #include "webrtc/modules/video_coding/video_coding_impl.h"
34 #include "webrtc/system_wrappers/include/field_trial.h" 35 #include "webrtc/system_wrappers/include/field_trial.h"
35 #include "webrtc/system_wrappers/include/metrics.h" 36 #include "webrtc/system_wrappers/include/metrics.h"
36 #include "webrtc/system_wrappers/include/timestamp_extrapolator.h" 37 #include "webrtc/system_wrappers/include/timestamp_extrapolator.h"
37 #include "webrtc/system_wrappers/include/trace.h" 38 #include "webrtc/system_wrappers/include/trace.h"
38 #include "webrtc/video/receive_statistics_proxy.h" 39 #include "webrtc/video/receive_statistics_proxy.h"
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 const size_t channels, 310 const size_t channels,
310 const uint32_t rate) { 311 const uint32_t rate) {
311 RTC_NOTREACHED(); 312 RTC_NOTREACHED();
312 return 0; 313 return 0;
313 } 314 }
314 315
315 void RtpStreamReceiver::OnIncomingSSRCChanged(const uint32_t ssrc) { 316 void RtpStreamReceiver::OnIncomingSSRCChanged(const uint32_t ssrc) {
316 rtp_rtcp_->SetRemoteSSRC(ssrc); 317 rtp_rtcp_->SetRemoteSSRC(ssrc);
317 } 318 }
318 319
319 bool RtpStreamReceiver::DeliverRtp(const uint8_t* rtp_packet, 320 bool RtpStreamReceiver::OnRtpPacket(const RtpPacketReceived& packet) {
320 size_t rtp_packet_length,
321 const PacketTime& packet_time) {
322 { 321 {
323 rtc::CritScope lock(&receive_cs_); 322 rtc::CritScope lock(&receive_cs_);
324 if (!receiving_) { 323 if (!receiving_) {
325 return false; 324 return false;
326 } 325 }
327 } 326 }
328 327
329 RTPHeader header; 328 RTPHeader header;
330 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, 329 packet.GetHeader(&header);
331 &header)) { 330
332 return false;
333 }
334 int64_t arrival_time_ms;
335 int64_t now_ms = clock_->TimeInMilliseconds(); 331 int64_t now_ms = clock_->TimeInMilliseconds();
336 if (packet_time.timestamp != -1)
337 arrival_time_ms = (packet_time.timestamp + 500) / 1000;
338 else
339 arrival_time_ms = now_ms;
340 332
341 { 333 {
342 // Periodically log the RTP header of incoming packets. 334 // Periodically log the RTP header of incoming packets.
343 rtc::CritScope lock(&receive_cs_); 335 rtc::CritScope lock(&receive_cs_);
344 if (now_ms - last_packet_log_ms_ > kPacketLogIntervalMs) { 336 if (now_ms - last_packet_log_ms_ > kPacketLogIntervalMs) {
345 std::stringstream ss; 337 std::stringstream ss;
346 ss << "Packet received on SSRC: " << header.ssrc << " with payload type: " 338 ss << "Packet received on SSRC: " << header.ssrc << " with payload type: "
brandtr 2017/02/09 14:22:17 Might as well remove the usage of |header| here, t
nisse-webrtc 2017/02/10 10:26:55 Done, except that (i) the ReceivePacket and Incomi
347 << static_cast<int>(header.payloadType) << ", timestamp: " 339 << static_cast<int>(header.payloadType) << ", timestamp: "
348 << header.timestamp << ", sequence number: " << header.sequenceNumber 340 << header.timestamp << ", sequence number: " << header.sequenceNumber
349 << ", arrival time: " << arrival_time_ms; 341 << ", arrival time: " << packet.arrival_time_ms();
350 if (header.extension.hasTransmissionTimeOffset) 342 if (header.extension.hasTransmissionTimeOffset)
351 ss << ", toffset: " << header.extension.transmissionTimeOffset; 343 ss << ", toffset: " << header.extension.transmissionTimeOffset;
352 if (header.extension.hasAbsoluteSendTime) 344 if (header.extension.hasAbsoluteSendTime)
353 ss << ", abs send time: " << header.extension.absoluteSendTime; 345 ss << ", abs send time: " << header.extension.absoluteSendTime;
354 LOG(LS_INFO) << ss.str(); 346 LOG(LS_INFO) << ss.str();
355 last_packet_log_ms_ = now_ms; 347 last_packet_log_ms_ = now_ms;
356 } 348 }
357 } 349 }
358 350
359 header.payload_type_frequency = kVideoPayloadTypeFrequency; 351 header.payload_type_frequency = kVideoPayloadTypeFrequency;
360 352
361 bool in_order = IsPacketInOrder(header); 353 bool in_order = IsPacketInOrder(header);
362 rtp_payload_registry_.SetIncomingPayloadType(header); 354 rtp_payload_registry_.SetIncomingPayloadType(header);
363 bool ret = ReceivePacket(rtp_packet, rtp_packet_length, header, in_order); 355 // TODO(nisse): Is .data() and .size() right? Strip headers or not?
356 bool ret = ReceivePacket(packet.data(), packet.size(), header, in_order);
brandtr 2017/02/09 14:22:17 I believe this is correct. If it were incorrect,
nisse-webrtc 2017/02/10 10:26:55 We'll see what happens to the tests.
364 // Update receive statistics after ReceivePacket. 357 // Update receive statistics after ReceivePacket.
365 // Receive statistics will be reset if the payload type changes (make sure 358 // Receive statistics will be reset if the payload type changes (make sure
366 // that the first packet is included in the stats). 359 // that the first packet is included in the stats).
367 rtp_receive_statistics_->IncomingPacket( 360 rtp_receive_statistics_->IncomingPacket(
368 header, rtp_packet_length, IsPacketRetransmitted(header, in_order)); 361 header, packet.size(), IsPacketRetransmitted(header, in_order));
369 return ret; 362 return ret;
370 } 363 }
371 364
372 int32_t RtpStreamReceiver::RequestKeyFrame() { 365 int32_t RtpStreamReceiver::RequestKeyFrame() {
373 return rtp_rtcp_->RequestKeyFrame(); 366 return rtp_rtcp_->RequestKeyFrame();
374 } 367 }
375 368
376 int32_t RtpStreamReceiver::SliceLossIndicationRequest( 369 int32_t RtpStreamReceiver::SliceLossIndicationRequest(
377 const uint64_t picture_id) { 370 const uint64_t picture_id) {
378 return rtp_rtcp_->SendRTCPSliceLossIndication( 371 return rtp_rtcp_->SendRTCPSliceLossIndication(
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 return; 661 return;
669 662
670 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) 663 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str()))
671 return; 664 return;
672 665
673 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), 666 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(),
674 sprop_decoder.pps_nalu()); 667 sprop_decoder.pps_nalu());
675 } 668 }
676 669
677 } // namespace webrtc 670 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698