Chromium Code Reviews| Index: webrtc/call/rtp_rtcp_demuxer_helper.h |
| diff --git a/webrtc/call/rtp_rtcp_demuxer_helper.h b/webrtc/call/rtp_rtcp_demuxer_helper.h |
| index 19bd60324445477e843f923f25d8d3dbe756efc2..d674f96c3f02030d392f33e152f3d377d12ddb59 100644 |
| --- a/webrtc/call/rtp_rtcp_demuxer_helper.h |
| +++ b/webrtc/call/rtp_rtcp_demuxer_helper.h |
| @@ -31,6 +31,7 @@ bool MultimapAssociationExists(const Container& multimap, |
| [val](Reference elem) { return elem.second == val; }); |
| } |
| +// TODO(eladalon): Remove this in the next CL. |
| template <typename Container, typename Value> |
| size_t RemoveFromMultimapByValue(Container* multimap, const Value& value) { |
| size_t count = 0; |
| @@ -45,11 +46,26 @@ size_t RemoveFromMultimapByValue(Container* multimap, const Value& value) { |
| return count; |
| } |
| +template <typename Map, typename Value> |
| +size_t RemoveFromMapByValue(Map* map, const Value& value) { |
| + size_t count = 0; |
| + for (auto it = map->begin(); it != map->end();) { |
| + if (it->second == value) { |
| + it = map->erase(it); |
| + ++count; |
| + } else { |
| + ++it; |
| + } |
| + } |
| + return count; |
| +} |
| + |
| template <typename Container, typename Key> |
| bool ContainerHasKey(const Container& c, const Key& k) { |
| return std::find(c.cbegin(), c.cend(), k) != c.cend(); |
| } |
| +// TODO(eladalon): Remove this in the next CL. |
|
danilchap
2017/06/30 16:45:31
Why next CL? do you mean 'Remove when unused'?
or
eladalon
2017/07/03 08:23:35
The next CL will do something similar for RtcpDemu
danilchap
2017/07/26 11:25:46
Acknowledged.
|
| template <typename Container> |
| bool MultimapHasValue(const Container& c, |
| const typename Container::mapped_type& v) { |
| @@ -59,6 +75,14 @@ bool MultimapHasValue(const Container& c, |
| return std::any_of(c.cbegin(), c.cend(), predicate); |
| } |
| +template <typename Map> |
| +bool MapHasValue(const Map& map, const typename Map::mapped_type& value) { |
| + auto predicate = [value](const typename Map::value_type& it) { |
| + return it.second == value; |
| + }; |
| + return std::any_of(map.cbegin(), map.cend(), predicate); |
| +} |
| + |
| rtc::Optional<uint32_t> ParseRtcpPacketSenderSsrc( |
| rtc::ArrayView<const uint8_t> packet); |