tor-browser

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

rtp_stream_receiver_controller.h (3186B)


      1 /*
      2 *  Copyright (c) 2017 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 #ifndef CALL_RTP_STREAM_RECEIVER_CONTROLLER_H_
     11 #define CALL_RTP_STREAM_RECEIVER_CONTROLLER_H_
     12 
     13 #include <cstdint>
     14 #include <memory>
     15 
     16 #include "api/sequence_checker.h"
     17 #include "call/rtp_demuxer.h"
     18 #include "call/rtp_stream_receiver_controller_interface.h"
     19 #include "modules/rtp_rtcp/include/recovered_packet_receiver.h"
     20 #include "rtc_base/thread_annotations.h"
     21 
     22 namespace webrtc {
     23 
     24 class RtpPacketReceived;
     25 
     26 // This class represents the RTP receive parsing and demuxing, for a
     27 // single RTP session.
     28 // TODO(bugs.webrtc.org/7135): Add RTCP processing, we should aim to terminate
     29 // RTCP and not leave any RTCP processing to individual receive streams.
     30 class RtpStreamReceiverController : public RtpStreamReceiverControllerInterface,
     31                                    public RecoveredPacketReceiver {
     32 public:
     33  RtpStreamReceiverController();
     34  ~RtpStreamReceiverController() override;
     35 
     36  // Implements RtpStreamReceiverControllerInterface.
     37  std::unique_ptr<RtpStreamReceiverInterface> CreateReceiver(
     38      uint32_t ssrc,
     39      RtpPacketSinkInterface* sink) override;
     40 
     41  // TODO(bugs.webrtc.org/7135): Not yet responsible for parsing.
     42  bool OnRtpPacket(const RtpPacketReceived& packet);
     43 
     44  // Implements RecoveredPacketReceiver.
     45  // Responsible for demuxing recovered FLEXFEC packets.
     46  void OnRecoveredPacket(const RtpPacketReceived& packet) override;
     47 
     48 private:
     49  class Receiver : public RtpStreamReceiverInterface {
     50   public:
     51    Receiver(RtpStreamReceiverController* controller,
     52             uint32_t ssrc,
     53             RtpPacketSinkInterface* sink);
     54 
     55    ~Receiver() override;
     56 
     57   private:
     58    RtpStreamReceiverController* const controller_;
     59    RtpPacketSinkInterface* const sink_;
     60  };
     61 
     62  // Thread-safe wrappers for the corresponding RtpDemuxer methods.
     63  bool AddSink(uint32_t ssrc, RtpPacketSinkInterface* sink);
     64  bool RemoveSink(const RtpPacketSinkInterface* sink);
     65 
     66  // TODO(bugs.webrtc.org/11993): We expect construction and all methods to be
     67  // called on the same thread/tq. Currently this is the worker thread
     68  // (including OnRtpPacket) but a more natural fit would be the network thread.
     69  // Using a sequence checker to ensure that usage is correct but at the same
     70  // time not require a specific thread/tq, an instance of this class + the
     71  // associated functionality should be easily moved from one execution context
     72  // to another (i.e. when network packets don't hop to the worker thread inside
     73  // of Call).
     74  SequenceChecker demuxer_sequence_;
     75  // At this level the demuxer is only configured to demux by SSRC, so don't
     76  // worry about MIDs (MIDs are handled by upper layers).
     77  RtpDemuxer demuxer_ RTC_GUARDED_BY(&demuxer_sequence_){false /*use_mid*/};
     78 };
     79 
     80 }  // namespace webrtc
     81 
     82 #endif  // CALL_RTP_STREAM_RECEIVER_CONTROLLER_H_