| 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 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // 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 |
| 25 // ssrc space, see RFC 7656). It isn't thread aware, leaving responsibility of | 25 // ssrc space, see RFC 7656). It isn't thread aware, leaving responsibility of |
| 26 // multithreading issues to the user of this class. | 26 // multithreading issues to the user of this class. |
| 27 // TODO(nisse): Should be extended to also do MID-based demux and payload-type | 27 // TODO(nisse): Should be extended to also do MID-based demux and payload-type |
| 28 // demux. | 28 // demux. |
| 29 class RtpDemuxer { | 29 class RtpDemuxer { |
| 30 public: | 30 public: |
| 31 RtpDemuxer(); | 31 RtpDemuxer(); |
| 32 ~RtpDemuxer(); | 32 ~RtpDemuxer(); |
| 33 | 33 |
| 34 // Registers a sink. Multiple SSRCs may be mapped to the same sink, but | 34 // Registers a sink. The same sink can be registered for multiple ssrcs, and |
| 35 // each SSRC may only be mapped to one sink. The return value reports | 35 // the same ssrc can have multiple sinks. Null pointer is not allowed. |
| 36 // whether the association has been recorded or rejected. Rejection may occur | 36 void AddSink(uint32_t ssrc, RtpPacketSinkInterface* sink); |
| 37 // if the SSRC has already been associated with a sink. The previously added | |
| 38 // sink is *not* forgotten. | |
| 39 bool AddSink(uint32_t ssrc, RtpPacketSinkInterface* sink); | |
| 40 | 37 |
| 41 // Registers a sink's association to an RSID. Only one sink may be associated | 38 // Registers a sink's association to an RSID. Null pointer is not allowed. |
| 42 // with a given RSID. Null pointer is not allowed. | |
| 43 void AddSink(const std::string& rsid, RtpPacketSinkInterface* sink); | 39 void AddSink(const std::string& rsid, RtpPacketSinkInterface* sink); |
| 44 | 40 |
| 45 // Removes a sink. Return value reports if anything was actually removed. | 41 // Removes a sink. Return value reports if anything was actually removed. |
| 46 // Null pointer is not allowed. | 42 // Null pointer is not allowed. |
| 47 bool RemoveSink(const RtpPacketSinkInterface* sink); | 43 bool RemoveSink(const RtpPacketSinkInterface* sink); |
| 48 | 44 |
| 49 // Handles RTP packets. Returns true if at least one matching sink was found. | 45 // Returns true if at least one matching sink was found. |
| 50 bool OnRtpPacket(const RtpPacketReceived& packet); | 46 bool OnRtpPacket(const RtpPacketReceived& packet); |
| 51 | 47 |
| 52 // Allows other objects to be notified when RSID-SSRC associations are | 48 // Allows other objects to be notified when RSID-SSRC associations are |
| 53 // resolved by this object. | 49 // resolved by this object. |
| 54 void RegisterRsidResolutionObserver(RsidResolutionObserver* observer); | 50 void RegisterRsidResolutionObserver(RsidResolutionObserver* observer); |
| 55 | 51 |
| 56 // Undo a previous RegisterRsidResolutionObserver(). | 52 // Undo a previous RegisterRsidResolutionObserver(). |
| 57 void DeregisterRsidResolutionObserver(const RsidResolutionObserver* observer); | 53 void DeregisterRsidResolutionObserver(const RsidResolutionObserver* observer); |
| 58 | 54 |
| 59 private: | 55 private: |
| 56 // Records a sink<->SSRC association. This can happen by explicit |
| 57 // configuration by AddSink(ssrc...), or by inferred configuration from an |
| 58 // RSID-based configuration which is resolved to an SSRC upon |
| 59 // packet reception. |
| 60 void RecordSsrcToSinkAssociation(uint32_t ssrc, RtpPacketSinkInterface* sink); |
| 61 |
| 60 // Find the associations of RSID to SSRCs. | 62 // Find the associations of RSID to SSRCs. |
| 61 void ResolveRsidToSsrcAssociations(const RtpPacketReceived& packet); | 63 void ResolveRsidToSsrcAssociations(const RtpPacketReceived& packet); |
| 62 | 64 |
| 63 // Notify observers of the resolution of an RSID to an SSRC. | 65 // Notify observers of the resolution of an RSID to an SSRC. |
| 64 void NotifyObserversOfRsidResolution(const std::string& rsid, uint32_t ssrc); | 66 void NotifyObserversOfRsidResolution(const std::string& rsid, uint32_t ssrc); |
| 65 | 67 |
| 66 // This records the association SSRCs to sinks. Other associations, such | 68 // This records the association SSRCs to sinks. Other associations, such |
| 67 // 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. |
| 68 std::map<uint32_t, RtpPacketSinkInterface*> ssrc_sinks_; | 70 std::multimap<uint32_t, RtpPacketSinkInterface*> ssrc_sinks_; |
| 69 | 71 |
| 70 // 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 |
| 71 // 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. |
| 72 // 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 |
| 73 // from this container, and moved into |ssrc_sinks_|. | 75 // from this container, and moved into |ssrc_sinks_|. |
| 74 std::map<std::string, RtpPacketSinkInterface*> rsid_sinks_; | 76 std::multimap<std::string, RtpPacketSinkInterface*> rsid_sinks_; |
| 75 | 77 |
| 76 // 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 |
| 77 // resolved by this object. | 79 // resolved by this object. |
| 78 std::vector<RsidResolutionObserver*> rsid_resolution_observers_; | 80 std::vector<RsidResolutionObserver*> rsid_resolution_observers_; |
| 79 }; | 81 }; |
| 80 | 82 |
| 81 } // namespace webrtc | 83 } // namespace webrtc |
| 82 | 84 |
| 83 #endif // WEBRTC_CALL_RTP_DEMUXER_H_ | 85 #endif // WEBRTC_CALL_RTP_DEMUXER_H_ |
| OLD | NEW |