| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 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 <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "webrtc/call/rtx_receive_stream.h" | 13 #include "webrtc/call/rtx_receive_stream.h" |
| 14 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" | |
| 15 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" | 14 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" |
| 16 #include "webrtc/rtc_base/logging.h" | 15 #include "webrtc/rtc_base/logging.h" |
| 17 | 16 |
| 18 namespace webrtc { | 17 namespace webrtc { |
| 19 | 18 |
| 20 RtxReceiveStream::RtxReceiveStream( | 19 RtxReceiveStream::RtxReceiveStream(RtpPacketSinkInterface* media_sink, |
| 21 RtpPacketSinkInterface* media_sink, | 20 std::map<int, int> associated_payload_types, |
| 22 std::map<int, int> associated_payload_types, | 21 uint32_t media_ssrc) |
| 23 uint32_t media_ssrc, | |
| 24 ReceiveStatistics* rtp_receive_statistics /* = nullptr */) | |
| 25 : media_sink_(media_sink), | 22 : media_sink_(media_sink), |
| 26 associated_payload_types_(std::move(associated_payload_types)), | 23 associated_payload_types_(std::move(associated_payload_types)), |
| 27 media_ssrc_(media_ssrc), | 24 media_ssrc_(media_ssrc) { |
| 28 rtp_receive_statistics_(rtp_receive_statistics) { | |
| 29 if (associated_payload_types_.empty()) { | 25 if (associated_payload_types_.empty()) { |
| 30 LOG(LS_WARNING) | 26 LOG(LS_WARNING) |
| 31 << "RtxReceiveStream created with empty payload type mapping."; | 27 << "RtxReceiveStream created with empty payload type mapping."; |
| 32 } | 28 } |
| 33 } | 29 } |
| 34 | 30 |
| 35 RtxReceiveStream::~RtxReceiveStream() = default; | 31 RtxReceiveStream::~RtxReceiveStream() = default; |
| 36 | 32 |
| 37 void RtxReceiveStream::OnRtpPacket(const RtpPacketReceived& rtx_packet) { | 33 void RtxReceiveStream::OnRtpPacket(const RtpPacketReceived& rtx_packet) { |
| 38 if (rtp_receive_statistics_) { | |
| 39 RTPHeader header; | |
| 40 rtx_packet.GetHeader(&header); | |
| 41 rtp_receive_statistics_->IncomingPacket(header, rtx_packet.size(), | |
| 42 false /* retransmitted */); | |
| 43 } | |
| 44 rtc::ArrayView<const uint8_t> payload = rtx_packet.payload(); | 34 rtc::ArrayView<const uint8_t> payload = rtx_packet.payload(); |
| 45 | 35 |
| 46 if (payload.size() < kRtxHeaderSize) { | 36 if (payload.size() < kRtxHeaderSize) { |
| 47 return; | 37 return; |
| 48 } | 38 } |
| 49 | 39 |
| 50 auto it = associated_payload_types_.find(rtx_packet.PayloadType()); | 40 auto it = associated_payload_types_.find(rtx_packet.PayloadType()); |
| 51 if (it == associated_payload_types_.end()) { | 41 if (it == associated_payload_types_.end()) { |
| 52 LOG(LS_VERBOSE) << "Unknown payload type " | 42 LOG(LS_VERBOSE) << "Unknown payload type " |
| 53 << static_cast<int>(rtx_packet.PayloadType()) | 43 << static_cast<int>(rtx_packet.PayloadType()) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 68 | 58 |
| 69 uint8_t* media_payload = media_packet.AllocatePayload(rtx_payload.size()); | 59 uint8_t* media_payload = media_packet.AllocatePayload(rtx_payload.size()); |
| 70 RTC_DCHECK(media_payload != nullptr); | 60 RTC_DCHECK(media_payload != nullptr); |
| 71 | 61 |
| 72 memcpy(media_payload, rtx_payload.data(), rtx_payload.size()); | 62 memcpy(media_payload, rtx_payload.data(), rtx_payload.size()); |
| 73 | 63 |
| 74 media_sink_->OnRtpPacket(media_packet); | 64 media_sink_->OnRtpPacket(media_packet); |
| 75 } | 65 } |
| 76 | 66 |
| 77 } // namespace webrtc | 67 } // namespace webrtc |
| OLD | NEW |