Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 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 | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #include "webrtc/base/checks.h" | |
| 12 #include "webrtc/call/rtp_demuxer.h" | |
| 13 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" | |
| 14 | |
| 15 namespace webrtc { | |
| 16 | |
| 17 RtpDemuxer::RtpDemuxer() {} | |
| 18 | |
| 19 RtpDemuxer::~RtpDemuxer() { | |
| 20 RTC_DCHECK(sinks_.empty()); | |
| 21 } | |
| 22 | |
| 23 void RtpDemuxer::AddSink(uint32_t ssrc, RtpPacketSinkInterface* sink) { | |
| 24 sinks_.emplace(ssrc, sink); | |
| 25 } | |
| 26 | |
| 27 size_t RtpDemuxer::RemoveSink(const RtpPacketSinkInterface* sink) { | |
| 28 size_t count = 0; | |
| 29 for (auto it = sinks_.begin(); it != sinks_.end(); ) { | |
| 30 if (it->second == sink) { | |
| 31 it = sinks_.erase(it); | |
| 32 count++; | |
|
danilchap
2017/05/09 13:23:41
nit: ++count
https://google.github.io/styleguide/c
nisse-webrtc
2017/05/12 08:50:08
Done.
| |
| 33 } else { | |
| 34 ++it; | |
| 35 } | |
| 36 } | |
| 37 return count; | |
| 38 } | |
| 39 | |
| 40 bool RtpDemuxer::OnRtpPacket(const RtpPacketReceived& packet) { | |
| 41 bool found = false; | |
| 42 auto it_range = sinks_.equal_range(packet.Ssrc()); | |
| 43 for (auto it = it_range.first; it != it_range.second; ++it) { | |
| 44 found = true; | |
| 45 it->second->OnRtpPacket(packet); | |
| 46 } | |
| 47 return found; | |
| 48 } | |
| 49 | |
| 50 } // namespace webrtc | |
| OLD | NEW |