blob: 802f91d2a89815b851e5b72d42fae1c0d6e2e19d [file] [log] [blame]
brandtr7250b392016-12-19 01:13:46 -08001/*
2 * Copyright (c) 2016 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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef CALL_FLEXFEC_RECEIVE_STREAM_IMPL_H_
12#define CALL_FLEXFEC_RECEIVE_STREAM_IMPL_H_
brandtr7250b392016-12-19 01:13:46 -080013
14#include <memory>
Tommi1f38a382021-09-08 10:44:50 +020015#include <vector>
brandtr7250b392016-12-19 01:13:46 -080016
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "call/flexfec_receive_stream.h"
18#include "call/rtp_packet_sink_interface.h"
Tomas Gunnarssonf25761d2020-06-03 22:55:33 +020019#include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h"
Tommi0377bab2021-05-31 14:26:05 +020020#include "rtc_base/system/no_unique_address.h"
Sebastian Jansson8026d602019-03-04 19:39:01 +010021#include "system_wrappers/include/clock.h"
brandtr7250b392016-12-19 01:13:46 -080022
23namespace webrtc {
24
brandtrfa5a3682017-01-17 01:33:54 -080025class FlexfecReceiver;
brandtrfa5a3682017-01-17 01:33:54 -080026class ReceiveStatistics;
27class RecoveredPacketReceiver;
28class RtcpRttStats;
29class RtpPacketReceived;
30class RtpRtcp;
nisse0f15f922017-06-21 01:05:22 -070031class RtpStreamReceiverControllerInterface;
32class RtpStreamReceiverInterface;
brandtrfa5a3682017-01-17 01:33:54 -080033
eladalonc0d481a2017-08-02 07:39:07 -070034class FlexfecReceiveStreamImpl : public FlexfecReceiveStream {
brandtr7250b392016-12-19 01:13:46 -080035 public:
Markus Handelleb61b7f2021-06-22 10:46:48 +020036 FlexfecReceiveStreamImpl(Clock* clock,
Tommicf4ed152022-05-09 20:46:57 +000037 Config config,
Markus Handelleb61b7f2021-06-22 10:46:48 +020038 RecoveredPacketReceiver* recovered_packet_receiver,
39 RtcpRttStats* rtt_stats);
Tommi0377bab2021-05-31 14:26:05 +020040 // Destruction happens on the worker thread. Prior to destruction the caller
41 // must ensure that a registration with the transport has been cleared. See
42 // `RegisterWithTransport` for details.
43 // TODO(tommi): As a further improvement to this, performing the full
44 // destruction on the network thread could be made the default.
brandtr7250b392016-12-19 01:13:46 -080045 ~FlexfecReceiveStreamImpl() override;
46
Tommi0377bab2021-05-31 14:26:05 +020047 // Called on the network thread to register/unregister with the network
48 // transport.
49 void RegisterWithTransport(
50 RtpStreamReceiverControllerInterface* receiver_controller);
51 // If registration has previously been done (via `RegisterWithTransport`) then
52 // `UnregisterFromTransport` must be called prior to destruction, on the
53 // network thread.
54 void UnregisterFromTransport();
55
nissee4bcd6d2017-05-16 04:47:04 -070056 // RtpPacketSinkInterface.
57 void OnRtpPacket(const RtpPacketReceived& packet) override;
Tommi0601db92022-05-18 09:18:37 +020058 // ReceiveStreamInterface impl.
Tommi1f38a382021-09-08 10:44:50 +020059 void SetRtpExtensions(std::vector<RtpExtension> extensions) override;
Tommicf4ed152022-05-09 20:46:57 +000060 RtpHeaderExtensionMap GetRtpExtensionMap() const override;
61
Tommi1331c182022-05-17 10:13:52 +020062 // Updates the `rtp_video_stream_receiver_`'s `local_ssrc` when the default
63 // sender has been created, changed or removed.
64 void SetLocalSsrc(uint32_t local_ssrc);
65
Tommifc2c24e2022-05-25 20:54:24 +020066 uint32_t remote_ssrc() const { return remote_ssrc_; }
Tommia136ed42022-05-30 15:08:13 +020067
Tommi7a15ff32022-05-09 18:54:02 +000068 bool transport_cc() const override {
69 RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
Tommifc2c24e2022-05-25 20:54:24 +020070 return transport_cc_;
Tommi7a15ff32022-05-09 18:54:02 +000071 }
brandtr7250b392016-12-19 01:13:46 -080072
Tommia136ed42022-05-30 15:08:13 +020073 void SetTransportCc(bool transport_cc) override {
74 RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
75 transport_cc_ = transport_cc;
76 }
77
brandtr7250b392016-12-19 01:13:46 -080078 private:
Tommi90738dd2021-05-31 17:36:47 +020079 RTC_NO_UNIQUE_ADDRESS SequenceChecker packet_sequence_checker_;
Tommi0377bab2021-05-31 14:26:05 +020080
Tommicf4ed152022-05-09 20:46:57 +000081 RtpHeaderExtensionMap extension_map_;
82
Tommifc2c24e2022-05-25 20:54:24 +020083 const uint32_t remote_ssrc_;
84 bool transport_cc_ RTC_GUARDED_BY(packet_sequence_checker_);
brandtrfa5a3682017-01-17 01:33:54 -080085
86 // Erasure code interfacing.
brandtr7250b392016-12-19 01:13:46 -080087 const std::unique_ptr<FlexfecReceiver> receiver_;
brandtrfa5a3682017-01-17 01:33:54 -080088
89 // RTCP reporting.
90 const std::unique_ptr<ReceiveStatistics> rtp_receive_statistics_;
Tomas Gunnarssonf25761d2020-06-03 22:55:33 +020091 const std::unique_ptr<ModuleRtpRtcpImpl2> rtp_rtcp_;
nisse0f15f922017-06-21 01:05:22 -070092
Tommi0377bab2021-05-31 14:26:05 +020093 std::unique_ptr<RtpStreamReceiverInterface> rtp_stream_receiver_
Tommi90738dd2021-05-31 17:36:47 +020094 RTC_GUARDED_BY(packet_sequence_checker_);
brandtr7250b392016-12-19 01:13:46 -080095};
96
97} // namespace webrtc
98
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020099#endif // CALL_FLEXFEC_RECEIVE_STREAM_IMPL_H_