Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1422)

Side by Side Diff: webrtc/call/rtp_rtcp_demuxer_helper.h

Issue 2943693003: Create RtcpDemuxer (Closed)
Patch Set: CR response Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_RTP_RTCP_DEMUXER_HELPER_H_
12 #define WEBRTC_CALL_RTP_RTCP_DEMUXER_HELPER_H_
13
14 #include <algorithm>
15 #include <map>
16 #include <utility>
17
18 #include "webrtc/base/array_view.h"
19 #include "webrtc/base/basictypes.h"
20
21 namespace webrtc {
22
23 template <typename Container,
24 typename Key = typename Container::key_type,
25 typename Value = typename Container::value_type>
26 bool MultimapAssociationExists(const Container& multimap, Key key, Value val) {
27 auto it_range = multimap.equal_range(key);
28 using Reference = typename Container::const_reference;
29 return std::any_of(it_range.first, it_range.second,
30 [val](Reference elem) { return elem.second == val; });
31 }
32
33 template <typename Container, typename Value = typename Container::value_type>
34 size_t RemoveFromMultimapByValue(Container* multimap, const Value value) {
danilchap 2017/06/16 16:46:19 const Value& value or Value value
eladalon 2017/06/19 11:28:47 (const Value&) was intended; thanks for catching.
35 size_t count = 0;
36 for (auto it = multimap->begin(); it != multimap->end();) {
37 if (it->second == value) {
38 it = multimap->erase(it);
39 ++count;
40 } else {
41 ++it;
42 }
43 }
44 return count;
45 }
46
47 template <typename Container, typename Key = typename Container::key_type>
danilchap 2017/06/16 16:46:19 why do you need default value for Key? since both
eladalon 2017/06/19 11:28:47 I was thinking of this as self-documenting code, b
48 bool ContainerHasKey(const Container& c, const Key& k) {
49 return std::find(c.cbegin(), c.cend(), k) != c.cend();
50 }
51
52 template <typename Container,
53 typename Key = typename Container::key_type,
54 typename Value = typename Container::value_type>
55 bool AssociativeContainerHasValue(const Container& c, const Value& v) {
56 auto predicate = [v](const std::pair<Key, Value>& it) {
57 return it.second == v;
58 };
59 return std::any_of(c.cbegin(), c.cend(), predicate);
60 }
61
62 bool ParseSenderSsrc(rtc::ArrayView<const uint8_t> packet,
danilchap 2017/06/16 16:46:19 Ensure function name mention it extract ssrc from
eladalon 2017/06/19 11:28:47 Done.
63 uint32_t* ssrc_sender);
64
65 } // namespace webrtc
66
67 #endif // WEBRTC_CALL_RTP_RTCP_DEMUXER_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698