tor-browser

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

rtp_sender_interface.h (5852B)


      1 /*
      2 *  Copyright 2015 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 // This file contains interfaces for RtpSenders
     12 // http://w3c.github.io/webrtc-pc/#rtcrtpsender-interface
     13 
     14 #ifndef API_RTP_SENDER_INTERFACE_H_
     15 #define API_RTP_SENDER_INTERFACE_H_
     16 
     17 #include <cstdint>
     18 #include <memory>
     19 #include <string>
     20 #include <utility>
     21 #include <vector>
     22 
     23 #include "absl/functional/any_invocable.h"
     24 #include "api/crypto/frame_encryptor_interface.h"
     25 #include "api/dtls_transport_interface.h"
     26 #include "api/dtmf_sender_interface.h"
     27 #include "api/frame_transformer_interface.h"
     28 #include "api/media_stream_interface.h"
     29 #include "api/media_types.h"
     30 #include "api/ref_count.h"
     31 #include "api/rtc_error.h"
     32 #include "api/rtp_parameters.h"
     33 #include "api/scoped_refptr.h"
     34 #include "api/video_codecs/video_encoder_factory.h"
     35 #include "rtc_base/system/rtc_export.h"
     36 
     37 #include "api/rtp_sender_setparameters_callback.h"
     38 
     39 namespace webrtc {
     40 
     41 class RtpSenderObserverInterface {
     42 public:
     43  // The observer is called when the first media packet is sent for the observed
     44  // sender. It is called immediately if the first packet was already sent.
     45  virtual void OnFirstPacketSent(MediaType media_type) = 0;
     46 
     47 protected:
     48  virtual ~RtpSenderObserverInterface() {}
     49 };
     50 
     51 class RTC_EXPORT RtpSenderInterface : public RefCountInterface,
     52                                      public FrameTransformerHost {
     53 public:
     54  // Returns true if successful in setting the track.
     55  // Fails if an audio track is set on a video RtpSender, or vice-versa.
     56  virtual bool SetTrack(MediaStreamTrackInterface* track) = 0;
     57  virtual scoped_refptr<MediaStreamTrackInterface> track() const = 0;
     58 
     59  // The dtlsTransport attribute exposes the DTLS transport on which the
     60  // media is sent. It may be null.
     61  // https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender-transport
     62  virtual scoped_refptr<DtlsTransportInterface> dtls_transport() const = 0;
     63 
     64  // Returns primary SSRC used by this sender for sending media.
     65  // Returns 0 if not yet determined.
     66  // TODO(deadbeef): Change to std::optional.
     67  // TODO(deadbeef): Remove? With GetParameters this should be redundant.
     68  virtual uint32_t ssrc() const = 0;
     69 
     70  // Audio or video sender?
     71  virtual MediaType media_type() const = 0;
     72 
     73  // Not to be confused with "mid", this is a field we can temporarily use
     74  // to uniquely identify a receiver until we implement Unified Plan SDP.
     75  virtual std::string id() const = 0;
     76 
     77  // Returns a list of media stream ids associated with this sender's track.
     78  // These are signalled in the SDP so that the remote side can associate
     79  // tracks.
     80  virtual std::vector<std::string> stream_ids() const = 0;
     81 
     82  // Sets the IDs of the media streams associated with this sender's track.
     83  // These are signalled in the SDP so that the remote side can associate
     84  // tracks.
     85  virtual void SetStreams(const std::vector<std::string>& stream_ids) = 0;
     86 
     87  // Returns the list of encoding parameters that will be applied when the SDP
     88  // local description is set. These initial encoding parameters can be set by
     89  // PeerConnection::AddTransceiver, and later updated with Get/SetParameters.
     90  // TODO(orphis): Make it pure virtual once Chrome has updated
     91  virtual std::vector<RtpEncodingParameters> init_send_encodings() const = 0;
     92 
     93  virtual RtpParameters GetParameters() const = 0;
     94  // Note that only a subset of the parameters can currently be changed. See
     95  // rtpparameters.h
     96  // The encodings are in increasing quality order for simulcast.
     97  virtual RTCError SetParameters(const RtpParameters& parameters) = 0;
     98  virtual void SetParametersAsync(const RtpParameters& parameters,
     99                                  SetParametersCallback callback);
    100 
    101  // Sets an observer which gets a callback when the first media packet is sent
    102  // for this sender.
    103  // Does not take ownership of observer.
    104  // Must call SetObserver(nullptr) before the observer is destroyed.
    105  virtual void SetObserver(RtpSenderObserverInterface* /* observer */) {}
    106 
    107  // Returns null for a video sender.
    108  virtual scoped_refptr<DtmfSenderInterface> GetDtmfSender() const = 0;
    109 
    110  // Sets a user defined frame encryptor that will encrypt the entire frame
    111  // before it is sent across the network. This will encrypt the entire frame
    112  // using the user provided encryption mechanism regardless of whether SRTP is
    113  // enabled or not.
    114  virtual void SetFrameEncryptor(
    115      scoped_refptr<FrameEncryptorInterface> frame_encryptor) = 0;
    116 
    117  // Returns a pointer to the frame encryptor set previously by the
    118  // user. This can be used to update the state of the object.
    119  virtual scoped_refptr<FrameEncryptorInterface> GetFrameEncryptor() const = 0;
    120 
    121  [[deprecated("Use SetFrameTransformer")]] virtual void
    122  SetEncoderToPacketizerFrameTransformer(
    123      scoped_refptr<FrameTransformerInterface> frame_transformer) {
    124    SetFrameTransformer(std::move(frame_transformer));
    125  }
    126 
    127  // Sets a user defined encoder selector.
    128  // Overrides selector that is (optionally) provided by VideoEncoderFactory.
    129  virtual void SetEncoderSelector(
    130      std::unique_ptr<VideoEncoderFactory::EncoderSelectorInterface>
    131          encoder_selector) = 0;
    132 
    133  // Default implementation of SetFrameTransformer.
    134  // TODO: bugs.webrtc.org/15929 - remove when all implementations are good
    135  void SetFrameTransformer(scoped_refptr<FrameTransformerInterface>
    136                           /* frame_transformer */) override {}
    137 
    138 protected:
    139  ~RtpSenderInterface() override = default;
    140 };
    141 
    142 }  // namespace webrtc
    143 
    144 #endif  // API_RTP_SENDER_INTERFACE_H_