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