ossu | f515ab8 | 2016-12-07 12:52:58 | [diff] [blame] | 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 | */ |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 10 | #ifndef CALL_CALL_H_ |
| 11 | #define CALL_CALL_H_ |
ossu | f515ab8 | 2016-12-07 12:52:58 | [diff] [blame] | 12 | |
zstein | a5e0df6 | 2017-06-14 18:41:48 | [diff] [blame] | 13 | #include <algorithm> |
zstein | 7cb69d5 | 2017-05-08 18:52:38 | [diff] [blame] | 14 | #include <memory> |
ossu | f515ab8 | 2016-12-07 12:52:58 | [diff] [blame] | 15 | #include <string> |
| 16 | #include <vector> |
| 17 | |
Patrik Höglund | b6b29e0 | 2018-06-21 14:58:01 | [diff] [blame] | 18 | #include "api/mediatypes.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 19 | #include "call/audio_receive_stream.h" |
| 20 | #include "call/audio_send_stream.h" |
Paulina Hensman | 11b34f4 | 2018-04-09 12:24:52 | [diff] [blame] | 21 | #include "call/call_config.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 22 | #include "call/flexfec_receive_stream.h" |
Niels Möller | 7008287 | 2018-08-07 09:03:12 | [diff] [blame] | 23 | #include "call/packet_receiver.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 24 | #include "call/rtp_transport_controller_send_interface.h" |
| 25 | #include "call/video_receive_stream.h" |
| 26 | #include "call/video_send_stream.h" |
Mirko Bonadei | 7120742 | 2017-09-15 11:58:09 | [diff] [blame] | 27 | #include "common_types.h" // NOLINT(build/include) |
Alex Narest | 78609d5 | 2017-10-20 08:37:47 | [diff] [blame] | 28 | #include "rtc_base/bitrateallocationstrategy.h" |
Danil Chapovalov | 292a73e | 2017-12-07 16:00:40 | [diff] [blame] | 29 | #include "rtc_base/copyonwritebuffer.h" |
Sebastian Jansson | 1298541 | 2018-10-15 19:06:26 | [diff] [blame^] | 30 | #include "rtc_base/network/sent_packet.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 31 | #include "rtc_base/networkroute.h" |
ossu | f515ab8 | 2016-12-07 12:52:58 | [diff] [blame] | 32 | |
| 33 | namespace webrtc { |
| 34 | |
ossu | f515ab8 | 2016-12-07 12:52:58 | [diff] [blame] | 35 | // A Call instance can contain several send and/or receive streams. All streams |
| 36 | // are assumed to have the same remote endpoint and will share bitrate estimates |
| 37 | // etc. |
| 38 | class Call { |
| 39 | public: |
Niels Möller | 8366e17 | 2018-02-14 11:20:13 | [diff] [blame] | 40 | using Config = CallConfig; |
ossu | f515ab8 | 2016-12-07 12:52:58 | [diff] [blame] | 41 | |
| 42 | struct Stats { |
| 43 | std::string ToString(int64_t time_ms) const; |
| 44 | |
| 45 | int send_bandwidth_bps = 0; // Estimated available send bandwidth. |
| 46 | int max_padding_bitrate_bps = 0; // Cumulative configured max padding. |
| 47 | int recv_bandwidth_bps = 0; // Estimated available receive bandwidth. |
| 48 | int64_t pacer_delay_ms = 0; |
| 49 | int64_t rtt_ms = -1; |
| 50 | }; |
| 51 | |
| 52 | static Call* Create(const Call::Config& config); |
| 53 | |
zstein | 7cb69d5 | 2017-05-08 18:52:38 | [diff] [blame] | 54 | // Allows mocking |transport_send| for testing. |
| 55 | static Call* Create( |
| 56 | const Call::Config& config, |
| 57 | std::unique_ptr<RtpTransportControllerSendInterface> transport_send); |
| 58 | |
ossu | f515ab8 | 2016-12-07 12:52:58 | [diff] [blame] | 59 | virtual AudioSendStream* CreateAudioSendStream( |
| 60 | const AudioSendStream::Config& config) = 0; |
| 61 | virtual void DestroyAudioSendStream(AudioSendStream* send_stream) = 0; |
| 62 | |
| 63 | virtual AudioReceiveStream* CreateAudioReceiveStream( |
| 64 | const AudioReceiveStream::Config& config) = 0; |
| 65 | virtual void DestroyAudioReceiveStream( |
| 66 | AudioReceiveStream* receive_stream) = 0; |
| 67 | |
| 68 | virtual VideoSendStream* CreateVideoSendStream( |
| 69 | VideoSendStream::Config config, |
| 70 | VideoEncoderConfig encoder_config) = 0; |
Ying Wang | 3b790f3 | 2018-01-19 16:58:57 | [diff] [blame] | 71 | virtual VideoSendStream* CreateVideoSendStream( |
| 72 | VideoSendStream::Config config, |
| 73 | VideoEncoderConfig encoder_config, |
| 74 | std::unique_ptr<FecController> fec_controller); |
ossu | f515ab8 | 2016-12-07 12:52:58 | [diff] [blame] | 75 | virtual void DestroyVideoSendStream(VideoSendStream* send_stream) = 0; |
| 76 | |
| 77 | virtual VideoReceiveStream* CreateVideoReceiveStream( |
| 78 | VideoReceiveStream::Config configuration) = 0; |
| 79 | virtual void DestroyVideoReceiveStream( |
| 80 | VideoReceiveStream* receive_stream) = 0; |
| 81 | |
brandtr | fb45c6c | 2017-01-27 14:47:55 | [diff] [blame] | 82 | // In order for a created VideoReceiveStream to be aware that it is |
| 83 | // protected by a FlexfecReceiveStream, the latter should be created before |
| 84 | // the former. |
ossu | f515ab8 | 2016-12-07 12:52:58 | [diff] [blame] | 85 | virtual FlexfecReceiveStream* CreateFlexfecReceiveStream( |
brandtr | 446fcb6 | 2016-12-08 12:14:24 | [diff] [blame] | 86 | const FlexfecReceiveStream::Config& config) = 0; |
ossu | f515ab8 | 2016-12-07 12:52:58 | [diff] [blame] | 87 | virtual void DestroyFlexfecReceiveStream( |
| 88 | FlexfecReceiveStream* receive_stream) = 0; |
| 89 | |
| 90 | // All received RTP and RTCP packets for the call should be inserted to this |
| 91 | // PacketReceiver. The PacketReceiver pointer is valid as long as the |
| 92 | // Call instance exists. |
| 93 | virtual PacketReceiver* Receiver() = 0; |
| 94 | |
Sebastian Jansson | 8f83b42 | 2018-02-21 12:07:13 | [diff] [blame] | 95 | // This is used to access the transport controller send instance owned by |
| 96 | // Call. The send transport controller is currently owned by Call for legacy |
| 97 | // reasons. (for instance variants of call tests are built on this assumtion) |
| 98 | // TODO(srte): Move ownership of transport controller send out of Call and |
| 99 | // remove this method interface. |
| 100 | virtual RtpTransportControllerSendInterface* GetTransportControllerSend() = 0; |
| 101 | |
ossu | f515ab8 | 2016-12-07 12:52:58 | [diff] [blame] | 102 | // Returns the call statistics, such as estimated send and receive bandwidth, |
| 103 | // pacing delay, etc. |
| 104 | virtual Stats GetStats() const = 0; |
| 105 | |
Alex Narest | 78609d5 | 2017-10-20 08:37:47 | [diff] [blame] | 106 | virtual void SetBitrateAllocationStrategy( |
| 107 | std::unique_ptr<rtc::BitrateAllocationStrategy> |
| 108 | bitrate_allocation_strategy) = 0; |
| 109 | |
ossu | f515ab8 | 2016-12-07 12:52:58 | [diff] [blame] | 110 | // TODO(skvlad): When the unbundled case with multiple streams for the same |
| 111 | // media type going over different networks is supported, track the state |
| 112 | // for each stream separately. Right now it's global per media type. |
| 113 | virtual void SignalChannelNetworkState(MediaType media, |
| 114 | NetworkState state) = 0; |
| 115 | |
Stefan Holmer | 64be7fa | 2018-10-04 13:21:55 | [diff] [blame] | 116 | virtual void OnAudioTransportOverheadChanged( |
ossu | f515ab8 | 2016-12-07 12:52:58 | [diff] [blame] | 117 | int transport_overhead_per_packet) = 0; |
| 118 | |
ossu | f515ab8 | 2016-12-07 12:52:58 | [diff] [blame] | 119 | virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0; |
| 120 | |
| 121 | virtual ~Call() {} |
| 122 | }; |
| 123 | |
| 124 | } // namespace webrtc |
| 125 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 126 | #endif // CALL_CALL_H_ |