blob: 285a33f7bbdf2356f475dd3461698c1f1ebdfe8c [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>
brandtr7250b392016-12-19 01:13:46 -080015
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "call/flexfec_receive_stream.h"
17#include "call/rtp_packet_sink_interface.h"
Tomas Gunnarssonf25761d2020-06-03 22:55:33 +020018#include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h"
Tommi0377bab2021-05-31 14:26:05 +020019#include "rtc_base/system/no_unique_address.h"
Sebastian Jansson8026d602019-03-04 19:39:01 +010020#include "system_wrappers/include/clock.h"
brandtr7250b392016-12-19 01:13:46 -080021
22namespace webrtc {
23
brandtrfa5a3682017-01-17 01:33:54 -080024class FlexfecReceiver;
brandtrfa5a3682017-01-17 01:33:54 -080025class ReceiveStatistics;
26class RecoveredPacketReceiver;
27class RtcpRttStats;
28class RtpPacketReceived;
29class RtpRtcp;
nisse0f15f922017-06-21 01:05:22 -070030class RtpStreamReceiverControllerInterface;
31class RtpStreamReceiverInterface;
brandtrfa5a3682017-01-17 01:33:54 -080032
eladalonc0d481a2017-08-02 07:39:07 -070033class FlexfecReceiveStreamImpl : public FlexfecReceiveStream {
brandtr7250b392016-12-19 01:13:46 -080034 public:
Markus Handelleb61b7f2021-06-22 10:46:48 +020035 FlexfecReceiveStreamImpl(Clock* clock,
36 const Config& config,
37 RecoveredPacketReceiver* recovered_packet_receiver,
38 RtcpRttStats* rtt_stats);
Tommi0377bab2021-05-31 14:26:05 +020039 // Destruction happens on the worker thread. Prior to destruction the caller
40 // must ensure that a registration with the transport has been cleared. See
41 // `RegisterWithTransport` for details.
42 // TODO(tommi): As a further improvement to this, performing the full
43 // destruction on the network thread could be made the default.
brandtr7250b392016-12-19 01:13:46 -080044 ~FlexfecReceiveStreamImpl() override;
45
Tommi0377bab2021-05-31 14:26:05 +020046 // Called on the network thread to register/unregister with the network
47 // transport.
48 void RegisterWithTransport(
49 RtpStreamReceiverControllerInterface* receiver_controller);
50 // If registration has previously been done (via `RegisterWithTransport`) then
51 // `UnregisterFromTransport` must be called prior to destruction, on the
52 // network thread.
53 void UnregisterFromTransport();
54
nissee4bcd6d2017-05-16 04:47:04 -070055 // RtpPacketSinkInterface.
56 void OnRtpPacket(const RtpPacketReceived& packet) override;
brandtr7250b392016-12-19 01:13:46 -080057
brandtr7250b392016-12-19 01:13:46 -080058 Stats GetStats() const override;
Tommid3500062021-06-14 19:39:45 +020059
60 // ReceiveStream impl.
61 const RtpConfig& rtp_config() const override { return config_.rtp; }
brandtr7250b392016-12-19 01:13:46 -080062
63 private:
Tommi90738dd2021-05-31 17:36:47 +020064 RTC_NO_UNIQUE_ADDRESS SequenceChecker packet_sequence_checker_;
Tommi0377bab2021-05-31 14:26:05 +020065
brandtrfa5a3682017-01-17 01:33:54 -080066 // Config.
brandtr7250b392016-12-19 01:13:46 -080067 const Config config_;
brandtrfa5a3682017-01-17 01:33:54 -080068
69 // Erasure code interfacing.
brandtr7250b392016-12-19 01:13:46 -080070 const std::unique_ptr<FlexfecReceiver> receiver_;
brandtrfa5a3682017-01-17 01:33:54 -080071
72 // RTCP reporting.
73 const std::unique_ptr<ReceiveStatistics> rtp_receive_statistics_;
Tomas Gunnarssonf25761d2020-06-03 22:55:33 +020074 const std::unique_ptr<ModuleRtpRtcpImpl2> rtp_rtcp_;
nisse0f15f922017-06-21 01:05:22 -070075
Tommi0377bab2021-05-31 14:26:05 +020076 std::unique_ptr<RtpStreamReceiverInterface> rtp_stream_receiver_
Tommi90738dd2021-05-31 17:36:47 +020077 RTC_GUARDED_BY(packet_sequence_checker_);
brandtr7250b392016-12-19 01:13:46 -080078};
79
80} // namespace webrtc
81
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020082#endif // CALL_FLEXFEC_RECEIVE_STREAM_IMPL_H_