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