tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

flexfec_receive_stream_impl.h (3472B)


      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 
     11 #ifndef CALL_FLEXFEC_RECEIVE_STREAM_IMPL_H_
     12 #define CALL_FLEXFEC_RECEIVE_STREAM_IMPL_H_
     13 
     14 #include <cstdint>
     15 #include <memory>
     16 
     17 #include "api/environment/environment.h"
     18 #include "api/rtp_headers.h"
     19 #include "api/sequence_checker.h"
     20 #include "call/flexfec_receive_stream.h"
     21 #include "call/rtp_packet_sink_interface.h"
     22 #include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h"
     23 #include "rtc_base/system/no_unique_address.h"
     24 #include "rtc_base/thread_annotations.h"
     25 
     26 namespace webrtc {
     27 
     28 class FlexfecReceiver;
     29 class ReceiveStatistics;
     30 class RecoveredPacketReceiver;
     31 class RtcpRttStats;
     32 class RtpPacketReceived;
     33 class RtpStreamReceiverControllerInterface;
     34 class RtpStreamReceiverInterface;
     35 
     36 class FlexfecReceiveStreamImpl : public FlexfecReceiveStream {
     37 public:
     38  FlexfecReceiveStreamImpl(const Environment& env,
     39                           Config config,
     40                           RecoveredPacketReceiver* recovered_packet_receiver,
     41                           RtcpRttStats* rtt_stats);
     42  // Destruction happens on the worker thread. Prior to destruction the caller
     43  // must ensure that a registration with the transport has been cleared. See
     44  // `RegisterWithTransport` for details.
     45  // TODO(tommi): As a further improvement to this, performing the full
     46  // destruction on the network thread could be made the default.
     47  ~FlexfecReceiveStreamImpl() override;
     48 
     49  // Called on the network thread to register/unregister with the network
     50  // transport.
     51  void RegisterWithTransport(
     52      RtpStreamReceiverControllerInterface* receiver_controller);
     53  // If registration has previously been done (via `RegisterWithTransport`) then
     54  // `UnregisterFromTransport` must be called prior to destruction, on the
     55  // network thread.
     56  void UnregisterFromTransport();
     57 
     58  // RtpPacketSinkInterface.
     59  void OnRtpPacket(const RtpPacketReceived& packet) override;
     60 
     61  void SetPayloadType(int payload_type) override;
     62  int payload_type() const override;
     63 
     64  // Updates the `rtp_video_stream_receiver_`'s `local_ssrc` when the default
     65  // sender has been created, changed or removed.
     66  void SetLocalSsrc(uint32_t local_ssrc);
     67 
     68  uint32_t remote_ssrc() const { return remote_ssrc_; }
     69 
     70  void SetRtcpMode(RtcpMode mode) override {
     71    RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
     72    rtp_rtcp_.SetRTCPStatus(mode);
     73  }
     74 
     75  const ReceiveStatistics* GetStats() const override {
     76    return rtp_receive_statistics_.get();
     77  }
     78 
     79 private:
     80  RTC_NO_UNIQUE_ADDRESS SequenceChecker packet_sequence_checker_;
     81 
     82  const uint32_t remote_ssrc_;
     83 
     84  // `payload_type_` is initially set to -1, indicating that FlexFec is
     85  // disabled.
     86  int payload_type_ RTC_GUARDED_BY(packet_sequence_checker_) = -1;
     87 
     88  // Erasure code interfacing.
     89  const std::unique_ptr<FlexfecReceiver> receiver_;
     90 
     91  // RTCP reporting.
     92  const std::unique_ptr<ReceiveStatistics> rtp_receive_statistics_;
     93  ModuleRtpRtcpImpl2 rtp_rtcp_;
     94 
     95  std::unique_ptr<RtpStreamReceiverInterface> rtp_stream_receiver_
     96      RTC_GUARDED_BY(packet_sequence_checker_);
     97 };
     98 
     99 }  // namespace webrtc
    100 
    101 #endif  // CALL_FLEXFEC_RECEIVE_STREAM_IMPL_H_