blob: 1040632639c26b5c2762f67bc457c4defa95d255 [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"
Per K5e5d0172022-12-22 12:43:4118#include "modules/rtp_rtcp/include/recovered_packet_receiver.h"
nisse0f15f922017-06-21 08:05:2219
20namespace webrtc {
21
22class RtpPacketReceived;
23
24// This class represents the RTP receive parsing and demuxing, for a
25// single RTP session.
Niels Möllercb99ccd2022-07-05 13:44:4826// TODO(bugs.webrtc.org/7135): Add RTCP processing, we should aim to terminate
27// RTCP and not leave any RTCP processing to individual receive streams.
Per K5e5d0172022-12-22 12:43:4128class RtpStreamReceiverController : public RtpStreamReceiverControllerInterface,
29 public RecoveredPacketReceiver {
nisse0f15f922017-06-21 08:05:2230 public:
31 RtpStreamReceiverController();
32 ~RtpStreamReceiverController() override;
33
34 // Implements RtpStreamReceiverControllerInterface.
35 std::unique_ptr<RtpStreamReceiverInterface> CreateReceiver(
36 uint32_t ssrc,
37 RtpPacketSinkInterface* sink) override;
38
Niels Möllercb99ccd2022-07-05 13:44:4839 // TODO(bugs.webrtc.org/7135): Not yet responsible for parsing.
nisse0f15f922017-06-21 08:05:2240 bool OnRtpPacket(const RtpPacketReceived& packet);
41
Per K5e5d0172022-12-22 12:43:4142 // Implements RecoveredPacketReceiver.
43 // Responsible for demuxing recovered FLEXFEC packets.
44 void OnRecoveredPacket(const RtpPacketReceived& packet) override;
45
nisse0f15f922017-06-21 08:05:2246 private:
47 class Receiver : public RtpStreamReceiverInterface {
48 public:
49 Receiver(RtpStreamReceiverController* controller,
50 uint32_t ssrc,
51 RtpPacketSinkInterface* sink);
52
53 ~Receiver() override;
54
55 private:
56 RtpStreamReceiverController* const controller_;
57 RtpPacketSinkInterface* const sink_;
58 };
59
Niels Möller25e268a2022-07-06 08:02:2360 // Thread-safe wrappers for the corresponding RtpDemuxer methods.
61 bool AddSink(uint32_t ssrc, RtpPacketSinkInterface* sink);
62 bool RemoveSink(const RtpPacketSinkInterface* sink);
63
Tomas Gunnarssone091fd22021-01-17 15:14:5264 // TODO(bugs.webrtc.org/11993): We expect construction and all methods to be
65 // called on the same thread/tq. Currently this is the worker thread
66 // (including OnRtpPacket) but a more natural fit would be the network thread.
67 // Using a sequence checker to ensure that usage is correct but at the same
68 // time not require a specific thread/tq, an instance of this class + the
69 // associated functionality should be easily moved from one execution context
70 // to another (i.e. when network packets don't hop to the worker thread inside
71 // of Call).
72 SequenceChecker demuxer_sequence_;
73 // At this level the demuxer is only configured to demux by SSRC, so don't
74 // worry about MIDs (MIDs are handled by upper layers).
75 RtpDemuxer demuxer_ RTC_GUARDED_BY(&demuxer_sequence_){false /*use_mid*/};
nisse0f15f922017-06-21 08:05:2276};
77
78} // namespace webrtc
79
Mirko Bonadei92ea95e2017-09-15 04:47:3180#endif // CALL_RTP_STREAM_RECEIVER_CONTROLLER_H_