blob: a6803351927912ef577547a74006aad41ba914e2 [file] [log] [blame]
ossuf515ab82016-12-07 12:52:581/*
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 */
Mirko Bonadei92ea95e2017-09-15 04:47:3110#ifndef CALL_CALL_H_
11#define CALL_CALL_H_
ossuf515ab82016-12-07 12:52:5812
zsteina5e0df62017-06-14 18:41:4813#include <algorithm>
zstein7cb69d52017-05-08 18:52:3814#include <memory>
ossuf515ab82016-12-07 12:52:5815#include <string>
16#include <vector>
17
Ali Tofigh641a1b12022-05-17 09:48:4618#include "absl/strings/string_view.h"
Henrik Boströmf4a99912020-06-11 10:07:1419#include "api/adaptation/resource.h"
Steve Anton10542f22019-01-11 17:11:0020#include "api/media_types.h"
Tomas Gunnarssone984aa22021-04-19 07:21:0621#include "api/task_queue/task_queue_base.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3122#include "call/audio_receive_stream.h"
23#include "call/audio_send_stream.h"
Paulina Hensman11b34f42018-04-09 12:24:5224#include "call/call_config.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3125#include "call/flexfec_receive_stream.h"
Niels Möller70082872018-08-07 09:03:1226#include "call/packet_receiver.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3127#include "call/video_receive_stream.h"
28#include "call/video_send_stream.h"
Steve Anton10542f22019-01-11 17:11:0029#include "rtc_base/copy_on_write_buffer.h"
Sebastian Jansson12985412018-10-15 19:06:2630#include "rtc_base/network/sent_packet.h"
Steve Anton10542f22019-01-11 17:11:0031#include "rtc_base/network_route.h"
Tommi25c77c12020-05-25 15:44:5532#include "rtc_base/ref_count.h"
ossuf515ab82016-12-07 12:52:5833
34namespace webrtc {
35
Harald Alvestrandd5f414c2022-01-24 09:11:2336// 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
ossuf515ab82016-12-07 12:52:5839// 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.
Harald Alvestrandd5f414c2022-01-24 09:11:2342
43// When using the PeerConnection API, there is an one to one relationship
44// between the PeerConnection and the Call.
45
ossuf515ab82016-12-07 12:52:5846class Call {
47 public:
ossuf515ab82016-12-07 12:52:5848 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
Danil Chapovalova3ce4072023-10-13 11:53:0058 static std::unique_ptr<Call> Create(const CallConfig& config);
ossuf515ab82016-12-07 12:52:5859
60 virtual AudioSendStream* CreateAudioSendStream(
61 const AudioSendStream::Config& config) = 0;
Piotr (Peter) Slatalacc8e8bb2018-11-15 16:26:1962
ossuf515ab82016-12-07 12:52:5863 virtual void DestroyAudioSendStream(AudioSendStream* send_stream) = 0;
64
Tommi3176ef72022-05-22 18:47:2865 virtual AudioReceiveStreamInterface* CreateAudioReceiveStream(
66 const AudioReceiveStreamInterface::Config& config) = 0;
ossuf515ab82016-12-07 12:52:5867 virtual void DestroyAudioReceiveStream(
Tommi3176ef72022-05-22 18:47:2868 AudioReceiveStreamInterface* receive_stream) = 0;
ossuf515ab82016-12-07 12:52:5869
70 virtual VideoSendStream* CreateVideoSendStream(
71 VideoSendStream::Config config,
72 VideoEncoderConfig encoder_config) = 0;
Ying Wang3b790f32018-01-19 16:58:5773 virtual VideoSendStream* CreateVideoSendStream(
74 VideoSendStream::Config config,
75 VideoEncoderConfig encoder_config,
76 std::unique_ptr<FecController> fec_controller);
ossuf515ab82016-12-07 12:52:5877 virtual void DestroyVideoSendStream(VideoSendStream* send_stream) = 0;
78
Tommif6f45432022-05-20 13:21:2079 virtual VideoReceiveStreamInterface* CreateVideoReceiveStream(
80 VideoReceiveStreamInterface::Config configuration) = 0;
ossuf515ab82016-12-07 12:52:5881 virtual void DestroyVideoReceiveStream(
Tommif6f45432022-05-20 13:21:2082 VideoReceiveStreamInterface* receive_stream) = 0;
ossuf515ab82016-12-07 12:52:5883
Tommif6f45432022-05-20 13:21:2084 // In order for a created VideoReceiveStreamInterface to be aware that it is
brandtrfb45c6c2017-01-27 14:47:5585 // protected by a FlexfecReceiveStream, the latter should be created before
86 // the former.
ossuf515ab82016-12-07 12:52:5887 virtual FlexfecReceiveStream* CreateFlexfecReceiveStream(
Tommicf4ed152022-05-09 20:46:5788 const FlexfecReceiveStream::Config config) = 0;
ossuf515ab82016-12-07 12:52:5889 virtual void DestroyFlexfecReceiveStream(
90 FlexfecReceiveStream* receive_stream) = 0;
91
Henrik Boströmf4a99912020-06-11 10:07:1492 // 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
ossuf515ab82016-12-07 12:52:5897 // 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
Sebastian Jansson8f83b422018-02-21 12:07:13102 // 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
ossuf515ab82016-12-07 12:52:58109 // Returns the call statistics, such as estimated send and receive bandwidth,
110 // pacing delay, etc.
111 virtual Stats GetStats() const = 0;
112
ossuf515ab82016-12-07 12:52:58113 // 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
Stefan Holmer64be7fa2018-10-04 13:21:55119 virtual void OnAudioTransportOverheadChanged(
ossuf515ab82016-12-07 12:52:58120 int transport_overhead_per_packet) = 0;
121
Tommi08be9ba2021-06-15 21:01:57122 // Called when a receive stream's local ssrc has changed and association with
123 // send streams needs to be updated.
Tommi3176ef72022-05-22 18:47:28124 virtual void OnLocalSsrcUpdated(AudioReceiveStreamInterface& stream,
Tommi08be9ba2021-06-15 21:01:57125 uint32_t local_ssrc) = 0;
Tommif6f45432022-05-20 13:21:20126 virtual void OnLocalSsrcUpdated(VideoReceiveStreamInterface& stream,
Tommi1331c182022-05-17 08:13:52127 uint32_t local_ssrc) = 0;
128 virtual void OnLocalSsrcUpdated(FlexfecReceiveStream& stream,
129 uint32_t local_ssrc) = 0;
Tommi08be9ba2021-06-15 21:01:57130
Tommi3176ef72022-05-22 18:47:28131 virtual void OnUpdateSyncGroup(AudioReceiveStreamInterface& stream,
Ali Tofigh641a1b12022-05-17 09:48:46132 absl::string_view sync_group) = 0;
Tommi55107c82021-06-16 14:31:18133
ossuf515ab82016-12-07 12:52:58134 virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0;
135
Piotr (Peter) Slatala7fbfaa42019-03-18 17:31:54136 virtual void SetClientBitratePreferences(
137 const BitrateSettings& preferences) = 0;
138
Jonas Orelande62c2f22022-03-29 09:04:48139 virtual const FieldTrialsView& trials() const = 0;
Erik Språngceb44952020-09-22 09:36:35140
Tomas Gunnarssone984aa22021-04-19 07:21:06141 virtual TaskQueueBase* network_thread() const = 0;
142 virtual TaskQueueBase* worker_thread() const = 0;
143
ossuf515ab82016-12-07 12:52:58144 virtual ~Call() {}
145};
146
147} // namespace webrtc
148
Mirko Bonadei92ea95e2017-09-15 04:47:31149#endif // CALL_CALL_H_