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

Side by Side Diff: webrtc/call/rtx_receive_stream.cc

Issue 2888093002: New class RtxReceiveStream. (Closed)
Patch Set: Address more comments. Created 3 years, 7 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
« no previous file with comments | « webrtc/call/rtx_receive_stream.h ('k') | webrtc/call/rtx_receive_stream_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <utility>
12
13 #include "webrtc/call/rtx_receive_stream.h"
14 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h"
15
16 namespace webrtc {
17
18 RtxReceiveStream::RtxReceiveStream(
19 RtpPacketSinkInterface* media_sink,
20 std::map<int, int> rtx_payload_type_map,
21 uint32_t media_ssrc)
22 : media_sink_(media_sink),
23 rtx_payload_type_map_(std::move(rtx_payload_type_map)),
24 media_ssrc_(media_ssrc) {}
25
26 void RtxReceiveStream::OnRtpPacket(const RtpPacketReceived& rtx_packet) {
27 rtc::ArrayView<const uint8_t> payload = rtx_packet.payload();
28
29 if (payload.size() < kRtxHeaderSize) {
30 return;
31 }
32
33 auto it = rtx_payload_type_map_.find(rtx_packet.PayloadType());
34 if (it == rtx_payload_type_map_.end()) {
35 return;
36 }
37 RtpPacketReceived media_packet;
38 media_packet.CopyHeaderFrom(rtx_packet);
39
40 media_packet.SetSsrc(media_ssrc_);
41 media_packet.SetSequenceNumber((payload[0] << 8) + payload[1]);
42 media_packet.SetPayloadType(it->second);
43
44 // Skip the RTX header.
45 rtc::ArrayView<const uint8_t> rtx_payload =
46 payload.subview(kRtxHeaderSize);
47
48 uint8_t* media_payload = media_packet.AllocatePayload(rtx_payload.size());
49 RTC_DCHECK(media_payload != nullptr);
50
51 memcpy(media_payload, rtx_payload.data(), rtx_payload.size());
52
53 media_sink_->OnRtpPacket(media_packet);
54 }
55
56 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/call/rtx_receive_stream.h ('k') | webrtc/call/rtx_receive_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698