blob: 2c9b7252799d27bd8b4fb61372e39aa02aa69a5d [file] [log] [blame]
nissee4bcd6d2017-05-16 11:47:041/*
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#ifndef WEBRTC_CALL_RTP_DEMUXER_H_
11#define WEBRTC_CALL_RTP_DEMUXER_H_
12
13#include <map>
14
15namespace webrtc {
16
17class RtpPacketReceived;
nissed76b7b22017-06-01 11:02:3518class RtpPacketSinkInterface;
nissee4bcd6d2017-05-16 11:47:0419
20// This class represents the RTP demuxing, for a single RTP session (i.e., one
21// ssrc space, see RFC 7656). It isn't thread aware, leaving responsibility of
22// multithreading issues to the user of this class.
23// TODO(nisse): Should be extended to also do MID-based demux and payload-type
24// demux.
25class RtpDemuxer {
26 public:
27 RtpDemuxer();
28 ~RtpDemuxer();
29
30 // Registers a sink. The same sink can be registered for multiple ssrcs, and
31 // the same ssrc can have multiple sinks. Null pointer is not allowed.
32 void AddSink(uint32_t ssrc, RtpPacketSinkInterface* sink);
33 // Removes a sink. Returns deletion count (a sink may be registered
34 // for multiple ssrcs). Null pointer is not allowed.
35 size_t RemoveSink(const RtpPacketSinkInterface* sink);
36
37 // Returns true if at least one matching sink was found, otherwise false.
38 bool OnRtpPacket(const RtpPacketReceived& packet);
39
40 private:
41 std::multimap<uint32_t, RtpPacketSinkInterface*> sinks_;
42};
43
44} // namespace webrtc
45
46#endif // WEBRTC_CALL_RTP_DEMUXER_H_