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/source/rtp_packet_received.h" | 14 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" |
| 15 #include "webrtc/rtc_base/logging.h" |
15 | 16 |
16 namespace webrtc { | 17 namespace webrtc { |
17 | 18 |
18 RtxReceiveStream::RtxReceiveStream( | 19 RtxReceiveStream::RtxReceiveStream(RtpPacketSinkInterface* media_sink, |
19 RtpPacketSinkInterface* media_sink, | 20 std::map<int, int> associated_payload_types, |
20 std::map<int, int> rtx_payload_type_map, | 21 uint32_t media_ssrc) |
21 uint32_t media_ssrc) | |
22 : media_sink_(media_sink), | 22 : media_sink_(media_sink), |
23 rtx_payload_type_map_(std::move(rtx_payload_type_map)), | 23 associated_payload_types_(std::move(associated_payload_types)), |
24 media_ssrc_(media_ssrc) {} | 24 media_ssrc_(media_ssrc) { |
| 25 if (associated_payload_types_.empty()) { |
| 26 LOG(LS_WARNING) |
| 27 << "RtxReceiveStream created with empty payload type mapping."; |
| 28 } |
| 29 } |
25 | 30 |
26 RtxReceiveStream::~RtxReceiveStream() = default; | 31 RtxReceiveStream::~RtxReceiveStream() = default; |
27 | 32 |
28 void RtxReceiveStream::OnRtpPacket(const RtpPacketReceived& rtx_packet) { | 33 void RtxReceiveStream::OnRtpPacket(const RtpPacketReceived& rtx_packet) { |
29 rtc::ArrayView<const uint8_t> payload = rtx_packet.payload(); | 34 rtc::ArrayView<const uint8_t> payload = rtx_packet.payload(); |
30 | 35 |
31 if (payload.size() < kRtxHeaderSize) { | 36 if (payload.size() < kRtxHeaderSize) { |
32 return; | 37 return; |
33 } | 38 } |
34 | 39 |
35 auto it = rtx_payload_type_map_.find(rtx_packet.PayloadType()); | 40 auto it = associated_payload_types_.find(rtx_packet.PayloadType()); |
36 if (it == rtx_payload_type_map_.end()) { | 41 if (it == associated_payload_types_.end()) { |
| 42 LOG(LS_VERBOSE) << "Unknown payload type " |
| 43 << static_cast<int>(rtx_packet.PayloadType()) |
| 44 << " on rtx ssrc " << rtx_packet.Ssrc(); |
37 return; | 45 return; |
38 } | 46 } |
39 RtpPacketReceived media_packet; | 47 RtpPacketReceived media_packet; |
40 media_packet.CopyHeaderFrom(rtx_packet); | 48 media_packet.CopyHeaderFrom(rtx_packet); |
41 | 49 |
42 media_packet.SetSsrc(media_ssrc_); | 50 media_packet.SetSsrc(media_ssrc_); |
43 media_packet.SetSequenceNumber((payload[0] << 8) + payload[1]); | 51 media_packet.SetSequenceNumber((payload[0] << 8) + payload[1]); |
44 media_packet.SetPayloadType(it->second); | 52 media_packet.SetPayloadType(it->second); |
| 53 media_packet.set_recovered(true); |
45 | 54 |
46 // Skip the RTX header. | 55 // Skip the RTX header. |
47 rtc::ArrayView<const uint8_t> rtx_payload = | 56 rtc::ArrayView<const uint8_t> rtx_payload = |
48 payload.subview(kRtxHeaderSize); | 57 payload.subview(kRtxHeaderSize); |
49 | 58 |
50 uint8_t* media_payload = media_packet.AllocatePayload(rtx_payload.size()); | 59 uint8_t* media_payload = media_packet.AllocatePayload(rtx_payload.size()); |
51 RTC_DCHECK(media_payload != nullptr); | 60 RTC_DCHECK(media_payload != nullptr); |
52 | 61 |
53 memcpy(media_payload, rtx_payload.data(), rtx_payload.size()); | 62 memcpy(media_payload, rtx_payload.data(), rtx_payload.size()); |
54 | 63 |
55 media_sink_->OnRtpPacket(media_packet); | 64 media_sink_->OnRtpPacket(media_packet); |
56 } | 65 } |
57 | 66 |
58 } // namespace webrtc | 67 } // namespace webrtc |
OLD | NEW |