 Chromium Code Reviews
 Chromium Code Reviews Issue 2867943003:
  New class RtpDemuxer and RtpPacketSinkInterface, use in Call.  (Closed)
    
  
    Issue 2867943003:
  New class RtpDemuxer and RtpPacketSinkInterface, use in Call.  (Closed) 
  | 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 <utility> | |
| 12 | |
| 13 #include "webrtc/base/checks.h" | |
| 14 #include "webrtc/call/rtp_demuxer.h" | |
| 15 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" | |
| 16 | |
| 17 namespace webrtc { | |
| 18 | |
| 19 RtpDemuxer::RtpDemuxer() {} | |
| 20 | |
| 21 RtpDemuxer::~RtpDemuxer() { | |
| 22 RTC_DCHECK(sinks_.empty()); | |
| 23 } | |
| 24 | |
| 25 void RtpDemuxer::AddSink(uint32_t ssrc, RtpPacketSinkInterface* sink) { | |
| 26 sinks_.insert(std::pair<uint32_t, RtpPacketSinkInterface*>(ssrc, sink)); | |
| 
danilchap
2017/05/09 09:20:22
sinks_.emplace(ssrc, sink);
 
nisse-webrtc
2017/05/09 12:11:49
Thanks, that looks better.
 | |
| 27 } | |
| 28 | |
| 29 void RtpDemuxer::RemoveSink(const RtpPacketSinkInterface* sink) { | |
| 30 for (auto it = sinks_.begin(); it != sinks_.end(); ) { | |
| 31 if (it->second == sink) | |
| 32 it = sinks_.erase(it); | |
| 33 else | |
| 34 ++it; | |
| 35 } | |
| 36 } | |
| 37 | |
| 38 bool RtpDemuxer::OnRtpPacket(const RtpPacketReceived& packet) { | |
| 39 bool found = false; | |
| 40 auto it_range = sinks_.equal_range(packet.Ssrc()); | |
| 41 for (auto it = it_range.first; it != it_range.second; ++it) { | |
| 42 found = true; | |
| 43 it->second->OnRtpPacket(packet); | |
| 44 } | |
| 45 return found; | |
| 46 } | |
| 47 | |
| 48 } // namespace webrtc | |
| OLD | NEW |