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