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

Unified Diff: webrtc/call/rtp_demuxer.cc

Issue 2902823004: Create unit tests for RtpDemuxer (Closed)
Patch Set: . 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
Index: webrtc/call/rtp_demuxer.cc
diff --git a/webrtc/call/rtp_demuxer.cc b/webrtc/call/rtp_demuxer.cc
index aea414e08dfc2a162691a69171be0b7aab909ce3..6ae9642f1d942c90915a701240329a9ebd6f68ce 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 ref_t = typename std::multimap<Key, Value>::const_reference;
danilchap 2017/05/24 17:14:02 name ref_t as a type too
eladalon 2017/05/25 08:00:05 Done.
+ return std::any_of(it_range.first, it_range.second,
+ [val](ref_t 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);
}

Powered by Google App Engine
This is Rietveld 408576698