mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [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 | */ |
mflodman@webrtc.org | b429e51 | 2013-12-18 09:46:22 +0000 | [diff] [blame] | 10 | #ifndef WEBRTC_CALL_H_ |
| 11 | #define WEBRTC_CALL_H_ |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 12 | |
| 13 | #include <string> |
| 14 | #include <vector> |
| 15 | |
| 16 | #include "webrtc/common_types.h" |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 17 | #include "webrtc/audio_receive_stream.h" |
Fredrik Solenberg | 04f4931 | 2015-06-08 13:04:56 +0200 | [diff] [blame] | 18 | #include "webrtc/audio_send_stream.h" |
solenberg | 566ef24 | 2015-11-06 15:34:49 -0800 | [diff] [blame] | 19 | #include "webrtc/audio_state.h" |
Honghai Zhang | 0e533ef | 2016-04-19 15:41:36 -0700 | [diff] [blame] | 20 | #include "webrtc/base/networkroute.h" |
ivoc | 14d5dbe | 2016-07-04 07:06:55 -0700 | [diff] [blame] | 21 | #include "webrtc/base/platform_file.h" |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 22 | #include "webrtc/base/socket.h" |
pbos@webrtc.org | 16e03b7 | 2013-10-28 16:32:01 +0000 | [diff] [blame] | 23 | #include "webrtc/video_receive_stream.h" |
| 24 | #include "webrtc/video_send_stream.h" |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 25 | |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 26 | namespace webrtc { |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 27 | |
Fredrik Solenberg | 04f4931 | 2015-06-08 13:04:56 +0200 | [diff] [blame] | 28 | class AudioProcessing; |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 29 | |
| 30 | const char* Version(); |
| 31 | |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 32 | enum class MediaType { |
| 33 | ANY, |
| 34 | AUDIO, |
| 35 | VIDEO, |
| 36 | DATA |
| 37 | }; |
| 38 | |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 39 | class PacketReceiver { |
| 40 | public: |
pbos@webrtc.org | caba2d2 | 2014-05-14 13:57:12 +0000 | [diff] [blame] | 41 | enum DeliveryStatus { |
| 42 | DELIVERY_OK, |
| 43 | DELIVERY_UNKNOWN_SSRC, |
| 44 | DELIVERY_PACKET_ERROR, |
| 45 | }; |
| 46 | |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 47 | virtual DeliveryStatus DeliverPacket(MediaType media_type, |
| 48 | const uint8_t* packet, |
stefan | 68786d2 | 2015-09-08 05:36:15 -0700 | [diff] [blame] | 49 | size_t length, |
| 50 | const PacketTime& packet_time) = 0; |
| 51 | |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 52 | protected: |
| 53 | virtual ~PacketReceiver() {} |
| 54 | }; |
| 55 | |
asapersson@webrtc.org | bdc5ed2 | 2014-01-31 10:05:07 +0000 | [diff] [blame] | 56 | // Callback interface for reporting when a system overuse is detected. |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 57 | class LoadObserver { |
asapersson@webrtc.org | bdc5ed2 | 2014-01-31 10:05:07 +0000 | [diff] [blame] | 58 | public: |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 59 | enum Load { kOveruse, kUnderuse }; |
| 60 | |
| 61 | // Triggered when overuse is detected or when we believe the system can take |
| 62 | // more load. |
| 63 | virtual void OnLoadUpdate(Load load) = 0; |
asapersson@webrtc.org | bdc5ed2 | 2014-01-31 10:05:07 +0000 | [diff] [blame] | 64 | |
| 65 | protected: |
pbos@webrtc.org | 42684be | 2014-10-03 11:25:45 +0000 | [diff] [blame] | 66 | virtual ~LoadObserver() {} |
asapersson@webrtc.org | bdc5ed2 | 2014-01-31 10:05:07 +0000 | [diff] [blame] | 67 | }; |
| 68 | |
pbos@webrtc.org | 841c8a4 | 2013-09-09 15:04:25 +0000 | [diff] [blame] | 69 | // A Call instance can contain several send and/or receive streams. All streams |
| 70 | // are assumed to have the same remote endpoint and will share bitrate estimates |
| 71 | // etc. |
| 72 | class Call { |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 73 | public: |
mflodman@webrtc.org | 6879c8a | 2013-07-23 11:35:00 +0000 | [diff] [blame] | 74 | struct Config { |
pbos@webrtc.org | a73a678 | 2014-10-14 11:52:10 +0000 | [diff] [blame] | 75 | static const int kDefaultStartBitrateBps; |
mflodman@webrtc.org | 6879c8a | 2013-07-23 11:35:00 +0000 | [diff] [blame] | 76 | |
pbos@webrtc.org | 0087318 | 2014-11-25 14:03:34 +0000 | [diff] [blame] | 77 | // Bitrate config used until valid bitrate estimates are calculated. Also |
| 78 | // used to cap total bitrate used. |
pbos@webrtc.org | 0087318 | 2014-11-25 14:03:34 +0000 | [diff] [blame] | 79 | struct BitrateConfig { |
Fredrik Solenberg | 78fb3b3 | 2015-06-11 12:38:38 +0200 | [diff] [blame] | 80 | int min_bitrate_bps = 0; |
| 81 | int start_bitrate_bps = kDefaultStartBitrateBps; |
| 82 | int max_bitrate_bps = -1; |
Stefan Holmer | e590416 | 2015-03-26 11:11:06 +0100 | [diff] [blame] | 83 | } bitrate_config; |
Fredrik Solenberg | 04f4931 | 2015-06-08 13:04:56 +0200 | [diff] [blame] | 84 | |
solenberg | 566ef24 | 2015-11-06 15:34:49 -0800 | [diff] [blame] | 85 | // AudioState which is possibly shared between multiple calls. |
| 86 | // TODO(solenberg): Change this to a shared_ptr once we can use C++11. |
| 87 | rtc::scoped_refptr<AudioState> audio_state; |
| 88 | |
| 89 | // Audio Processing Module to be used in this call. |
| 90 | // TODO(solenberg): Change this to a shared_ptr once we can use C++11. |
| 91 | AudioProcessing* audio_processing = nullptr; |
mflodman@webrtc.org | 6879c8a | 2013-07-23 11:35:00 +0000 | [diff] [blame] | 92 | }; |
| 93 | |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame] | 94 | struct Stats { |
asapersson | 2e5cfcd | 2016-08-11 08:41:18 -0700 | [diff] [blame] | 95 | std::string ToString(int64_t time_ms) const; |
| 96 | |
sprang | 9c0b551 | 2016-07-06 00:54:28 -0700 | [diff] [blame] | 97 | int send_bandwidth_bps = 0; // Estimated available send bandwidth. |
| 98 | int max_padding_bitrate_bps = 0; // Cumulative configured max padding. |
| 99 | int recv_bandwidth_bps = 0; // Estimated available receive bandwidth. |
Fredrik Solenberg | 78fb3b3 | 2015-06-11 12:38:38 +0200 | [diff] [blame] | 100 | int64_t pacer_delay_ms = 0; |
| 101 | int64_t rtt_ms = -1; |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame] | 102 | }; |
| 103 | |
pbos@webrtc.org | 841c8a4 | 2013-09-09 15:04:25 +0000 | [diff] [blame] | 104 | static Call* Create(const Call::Config& config); |
pbos@webrtc.org | fd39e13 | 2013-08-14 13:52:52 +0000 | [diff] [blame] | 105 | |
Fredrik Solenberg | 04f4931 | 2015-06-08 13:04:56 +0200 | [diff] [blame] | 106 | virtual AudioSendStream* CreateAudioSendStream( |
| 107 | const AudioSendStream::Config& config) = 0; |
| 108 | virtual void DestroyAudioSendStream(AudioSendStream* send_stream) = 0; |
| 109 | |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 110 | virtual AudioReceiveStream* CreateAudioReceiveStream( |
| 111 | const AudioReceiveStream::Config& config) = 0; |
| 112 | virtual void DestroyAudioReceiveStream( |
| 113 | AudioReceiveStream* receive_stream) = 0; |
| 114 | |
pbos@webrtc.org | 5a63655 | 2013-11-20 10:40:25 +0000 | [diff] [blame] | 115 | virtual VideoSendStream* CreateVideoSendStream( |
perkj | cc16836 | 2016-08-16 00:38:44 -0700 | [diff] [blame] | 116 | VideoSendStream::Config config, |
| 117 | VideoEncoderConfig encoder_config) = 0; |
pbos@webrtc.org | 2c46f8d | 2013-11-21 13:49:43 +0000 | [diff] [blame] | 118 | virtual void DestroyVideoSendStream(VideoSendStream* send_stream) = 0; |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 119 | |
pbos@webrtc.org | 5a63655 | 2013-11-20 10:40:25 +0000 | [diff] [blame] | 120 | virtual VideoReceiveStream* CreateVideoReceiveStream( |
Tommi | 733b547 | 2016-06-10 17:58:01 +0200 | [diff] [blame] | 121 | VideoReceiveStream::Config configuration) = 0; |
pbos@webrtc.org | 2c46f8d | 2013-11-21 13:49:43 +0000 | [diff] [blame] | 122 | virtual void DestroyVideoReceiveStream( |
| 123 | VideoReceiveStream* receive_stream) = 0; |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 124 | |
| 125 | // All received RTP and RTCP packets for the call should be inserted to this |
| 126 | // PacketReceiver. The PacketReceiver pointer is valid as long as the |
pbos@webrtc.org | 841c8a4 | 2013-09-09 15:04:25 +0000 | [diff] [blame] | 127 | // Call instance exists. |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 128 | virtual PacketReceiver* Receiver() = 0; |
| 129 | |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame] | 130 | // Returns the call statistics, such as estimated send and receive bandwidth, |
| 131 | // pacing delay, etc. |
| 132 | virtual Stats GetStats() const = 0; |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 133 | |
pbos@webrtc.org | 0087318 | 2014-11-25 14:03:34 +0000 | [diff] [blame] | 134 | // TODO(pbos): Like BitrateConfig above this is currently per-stream instead |
| 135 | // of maximum for entire Call. This should be fixed along with the above. |
| 136 | // Specifying a start bitrate (>0) will currently reset the current bitrate |
| 137 | // estimate. This is due to how the 'x-google-start-bitrate' flag is currently |
| 138 | // implemented. |
| 139 | virtual void SetBitrateConfig( |
| 140 | const Config::BitrateConfig& bitrate_config) = 0; |
skvlad | 7a43d25 | 2016-03-22 15:32:27 -0700 | [diff] [blame] | 141 | |
| 142 | // TODO(skvlad): When the unbundled case with multiple streams for the same |
| 143 | // media type going over different networks is supported, track the state |
| 144 | // for each stream separately. Right now it's global per media type. |
| 145 | virtual void SignalChannelNetworkState(MediaType media, |
| 146 | NetworkState state) = 0; |
pbos@webrtc.org | 26c0c41 | 2014-09-03 16:17:12 +0000 | [diff] [blame] | 147 | |
Honghai Zhang | 0e533ef | 2016-04-19 15:41:36 -0700 | [diff] [blame] | 148 | virtual void OnNetworkRouteChanged( |
| 149 | const std::string& transport_name, |
| 150 | const rtc::NetworkRoute& network_route) = 0; |
| 151 | |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 152 | virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0; |
| 153 | |
ivoc | 14d5dbe | 2016-07-04 07:06:55 -0700 | [diff] [blame] | 154 | virtual bool StartEventLog(rtc::PlatformFile log_file, |
| 155 | int64_t max_size_bytes) = 0; |
| 156 | virtual void StopEventLog() = 0; |
| 157 | |
pbos@webrtc.org | 841c8a4 | 2013-09-09 15:04:25 +0000 | [diff] [blame] | 158 | virtual ~Call() {} |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 159 | }; |
Jelena Marusic | cd67022 | 2015-07-16 09:30:09 +0200 | [diff] [blame] | 160 | |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 161 | } // namespace webrtc |
| 162 | |
mflodman@webrtc.org | b429e51 | 2013-12-18 09:46:22 +0000 | [diff] [blame] | 163 | #endif // WEBRTC_CALL_H_ |