blob: f21425fb99f9610af6a8005d97da367abed3f368 [file] [log] [blame]
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +00001/*
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.orgb429e512013-12-18 09:46:22 +000010#ifndef WEBRTC_CALL_H_
11#define WEBRTC_CALL_H_
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000012
13#include <string>
14#include <vector>
15
16#include "webrtc/common_types.h"
pbos@webrtc.org16e03b72013-10-28 16:32:01 +000017#include "webrtc/video_receive_stream.h"
18#include "webrtc/video_send_stream.h"
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000019
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000020namespace webrtc {
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000021
22class VoiceEngine;
23
24const char* Version();
25
26class PacketReceiver {
27 public:
pbos@webrtc.orgcaba2d22014-05-14 13:57:12 +000028 enum DeliveryStatus {
29 DELIVERY_OK,
30 DELIVERY_UNKNOWN_SSRC,
31 DELIVERY_PACKET_ERROR,
32 };
33
34 virtual DeliveryStatus DeliverPacket(const uint8_t* packet,
35 size_t length) = 0;
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000036
37 protected:
38 virtual ~PacketReceiver() {}
39};
40
asapersson@webrtc.orgbdc5ed22014-01-31 10:05:07 +000041// Callback interface for reporting when a system overuse is detected.
pbos@webrtc.org42684be2014-10-03 11:25:45 +000042class LoadObserver {
asapersson@webrtc.orgbdc5ed22014-01-31 10:05:07 +000043 public:
pbos@webrtc.org42684be2014-10-03 11:25:45 +000044 enum Load { kOveruse, kUnderuse };
45
46 // Triggered when overuse is detected or when we believe the system can take
47 // more load.
48 virtual void OnLoadUpdate(Load load) = 0;
asapersson@webrtc.orgbdc5ed22014-01-31 10:05:07 +000049
50 protected:
pbos@webrtc.org42684be2014-10-03 11:25:45 +000051 virtual ~LoadObserver() {}
asapersson@webrtc.orgbdc5ed22014-01-31 10:05:07 +000052};
53
pbos@webrtc.org841c8a42013-09-09 15:04:25 +000054// A Call instance can contain several send and/or receive streams. All streams
55// are assumed to have the same remote endpoint and will share bitrate estimates
56// etc.
57class Call {
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000058 public:
pbos@webrtc.org26c0c412014-09-03 16:17:12 +000059 enum NetworkState {
60 kNetworkUp,
61 kNetworkDown,
62 };
mflodman@webrtc.org6879c8a2013-07-23 11:35:00 +000063 struct Config {
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000064 explicit Config(newapi::Transport* send_transport)
stefan@webrtc.org7e9315b2013-12-04 10:24:26 +000065 : webrtc_config(NULL),
66 send_transport(send_transport),
pbos@webrtc.orgfd39e132013-08-14 13:52:52 +000067 voice_engine(NULL),
mflodman@webrtc.orgeb16b812014-06-16 08:57:39 +000068 overuse_callback(NULL),
pbos@webrtc.orga73a6782014-10-14 11:52:10 +000069 stream_start_bitrate_bps(kDefaultStartBitrateBps) {}
70
71 static const int kDefaultStartBitrateBps;
mflodman@webrtc.org6879c8a2013-07-23 11:35:00 +000072
stefan@webrtc.org7e9315b2013-12-04 10:24:26 +000073 webrtc::Config* webrtc_config;
74
pbos@webrtc.org74fa4892013-08-23 09:19:30 +000075 newapi::Transport* send_transport;
pbos@webrtc.orgfd39e132013-08-14 13:52:52 +000076
pbos@webrtc.org841c8a42013-09-09 15:04:25 +000077 // VoiceEngine used for audio/video synchronization for this Call.
pbos@webrtc.orgfd39e132013-08-14 13:52:52 +000078 VoiceEngine* voice_engine;
79
asapersson@webrtc.orgbdc5ed22014-01-31 10:05:07 +000080 // Callback for overuse and normal usage based on the jitter of incoming
81 // captured frames. 'NULL' disables the callback.
pbos@webrtc.org42684be2014-10-03 11:25:45 +000082 LoadObserver* overuse_callback;
mflodman@webrtc.orgeb16b812014-06-16 08:57:39 +000083
pbos@webrtc.orga73a6782014-10-14 11:52:10 +000084 // Start bitrate used before a valid bitrate estimate is calculated.
85 // Note: This is currently set only for video and is per-stream rather of
86 // for the entire link.
87 // TODO(pbos): Set start bitrate for entire Call.
88 int stream_start_bitrate_bps;
mflodman@webrtc.org6879c8a2013-07-23 11:35:00 +000089 };
90
pbos@webrtc.org841c8a42013-09-09 15:04:25 +000091 static Call* Create(const Call::Config& config);
pbos@webrtc.orgfd39e132013-08-14 13:52:52 +000092
stefan@webrtc.org7e9315b2013-12-04 10:24:26 +000093 static Call* Create(const Call::Config& config,
94 const webrtc::Config& webrtc_config);
95
pbos@webrtc.org5a636552013-11-20 10:40:25 +000096 virtual VideoSendStream* CreateVideoSendStream(
pbos@webrtc.org6ae48c62014-06-06 10:49:19 +000097 const VideoSendStream::Config& config,
pbos@webrtc.orgbbe0a852014-09-19 12:30:25 +000098 const VideoEncoderConfig& encoder_config) = 0;
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +000099
pbos@webrtc.org2c46f8d2013-11-21 13:49:43 +0000100 virtual void DestroyVideoSendStream(VideoSendStream* send_stream) = 0;
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +0000101
pbos@webrtc.org5a636552013-11-20 10:40:25 +0000102 virtual VideoReceiveStream* CreateVideoReceiveStream(
pbos@webrtc.org025f4f12013-06-05 11:33:21 +0000103 const VideoReceiveStream::Config& config) = 0;
pbos@webrtc.org2c46f8d2013-11-21 13:49:43 +0000104 virtual void DestroyVideoReceiveStream(
105 VideoReceiveStream* receive_stream) = 0;
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +0000106
107 // All received RTP and RTCP packets for the call should be inserted to this
108 // PacketReceiver. The PacketReceiver pointer is valid as long as the
pbos@webrtc.org841c8a42013-09-09 15:04:25 +0000109 // Call instance exists.
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +0000110 virtual PacketReceiver* Receiver() = 0;
111
112 // Returns the estimated total send bandwidth. Note: this can differ from the
113 // actual encoded bitrate.
114 virtual uint32_t SendBitrateEstimate() = 0;
115
116 // Returns the total estimated receive bandwidth for the call. Note: this can
117 // differ from the actual receive bitrate.
118 virtual uint32_t ReceiveBitrateEstimate() = 0;
119
pbos@webrtc.org26c0c412014-09-03 16:17:12 +0000120 virtual void SignalNetworkState(NetworkState state) = 0;
121
pbos@webrtc.org841c8a42013-09-09 15:04:25 +0000122 virtual ~Call() {}
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +0000123};
mflodman@webrtc.org65f995a2013-04-18 12:02:52 +0000124} // namespace webrtc
125
mflodman@webrtc.orgb429e512013-12-18 09:46:22 +0000126#endif // WEBRTC_CALL_H_