Partial revert: "Use unordered map in RtpDemuxer"

While the savings were positive in Media Servers, there was a regression
in some scenarios (crbug.com/webrtc/12718) so let's revert it.

This partially reverts commit 553fd3220b.

Bug: webrtc:12718
Change-Id: If9252fd996ffc5efd7609eb4c7c0e7f001893676
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/220103
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34117}
This commit is contained in:
Victor Boivie 2021-05-25 13:34:07 +02:00 committed by WebRTC LUCI CQ
parent 238da9a57e
commit fade919bb1

View file

@ -14,12 +14,9 @@
#include <map> #include <map>
#include <set> #include <set>
#include <string> #include <string>
#include <unordered_map>
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "rtc_base/hash.h"
namespace webrtc { namespace webrtc {
class RtpPacketReceived; class RtpPacketReceived;
@ -171,14 +168,12 @@ class RtpDemuxer {
// Note: Mappings are only modified by AddSink/RemoveSink (except for // Note: Mappings are only modified by AddSink/RemoveSink (except for
// SSRC mapping which receives all MID, payload type, or RSID to SSRC bindings // SSRC mapping which receives all MID, payload type, or RSID to SSRC bindings
// discovered when demuxing packets). // discovered when demuxing packets).
std::unordered_map<std::string, RtpPacketSinkInterface*> sink_by_mid_; std::map<std::string, RtpPacketSinkInterface*> sink_by_mid_;
std::unordered_map<uint32_t, RtpPacketSinkInterface*> sink_by_ssrc_; std::map<uint32_t, RtpPacketSinkInterface*> sink_by_ssrc_;
std::unordered_multimap<uint8_t, RtpPacketSinkInterface*> sinks_by_pt_; std::multimap<uint8_t, RtpPacketSinkInterface*> sinks_by_pt_;
std::unordered_map<std::pair<std::string, std::string>, std::map<std::pair<std::string, std::string>, RtpPacketSinkInterface*>
RtpPacketSinkInterface*,
webrtc::PairHash>
sink_by_mid_and_rsid_; sink_by_mid_and_rsid_;
std::unordered_map<std::string, RtpPacketSinkInterface*> sink_by_rsid_; std::map<std::string, RtpPacketSinkInterface*> sink_by_rsid_;
// Tracks all the MIDs that have been identified in added criteria. Used to // Tracks all the MIDs that have been identified in added criteria. Used to
// determine if a packet should be dropped right away because the MID is // determine if a packet should be dropped right away because the MID is
@ -189,8 +184,8 @@ class RtpDemuxer {
// received. // received.
// This is stored separately from the sink mappings because if a sink is // This is stored separately from the sink mappings because if a sink is
// removed we want to still remember these associations. // removed we want to still remember these associations.
std::unordered_map<uint32_t, std::string> mid_by_ssrc_; std::map<uint32_t, std::string> mid_by_ssrc_;
std::unordered_map<uint32_t, std::string> rsid_by_ssrc_; std::map<uint32_t, std::string> rsid_by_ssrc_;
// Adds a binding from the SSRC to the given sink. // Adds a binding from the SSRC to the given sink.
void AddSsrcSinkBinding(uint32_t ssrc, RtpPacketSinkInterface* sink); void AddSsrcSinkBinding(uint32_t ssrc, RtpPacketSinkInterface* sink);