tor-browser

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

call.h (6575B)


      1 /*
      2 *  Copyright (c) 2013 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_CALL_H_
     11 #define CALL_CALL_H_
     12 
     13 #include <cstdint>
     14 #include <memory>
     15 #include <optional>
     16 #include <string>
     17 
     18 #include "absl/strings/string_view.h"
     19 #include "api/adaptation/resource.h"
     20 #include "api/fec_controller.h"
     21 #include "api/media_types.h"
     22 #include "api/rtp_headers.h"
     23 #include "api/rtp_parameters.h"
     24 #include "api/scoped_refptr.h"
     25 #include "api/task_queue/task_queue_base.h"
     26 #include "api/transport/bitrate_settings.h"
     27 #include "call/audio_receive_stream.h"
     28 #include "call/audio_send_stream.h"
     29 #include "call/call_basic_stats.h"
     30 #include "call/call_config.h"
     31 #include "call/flexfec_receive_stream.h"
     32 #include "call/packet_receiver.h"
     33 #include "call/payload_type.h"
     34 #include "call/rtp_transport_controller_send_interface.h"
     35 #include "call/video_receive_stream.h"
     36 #include "call/video_send_stream.h"
     37 #include "rtc_base/checks.h"
     38 #include "rtc_base/network/sent_packet.h"
     39 #include "video/config/video_encoder_config.h"
     40 
     41 namespace webrtc {
     42 
     43 // A Call represents a two-way connection carrying zero or more outgoing
     44 // and incoming media streams, transported over one or more RTP transports.
     45 
     46 // A Call instance can contain several send and/or receive streams. All streams
     47 // are assumed to have the same remote endpoint and will share bitrate estimates
     48 // etc.
     49 
     50 // When using the PeerConnection API, there is an one to one relationship
     51 // between the PeerConnection and the Call.
     52 
     53 class Call {
     54 public:
     55  using Stats = CallBasicStats;
     56 
     57  static std::unique_ptr<Call> Create(CallConfig config);
     58 
     59  virtual AudioSendStream* CreateAudioSendStream(
     60      const AudioSendStream::Config& config) = 0;
     61 
     62  virtual void DestroyAudioSendStream(AudioSendStream* send_stream) = 0;
     63 
     64  virtual AudioReceiveStreamInterface* CreateAudioReceiveStream(
     65      const AudioReceiveStreamInterface::Config& config) = 0;
     66  virtual void DestroyAudioReceiveStream(
     67      AudioReceiveStreamInterface* receive_stream) = 0;
     68 
     69  virtual VideoSendStream* CreateVideoSendStream(
     70      VideoSendStream::Config config,
     71      VideoEncoderConfig encoder_config) = 0;
     72  virtual VideoSendStream* CreateVideoSendStream(
     73      VideoSendStream::Config config,
     74      VideoEncoderConfig encoder_config,
     75      std::unique_ptr<FecController> fec_controller);
     76  virtual void DestroyVideoSendStream(VideoSendStream* send_stream) = 0;
     77 
     78  virtual VideoReceiveStreamInterface* CreateVideoReceiveStream(
     79      VideoReceiveStreamInterface::Config configuration) = 0;
     80  virtual void DestroyVideoReceiveStream(
     81      VideoReceiveStreamInterface* receive_stream) = 0;
     82 
     83  // In order for a created VideoReceiveStreamInterface to be aware that it is
     84  // protected by a FlexfecReceiveStream, the latter should be created before
     85  // the former.
     86  virtual FlexfecReceiveStream* CreateFlexfecReceiveStream(
     87      const FlexfecReceiveStream::Config config) = 0;
     88  virtual void DestroyFlexfecReceiveStream(
     89      FlexfecReceiveStream* receive_stream) = 0;
     90 
     91  // When a resource is overused, the Call will try to reduce the load on the
     92  // sysem, for example by reducing the resolution or frame rate of encoded
     93  // streams.
     94  virtual void AddAdaptationResource(scoped_refptr<Resource> resource) = 0;
     95 
     96  // All received RTP and RTCP packets for the call should be inserted to this
     97  // PacketReceiver. The PacketReceiver pointer is valid as long as the
     98  // Call instance exists.
     99  virtual PacketReceiver* Receiver() = 0;
    100 
    101  // This is used to access the transport controller send instance owned by
    102  // Call. The send transport controller is currently owned by Call for legacy
    103  // reasons. (for instance  variants of call tests are built on this assumtion)
    104  // TODO(srte): Move ownership of transport controller send out of Call and
    105  // remove this method interface.
    106  virtual RtpTransportControllerSendInterface* GetTransportControllerSend() = 0;
    107 
    108  // A class that keeps track of payload types on the transport(s), and
    109  // suggests new ones when needed.
    110  virtual PayloadTypeSuggester* GetPayloadTypeSuggester() {
    111    // TODO: https://issues.webrtc.org/360058654 - make pure virtual
    112    RTC_CHECK_NOTREACHED();
    113    return nullptr;
    114  }
    115  virtual void SetPayloadTypeSuggester(PayloadTypeSuggester* /* suggester */) {
    116    // TODO: https://issues.webrtc.org/360058654 - make pure virtual
    117    RTC_CHECK_NOTREACHED();
    118  }
    119 
    120  // Returns the call statistics, such as estimated send and receive bandwidth,
    121  // pacing delay, etc.
    122  virtual Stats GetStats() const = 0;
    123 
    124  // TODO(skvlad): When the unbundled case with multiple streams for the same
    125  // media type going over different networks is supported, track the state
    126  // for each stream separately. Right now it's global per media type.
    127  virtual void SignalChannelNetworkState(MediaType media,
    128                                         NetworkState state) = 0;
    129 
    130  virtual void OnAudioTransportOverheadChanged(
    131      int transport_overhead_per_packet) = 0;
    132 
    133  // Called when a receive stream's local ssrc has changed and association with
    134  // send streams needs to be updated.
    135  virtual void OnLocalSsrcUpdated(AudioReceiveStreamInterface& stream,
    136                                  uint32_t local_ssrc) = 0;
    137  virtual void OnLocalSsrcUpdated(VideoReceiveStreamInterface& stream,
    138                                  uint32_t local_ssrc) = 0;
    139  virtual void OnLocalSsrcUpdated(FlexfecReceiveStream& stream,
    140                                  uint32_t local_ssrc) = 0;
    141 
    142  virtual void OnUpdateSyncGroup(AudioReceiveStreamInterface& stream,
    143                                 absl::string_view sync_group) = 0;
    144 
    145  virtual void OnSentPacket(const SentPacketInfo& sent_packet) = 0;
    146 
    147  virtual void SetClientBitratePreferences(
    148      const BitrateSettings& preferences) = 0;
    149 
    150  // Decides which RTCP feedback type to use for congestion control.
    151  virtual void SetPreferredRtcpCcAckType(
    152      RtcpFeedbackType preferred_rtcp_cc_ack_type) = 0;
    153  virtual std::optional<int> FeedbackAccordingToRfc8888Count() = 0;
    154  virtual std::optional<int> FeedbackAccordingToTransportCcCount() = 0;
    155 
    156  virtual TaskQueueBase* network_thread() const = 0;
    157  virtual TaskQueueBase* worker_thread() const = 0;
    158 
    159  virtual ~Call() = default;
    160 };
    161 
    162 }  // namespace webrtc
    163 
    164 #endif  // CALL_CALL_H_