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

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

Issue 2957763002: Revert of Create RtcpDemuxer (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « webrtc/call/rtcp_packet_sink_interface.h ('k') | webrtc/call/rtp_demuxer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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> 15 #include <set>
16 #include <string> 16 #include <string>
17 #include <vector>
18 17
19 namespace webrtc { 18 namespace webrtc {
20 19
21 class RsidResolutionObserver;
22 class RtpPacketReceived; 20 class RtpPacketReceived;
23 class RtpPacketSinkInterface; 21 class RtpPacketSinkInterface;
24 22
25 // This class represents the RTP demuxing, for a single RTP session (i.e., one 23 // This class represents the RTP demuxing, for a single RTP session (i.e., one
26 // ssrc space, see RFC 7656). It isn't thread aware, leaving responsibility of 24 // ssrc space, see RFC 7656). It isn't thread aware, leaving responsibility of
27 // multithreading issues to the user of this class. 25 // multithreading issues to the user of this class.
28 // TODO(nisse): Should be extended to also do MID-based demux and payload-type 26 // TODO(nisse): Should be extended to also do MID-based demux and payload-type
29 // demux. 27 // demux.
30 class RtpDemuxer { 28 class RtpDemuxer {
31 public: 29 public:
32 RtpDemuxer(); 30 RtpDemuxer();
33 ~RtpDemuxer(); 31 ~RtpDemuxer();
34 32
35 // Registers a sink. The same sink can be registered for multiple ssrcs, and 33 // Registers a sink. The same sink can be registered for multiple ssrcs, and
36 // the same ssrc can have multiple sinks. Null pointer is not allowed. 34 // the same ssrc can have multiple sinks. Null pointer is not allowed.
37 void AddSink(uint32_t ssrc, RtpPacketSinkInterface* sink); 35 void AddSink(uint32_t ssrc, RtpPacketSinkInterface* sink);
38 36
39 // Registers a sink's association to an RSID. Null pointer is not allowed. 37 // Registers a sink's association to an RSID. Null pointer is not allowed.
40 void AddSink(const std::string& rsid, RtpPacketSinkInterface* sink); 38 void AddSink(const std::string& rsid, RtpPacketSinkInterface* sink);
41 39
42 // Removes a sink. Return value reports if anything was actually removed. 40 // Removes a sink. Return value reports if anything was actually removed.
43 // Null pointer is not allowed. 41 // Null pointer is not allowed.
44 bool RemoveSink(const RtpPacketSinkInterface* sink); 42 bool RemoveSink(const RtpPacketSinkInterface* sink);
45 43
46 // Returns true if at least one matching sink was found. 44 // Returns true if at least one matching sink was found, otherwise false.
47 bool OnRtpPacket(const RtpPacketReceived& packet); 45 bool OnRtpPacket(const RtpPacketReceived& packet);
48 46
49 // Allows other objects to be notified when RSID-SSRC associations are
50 // resolved by this object.
51 void RegisterRsidResolutionObserver(RsidResolutionObserver* observer);
52
53 // Undo a previous RegisterRsidResolutionObserver().
54 void DeregisterRsidResolutionObserver(const RsidResolutionObserver* observer);
55
56 private: 47 private:
57 // Records a sink<->SSRC association. This can happen by explicit 48 // Records a sink<->SSRC association. This can happen by explicit
58 // configuration by AddSink(ssrc...), or by inferred configuration from an 49 // configuration by AddSink(ssrc...), or by inferred configuration from an
59 // RSID-based configuration which is resolved to an SSRC upon 50 // RSID-based configuration which is resolved to an SSRC upon
60 // packet reception. 51 // packet reception.
61 void RecordSsrcToSinkAssociation(uint32_t ssrc, RtpPacketSinkInterface* sink); 52 void RecordSsrcToSinkAssociation(uint32_t ssrc, RtpPacketSinkInterface* sink);
62 53
63 // When a new packet arrives, we attempt to resolve extra associations. 54 // When a new packet arrives, we attempt to resolve extra associations,
64 void ResolveAssociations(const RtpPacketReceived& packet); 55 // such as which RSIDs are associated with which SSRCs.
65 56 void FindSsrcAssociations(const RtpPacketReceived& packet);
66 // Find the associations of RSID to SSRCs.
67 void ResolveRsidToSsrcAssociations(const RtpPacketReceived& packet);
68
69 // Notify observers of the resolution of an RSID to an SSRC.
70 void NotifyObserversOfRsidResolution(const std::string& rsid, uint32_t ssrc);
71 57
72 // This records the association SSRCs to sinks. Other associations, such 58 // 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. 59 // as by RSID, also end up here once the RSID, etc., is resolved to an SSRC.
74 std::multimap<uint32_t, RtpPacketSinkInterface*> sinks_; 60 std::multimap<uint32_t, RtpPacketSinkInterface*> sinks_;
75 61
76 // A sink may be associated with an RSID - RTP Stream ID. This tag has a 62 // 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. 63 // 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 64 // When it becomes known, the association of the sink to the RSID is deleted
79 // from this container, and moved into |sinks_|. 65 // from this container, and moved into |sinks_|.
80 std::multimap<std::string, RtpPacketSinkInterface*> rsid_sinks_; 66 std::multimap<std::string, RtpPacketSinkInterface*> rsid_sinks_;
81 67
82 // Iterating over |rsid_sinks_| for each incoming and performing multiple 68 // Iterating over |rsid_sinks_| for each incoming and performing multiple
83 // string comparisons is of non-trivial cost. To avoid this cost, we only 69 // 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. 70 // check RSIDs for the first packet on each incoming SSRC stream.
85 // (If RSID associations are added later, we check again.) 71 // (If RSID associations are added later, we check again.)
86 std::set<uint32_t> processed_ssrcs_; 72 std::set<uint32_t> processed_ssrcs_;
87 73
88 // Avoid an attack that would create excessive logging. 74 // Avoid an attack that would create excessive logging.
89 bool logged_max_processed_ssrcs_exceeded_ = false; 75 bool logged_max_processed_ssrcs_exceeded_ = false;
90
91 // Observers which will be notified when an RSID association to an SSRC is
92 // resolved by this object.
93 std::vector<RsidResolutionObserver*> rsid_resolution_observers_;
94 }; 76 };
95 77
96 } // namespace webrtc 78 } // namespace webrtc
97 79
98 #endif // WEBRTC_CALL_RTP_DEMUXER_H_ 80 #endif // WEBRTC_CALL_RTP_DEMUXER_H_
OLDNEW
« no previous file with comments | « webrtc/call/rtcp_packet_sink_interface.h ('k') | webrtc/call/rtp_demuxer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698