| 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 #ifndef WEBRTC_CALL_RTCP_DEMUXER_H_ | |
| 12 #define WEBRTC_CALL_RTCP_DEMUXER_H_ | |
| 13 | |
| 14 #include <map> | |
| 15 #include <string> | |
| 16 #include <vector> | |
| 17 | |
| 18 #include "webrtc/base/array_view.h" | |
| 19 #include "webrtc/base/basictypes.h" | |
| 20 #include "webrtc/call/rsid_resolution_observer.h" | |
| 21 | |
| 22 namespace webrtc { | |
| 23 | |
| 24 class RtcpPacketSinkInterface; | |
| 25 | |
| 26 // This class represents the RTCP demuxing, for a single RTP session (i.e., one | |
| 27 // SSRC space, see RFC 7656). It isn't thread aware, leaving responsibility of | |
| 28 // multithreading issues to the user of this class. | |
| 29 class RtcpDemuxer : public RsidResolutionObserver { | |
| 30 public: | |
| 31 RtcpDemuxer(); | |
| 32 ~RtcpDemuxer() override; | |
| 33 | |
| 34 // Registers a sink. The sink will be notified of incoming RTCP packets with | |
| 35 // that sender-SSRC. The same sink can be registered for multiple SSRCs, and | |
| 36 // the same SSRC can have multiple sinks. Null pointer is not allowed. | |
| 37 // Sinks may be associated with both an SSRC and an RSID. | |
| 38 // Sinks may be registered as SSRC/RSID-specific or broadcast, but not both. | |
| 39 void AddSink(uint32_t sender_ssrc, RtcpPacketSinkInterface* sink); | |
| 40 | |
| 41 // Registers a sink. Once the RSID is resolved to an SSRC, the sink will be | |
| 42 // notified of all RTCP packets with that sender-SSRC. | |
| 43 // The same sink can be registered for multiple RSIDs, and | |
| 44 // the same RSID can have multiple sinks. Null pointer is not allowed. | |
| 45 // Sinks may be associated with both an SSRC and an RSID. | |
| 46 // Sinks may be registered as SSRC/RSID-specific or broadcast, but not both. | |
| 47 void AddSink(const std::string& rsid, RtcpPacketSinkInterface* sink); | |
| 48 | |
| 49 // Registers a sink. The sink will be notified of any incoming RTCP packet. | |
| 50 // Null pointer is not allowed. | |
| 51 // Sinks may be registered as SSRC/RSID-specific or broadcast, but not both. | |
| 52 void AddBroadcastSink(RtcpPacketSinkInterface* sink); | |
| 53 | |
| 54 // Undo previous AddSink() calls with the given sink. | |
| 55 void RemoveSink(const RtcpPacketSinkInterface* sink); | |
| 56 | |
| 57 // Undo AddBroadcastSink(). | |
| 58 void RemoveBroadcastSink(const RtcpPacketSinkInterface* sink); | |
| 59 | |
| 60 // Process a new RTCP packet and forward it to the appropriate sinks. | |
| 61 void OnRtcpPacket(rtc::ArrayView<const uint8_t> packet); | |
| 62 | |
| 63 // Implement RsidResolutionObserver - become notified whenever RSIDs resolve | |
| 64 // to an SSRC. | |
| 65 void OnRsidResolved(const std::string& rsid, uint32_t ssrc) override; | |
| 66 | |
| 67 // TODO(eladalon): Add the ability to resolve RSIDs and inform observers, | |
| 68 // like in the RtpDemuxer case, once the relevant standard is finalized. | |
| 69 | |
| 70 private: | |
| 71 // Records the association SSRCs to sinks. | |
| 72 std::multimap<uint32_t, RtcpPacketSinkInterface*> ssrc_sinks_; | |
| 73 | |
| 74 // Records the association RSIDs to sinks. | |
| 75 std::multimap<std::string, RtcpPacketSinkInterface*> rsid_sinks_; | |
| 76 | |
| 77 // Sinks which will receive notifications of all incoming RTCP packets. | |
| 78 // Additional/removal of sinks is expected to be significantly less frequent | |
| 79 // than RTCP message reception; container chosen for iteration performance. | |
| 80 std::vector<RtcpPacketSinkInterface*> broadcast_sinks_; | |
| 81 }; | |
| 82 | |
| 83 } // namespace webrtc | |
| 84 | |
| 85 #endif // WEBRTC_CALL_RTCP_DEMUXER_H_ | |
| OLD | NEW |