tor-browser

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

rtp_receiver_interface.h (5612B)


      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 RtpReceivers
     12 // http://w3c.github.io/webrtc-pc/#rtcrtpreceiver-interface
     13 
     14 #ifndef API_RTP_RECEIVER_INTERFACE_H_
     15 #define API_RTP_RECEIVER_INTERFACE_H_
     16 
     17 #include <optional>
     18 #include <string>
     19 #include <utility>
     20 #include <vector>
     21 
     22 #include "api/crypto/frame_decryptor_interface.h"
     23 #include "api/dtls_transport_interface.h"
     24 #include "api/frame_transformer_interface.h"
     25 #include "api/media_stream_interface.h"
     26 #include "api/media_types.h"
     27 #include "api/ref_count.h"
     28 #include "api/rtp_parameters.h"
     29 #include "api/scoped_refptr.h"
     30 #include "api/transport/rtp/rtp_source.h"
     31 #include "rtc_base/system/rtc_export.h"
     32 
     33 namespace webrtc {
     34 
     35 class RtpReceiverObserverInterface {
     36 public:
     37  // Note: Currently if there are multiple RtpReceivers of the same media type,
     38  // they will all call OnFirstPacketReceived at once.
     39  //
     40  // In the future, it's likely that an RtpReceiver will only call
     41  // OnFirstPacketReceived when a packet is received specifically for its
     42  // SSRC/mid.
     43  virtual void OnFirstPacketReceived(MediaType media_type) = 0;
     44 
     45 protected:
     46  virtual ~RtpReceiverObserverInterface() {}
     47 };
     48 
     49 class RTC_EXPORT RtpReceiverInterface : public RefCountInterface,
     50                                        public FrameTransformerHost {
     51 public:
     52  virtual scoped_refptr<MediaStreamTrackInterface> track() const = 0;
     53 
     54  // The dtlsTransport attribute exposes the DTLS transport on which the
     55  // media is received. It may be null.
     56  // https://w3c.github.io/webrtc-pc/#dom-rtcrtpreceiver-transport
     57  // TODO(https://bugs.webrtc.org/907849) remove default implementation
     58  virtual scoped_refptr<DtlsTransportInterface> dtls_transport() const;
     59 
     60  // The list of streams that `track` is associated with. This is the same as
     61  // the [[AssociatedRemoteMediaStreams]] internal slot in the spec.
     62  // https://w3c.github.io/webrtc-pc/#dfn-associatedremotemediastreams
     63  // TODO(hbos): Make pure virtual as soon as Chromium's mock implements this.
     64  // TODO(https://crbug.com/webrtc/9480): Remove streams() in favor of
     65  // stream_ids() as soon as downstream projects are no longer dependent on
     66  // stream objects.
     67  virtual std::vector<std::string> stream_ids() const;
     68  virtual std::vector<scoped_refptr<MediaStreamInterface>> streams() const;
     69 
     70  // Audio or video receiver?
     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  // The WebRTC specification only defines RTCRtpParameters in terms of senders,
     78  // but this API also applies them to receivers, similar to ORTC:
     79  // http://ortc.org/wp-content/uploads/2016/03/ortc.html#rtcrtpparameters*.
     80  virtual RtpParameters GetParameters() const = 0;
     81  // TODO(dinosaurav): Delete SetParameters entirely after rolling to Chromium.
     82  // Currently, doesn't support changing any parameters.
     83  virtual bool SetParameters(const RtpParameters& /* parameters */) {
     84    return false;
     85  }
     86 
     87  // Does not take ownership of observer.
     88  // Must call SetObserver(nullptr) before the observer is destroyed.
     89  virtual void SetObserver(RtpReceiverObserverInterface* observer) = 0;
     90 
     91  // Sets the jitter buffer minimum delay until media playout. Actual observed
     92  // delay may differ depending on the congestion control. `delay_seconds` is a
     93  // positive value including 0.0 measured in seconds. `nullopt` means default
     94  // value must be used.
     95  virtual void SetJitterBufferMinimumDelay(
     96      std::optional<double> delay_seconds) = 0;
     97 
     98  // TODO(zhihuang): Remove the default implementation once the subclasses
     99  // implement this. Currently, the only relevant subclass is the
    100  // content::FakeRtpReceiver in Chromium.
    101  virtual std::vector<RtpSource> GetSources() const;
    102 
    103  // Sets a user defined frame decryptor that will decrypt the entire frame
    104  // before it is sent across the network. This will decrypt the entire frame
    105  // using the user provided decryption mechanism regardless of whether SRTP is
    106  // enabled or not.
    107  // TODO(bugs.webrtc.org/12772): Remove.
    108  virtual void SetFrameDecryptor(
    109      scoped_refptr<FrameDecryptorInterface> frame_decryptor);
    110 
    111  // Returns a pointer to the frame decryptor set previously by the
    112  // user. This can be used to update the state of the object.
    113  // TODO(bugs.webrtc.org/12772): Remove.
    114  virtual scoped_refptr<FrameDecryptorInterface> GetFrameDecryptor() const;
    115 
    116  // Sets a frame transformer between the depacketizer and the decoder to enable
    117  // client code to transform received frames according to their own processing
    118  // logic.
    119  [[deprecated("Use SetFrameTransformer")]] virtual void
    120  SetDepacketizerToDecoderFrameTransformer(
    121      scoped_refptr<FrameTransformerInterface> frame_transformer) {
    122    SetFrameTransformer(std::move(frame_transformer));
    123  }
    124 
    125  // Default implementation of SetFrameTransformer.
    126  // TODO: bugs.webrtc.org/15929 - Make pure virtual.
    127  void SetFrameTransformer(
    128      scoped_refptr<FrameTransformerInterface> frame_transformer) override;
    129 
    130 protected:
    131  ~RtpReceiverInterface() override = default;
    132 };
    133 
    134 }  // namespace webrtc
    135 
    136 #endif  // API_RTP_RECEIVER_INTERFACE_H_