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 RTC_DCHECK(sink); |
| 25 sinks_.emplace(ssrc, sink); |
| 26 } |
| 27 |
| 28 size_t RtpDemuxer::RemoveSink(const RtpPacketSinkInterface* sink) { |
| 29 RTC_DCHECK(sink); |
| 30 size_t count = 0; |
| 31 for (auto it = sinks_.begin(); it != sinks_.end(); ) { |
| 32 if (it->second == sink) { |
| 33 it = sinks_.erase(it); |
| 34 ++count; |
| 35 } else { |
| 36 ++it; |
| 37 } |
| 38 } |
| 39 return count; |
| 40 } |
| 41 |
| 42 bool RtpDemuxer::OnRtpPacket(const RtpPacketReceived& packet) { |
| 43 bool found = false; |
| 44 auto it_range = sinks_.equal_range(packet.Ssrc()); |
| 45 for (auto it = it_range.first; it != it_range.second; ++it) { |
| 46 found = true; |
| 47 it->second->OnRtpPacket(packet); |
| 48 } |
| 49 return found; |
| 50 } |
| 51 |
| 52 } // namespace webrtc |
OLD | NEW |