blob: 284c9fa12fba4ce45464e8845b0556401079d6be [file] [log] [blame]
nisse0f15f922017-06-21 08:05:221/*
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 */
Mirko Bonadei92ea95e2017-09-15 04:47:3110#ifndef CALL_RTP_STREAM_RECEIVER_CONTROLLER_H_
11#define CALL_RTP_STREAM_RECEIVER_CONTROLLER_H_
nisse0f15f922017-06-21 08:05:2212
13#include <memory>
14
Artem Titovd15a5752021-02-10 13:31:2415#include "api/sequence_checker.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3116#include "call/rtp_demuxer.h"
17#include "call/rtp_stream_receiver_controller_interface.h"
nisse0f15f922017-06-21 08:05:2218
19namespace webrtc {
20
21class RtpPacketReceived;
22
23// This class represents the RTP receive parsing and demuxing, for a
24// single RTP session.
25// TODO(nisse): Add RTCP processing, we should aim to terminate RTCP
26// and not leave any RTCP processing to individual receive streams.
27// TODO(nisse): Extract per-packet processing, including parsing and
28// demuxing, into a separate class.
29class RtpStreamReceiverController
30 : public RtpStreamReceiverControllerInterface {
31 public:
32 RtpStreamReceiverController();
33 ~RtpStreamReceiverController() override;
34
35 // Implements RtpStreamReceiverControllerInterface.
36 std::unique_ptr<RtpStreamReceiverInterface> CreateReceiver(
37 uint32_t ssrc,
38 RtpPacketSinkInterface* sink) override;
39
40 // Thread-safe wrappers for the corresponding RtpDemuxer methods.
eladalon5daecca2017-08-04 13:34:5441 bool AddSink(uint32_t ssrc, RtpPacketSinkInterface* sink) override;
nisse0f15f922017-06-21 08:05:2242 size_t RemoveSink(const RtpPacketSinkInterface* sink) override;
43
44 // TODO(nisse): Not yet responsible for parsing.
45 bool OnRtpPacket(const RtpPacketReceived& packet);
46
47 private:
48 class Receiver : public RtpStreamReceiverInterface {
49 public:
50 Receiver(RtpStreamReceiverController* controller,
51 uint32_t ssrc,
52 RtpPacketSinkInterface* sink);
53
54 ~Receiver() override;
55
56 private:
57 RtpStreamReceiverController* const controller_;
58 RtpPacketSinkInterface* const sink_;
59 };
60
Tomas Gunnarssone091fd22021-01-17 15:14:5261 // TODO(bugs.webrtc.org/11993): We expect construction and all methods to be
62 // called on the same thread/tq. Currently this is the worker thread
63 // (including OnRtpPacket) but a more natural fit would be the network thread.
64 // Using a sequence checker to ensure that usage is correct but at the same
65 // time not require a specific thread/tq, an instance of this class + the
66 // associated functionality should be easily moved from one execution context
67 // to another (i.e. when network packets don't hop to the worker thread inside
68 // of Call).
69 SequenceChecker demuxer_sequence_;
70 // At this level the demuxer is only configured to demux by SSRC, so don't
71 // worry about MIDs (MIDs are handled by upper layers).
72 RtpDemuxer demuxer_ RTC_GUARDED_BY(&demuxer_sequence_){false /*use_mid*/};
nisse0f15f922017-06-21 08:05:2273};
74
75} // namespace webrtc
76
Mirko Bonadei92ea95e2017-09-15 04:47:3177#endif // CALL_RTP_STREAM_RECEIVER_CONTROLLER_H_