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

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

Issue 2941513002: Log an error in RtpDemuxer::FindSsrcAssociations() if kMaxProcessedSsrcs exceeded (Closed)
Patch Set: Created 3 years, 6 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "webrtc/base/checks.h" 11 #include "webrtc/base/checks.h"
12 #include "webrtc/base/logging.h"
12 #include "webrtc/call/rtp_demuxer.h" 13 #include "webrtc/call/rtp_demuxer.h"
13 #include "webrtc/call/rtp_packet_sink_interface.h" 14 #include "webrtc/call/rtp_packet_sink_interface.h"
14 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" 15 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h"
15 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" 16 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h"
16 17
17 namespace webrtc { 18 namespace webrtc {
18 19
19 namespace { 20 namespace {
20 21
21 constexpr size_t kMaxProcessedSsrcs = 1000; // Prevent memory overuse. 22 constexpr size_t kMaxProcessedSsrcs = 1000; // Prevent memory overuse.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 RtpPacketSinkInterface* sink) { 80 RtpPacketSinkInterface* sink) {
80 RTC_DCHECK(sink); 81 RTC_DCHECK(sink);
81 // The association might already have been set by a different 82 // The association might already have been set by a different
82 // configuration source. 83 // configuration source.
83 if (!MultimapAssociationExists(sinks_, ssrc, sink)) { 84 if (!MultimapAssociationExists(sinks_, ssrc, sink)) {
84 sinks_.emplace(ssrc, sink); 85 sinks_.emplace(ssrc, sink);
85 } 86 }
86 } 87 }
87 88
88 bool RtpDemuxer::OnRtpPacket(const RtpPacketReceived& packet) { 89 bool RtpDemuxer::OnRtpPacket(const RtpPacketReceived& packet) {
89 FindSsrcAssociations(packet); 90 FindSsrcAssociations(packet);
nisse-webrtc 2017/06/13 13:09:26 Unrelated to this cl, but I wonder if it's really
eladalon 2017/06/13 13:19:12 Yes. It could be that sink A is associated with SS
90 auto it_range = sinks_.equal_range(packet.Ssrc()); 91 auto it_range = sinks_.equal_range(packet.Ssrc());
91 for (auto it = it_range.first; it != it_range.second; ++it) { 92 for (auto it = it_range.first; it != it_range.second; ++it) {
92 it->second->OnRtpPacket(packet); 93 it->second->OnRtpPacket(packet);
93 } 94 }
94 return it_range.first != it_range.second; 95 return it_range.first != it_range.second;
95 } 96 }
96 97
97 void RtpDemuxer::FindSsrcAssociations(const RtpPacketReceived& packet) { 98 void RtpDemuxer::FindSsrcAssociations(const RtpPacketReceived& packet) {
98 // Avoid expensive string comparisons for RSID by looking the sinks up only 99 // Avoid expensive string comparisons for RSID by looking the sinks up only
99 // by SSRC whenever possible. 100 // by SSRC whenever possible.
(...skipping 11 matching lines...) Expand all
111 RecordSsrcToSinkAssociation(packet.Ssrc(), it->second); 112 RecordSsrcToSinkAssociation(packet.Ssrc(), it->second);
112 } 113 }
113 114
114 // To prevent memory-overuse attacks, forget this RSID. Future packets 115 // To prevent memory-overuse attacks, forget this RSID. Future packets
115 // with this RSID, but a different SSRC, will not spawn new associations. 116 // with this RSID, but a different SSRC, will not spawn new associations.
116 rsid_sinks_.erase(it_range.first, it_range.second); 117 rsid_sinks_.erase(it_range.first, it_range.second);
117 } 118 }
118 119
119 if (processed_ssrcs_.size() < kMaxProcessedSsrcs) { // Prevent memory overuse 120 if (processed_ssrcs_.size() < kMaxProcessedSsrcs) { // Prevent memory overuse
120 processed_ssrcs_.insert(packet.Ssrc()); // Avoid re-examining in-depth. 121 processed_ssrcs_.insert(packet.Ssrc()); // Avoid re-examining in-depth.
122 } else {
123 LOG(LS_WARNING) << "More than kMaxProcessedSsrcs different SSRCs seen.";
danilchap 2017/06/13 12:59:01 if you have to log it, then likely you want to log
danilchap 2017/06/13 13:00:08 log value of the kMaxProcessedSsrcs: "More than "
121 } 124 }
122 } 125 }
123 126
124 } // namespace webrtc 127 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698