blob: 779ffe9d0de68e015117792614e6d2a10e68e83d [file] [log] [blame]
mflodman@webrtc.org06e80262013-04-18 12:02:521/*
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.org5e0cbcf2013-12-18 09:46:2210#ifndef WEBRTC_CALL_H_
11#define WEBRTC_CALL_H_
mflodman@webrtc.org06e80262013-04-18 12:02:5212
13#include <string>
14#include <vector>
15
16#include "webrtc/common_types.h"
Fredrik Solenbergad867862015-04-29 13:24:0117#include "webrtc/audio_receive_stream.h"
Fredrik Solenbergee9b72e2015-06-08 11:04:5618#include "webrtc/audio_send_stream.h"
solenbergb0f22c52015-11-06 23:34:4919#include "webrtc/audio_state.h"
Honghai Zhang512897c2016-04-19 22:41:3620#include "webrtc/base/networkroute.h"
ivoc23ea12e2016-07-04 14:06:5521#include "webrtc/base/platform_file.h"
stefan15b20992015-10-15 14:26:0722#include "webrtc/base/socket.h"
pbos@webrtc.org24e20892013-10-28 16:32:0123#include "webrtc/video_receive_stream.h"
24#include "webrtc/video_send_stream.h"
mflodman@webrtc.org06e80262013-04-18 12:02:5225
mflodman@webrtc.org06e80262013-04-18 12:02:5226namespace webrtc {
mflodman@webrtc.org06e80262013-04-18 12:02:5227
Fredrik Solenbergee9b72e2015-06-08 11:04:5628class AudioProcessing;
mflodman@webrtc.org06e80262013-04-18 12:02:5229
30const char* Version();
31
Fredrik Solenbergad867862015-04-29 13:24:0132enum class MediaType {
33 ANY,
34 AUDIO,
35 VIDEO,
36 DATA
37};
38
mflodman@webrtc.org06e80262013-04-18 12:02:5239class PacketReceiver {
40 public:
pbos@webrtc.orgbc57e0f2014-05-14 13:57:1241 enum DeliveryStatus {
42 DELIVERY_OK,
43 DELIVERY_UNKNOWN_SSRC,
44 DELIVERY_PACKET_ERROR,
45 };
46
Fredrik Solenbergad867862015-04-29 13:24:0147 virtual DeliveryStatus DeliverPacket(MediaType media_type,
48 const uint8_t* packet,
stefan30bf7782015-09-08 12:36:1549 size_t length,
50 const PacketTime& packet_time) = 0;
51
mflodman@webrtc.org06e80262013-04-18 12:02:5252 protected:
53 virtual ~PacketReceiver() {}
54};
55
asapersson@webrtc.org8ef65482014-01-31 10:05:0756// Callback interface for reporting when a system overuse is detected.
pbos@webrtc.orgd3e3c9b2014-10-03 11:25:4557class LoadObserver {
asapersson@webrtc.org8ef65482014-01-31 10:05:0758 public:
pbos@webrtc.orgd3e3c9b2014-10-03 11:25:4559 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.org8ef65482014-01-31 10:05:0764
65 protected:
pbos@webrtc.orgd3e3c9b2014-10-03 11:25:4566 virtual ~LoadObserver() {}
asapersson@webrtc.org8ef65482014-01-31 10:05:0767};
68
pbos@webrtc.orgbf6d5722013-09-09 15:04:2569// 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.
72class Call {
mflodman@webrtc.org06e80262013-04-18 12:02:5273 public:
mflodman@webrtc.orgbf76ae22013-07-23 11:35:0074 struct Config {
pbos@webrtc.org7da30672014-10-14 11:52:1075 static const int kDefaultStartBitrateBps;
mflodman@webrtc.orgbf76ae22013-07-23 11:35:0076
pbos@webrtc.org5e3f6b42014-11-25 14:03:3477 // Bitrate config used until valid bitrate estimates are calculated. Also
78 // used to cap total bitrate used.
pbos@webrtc.org5e3f6b42014-11-25 14:03:3479 struct BitrateConfig {
Fredrik Solenberge48d6772015-06-11 10:38:3880 int min_bitrate_bps = 0;
81 int start_bitrate_bps = kDefaultStartBitrateBps;
82 int max_bitrate_bps = -1;
Stefan Holmerca55fa12015-03-26 10:11:0683 } bitrate_config;
Fredrik Solenbergee9b72e2015-06-08 11:04:5684
solenbergb0f22c52015-11-06 23:34:4985 // 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.orgbf76ae22013-07-23 11:35:0092 };
93
stefan@webrtc.org52322672014-11-05 14:05:2994 struct Stats {
sprangd7aa8192016-07-06 07:54:2895 int send_bandwidth_bps = 0; // Estimated available send bandwidth.
96 int max_padding_bitrate_bps = 0; // Cumulative configured max padding.
97 int recv_bandwidth_bps = 0; // Estimated available receive bandwidth.
Fredrik Solenberge48d6772015-06-11 10:38:3898 int64_t pacer_delay_ms = 0;
99 int64_t rtt_ms = -1;
stefan@webrtc.org52322672014-11-05 14:05:29100 };
101
pbos@webrtc.orgbf6d5722013-09-09 15:04:25102 static Call* Create(const Call::Config& config);
pbos@webrtc.orgc2014fd2013-08-14 13:52:52103
Fredrik Solenbergee9b72e2015-06-08 11:04:56104 virtual AudioSendStream* CreateAudioSendStream(
105 const AudioSendStream::Config& config) = 0;
106 virtual void DestroyAudioSendStream(AudioSendStream* send_stream) = 0;
107
Fredrik Solenbergad867862015-04-29 13:24:01108 virtual AudioReceiveStream* CreateAudioReceiveStream(
109 const AudioReceiveStream::Config& config) = 0;
110 virtual void DestroyAudioReceiveStream(
111 AudioReceiveStream* receive_stream) = 0;
112
pbos@webrtc.org964d78e2013-11-20 10:40:25113 virtual VideoSendStream* CreateVideoSendStream(
pbos@webrtc.orgbdfcddf2014-06-06 10:49:19114 const VideoSendStream::Config& config,
pbos@webrtc.org58b51402014-09-19 12:30:25115 const VideoEncoderConfig& encoder_config) = 0;
pbos@webrtc.org12a93e02013-11-21 13:49:43116 virtual void DestroyVideoSendStream(VideoSendStream* send_stream) = 0;
mflodman@webrtc.org06e80262013-04-18 12:02:52117
pbos@webrtc.org964d78e2013-11-20 10:40:25118 virtual VideoReceiveStream* CreateVideoReceiveStream(
Tommi87875ef2016-06-10 15:58:01119 VideoReceiveStream::Config configuration) = 0;
pbos@webrtc.org12a93e02013-11-21 13:49:43120 virtual void DestroyVideoReceiveStream(
121 VideoReceiveStream* receive_stream) = 0;
mflodman@webrtc.org06e80262013-04-18 12:02:52122
123 // All received RTP and RTCP packets for the call should be inserted to this
124 // PacketReceiver. The PacketReceiver pointer is valid as long as the
pbos@webrtc.orgbf6d5722013-09-09 15:04:25125 // Call instance exists.
mflodman@webrtc.org06e80262013-04-18 12:02:52126 virtual PacketReceiver* Receiver() = 0;
127
stefan@webrtc.org52322672014-11-05 14:05:29128 // Returns the call statistics, such as estimated send and receive bandwidth,
129 // pacing delay, etc.
130 virtual Stats GetStats() const = 0;
mflodman@webrtc.org06e80262013-04-18 12:02:52131
pbos@webrtc.org5e3f6b42014-11-25 14:03:34132 // TODO(pbos): Like BitrateConfig above this is currently per-stream instead
133 // of maximum for entire Call. This should be fixed along with the above.
134 // Specifying a start bitrate (>0) will currently reset the current bitrate
135 // estimate. This is due to how the 'x-google-start-bitrate' flag is currently
136 // implemented.
137 virtual void SetBitrateConfig(
138 const Config::BitrateConfig& bitrate_config) = 0;
skvladee1e4ed2016-03-22 22:32:27139
140 // TODO(skvlad): When the unbundled case with multiple streams for the same
141 // media type going over different networks is supported, track the state
142 // for each stream separately. Right now it's global per media type.
143 virtual void SignalChannelNetworkState(MediaType media,
144 NetworkState state) = 0;
pbos@webrtc.org9b707ca2014-09-03 16:17:12145
Honghai Zhang512897c2016-04-19 22:41:36146 virtual void OnNetworkRouteChanged(
147 const std::string& transport_name,
148 const rtc::NetworkRoute& network_route) = 0;
149
stefan15b20992015-10-15 14:26:07150 virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0;
151
ivoc23ea12e2016-07-04 14:06:55152 virtual bool StartEventLog(rtc::PlatformFile log_file,
153 int64_t max_size_bytes) = 0;
154 virtual void StopEventLog() = 0;
155
pbos@webrtc.orgbf6d5722013-09-09 15:04:25156 virtual ~Call() {}
mflodman@webrtc.org06e80262013-04-18 12:02:52157};
Jelena Marusic2fb88e42015-07-16 07:30:09158
mflodman@webrtc.org06e80262013-04-18 12:02:52159} // namespace webrtc
160
mflodman@webrtc.org5e0cbcf2013-12-18 09:46:22161#endif // WEBRTC_CALL_H_