blob: ab834f3c84c9c28a71a1fcbb90c0958773680f9d [file] [log] [blame]
ossuf515ab82016-12-07 04:52:58 -08001/*
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 06:47:31 +020010#ifndef CALL_CALL_H_
11#define CALL_CALL_H_
ossuf515ab82016-12-07 04:52:58 -080012
zsteina5e0df62017-06-14 11:41:48 -070013#include <algorithm>
zstein7cb69d52017-05-08 11:52:38 -070014#include <memory>
ossuf515ab82016-12-07 04:52:58 -080015#include <string>
16#include <vector>
17
Steve Anton10542f22019-01-11 09:11:00 -080018#include "api/media_types.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "call/audio_receive_stream.h"
20#include "call/audio_send_stream.h"
Paulina Hensman11b34f42018-04-09 14:24:52 +020021#include "call/call_config.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020022#include "call/flexfec_receive_stream.h"
Niels Möller70082872018-08-07 11:03:12 +020023#include "call/packet_receiver.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020024#include "call/rtp_transport_controller_send_interface.h"
25#include "call/video_receive_stream.h"
26#include "call/video_send_stream.h"
Steve Anton10542f22019-01-11 09:11:00 -080027#include "rtc_base/bitrate_allocation_strategy.h"
28#include "rtc_base/copy_on_write_buffer.h"
Sebastian Jansson12985412018-10-15 21:06:26 +020029#include "rtc_base/network/sent_packet.h"
Steve Anton10542f22019-01-11 09:11:00 -080030#include "rtc_base/network_route.h"
ossuf515ab82016-12-07 04:52:58 -080031
32namespace webrtc {
33
ossuf515ab82016-12-07 04:52:58 -080034// A Call instance can contain several send and/or receive streams. All streams
35// are assumed to have the same remote endpoint and will share bitrate estimates
36// etc.
37class Call {
38 public:
Niels Möller8366e172018-02-14 12:20:13 +010039 using Config = CallConfig;
ossuf515ab82016-12-07 04:52:58 -080040
41 struct Stats {
42 std::string ToString(int64_t time_ms) const;
43
44 int send_bandwidth_bps = 0; // Estimated available send bandwidth.
45 int max_padding_bitrate_bps = 0; // Cumulative configured max padding.
46 int recv_bandwidth_bps = 0; // Estimated available receive bandwidth.
47 int64_t pacer_delay_ms = 0;
48 int64_t rtt_ms = -1;
49 };
50
51 static Call* Create(const Call::Config& config);
52
zstein7cb69d52017-05-08 11:52:38 -070053 // Allows mocking |transport_send| for testing.
54 static Call* Create(
55 const Call::Config& config,
56 std::unique_ptr<RtpTransportControllerSendInterface> transport_send);
57
ossuf515ab82016-12-07 04:52:58 -080058 virtual AudioSendStream* CreateAudioSendStream(
59 const AudioSendStream::Config& config) = 0;
Piotr (Peter) Slatalacc8e8bb2018-11-15 08:26:19 -080060
61 // Gets called when media transport is created or removed.
62 virtual void MediaTransportChange(
63 MediaTransportInterface* media_transport_interface) = 0;
64
ossuf515ab82016-12-07 04:52:58 -080065 virtual void DestroyAudioSendStream(AudioSendStream* send_stream) = 0;
66
67 virtual AudioReceiveStream* CreateAudioReceiveStream(
68 const AudioReceiveStream::Config& config) = 0;
69 virtual void DestroyAudioReceiveStream(
70 AudioReceiveStream* receive_stream) = 0;
71
72 virtual VideoSendStream* CreateVideoSendStream(
73 VideoSendStream::Config config,
74 VideoEncoderConfig encoder_config) = 0;
Ying Wang3b790f32018-01-19 17:58:57 +010075 virtual VideoSendStream* CreateVideoSendStream(
76 VideoSendStream::Config config,
77 VideoEncoderConfig encoder_config,
78 std::unique_ptr<FecController> fec_controller);
ossuf515ab82016-12-07 04:52:58 -080079 virtual void DestroyVideoSendStream(VideoSendStream* send_stream) = 0;
80
81 virtual VideoReceiveStream* CreateVideoReceiveStream(
82 VideoReceiveStream::Config configuration) = 0;
83 virtual void DestroyVideoReceiveStream(
84 VideoReceiveStream* receive_stream) = 0;
85
brandtrfb45c6c2017-01-27 06:47:55 -080086 // In order for a created VideoReceiveStream to be aware that it is
87 // protected by a FlexfecReceiveStream, the latter should be created before
88 // the former.
ossuf515ab82016-12-07 04:52:58 -080089 virtual FlexfecReceiveStream* CreateFlexfecReceiveStream(
brandtr446fcb62016-12-08 04:14:24 -080090 const FlexfecReceiveStream::Config& config) = 0;
ossuf515ab82016-12-07 04:52:58 -080091 virtual void DestroyFlexfecReceiveStream(
92 FlexfecReceiveStream* receive_stream) = 0;
93
94 // All received RTP and RTCP packets for the call should be inserted to this
95 // PacketReceiver. The PacketReceiver pointer is valid as long as the
96 // Call instance exists.
97 virtual PacketReceiver* Receiver() = 0;
98
Sebastian Jansson8f83b422018-02-21 13:07:13 +010099 // This is used to access the transport controller send instance owned by
100 // Call. The send transport controller is currently owned by Call for legacy
101 // reasons. (for instance variants of call tests are built on this assumtion)
102 // TODO(srte): Move ownership of transport controller send out of Call and
103 // remove this method interface.
104 virtual RtpTransportControllerSendInterface* GetTransportControllerSend() = 0;
105
ossuf515ab82016-12-07 04:52:58 -0800106 // Returns the call statistics, such as estimated send and receive bandwidth,
107 // pacing delay, etc.
108 virtual Stats GetStats() const = 0;
109
Alex Narest78609d52017-10-20 10:37:47 +0200110 virtual void SetBitrateAllocationStrategy(
111 std::unique_ptr<rtc::BitrateAllocationStrategy>
112 bitrate_allocation_strategy) = 0;
113
ossuf515ab82016-12-07 04:52:58 -0800114 // TODO(skvlad): When the unbundled case with multiple streams for the same
115 // media type going over different networks is supported, track the state
116 // for each stream separately. Right now it's global per media type.
117 virtual void SignalChannelNetworkState(MediaType media,
118 NetworkState state) = 0;
119
Stefan Holmer64be7fa2018-10-04 15:21:55 +0200120 virtual void OnAudioTransportOverheadChanged(
ossuf515ab82016-12-07 04:52:58 -0800121 int transport_overhead_per_packet) = 0;
122
ossuf515ab82016-12-07 04:52:58 -0800123 virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0;
124
125 virtual ~Call() {}
126};
127
128} // namespace webrtc
129
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200130#endif // CALL_CALL_H_