blob: e426cc5c4be24d589872d8e052d6c76475b74555 [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"
pbos@webrtc.org24e20892013-10-28 16:32:0119#include "webrtc/video_receive_stream.h"
20#include "webrtc/video_send_stream.h"
mflodman@webrtc.org06e80262013-04-18 12:02:5221
mflodman@webrtc.org06e80262013-04-18 12:02:5222namespace webrtc {
mflodman@webrtc.org06e80262013-04-18 12:02:5223
Fredrik Solenbergee9b72e2015-06-08 11:04:5624class AudioDeviceModule;
25class AudioProcessing;
mflodman@webrtc.org06e80262013-04-18 12:02:5226class VoiceEngine;
Fredrik Solenbergee9b72e2015-06-08 11:04:5627class VoiceEngineObserver;
mflodman@webrtc.org06e80262013-04-18 12:02:5228
29const char* Version();
30
Fredrik Solenbergad867862015-04-29 13:24:0131enum class MediaType {
32 ANY,
33 AUDIO,
34 VIDEO,
35 DATA
36};
37
mflodman@webrtc.org06e80262013-04-18 12:02:5238class PacketReceiver {
39 public:
pbos@webrtc.orgbc57e0f2014-05-14 13:57:1240 enum DeliveryStatus {
41 DELIVERY_OK,
42 DELIVERY_UNKNOWN_SSRC,
43 DELIVERY_PACKET_ERROR,
44 };
45
Fredrik Solenbergad867862015-04-29 13:24:0146 virtual DeliveryStatus DeliverPacket(MediaType media_type,
47 const uint8_t* packet,
stefan30bf7782015-09-08 12:36:1548 size_t length,
49 const PacketTime& packet_time) = 0;
50
mflodman@webrtc.org06e80262013-04-18 12:02:5251 protected:
52 virtual ~PacketReceiver() {}
53};
54
asapersson@webrtc.org8ef65482014-01-31 10:05:0755// Callback interface for reporting when a system overuse is detected.
pbos@webrtc.orgd3e3c9b2014-10-03 11:25:4556class LoadObserver {
asapersson@webrtc.org8ef65482014-01-31 10:05:0757 public:
pbos@webrtc.orgd3e3c9b2014-10-03 11:25:4558 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.org8ef65482014-01-31 10:05:0763
64 protected:
pbos@webrtc.orgd3e3c9b2014-10-03 11:25:4565 virtual ~LoadObserver() {}
asapersson@webrtc.org8ef65482014-01-31 10:05:0766};
67
pbos@webrtc.orgbf6d5722013-09-09 15:04:2568// 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.
71class Call {
mflodman@webrtc.org06e80262013-04-18 12:02:5272 public:
mflodman@webrtc.orgbf76ae22013-07-23 11:35:0073 struct Config {
pbos@webrtc.org7da30672014-10-14 11:52:1074 static const int kDefaultStartBitrateBps;
mflodman@webrtc.orgbf76ae22013-07-23 11:35:0075
pbos@webrtc.orgbf6d5722013-09-09 15:04:2576 // VoiceEngine used for audio/video synchronization for this Call.
Fredrik Solenberge48d6772015-06-11 10:38:3877 VoiceEngine* voice_engine = nullptr;
pbos@webrtc.orgc2014fd2013-08-14 13:52:5278
pbos@webrtc.org5e3f6b42014-11-25 14:03:3479 // Bitrate config used until valid bitrate estimates are calculated. Also
80 // used to cap total bitrate used.
pbos@webrtc.org5e3f6b42014-11-25 14:03:3481 struct BitrateConfig {
Fredrik Solenberge48d6772015-06-11 10:38:3882 int min_bitrate_bps = 0;
83 int start_bitrate_bps = kDefaultStartBitrateBps;
84 int max_bitrate_bps = -1;
Stefan Holmerca55fa12015-03-26 10:11:0685 } bitrate_config;
Fredrik Solenbergee9b72e2015-06-08 11:04:5686
87 struct AudioConfig {
Fredrik Solenberge48d6772015-06-11 10:38:3888 AudioDeviceModule* audio_device_manager = nullptr;
89 AudioProcessing* audio_processing = nullptr;
90 VoiceEngineObserver* voice_engine_observer = nullptr;
Fredrik Solenbergee9b72e2015-06-08 11:04:5691 } audio_config;
mflodman@webrtc.orgbf76ae22013-07-23 11:35:0092 };
93
stefan@webrtc.org52322672014-11-05 14:05:2994 struct Stats {
Fredrik Solenberge48d6772015-06-11 10:38:3895 int send_bandwidth_bps = 0;
96 int recv_bandwidth_bps = 0;
97 int64_t pacer_delay_ms = 0;
98 int64_t rtt_ms = -1;
stefan@webrtc.org52322672014-11-05 14:05:2999 };
100
pbos@webrtc.orgbf6d5722013-09-09 15:04:25101 static Call* Create(const Call::Config& config);
pbos@webrtc.orgc2014fd2013-08-14 13:52:52102
Fredrik Solenbergee9b72e2015-06-08 11:04:56103 virtual AudioSendStream* CreateAudioSendStream(
104 const AudioSendStream::Config& config) = 0;
105 virtual void DestroyAudioSendStream(AudioSendStream* send_stream) = 0;
106
Fredrik Solenbergad867862015-04-29 13:24:01107 virtual AudioReceiveStream* CreateAudioReceiveStream(
108 const AudioReceiveStream::Config& config) = 0;
109 virtual void DestroyAudioReceiveStream(
110 AudioReceiveStream* receive_stream) = 0;
111
pbos@webrtc.org964d78e2013-11-20 10:40:25112 virtual VideoSendStream* CreateVideoSendStream(
pbos@webrtc.orgbdfcddf2014-06-06 10:49:19113 const VideoSendStream::Config& config,
pbos@webrtc.org58b51402014-09-19 12:30:25114 const VideoEncoderConfig& encoder_config) = 0;
pbos@webrtc.org12a93e02013-11-21 13:49:43115 virtual void DestroyVideoSendStream(VideoSendStream* send_stream) = 0;
mflodman@webrtc.org06e80262013-04-18 12:02:52116
pbos@webrtc.org964d78e2013-11-20 10:40:25117 virtual VideoReceiveStream* CreateVideoReceiveStream(
pbos@webrtc.org6f1c3ef2013-06-05 11:33:21118 const VideoReceiveStream::Config& config) = 0;
pbos@webrtc.org12a93e02013-11-21 13:49:43119 virtual void DestroyVideoReceiveStream(
120 VideoReceiveStream* receive_stream) = 0;
mflodman@webrtc.org06e80262013-04-18 12:02:52121
122 // All received RTP and RTCP packets for the call should be inserted to this
123 // PacketReceiver. The PacketReceiver pointer is valid as long as the
pbos@webrtc.orgbf6d5722013-09-09 15:04:25124 // Call instance exists.
mflodman@webrtc.org06e80262013-04-18 12:02:52125 virtual PacketReceiver* Receiver() = 0;
126
stefan@webrtc.org52322672014-11-05 14:05:29127 // Returns the call statistics, such as estimated send and receive bandwidth,
128 // pacing delay, etc.
129 virtual Stats GetStats() const = 0;
mflodman@webrtc.org06e80262013-04-18 12:02:52130
pbos@webrtc.org5e3f6b42014-11-25 14:03:34131 // TODO(pbos): Like BitrateConfig above this is currently per-stream instead
132 // of maximum for entire Call. This should be fixed along with the above.
133 // Specifying a start bitrate (>0) will currently reset the current bitrate
134 // estimate. This is due to how the 'x-google-start-bitrate' flag is currently
135 // implemented.
136 virtual void SetBitrateConfig(
137 const Config::BitrateConfig& bitrate_config) = 0;
pbos@webrtc.org9b707ca2014-09-03 16:17:12138 virtual void SignalNetworkState(NetworkState state) = 0;
139
pbos@webrtc.orgbf6d5722013-09-09 15:04:25140 virtual ~Call() {}
mflodman@webrtc.org06e80262013-04-18 12:02:52141};
Jelena Marusic2fb88e42015-07-16 07:30:09142
mflodman@webrtc.org06e80262013-04-18 12:02:52143} // namespace webrtc
144
mflodman@webrtc.org5e0cbcf2013-12-18 09:46:22145#endif // WEBRTC_CALL_H_