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 |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 } else { | 268 } else { |
269 uint8_t* data = new uint8_t[packet.sizeBytes]; | 269 uint8_t* data = new uint8_t[packet.sizeBytes]; |
270 memcpy(data, packet.dataPtr, packet.sizeBytes); | 270 memcpy(data, packet.dataPtr, packet.sizeBytes); |
271 packet.dataPtr = data; | 271 packet.dataPtr = data; |
272 } | 272 } |
273 | 273 |
274 packet_buffer_->InsertPacket(&packet); | 274 packet_buffer_->InsertPacket(&packet); |
275 return 0; | 275 return 0; |
276 } | 276 } |
277 | 277 |
278 // TODO(nisse): Try to delete this method. Obstacles: It is used by | |
279 // ParseAndHandleEncapsulatingHeader, for handling Rtx packets. And | |
280 // it's part of the RtpData interface which we implement. | |
278 bool RtpStreamReceiver::OnRecoveredPacket(const uint8_t* rtp_packet, | 281 bool RtpStreamReceiver::OnRecoveredPacket(const uint8_t* rtp_packet, |
279 size_t rtp_packet_length) { | 282 size_t rtp_packet_length) { |
280 RTPHeader header; | 283 RTPHeader header; |
281 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) { | 284 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) { |
282 return false; | 285 return false; |
283 } | 286 } |
284 header.payload_type_frequency = kVideoPayloadTypeFrequency; | 287 header.payload_type_frequency = kVideoPayloadTypeFrequency; |
285 bool in_order = IsPacketInOrder(header); | 288 bool in_order = IsPacketInOrder(header); |
286 return ReceivePacket(rtp_packet, rtp_packet_length, header, in_order); | 289 return ReceivePacket(rtp_packet, rtp_packet_length, header, in_order); |
287 } | 290 } |
288 | 291 |
289 // TODO(pbos): Remove as soon as audio can handle a changing payload type | 292 // TODO(pbos): Remove as soon as audio can handle a changing payload type |
290 // without this callback. | 293 // without this callback. |
291 int32_t RtpStreamReceiver::OnInitializeDecoder( | 294 int32_t RtpStreamReceiver::OnInitializeDecoder( |
292 const int8_t payload_type, | 295 const int8_t payload_type, |
293 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 296 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
294 const int frequency, | 297 const int frequency, |
295 const size_t channels, | 298 const size_t channels, |
296 const uint32_t rate) { | 299 const uint32_t rate) { |
297 RTC_NOTREACHED(); | 300 RTC_NOTREACHED(); |
298 return 0; | 301 return 0; |
299 } | 302 } |
300 | 303 |
301 void RtpStreamReceiver::OnIncomingSSRCChanged(const uint32_t ssrc) { | 304 void RtpStreamReceiver::OnIncomingSSRCChanged(const uint32_t ssrc) { |
302 rtp_rtcp_->SetRemoteSSRC(ssrc); | 305 rtp_rtcp_->SetRemoteSSRC(ssrc); |
303 } | 306 } |
304 | 307 |
308 // This method handles both regular RTP packets and packets recovered | |
309 // via FlexFEC. | |
305 void RtpStreamReceiver::OnRtpPacket(const RtpPacketReceived& packet) { | 310 void RtpStreamReceiver::OnRtpPacket(const RtpPacketReceived& packet) { |
306 { | 311 { |
307 rtc::CritScope lock(&receive_cs_); | 312 rtc::CritScope lock(&receive_cs_); |
308 if (!receiving_) { | 313 if (!receiving_) { |
309 return; | 314 return; |
310 } | 315 } |
311 } | |
312 | 316 |
313 int64_t now_ms = clock_->TimeInMilliseconds(); | 317 if (!packet.recovered()) { |
mflodman
2017/05/11 13:26:29
Why do we only want to log non-recovered packets?
nisse-webrtc
2017/05/11 13:31:55
Only to keep the previous behavior unchanged.
| |
318 int64_t now_ms = clock_->TimeInMilliseconds(); | |
314 | 319 |
315 { | 320 // Periodically log the RTP header of incoming packets. |
316 // Periodically log the RTP header of incoming packets. | 321 if (now_ms - last_packet_log_ms_ > kPacketLogIntervalMs) { |
317 rtc::CritScope lock(&receive_cs_); | 322 std::stringstream ss; |
318 if (now_ms - last_packet_log_ms_ > kPacketLogIntervalMs) { | 323 ss << "Packet received on SSRC: " << packet.Ssrc() |
319 std::stringstream ss; | 324 << " with payload type: " << static_cast<int>(packet.PayloadType()) |
320 ss << "Packet received on SSRC: " << packet.Ssrc() | 325 << ", timestamp: " << packet.Timestamp() |
321 << " with payload type: " << static_cast<int>(packet.PayloadType()) | 326 << ", sequence number: " << packet.SequenceNumber() |
322 << ", timestamp: " << packet.Timestamp() | 327 << ", arrival time: " << packet.arrival_time_ms(); |
323 << ", sequence number: " << packet.SequenceNumber() | 328 int32_t time_offset; |
324 << ", arrival time: " << packet.arrival_time_ms(); | 329 if (packet.GetExtension<TransmissionOffset>(&time_offset)) { |
325 int32_t time_offset; | 330 ss << ", toffset: " << time_offset; |
326 if (packet.GetExtension<TransmissionOffset>(&time_offset)) { | 331 } |
327 ss << ", toffset: " << time_offset; | 332 uint32_t send_time; |
333 if (packet.GetExtension<AbsoluteSendTime>(&send_time)) { | |
334 ss << ", abs send time: " << send_time; | |
335 } | |
336 LOG(LS_INFO) << ss.str(); | |
337 last_packet_log_ms_ = now_ms; | |
328 } | 338 } |
329 uint32_t send_time; | |
330 if (packet.GetExtension<AbsoluteSendTime>(&send_time)) { | |
331 ss << ", abs send time: " << send_time; | |
332 } | |
333 LOG(LS_INFO) << ss.str(); | |
334 last_packet_log_ms_ = now_ms; | |
335 } | 339 } |
336 } | 340 } |
337 | 341 |
338 // TODO(nisse): Delete use of GetHeader, but needs refactoring of | 342 // TODO(nisse): Delete use of GetHeader, but needs refactoring of |
339 // ReceivePacket and IncomingPacket methods below. | 343 // ReceivePacket and IncomingPacket methods below. |
340 RTPHeader header; | 344 RTPHeader header; |
341 packet.GetHeader(&header); | 345 packet.GetHeader(&header); |
342 | 346 |
343 header.payload_type_frequency = kVideoPayloadTypeFrequency; | 347 header.payload_type_frequency = kVideoPayloadTypeFrequency; |
344 | 348 |
345 bool in_order = IsPacketInOrder(header); | 349 bool in_order = IsPacketInOrder(header); |
346 rtp_payload_registry_.SetIncomingPayloadType(header); | 350 if (!packet.recovered()) { |
351 // TODO(nisse): Why isn't this done for recovered packets? | |
352 rtp_payload_registry_.SetIncomingPayloadType(header); | |
353 } | |
347 ReceivePacket(packet.data(), packet.size(), header, in_order); | 354 ReceivePacket(packet.data(), packet.size(), header, in_order); |
348 // Update receive statistics after ReceivePacket. | 355 // Update receive statistics after ReceivePacket. |
349 // Receive statistics will be reset if the payload type changes (make sure | 356 // Receive statistics will be reset if the payload type changes (make sure |
350 // that the first packet is included in the stats). | 357 // that the first packet is included in the stats). |
351 rtp_receive_statistics_->IncomingPacket( | 358 if (!packet.recovered()) { |
352 header, packet.size(), IsPacketRetransmitted(header, in_order)); | 359 // TODO(nisse): We should pass a recovered flag to stats, to aid |
360 // fixing bug bugs.webrtc.org/6339. | |
361 rtp_receive_statistics_->IncomingPacket( | |
362 header, packet.size(), IsPacketRetransmitted(header, in_order)); | |
363 } | |
353 } | 364 } |
354 | 365 |
355 int32_t RtpStreamReceiver::RequestKeyFrame() { | 366 int32_t RtpStreamReceiver::RequestKeyFrame() { |
356 return rtp_rtcp_->RequestKeyFrame(); | 367 return rtp_rtcp_->RequestKeyFrame(); |
357 } | 368 } |
358 | 369 |
359 bool RtpStreamReceiver::IsUlpfecEnabled() const { | 370 bool RtpStreamReceiver::IsUlpfecEnabled() const { |
360 return config_.rtp.ulpfec.ulpfec_payload_type != -1; | 371 return config_.rtp.ulpfec.ulpfec_payload_type != -1; |
361 } | 372 } |
362 | 373 |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
649 return; | 660 return; |
650 | 661 |
651 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) | 662 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) |
652 return; | 663 return; |
653 | 664 |
654 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), | 665 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), |
655 sprop_decoder.pps_nalu()); | 666 sprop_decoder.pps_nalu()); |
656 } | 667 } |
657 | 668 |
658 } // namespace webrtc | 669 } // namespace webrtc |
OLD | NEW |