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