brandtr | 7250b39 | 2016-12-19 01:13:46 -0800 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef CALL_FLEXFEC_RECEIVE_STREAM_IMPL_H_ |
| 12 | #define CALL_FLEXFEC_RECEIVE_STREAM_IMPL_H_ |
brandtr | 7250b39 | 2016-12-19 01:13:46 -0800 | [diff] [blame] | 13 | |
| 14 | #include <memory> |
Tommi | 1f38a38 | 2021-09-08 10:44:50 +0200 | [diff] [blame^] | 15 | #include <vector> |
brandtr | 7250b39 | 2016-12-19 01:13:46 -0800 | [diff] [blame] | 16 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #include "call/flexfec_receive_stream.h" |
| 18 | #include "call/rtp_packet_sink_interface.h" |
Tomas Gunnarsson | f25761d | 2020-06-03 22:55:33 +0200 | [diff] [blame] | 19 | #include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h" |
Tommi | 0377bab | 2021-05-31 14:26:05 +0200 | [diff] [blame] | 20 | #include "rtc_base/system/no_unique_address.h" |
Sebastian Jansson | 8026d60 | 2019-03-04 19:39:01 +0100 | [diff] [blame] | 21 | #include "system_wrappers/include/clock.h" |
brandtr | 7250b39 | 2016-12-19 01:13:46 -0800 | [diff] [blame] | 22 | |
| 23 | namespace webrtc { |
| 24 | |
brandtr | fa5a368 | 2017-01-17 01:33:54 -0800 | [diff] [blame] | 25 | class FlexfecReceiver; |
brandtr | fa5a368 | 2017-01-17 01:33:54 -0800 | [diff] [blame] | 26 | class ReceiveStatistics; |
| 27 | class RecoveredPacketReceiver; |
| 28 | class RtcpRttStats; |
| 29 | class RtpPacketReceived; |
| 30 | class RtpRtcp; |
nisse | 0f15f92 | 2017-06-21 01:05:22 -0700 | [diff] [blame] | 31 | class RtpStreamReceiverControllerInterface; |
| 32 | class RtpStreamReceiverInterface; |
brandtr | fa5a368 | 2017-01-17 01:33:54 -0800 | [diff] [blame] | 33 | |
eladalon | c0d481a | 2017-08-02 07:39:07 -0700 | [diff] [blame] | 34 | class FlexfecReceiveStreamImpl : public FlexfecReceiveStream { |
brandtr | 7250b39 | 2016-12-19 01:13:46 -0800 | [diff] [blame] | 35 | public: |
Markus Handell | eb61b7f | 2021-06-22 10:46:48 +0200 | [diff] [blame] | 36 | FlexfecReceiveStreamImpl(Clock* clock, |
| 37 | const Config& config, |
| 38 | RecoveredPacketReceiver* recovered_packet_receiver, |
| 39 | RtcpRttStats* rtt_stats); |
Tommi | 0377bab | 2021-05-31 14:26:05 +0200 | [diff] [blame] | 40 | // 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. |
brandtr | 7250b39 | 2016-12-19 01:13:46 -0800 | [diff] [blame] | 45 | ~FlexfecReceiveStreamImpl() override; |
| 46 | |
Tommi | 0377bab | 2021-05-31 14:26:05 +0200 | [diff] [blame] | 47 | // 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 | |
nisse | e4bcd6d | 2017-05-16 04:47:04 -0700 | [diff] [blame] | 56 | // RtpPacketSinkInterface. |
| 57 | void OnRtpPacket(const RtpPacketReceived& packet) override; |
brandtr | 7250b39 | 2016-12-19 01:13:46 -0800 | [diff] [blame] | 58 | |
brandtr | 7250b39 | 2016-12-19 01:13:46 -0800 | [diff] [blame] | 59 | Stats GetStats() const override; |
Tommi | d350006 | 2021-06-14 19:39:45 +0200 | [diff] [blame] | 60 | |
| 61 | // ReceiveStream impl. |
Tommi | 1f38a38 | 2021-09-08 10:44:50 +0200 | [diff] [blame^] | 62 | void SetRtpExtensions(std::vector<RtpExtension> extensions) override; |
Tommi | d350006 | 2021-06-14 19:39:45 +0200 | [diff] [blame] | 63 | const RtpConfig& rtp_config() const override { return config_.rtp; } |
brandtr | 7250b39 | 2016-12-19 01:13:46 -0800 | [diff] [blame] | 64 | |
| 65 | private: |
Tommi | 90738dd | 2021-05-31 17:36:47 +0200 | [diff] [blame] | 66 | RTC_NO_UNIQUE_ADDRESS SequenceChecker packet_sequence_checker_; |
Tommi | 0377bab | 2021-05-31 14:26:05 +0200 | [diff] [blame] | 67 | |
Tommi | 1f38a38 | 2021-09-08 10:44:50 +0200 | [diff] [blame^] | 68 | // Config. Mostly const, header extensions may change. |
| 69 | Config config_ RTC_GUARDED_BY(packet_sequence_checker_); |
brandtr | fa5a368 | 2017-01-17 01:33:54 -0800 | [diff] [blame] | 70 | |
| 71 | // Erasure code interfacing. |
brandtr | 7250b39 | 2016-12-19 01:13:46 -0800 | [diff] [blame] | 72 | const std::unique_ptr<FlexfecReceiver> receiver_; |
brandtr | fa5a368 | 2017-01-17 01:33:54 -0800 | [diff] [blame] | 73 | |
| 74 | // RTCP reporting. |
| 75 | const std::unique_ptr<ReceiveStatistics> rtp_receive_statistics_; |
Tomas Gunnarsson | f25761d | 2020-06-03 22:55:33 +0200 | [diff] [blame] | 76 | const std::unique_ptr<ModuleRtpRtcpImpl2> rtp_rtcp_; |
nisse | 0f15f92 | 2017-06-21 01:05:22 -0700 | [diff] [blame] | 77 | |
Tommi | 0377bab | 2021-05-31 14:26:05 +0200 | [diff] [blame] | 78 | std::unique_ptr<RtpStreamReceiverInterface> rtp_stream_receiver_ |
Tommi | 90738dd | 2021-05-31 17:36:47 +0200 | [diff] [blame] | 79 | RTC_GUARDED_BY(packet_sequence_checker_); |
brandtr | 7250b39 | 2016-12-19 01:13:46 -0800 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | } // namespace webrtc |
| 83 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 84 | #endif // CALL_FLEXFEC_RECEIVE_STREAM_IMPL_H_ |