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

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

Issue 2490523002: Wire up FlexfecSender in RTPSenderVideo. (Closed)
Patch Set: Feedback response 3. 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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 20 matching lines...) Expand all
31 // clock for the RTP timestamps. (This is according to the RFC, which states 31 // clock for the RTP timestamps. (This is according to the RFC, which states
32 // that it is RECOMMENDED to use the same clock frequency for FlexFEC as for 32 // that it is RECOMMENDED to use the same clock frequency for FlexFEC as for
33 // the protected media stream.) 33 // the protected media stream.)
34 // The constant converts from clock millisecond timestamps to the 90 kHz 34 // The constant converts from clock millisecond timestamps to the 90 kHz
35 // RTP timestamp. 35 // RTP timestamp.
36 const int kMsToRtpTimestamp = kVideoPayloadTypeFrequency / 1000; 36 const int kMsToRtpTimestamp = kVideoPayloadTypeFrequency / 1000;
37 37
38 // How often to log the generated FEC packets to the text log. 38 // How often to log the generated FEC packets to the text log.
39 constexpr int64_t kPacketLogIntervalMs = 10000; 39 constexpr int64_t kPacketLogIntervalMs = 10000;
40 40
41 // Only activate BWE header extensions for FlexFEC.
42 RtpHeaderExtensionMap FilterRtpHeaderExtensions(
43 const std::vector<RtpExtension>& rtp_header_extensions) {
44 RtpHeaderExtensionMap map;
45 for (const auto& extension : rtp_header_extensions) {
46 if (extension.uri == RtpExtension::kTransportSequenceNumberUri) {
47 map.Register(kRtpExtensionTransportSequenceNumber, extension.id);
danilchap 2016/11/10 11:29:23 I would like to remove this version of Register ev
brandtr 2016/11/10 12:00:41 Done.
48 } else if (extension.uri == RtpExtension::kAbsSendTimeUri) {
49 map.Register(kRtpExtensionAbsoluteSendTime, extension.id);
50 } else if (extension.uri == RtpExtension::kTimestampOffsetUri) {
51 map.Register(kRtpExtensionTransmissionTimeOffset, extension.id);
52 } else {
53 LOG(LS_WARNING) << "RTP header extension with id: " << extension.id
54 << ", uri: " << extension.uri
55 << ", is unsupported by FlexfecSender.";
56 }
57 }
58 return map;
59 }
60
41 } // namespace 61 } // namespace
42 62
43 FlexfecSender::FlexfecSender( 63 FlexfecSender::FlexfecSender(
44 int payload_type, 64 int payload_type,
45 uint32_t ssrc, 65 uint32_t ssrc,
46 uint32_t protected_media_ssrc, 66 uint32_t protected_media_ssrc,
47 const std::vector<RtpExtension>& rtp_header_extensions, 67 const std::vector<RtpExtension>& rtp_header_extensions,
48 Clock* clock) 68 Clock* clock)
49 : clock_(clock), 69 : clock_(clock),
50 random_(clock_->TimeInMicroseconds()), 70 random_(clock_->TimeInMicroseconds()),
51 last_generated_packet_ms_(-1), 71 last_generated_packet_ms_(-1),
52 payload_type_(payload_type), 72 payload_type_(payload_type),
53 // Initialize the timestamp offset and RTP sequence numbers randomly. 73 // Initialize the timestamp offset and RTP sequence numbers randomly.
54 // (This is not intended to be cryptographically strong.) 74 // (This is not intended to be cryptographically strong.)
55 timestamp_offset_(random_.Rand<uint32_t>()), 75 timestamp_offset_(random_.Rand<uint32_t>()),
56 ssrc_(ssrc), 76 ssrc_(ssrc),
57 protected_media_ssrc_(protected_media_ssrc), 77 protected_media_ssrc_(protected_media_ssrc),
58 seq_num_(random_.Rand(1, kMaxInitRtpSeqNumber)), 78 seq_num_(random_.Rand(1, kMaxInitRtpSeqNumber)),
59 ulpfec_generator_(ForwardErrorCorrection::CreateFlexfec()), 79 ulpfec_generator_(ForwardErrorCorrection::CreateFlexfec()),
60 rtp_header_extension_map_() { 80 rtp_header_extension_map_(
81 FilterRtpHeaderExtensions(rtp_header_extensions)) {
danilchap 2016/11/10 11:29:23 maybe call this function 'RegisterBweExtensions'
brandtr 2016/11/10 12:00:41 Done.
61 // This object should not have been instantiated if FlexFEC is disabled. 82 // This object should not have been instantiated if FlexFEC is disabled.
62 RTC_DCHECK_GE(payload_type, 0); 83 RTC_DCHECK_GE(payload_type, 0);
63 RTC_DCHECK_LE(payload_type, 127); 84 RTC_DCHECK_LE(payload_type, 127);
64 85
65 // It's OK to create this object on a different thread/task queue than 86 // It's OK to create this object on a different thread/task queue than
66 // the one used during main operation. 87 // the one used during main operation.
67 sequence_checker_.Detach(); 88 sequence_checker_.Detach();
68
69 // Register RTP header extensions for BWE.
70 for (const auto& extension : rtp_header_extensions) {
71 if (extension.uri == RtpExtension::kTransportSequenceNumberUri) {
72 rtp_header_extension_map_.Register(kRtpExtensionTransportSequenceNumber,
73 extension.id);
74 } else if (extension.uri == RtpExtension::kAbsSendTimeUri) {
75 rtp_header_extension_map_.Register(kRtpExtensionAbsoluteSendTime,
76 extension.id);
77 } else if (extension.uri == RtpExtension::kTimestampOffsetUri) {
78 rtp_header_extension_map_.Register(kRtpExtensionTransmissionTimeOffset,
79 extension.id);
80 } else {
81 LOG(LS_WARNING) << "RTP header extension with id: " << extension.id
82 << ", uri: " << extension.uri
83 << ", is unsupported by FlexfecSender.";
84 }
85 }
86 } 89 }
87 90
88 FlexfecSender::~FlexfecSender() = default; 91 FlexfecSender::~FlexfecSender() = default;
89 92
90 // We are reusing the implementation from UlpfecGenerator for SetFecParameters, 93 // We are reusing the implementation from UlpfecGenerator for SetFecParameters,
91 // AddRtpPacketAndGenerateFec, and FecAvailable. 94 // AddRtpPacketAndGenerateFec, and FecAvailable.
92 void FlexfecSender::SetFecParameters(const FecProtectionParams& params) { 95 void FlexfecSender::SetFecParameters(const FecProtectionParams& params) {
93 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_); 96 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
94 ulpfec_generator_.SetFecParameters(params); 97 ulpfec_generator_.SetFecParameters(params);
95 } 98 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 now_ms - last_generated_packet_ms_ > kPacketLogIntervalMs) { 154 now_ms - last_generated_packet_ms_ > kPacketLogIntervalMs) {
152 LOG(LS_INFO) << "Generated " << fec_packets_to_send.size() 155 LOG(LS_INFO) << "Generated " << fec_packets_to_send.size()
153 << " FlexFEC packets with payload type: " << payload_type_ 156 << " FlexFEC packets with payload type: " << payload_type_
154 << " and SSRC: " << ssrc_ << "."; 157 << " and SSRC: " << ssrc_ << ".";
155 last_generated_packet_ms_ = now_ms; 158 last_generated_packet_ms_ = now_ms;
156 } 159 }
157 160
158 return fec_packets_to_send; 161 return fec_packets_to_send;
159 } 162 }
160 163
164 // For FlexFEC, the overhead is the FEC header, as well as the BWE header exts.
danilchap 2016/11/10 11:29:23 may be instead of shortering word remove redundant
brandtr 2016/11/10 12:00:41 Done.
161 size_t FlexfecSender::MaxPacketOverhead() const { 165 size_t FlexfecSender::MaxPacketOverhead() const {
162 return kFlexfecMaxHeaderSize; 166 return kFlexfecMaxHeaderSize +
167 rtp_header_extension_map_.GetTotalLengthInBytes();
danilchap 2016/11/10 11:29:23 really tiny nit: may be sum other way around since
brandtr 2016/11/10 12:00:41 I like that! These things make the code easier to
163 } 168 }
164 169
165 } // namespace webrtc 170 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/include/flexfec_sender.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_sender_video.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698