2016-12-19 01:13:46 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef CALL_FLEXFEC_RECEIVE_STREAM_IMPL_H_
|
|
|
|
|
#define CALL_FLEXFEC_RECEIVE_STREAM_IMPL_H_
|
2016-12-19 01:13:46 -08:00
|
|
|
|
2024-09-02 20:55:52 +00:00
|
|
|
#include <cstdint>
|
2016-12-19 01:13:46 -08:00
|
|
|
#include <memory>
|
|
|
|
|
|
2024-08-30 15:10:20 +02:00
|
|
|
#include "api/environment/environment.h"
|
2024-09-02 20:55:52 +00:00
|
|
|
#include "api/rtp_headers.h"
|
|
|
|
|
#include "api/sequence_checker.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "call/flexfec_receive_stream.h"
|
|
|
|
|
#include "call/rtp_packet_sink_interface.h"
|
2020-06-03 22:55:33 +02:00
|
|
|
#include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h"
|
2021-05-31 14:26:05 +02:00
|
|
|
#include "rtc_base/system/no_unique_address.h"
|
2024-09-02 20:55:52 +00:00
|
|
|
#include "rtc_base/thread_annotations.h"
|
2016-12-19 01:13:46 -08:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2017-01-17 01:33:54 -08:00
|
|
|
class FlexfecReceiver;
|
|
|
|
|
class ReceiveStatistics;
|
|
|
|
|
class RecoveredPacketReceiver;
|
|
|
|
|
class RtcpRttStats;
|
|
|
|
|
class RtpPacketReceived;
|
2017-06-21 01:05:22 -07:00
|
|
|
class RtpStreamReceiverControllerInterface;
|
|
|
|
|
class RtpStreamReceiverInterface;
|
2017-01-17 01:33:54 -08:00
|
|
|
|
2017-08-02 07:39:07 -07:00
|
|
|
class FlexfecReceiveStreamImpl : public FlexfecReceiveStream {
|
2016-12-19 01:13:46 -08:00
|
|
|
public:
|
2024-08-30 15:10:20 +02:00
|
|
|
FlexfecReceiveStreamImpl(const Environment& env,
|
2022-05-09 20:46:57 +00:00
|
|
|
Config config,
|
2021-06-22 10:46:48 +02:00
|
|
|
RecoveredPacketReceiver* recovered_packet_receiver,
|
|
|
|
|
RtcpRttStats* rtt_stats);
|
2021-05-31 14:26:05 +02:00
|
|
|
// Destruction happens on the worker thread. Prior to destruction the caller
|
|
|
|
|
// must ensure that a registration with the transport has been cleared. See
|
|
|
|
|
// `RegisterWithTransport` for details.
|
|
|
|
|
// TODO(tommi): As a further improvement to this, performing the full
|
|
|
|
|
// destruction on the network thread could be made the default.
|
2016-12-19 01:13:46 -08:00
|
|
|
~FlexfecReceiveStreamImpl() override;
|
|
|
|
|
|
2021-05-31 14:26:05 +02:00
|
|
|
// Called on the network thread to register/unregister with the network
|
|
|
|
|
// transport.
|
|
|
|
|
void RegisterWithTransport(
|
|
|
|
|
RtpStreamReceiverControllerInterface* receiver_controller);
|
|
|
|
|
// If registration has previously been done (via `RegisterWithTransport`) then
|
|
|
|
|
// `UnregisterFromTransport` must be called prior to destruction, on the
|
|
|
|
|
// network thread.
|
|
|
|
|
void UnregisterFromTransport();
|
|
|
|
|
|
2017-05-16 04:47:04 -07:00
|
|
|
// RtpPacketSinkInterface.
|
|
|
|
|
void OnRtpPacket(const RtpPacketReceived& packet) override;
|
2022-07-28 09:24:52 +02:00
|
|
|
|
|
|
|
|
void SetPayloadType(int payload_type) override;
|
|
|
|
|
int payload_type() const override;
|
|
|
|
|
|
2022-05-17 10:13:52 +02:00
|
|
|
// Updates the `rtp_video_stream_receiver_`'s `local_ssrc` when the default
|
|
|
|
|
// sender has been created, changed or removed.
|
|
|
|
|
void SetLocalSsrc(uint32_t local_ssrc);
|
|
|
|
|
|
2022-05-25 20:54:24 +02:00
|
|
|
uint32_t remote_ssrc() const { return remote_ssrc_; }
|
2022-05-30 15:08:13 +02:00
|
|
|
|
2022-07-14 18:33:42 +02:00
|
|
|
void SetRtcpMode(RtcpMode mode) override {
|
|
|
|
|
RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
|
2024-08-30 15:10:20 +02:00
|
|
|
rtp_rtcp_.SetRTCPStatus(mode);
|
2022-07-14 18:33:42 +02:00
|
|
|
}
|
|
|
|
|
|
2023-06-21 13:53:41 +02:00
|
|
|
const ReceiveStatistics* GetStats() const override {
|
|
|
|
|
return rtp_receive_statistics_.get();
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-19 01:13:46 -08:00
|
|
|
private:
|
2021-05-31 17:36:47 +02:00
|
|
|
RTC_NO_UNIQUE_ADDRESS SequenceChecker packet_sequence_checker_;
|
2021-05-31 14:26:05 +02:00
|
|
|
|
2022-05-25 20:54:24 +02:00
|
|
|
const uint32_t remote_ssrc_;
|
2016-12-19 01:13:46 -08:00
|
|
|
|
2022-07-28 09:24:52 +02:00
|
|
|
// `payload_type_` is initially set to -1, indicating that FlexFec is
|
|
|
|
|
// disabled.
|
|
|
|
|
int payload_type_ RTC_GUARDED_BY(packet_sequence_checker_) = -1;
|
|
|
|
|
|
2017-01-17 01:33:54 -08:00
|
|
|
// Erasure code interfacing.
|
2016-12-19 01:13:46 -08:00
|
|
|
const std::unique_ptr<FlexfecReceiver> receiver_;
|
2017-01-17 01:33:54 -08:00
|
|
|
|
|
|
|
|
// RTCP reporting.
|
|
|
|
|
const std::unique_ptr<ReceiveStatistics> rtp_receive_statistics_;
|
2024-08-30 15:10:20 +02:00
|
|
|
ModuleRtpRtcpImpl2 rtp_rtcp_;
|
2017-06-21 01:05:22 -07:00
|
|
|
|
2021-05-31 14:26:05 +02:00
|
|
|
std::unique_ptr<RtpStreamReceiverInterface> rtp_stream_receiver_
|
2021-05-31 17:36:47 +02:00
|
|
|
RTC_GUARDED_BY(packet_sequence_checker_);
|
2016-12-19 01:13:46 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // CALL_FLEXFEC_RECEIVE_STREAM_IMPL_H_
|