Reason for revert: About to fix problem and reland. Original issue's description: > Revert of Create RtcpDemuxer (patchset #13 id:240001 of https://codereview.webrtc.org/2943693003/ ) > > Reason for revert: > Breaks Chromium FYI bots. > > The problem is in the BUILD.gn file. > > Sample failure: > https://build.chromium.org/p/chromium.webrtc.fyi/builders/Linux%20Builder/builds/17829 > > Sample logs: > use_goma = true > """ to /b/c/b/Linux_Builder/src/out/Release/args.gn. > > /b/c/b/Linux_Builder/src/buildtools/linux64/gn gen //out/Release --check > -> returned 1 > ERROR at //third_party/webrtc/call/BUILD.gn:46:5: Can't load input file. > "//webrtc/base:rtc_base_approved", > ^-------------------------------- > > Original issue's description: > > Create RtcpDemuxer. Capabilities: > > 1. Demux RTCP messages according to the sender-SSRC. > > 2. Demux RTCP messages according to the RSID (resolved to an SSRC, then compared to the sender-RTCP). > > 3. Allow listening in on all RTCP messages passing through the demuxer ("broadcast sinks"). > > > > BUG=webrtc:7135 > > > > Review-Url: https://codereview.webrtc.org/2943693003 > > Cr-Commit-Position: refs/heads/master@{#18763} > > Committed:cb83bdf01f> > BUG=webrtc:7135 > > Review-Url: https://codereview.webrtc.org/2957763002 > Cr-Commit-Position: refs/heads/master@{#18764} > Committed:0e7e7869e7BUG=webrtc:7135 Review-Url: https://codereview.webrtc.org/2960623002 Cr-Commit-Position: refs/heads/master@{#18768}
99 lines
3.8 KiB
C++
99 lines
3.8 KiB
C++
/*
|
|
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef WEBRTC_CALL_RTP_DEMUXER_H_
|
|
#define WEBRTC_CALL_RTP_DEMUXER_H_
|
|
|
|
#include <map>
|
|
#include <set>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace webrtc {
|
|
|
|
class RsidResolutionObserver;
|
|
class RtpPacketReceived;
|
|
class RtpPacketSinkInterface;
|
|
|
|
// This class represents the RTP demuxing, for a single RTP session (i.e., one
|
|
// ssrc space, see RFC 7656). It isn't thread aware, leaving responsibility of
|
|
// multithreading issues to the user of this class.
|
|
// TODO(nisse): Should be extended to also do MID-based demux and payload-type
|
|
// demux.
|
|
class RtpDemuxer {
|
|
public:
|
|
RtpDemuxer();
|
|
~RtpDemuxer();
|
|
|
|
// Registers a sink. The same sink can be registered for multiple ssrcs, and
|
|
// the same ssrc can have multiple sinks. Null pointer is not allowed.
|
|
void AddSink(uint32_t ssrc, RtpPacketSinkInterface* sink);
|
|
|
|
// Registers a sink's association to an RSID. Null pointer is not allowed.
|
|
void AddSink(const std::string& rsid, RtpPacketSinkInterface* sink);
|
|
|
|
// Removes a sink. Return value reports if anything was actually removed.
|
|
// Null pointer is not allowed.
|
|
bool RemoveSink(const RtpPacketSinkInterface* sink);
|
|
|
|
// Returns true if at least one matching sink was found.
|
|
bool OnRtpPacket(const RtpPacketReceived& packet);
|
|
|
|
// Allows other objects to be notified when RSID-SSRC associations are
|
|
// resolved by this object.
|
|
void RegisterRsidResolutionObserver(RsidResolutionObserver* observer);
|
|
|
|
// Undo a previous RegisterRsidResolutionObserver().
|
|
void DeregisterRsidResolutionObserver(const RsidResolutionObserver* observer);
|
|
|
|
private:
|
|
// Records a sink<->SSRC association. This can happen by explicit
|
|
// configuration by AddSink(ssrc...), or by inferred configuration from an
|
|
// RSID-based configuration which is resolved to an SSRC upon
|
|
// packet reception.
|
|
void RecordSsrcToSinkAssociation(uint32_t ssrc, RtpPacketSinkInterface* sink);
|
|
|
|
// When a new packet arrives, we attempt to resolve extra associations.
|
|
void ResolveAssociations(const RtpPacketReceived& packet);
|
|
|
|
// Find the associations of RSID to SSRCs.
|
|
void ResolveRsidToSsrcAssociations(const RtpPacketReceived& packet);
|
|
|
|
// Notify observers of the resolution of an RSID to an SSRC.
|
|
void NotifyObserversOfRsidResolution(const std::string& rsid, uint32_t ssrc);
|
|
|
|
// This records the association SSRCs to sinks. Other associations, such
|
|
// as by RSID, also end up here once the RSID, etc., is resolved to an SSRC.
|
|
std::multimap<uint32_t, RtpPacketSinkInterface*> sinks_;
|
|
|
|
// A sink may be associated with an RSID - RTP Stream ID. This tag has a
|
|
// one-to-one association with an SSRC, but that SSRC is not yet known.
|
|
// When it becomes known, the association of the sink to the RSID is deleted
|
|
// from this container, and moved into |sinks_|.
|
|
std::multimap<std::string, RtpPacketSinkInterface*> rsid_sinks_;
|
|
|
|
// Iterating over |rsid_sinks_| for each incoming and performing multiple
|
|
// string comparisons is of non-trivial cost. To avoid this cost, we only
|
|
// check RSIDs for the first packet on each incoming SSRC stream.
|
|
// (If RSID associations are added later, we check again.)
|
|
std::set<uint32_t> processed_ssrcs_;
|
|
|
|
// Avoid an attack that would create excessive logging.
|
|
bool logged_max_processed_ssrcs_exceeded_ = false;
|
|
|
|
// Observers which will be notified when an RSID association to an SSRC is
|
|
// resolved by this object.
|
|
std::vector<RsidResolutionObserver*> rsid_resolution_observers_;
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // WEBRTC_CALL_RTP_DEMUXER_H_
|