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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/ulpfec_receiver_impl.cc

Issue 2451643002: Rename FecReceiver to UlpfecReceiver. (Closed)
Patch Set: Fix GYP. Created 4 years, 1 month 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
OLDNEW
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/modules/rtp_rtcp/source/fec_receiver_impl.h" 11 #include "webrtc/modules/rtp_rtcp/source/ulpfec_receiver_impl.h"
12 12
13 #include <memory> 13 #include <memory>
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/modules/rtp_rtcp/source/byte_io.h" 18 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
19 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h" 19 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h"
20 20
21 namespace webrtc { 21 namespace webrtc {
22 22
23 FecReceiver* FecReceiver::Create(RtpData* callback) { 23 UlpfecReceiver* UlpfecReceiver::Create(RtpData* callback) {
24 return new FecReceiverImpl(callback); 24 return new UlpfecReceiverImpl(callback);
25 } 25 }
26 26
27 FecReceiverImpl::FecReceiverImpl(RtpData* callback) 27 UlpfecReceiverImpl::UlpfecReceiverImpl(RtpData* callback)
28 : recovered_packet_callback_(callback), 28 : recovered_packet_callback_(callback),
29 fec_(ForwardErrorCorrection::CreateUlpfec()) {} 29 fec_(ForwardErrorCorrection::CreateUlpfec()) {}
30 30
31 FecReceiverImpl::~FecReceiverImpl() { 31 UlpfecReceiverImpl::~UlpfecReceiverImpl() {
32 received_packets_.clear(); 32 received_packets_.clear();
33 fec_->ResetState(&recovered_packets_); 33 fec_->ResetState(&recovered_packets_);
34 } 34 }
35 35
36 FecPacketCounter FecReceiverImpl::GetPacketCounter() const { 36 FecPacketCounter UlpfecReceiverImpl::GetPacketCounter() const {
37 rtc::CritScope cs(&crit_sect_); 37 rtc::CritScope cs(&crit_sect_);
38 return packet_counter_; 38 return packet_counter_;
39 } 39 }
40 40
41 // 0 1 2 3 41 // 0 1 2 3
42 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 42 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
43 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 43 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 // |F| block PT | timestamp offset | block length | 44 // |F| block PT | timestamp offset | block length |
45 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 45 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 // 46 //
(...skipping 12 matching lines...) Expand all
59 // timestamp offset: 14 bits Unsigned offset of timestamp of this block 59 // timestamp offset: 14 bits Unsigned offset of timestamp of this block
60 // relative to timestamp given in RTP header. The use of an unsigned 60 // relative to timestamp given in RTP header. The use of an unsigned
61 // offset implies that redundant data must be sent after the primary 61 // offset implies that redundant data must be sent after the primary
62 // data, and is hence a time to be subtracted from the current 62 // data, and is hence a time to be subtracted from the current
63 // timestamp to determine the timestamp of the data for which this 63 // timestamp to determine the timestamp of the data for which this
64 // block is the redundancy. 64 // block is the redundancy.
65 // 65 //
66 // block length: 10 bits Length in bytes of the corresponding data 66 // block length: 10 bits Length in bytes of the corresponding data
67 // block excluding header. 67 // block excluding header.
68 68
69 int32_t FecReceiverImpl::AddReceivedRedPacket( 69 int32_t UlpfecReceiverImpl::AddReceivedRedPacket(
70 const RTPHeader& header, const uint8_t* incoming_rtp_packet, 70 const RTPHeader& header,
71 size_t packet_length, uint8_t ulpfec_payload_type) { 71 const uint8_t* incoming_rtp_packet,
72 size_t packet_length,
73 uint8_t ulpfec_payload_type) {
72 rtc::CritScope cs(&crit_sect_); 74 rtc::CritScope cs(&crit_sect_);
73 75
74 uint8_t red_header_length = 1; 76 uint8_t red_header_length = 1;
75 size_t payload_data_length = packet_length - header.headerLength; 77 size_t payload_data_length = packet_length - header.headerLength;
76 78
77 if (payload_data_length == 0) { 79 if (payload_data_length == 0) {
78 LOG(LS_WARNING) << "Corrupt/truncated FEC packet."; 80 LOG(LS_WARNING) << "Corrupt/truncated FEC packet.";
79 return -1; 81 return -1;
80 } 82 }
81 83
(...skipping 11 matching lines...) Expand all
93 if (incoming_rtp_packet[header.headerLength] & 0x80) { 95 if (incoming_rtp_packet[header.headerLength] & 0x80) {
94 // f bit set in RED header, i.e. there are more than one RED header blocks. 96 // f bit set in RED header, i.e. there are more than one RED header blocks.
95 red_header_length = 4; 97 red_header_length = 4;
96 if (payload_data_length < red_header_length + 1u) { 98 if (payload_data_length < red_header_length + 1u) {
97 LOG(LS_WARNING) << "Corrupt/truncated FEC packet."; 99 LOG(LS_WARNING) << "Corrupt/truncated FEC packet.";
98 return -1; 100 return -1;
99 } 101 }
100 102
101 uint16_t timestamp_offset = incoming_rtp_packet[header.headerLength + 1] 103 uint16_t timestamp_offset = incoming_rtp_packet[header.headerLength + 1]
102 << 8; 104 << 8;
103 timestamp_offset += 105 timestamp_offset += incoming_rtp_packet[header.headerLength + 2];
104 incoming_rtp_packet[header.headerLength + 2];
105 timestamp_offset = timestamp_offset >> 2; 106 timestamp_offset = timestamp_offset >> 2;
106 if (timestamp_offset != 0) { 107 if (timestamp_offset != 0) {
107 LOG(LS_WARNING) << "Corrupt payload found."; 108 LOG(LS_WARNING) << "Corrupt payload found.";
108 return -1; 109 return -1;
109 } 110 }
110 111
111 block_length = (0x3 & incoming_rtp_packet[header.headerLength + 2]) << 8; 112 block_length = (0x3 & incoming_rtp_packet[header.headerLength + 2]) << 8;
112 block_length += incoming_rtp_packet[header.headerLength + 3]; 113 block_length += incoming_rtp_packet[header.headerLength + 3];
113 114
114 // Check next RED header block. 115 // Check next RED header block.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 return 0; 193 return 0;
193 } 194 }
194 195
195 received_packets_.push_back(std::move(received_packet)); 196 received_packets_.push_back(std::move(received_packet));
196 if (second_received_packet) { 197 if (second_received_packet) {
197 received_packets_.push_back(std::move(second_received_packet)); 198 received_packets_.push_back(std::move(second_received_packet));
198 } 199 }
199 return 0; 200 return 0;
200 } 201 }
201 202
202 int32_t FecReceiverImpl::ProcessReceivedFec() { 203 int32_t UlpfecReceiverImpl::ProcessReceivedFec() {
203 crit_sect_.Enter(); 204 crit_sect_.Enter();
204 if (!received_packets_.empty()) { 205 if (!received_packets_.empty()) {
205 // Send received media packet to VCM. 206 // Send received media packet to VCM.
206 if (!received_packets_.front()->is_fec) { 207 if (!received_packets_.front()->is_fec) {
207 ForwardErrorCorrection::Packet* packet = received_packets_.front()->pkt; 208 ForwardErrorCorrection::Packet* packet = received_packets_.front()->pkt;
208 crit_sect_.Leave(); 209 crit_sect_.Leave();
209 if (!recovered_packet_callback_->OnRecoveredPacket(packet->data, 210 if (!recovered_packet_callback_->OnRecoveredPacket(packet->data,
210 packet->length)) { 211 packet->length)) {
211 return -1; 212 return -1;
212 } 213 }
(...skipping 19 matching lines...) Expand all
232 return -1; 233 return -1;
233 } 234 }
234 crit_sect_.Enter(); 235 crit_sect_.Enter();
235 recovered_packet->returned = true; 236 recovered_packet->returned = true;
236 } 237 }
237 crit_sect_.Leave(); 238 crit_sect_.Leave();
238 return 0; 239 return 0;
239 } 240 }
240 241
241 } // namespace webrtc 242 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/ulpfec_receiver_impl.h ('k') | webrtc/modules/rtp_rtcp/source/ulpfec_receiver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698