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

Unified Diff: webrtc/call/rtp_demuxer.cc

Issue 2902823004: Create unit tests for RtpDemuxer (Closed)
Patch Set: Might as well remove the flaky death-test. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/call/BUILD.gn ('k') | webrtc/call/rtp_demuxer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/call/rtp_demuxer.cc
diff --git a/webrtc/call/rtp_demuxer.cc b/webrtc/call/rtp_demuxer.cc
index aea414e08dfc2a162691a69171be0b7aab909ce3..d7179c04acc8a1cf48984685bfe0751eac008d42 100644
--- a/webrtc/call/rtp_demuxer.cc
+++ b/webrtc/call/rtp_demuxer.cc
@@ -14,6 +14,20 @@
namespace webrtc {
+namespace {
+
+template <typename Key, typename Value>
+bool MultimapAssociationExists(const std::multimap<Key, Value>& multimap,
+ Key key,
+ Value val) {
+ auto it_range = multimap.equal_range(key);
+ using Reference = typename std::multimap<Key, Value>::const_reference;
+ return std::any_of(it_range.first, it_range.second,
+ [val](Reference elem) { return elem.second == val; });
+}
+
+} // namespace
+
RtpDemuxer::RtpDemuxer() {}
RtpDemuxer::~RtpDemuxer() {
@@ -22,6 +36,7 @@ RtpDemuxer::~RtpDemuxer() {
void RtpDemuxer::AddSink(uint32_t ssrc, RtpPacketSinkInterface* sink) {
RTC_DCHECK(sink);
+ RTC_DCHECK(!MultimapAssociationExists(sinks_, ssrc, sink));
sinks_.emplace(ssrc, sink);
}
« no previous file with comments | « webrtc/call/BUILD.gn ('k') | webrtc/call/rtp_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698