Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_header_extensions.h" | |
| 30 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" | |
| 29 #include "webrtc/modules/video_coding/frame_object.h" | 31 #include "webrtc/modules/video_coding/frame_object.h" |
| 30 #include "webrtc/modules/video_coding/h264_sprop_parameter_sets.h" | 32 #include "webrtc/modules/video_coding/h264_sprop_parameter_sets.h" |
| 31 #include "webrtc/modules/video_coding/h264_sps_pps_tracker.h" | 33 #include "webrtc/modules/video_coding/h264_sps_pps_tracker.h" |
| 32 #include "webrtc/modules/video_coding/packet_buffer.h" | 34 #include "webrtc/modules/video_coding/packet_buffer.h" |
| 33 #include "webrtc/modules/video_coding/video_coding_impl.h" | 35 #include "webrtc/modules/video_coding/video_coding_impl.h" |
| 34 #include "webrtc/system_wrappers/include/field_trial.h" | 36 #include "webrtc/system_wrappers/include/field_trial.h" |
| 35 #include "webrtc/system_wrappers/include/metrics.h" | 37 #include "webrtc/system_wrappers/include/metrics.h" |
| 36 #include "webrtc/system_wrappers/include/timestamp_extrapolator.h" | 38 #include "webrtc/system_wrappers/include/timestamp_extrapolator.h" |
| 37 #include "webrtc/system_wrappers/include/trace.h" | 39 #include "webrtc/system_wrappers/include/trace.h" |
| 38 #include "webrtc/video/receive_statistics_proxy.h" | 40 #include "webrtc/video/receive_statistics_proxy.h" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 const size_t channels, | 311 const size_t channels, |
| 310 const uint32_t rate) { | 312 const uint32_t rate) { |
| 311 RTC_NOTREACHED(); | 313 RTC_NOTREACHED(); |
| 312 return 0; | 314 return 0; |
| 313 } | 315 } |
| 314 | 316 |
| 315 void RtpStreamReceiver::OnIncomingSSRCChanged(const uint32_t ssrc) { | 317 void RtpStreamReceiver::OnIncomingSSRCChanged(const uint32_t ssrc) { |
| 316 rtp_rtcp_->SetRemoteSSRC(ssrc); | 318 rtp_rtcp_->SetRemoteSSRC(ssrc); |
| 317 } | 319 } |
| 318 | 320 |
| 319 bool RtpStreamReceiver::DeliverRtp(const uint8_t* rtp_packet, | 321 bool RtpStreamReceiver::OnRtpPacket(const RtpPacketReceived& packet) { |
| 320 size_t rtp_packet_length, | |
| 321 const PacketTime& packet_time) { | |
| 322 { | 322 { |
| 323 rtc::CritScope lock(&receive_cs_); | 323 rtc::CritScope lock(&receive_cs_); |
| 324 if (!receiving_) { | 324 if (!receiving_) { |
| 325 return false; | 325 return false; |
| 326 } | 326 } |
| 327 } | 327 } |
| 328 | 328 |
| 329 RTPHeader header; | |
| 330 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, | |
| 331 &header)) { | |
| 332 return false; | |
| 333 } | |
| 334 int64_t arrival_time_ms; | |
| 335 int64_t now_ms = clock_->TimeInMilliseconds(); | 329 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 | 330 |
| 341 { | 331 { |
| 342 // Periodically log the RTP header of incoming packets. | 332 // Periodically log the RTP header of incoming packets. |
| 343 rtc::CritScope lock(&receive_cs_); | 333 rtc::CritScope lock(&receive_cs_); |
| 344 if (now_ms - last_packet_log_ms_ > kPacketLogIntervalMs) { | 334 if (now_ms - last_packet_log_ms_ > kPacketLogIntervalMs) { |
| 345 std::stringstream ss; | 335 std::stringstream ss; |
| 346 ss << "Packet received on SSRC: " << header.ssrc << " with payload type: " | 336 ss << "Packet received on SSRC: " << packet.Ssrc() |
| 347 << static_cast<int>(header.payloadType) << ", timestamp: " | 337 << " with payload type: " << static_cast<int>(packet.PayloadType()) |
| 348 << header.timestamp << ", sequence number: " << header.sequenceNumber | 338 << ", timestamp: " << packet.Timestamp() |
| 349 << ", arrival time: " << arrival_time_ms; | 339 << ", sequence number: " << packet.SequenceNumber() |
| 350 if (header.extension.hasTransmissionTimeOffset) | 340 << ", arrival time: " << packet.arrival_time_ms(); |
| 351 ss << ", toffset: " << header.extension.transmissionTimeOffset; | 341 if (packet.HasExtension<TransmissionOffset>()) { |
| 352 if (header.extension.hasAbsoluteSendTime) | 342 int32_t time_offset; |
| 353 ss << ", abs send time: " << header.extension.absoluteSendTime; | 343 packet.GetExtension<TransmissionOffset>(&time_offset); |
|
brandtr
2017/02/10 11:43:00
I believe you could simplify this:
int32_t time_o
nisse-webrtc
2017/02/10 11:56:27
Done.
| |
| 344 ss << ", toffset: " << time_offset; | |
| 345 } | |
| 346 if (packet.HasExtension<AbsoluteSendTime>()) { | |
| 347 uint32_t send_time; | |
|
brandtr
2017/02/10 11:43:00
same here.
nisse-webrtc
2017/02/10 11:56:27
Done.
| |
| 348 packet.GetExtension<AbsoluteSendTime>(&send_time); | |
| 349 ss << ", abs send time: " << send_time; | |
| 350 } | |
| 354 LOG(LS_INFO) << ss.str(); | 351 LOG(LS_INFO) << ss.str(); |
| 355 last_packet_log_ms_ = now_ms; | 352 last_packet_log_ms_ = now_ms; |
| 356 } | 353 } |
| 357 } | 354 } |
| 358 | 355 |
| 356 // TODO(nisse): Delete use of GetHeader, but needs refactoring of | |
| 357 // ReceivePacket and IncomingPacket methods below. | |
| 358 RTPHeader header; | |
| 359 packet.GetHeader(&header); | |
| 360 | |
| 359 header.payload_type_frequency = kVideoPayloadTypeFrequency; | 361 header.payload_type_frequency = kVideoPayloadTypeFrequency; |
| 360 | 362 |
| 361 bool in_order = IsPacketInOrder(header); | 363 bool in_order = IsPacketInOrder(header); |
| 362 rtp_payload_registry_.SetIncomingPayloadType(header); | 364 rtp_payload_registry_.SetIncomingPayloadType(header); |
| 363 bool ret = ReceivePacket(rtp_packet, rtp_packet_length, header, in_order); | 365 bool ret = ReceivePacket(packet.data(), packet.size(), header, in_order); |
| 364 // Update receive statistics after ReceivePacket. | 366 // Update receive statistics after ReceivePacket. |
| 365 // Receive statistics will be reset if the payload type changes (make sure | 367 // Receive statistics will be reset if the payload type changes (make sure |
| 366 // that the first packet is included in the stats). | 368 // that the first packet is included in the stats). |
| 367 rtp_receive_statistics_->IncomingPacket( | 369 rtp_receive_statistics_->IncomingPacket( |
| 368 header, rtp_packet_length, IsPacketRetransmitted(header, in_order)); | 370 header, packet.size(), IsPacketRetransmitted(header, in_order)); |
| 369 return ret; | 371 return ret; |
| 370 } | 372 } |
| 371 | 373 |
| 372 int32_t RtpStreamReceiver::RequestKeyFrame() { | 374 int32_t RtpStreamReceiver::RequestKeyFrame() { |
| 373 return rtp_rtcp_->RequestKeyFrame(); | 375 return rtp_rtcp_->RequestKeyFrame(); |
| 374 } | 376 } |
| 375 | 377 |
| 376 int32_t RtpStreamReceiver::SliceLossIndicationRequest( | 378 int32_t RtpStreamReceiver::SliceLossIndicationRequest( |
| 377 const uint64_t picture_id) { | 379 const uint64_t picture_id) { |
| 378 return rtp_rtcp_->SendRTCPSliceLossIndication( | 380 return rtp_rtcp_->SendRTCPSliceLossIndication( |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 668 return; | 670 return; |
| 669 | 671 |
| 670 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) | 672 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) |
| 671 return; | 673 return; |
| 672 | 674 |
| 673 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), | 675 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), |
| 674 sprop_decoder.pps_nalu()); | 676 sprop_decoder.pps_nalu()); |
| 675 } | 677 } |
| 676 | 678 |
| 677 } // namespace webrtc | 679 } // namespace webrtc |
| OLD | NEW |