OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_CALL_RTP_DEMUXER_H_ | 11 #ifndef WEBRTC_CALL_RTP_DEMUXER_H_ |
12 #define WEBRTC_CALL_RTP_DEMUXER_H_ | 12 #define WEBRTC_CALL_RTP_DEMUXER_H_ |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <set> | |
16 #include <string> | 15 #include <string> |
17 #include <vector> | 16 #include <vector> |
18 | 17 |
19 namespace webrtc { | 18 namespace webrtc { |
20 | 19 |
21 class RsidResolutionObserver; | 20 class RsidResolutionObserver; |
22 class RtpPacketReceived; | 21 class RtpPacketReceived; |
23 class RtpPacketSinkInterface; | 22 class RtpPacketSinkInterface; |
24 | 23 |
25 // This class represents the RTP demuxing, for a single RTP session (i.e., one | 24 // This class represents the RTP demuxing, for a single RTP session (i.e., one |
(...skipping 27 matching lines...) Expand all Loading... |
53 // Undo a previous RegisterRsidResolutionObserver(). | 52 // Undo a previous RegisterRsidResolutionObserver(). |
54 void DeregisterRsidResolutionObserver(const RsidResolutionObserver* observer); | 53 void DeregisterRsidResolutionObserver(const RsidResolutionObserver* observer); |
55 | 54 |
56 private: | 55 private: |
57 // Records a sink<->SSRC association. This can happen by explicit | 56 // Records a sink<->SSRC association. This can happen by explicit |
58 // configuration by AddSink(ssrc...), or by inferred configuration from an | 57 // configuration by AddSink(ssrc...), or by inferred configuration from an |
59 // RSID-based configuration which is resolved to an SSRC upon | 58 // RSID-based configuration which is resolved to an SSRC upon |
60 // packet reception. | 59 // packet reception. |
61 void RecordSsrcToSinkAssociation(uint32_t ssrc, RtpPacketSinkInterface* sink); | 60 void RecordSsrcToSinkAssociation(uint32_t ssrc, RtpPacketSinkInterface* sink); |
62 | 61 |
63 // When a new packet arrives, we attempt to resolve extra associations. | |
64 void ResolveAssociations(const RtpPacketReceived& packet); | |
65 | |
66 // Find the associations of RSID to SSRCs. | 62 // Find the associations of RSID to SSRCs. |
67 void ResolveRsidToSsrcAssociations(const RtpPacketReceived& packet); | 63 void ResolveRsidToSsrcAssociations(const RtpPacketReceived& packet); |
68 | 64 |
69 // Notify observers of the resolution of an RSID to an SSRC. | 65 // Notify observers of the resolution of an RSID to an SSRC. |
70 void NotifyObserversOfRsidResolution(const std::string& rsid, uint32_t ssrc); | 66 void NotifyObserversOfRsidResolution(const std::string& rsid, uint32_t ssrc); |
71 | 67 |
72 // This records the association SSRCs to sinks. Other associations, such | 68 // This records the association SSRCs to sinks. Other associations, such |
73 // as by RSID, also end up here once the RSID, etc., is resolved to an SSRC. | 69 // as by RSID, also end up here once the RSID, etc., is resolved to an SSRC. |
74 std::multimap<uint32_t, RtpPacketSinkInterface*> ssrc_sinks_; | 70 std::multimap<uint32_t, RtpPacketSinkInterface*> ssrc_sinks_; |
75 | 71 |
76 // A sink may be associated with an RSID - RTP Stream ID. This tag has a | 72 // A sink may be associated with an RSID - RTP Stream ID. This tag has a |
77 // one-to-one association with an SSRC, but that SSRC is not yet known. | 73 // one-to-one association with an SSRC, but that SSRC is not yet known. |
78 // When it becomes known, the association of the sink to the RSID is deleted | 74 // When it becomes known, the association of the sink to the RSID is deleted |
79 // from this container, and moved into |ssrc_sinks_|. | 75 // from this container, and moved into |ssrc_sinks_|. |
80 std::multimap<std::string, RtpPacketSinkInterface*> rsid_sinks_; | 76 std::multimap<std::string, RtpPacketSinkInterface*> rsid_sinks_; |
81 | 77 |
82 // Iterating over |rsid_sinks_| for each incoming and performing multiple | |
83 // string comparisons is of non-trivial cost. To avoid this cost, we only | |
84 // check RSIDs for the first packet on each incoming SSRC stream. | |
85 // (If RSID associations are added later, we check again.) | |
86 std::set<uint32_t> processed_ssrcs_; | |
87 | |
88 // Avoid an attack that would create excessive logging. | |
89 bool logged_max_processed_ssrcs_exceeded_ = false; | |
90 | |
91 // Observers which will be notified when an RSID association to an SSRC is | 78 // Observers which will be notified when an RSID association to an SSRC is |
92 // resolved by this object. | 79 // resolved by this object. |
93 std::vector<RsidResolutionObserver*> rsid_resolution_observers_; | 80 std::vector<RsidResolutionObserver*> rsid_resolution_observers_; |
94 }; | 81 }; |
95 | 82 |
96 } // namespace webrtc | 83 } // namespace webrtc |
97 | 84 |
98 #endif // WEBRTC_CALL_RTP_DEMUXER_H_ | 85 #endif // WEBRTC_CALL_RTP_DEMUXER_H_ |
OLD | NEW |