blob: 43ce4c182ead6b1b3aeba16702a03497144b0730 [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"
pbos@webrtc.org24e20892013-10-28 16:32:0117#include "webrtc/video_receive_stream.h"
18#include "webrtc/video_send_stream.h"
mflodman@webrtc.org06e80262013-04-18 12:02:5219
mflodman@webrtc.org06e80262013-04-18 12:02:5220namespace webrtc {
mflodman@webrtc.org06e80262013-04-18 12:02:5221
22class VoiceEngine;
23
24const char* Version();
25
26class PacketReceiver {
27 public:
pbos@webrtc.orgbc57e0f2014-05-14 13:57:1228 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.org06e80262013-04-18 12:02:5236
37 protected:
38 virtual ~PacketReceiver() {}
39};
40
asapersson@webrtc.org8ef65482014-01-31 10:05:0741// Callback interface for reporting when a system overuse is detected.
pbos@webrtc.orgd3e3c9b2014-10-03 11:25:4542class LoadObserver {
asapersson@webrtc.org8ef65482014-01-31 10:05:0743 public:
pbos@webrtc.orgd3e3c9b2014-10-03 11:25:4544 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.org8ef65482014-01-31 10:05:0749
50 protected:
pbos@webrtc.orgd3e3c9b2014-10-03 11:25:4551 virtual ~LoadObserver() {}
asapersson@webrtc.org8ef65482014-01-31 10:05:0752};
53
pbos@webrtc.orgbf6d5722013-09-09 15:04:2554// 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.org06e80262013-04-18 12:02:5258 public:
pbos@webrtc.org9b707ca2014-09-03 16:17:1259 enum NetworkState {
60 kNetworkUp,
61 kNetworkDown,
62 };
mflodman@webrtc.orgbf76ae22013-07-23 11:35:0063 struct Config {
pbos@webrtc.orgc1797062013-08-23 09:19:3064 explicit Config(newapi::Transport* send_transport)
stefan@webrtc.org47f0c412013-12-04 10:24:2665 : webrtc_config(NULL),
66 send_transport(send_transport),
pbos@webrtc.orgc2014fd2013-08-14 13:52:5267 voice_engine(NULL),
mflodman@webrtc.orgf89ce462014-06-16 08:57:3968 overuse_callback(NULL),
69 start_bitrate_bps(-1) {}
mflodman@webrtc.orgbf76ae22013-07-23 11:35:0070
stefan@webrtc.org47f0c412013-12-04 10:24:2671 webrtc::Config* webrtc_config;
72
pbos@webrtc.orgc1797062013-08-23 09:19:3073 newapi::Transport* send_transport;
pbos@webrtc.orgc2014fd2013-08-14 13:52:5274
pbos@webrtc.orgbf6d5722013-09-09 15:04:2575 // VoiceEngine used for audio/video synchronization for this Call.
pbos@webrtc.orgc2014fd2013-08-14 13:52:5276 VoiceEngine* voice_engine;
77
asapersson@webrtc.org8ef65482014-01-31 10:05:0778 // Callback for overuse and normal usage based on the jitter of incoming
79 // captured frames. 'NULL' disables the callback.
pbos@webrtc.orgd3e3c9b2014-10-03 11:25:4580 LoadObserver* overuse_callback;
mflodman@webrtc.orgf89ce462014-06-16 08:57:3981
82 // Start bitrate used before a valid bitrate estimate is calculated. '-1'
83 // lets the call decide start bitrate.
84 // Note: This currently only affects video.
85 int start_bitrate_bps;
mflodman@webrtc.orgbf76ae22013-07-23 11:35:0086 };
87
pbos@webrtc.orgbf6d5722013-09-09 15:04:2588 static Call* Create(const Call::Config& config);
pbos@webrtc.orgc2014fd2013-08-14 13:52:5289
stefan@webrtc.org47f0c412013-12-04 10:24:2690 static Call* Create(const Call::Config& config,
91 const webrtc::Config& webrtc_config);
92
pbos@webrtc.org964d78e2013-11-20 10:40:2593 virtual VideoSendStream* CreateVideoSendStream(
pbos@webrtc.orgbdfcddf2014-06-06 10:49:1994 const VideoSendStream::Config& config,
pbos@webrtc.org58b51402014-09-19 12:30:2595 const VideoEncoderConfig& encoder_config) = 0;
mflodman@webrtc.org06e80262013-04-18 12:02:5296
pbos@webrtc.org12a93e02013-11-21 13:49:4397 virtual void DestroyVideoSendStream(VideoSendStream* send_stream) = 0;
mflodman@webrtc.org06e80262013-04-18 12:02:5298
pbos@webrtc.org964d78e2013-11-20 10:40:2599 virtual VideoReceiveStream* CreateVideoReceiveStream(
pbos@webrtc.org6f1c3ef2013-06-05 11:33:21100 const VideoReceiveStream::Config& config) = 0;
pbos@webrtc.org12a93e02013-11-21 13:49:43101 virtual void DestroyVideoReceiveStream(
102 VideoReceiveStream* receive_stream) = 0;
mflodman@webrtc.org06e80262013-04-18 12:02:52103
104 // All received RTP and RTCP packets for the call should be inserted to this
105 // PacketReceiver. The PacketReceiver pointer is valid as long as the
pbos@webrtc.orgbf6d5722013-09-09 15:04:25106 // Call instance exists.
mflodman@webrtc.org06e80262013-04-18 12:02:52107 virtual PacketReceiver* Receiver() = 0;
108
109 // Returns the estimated total send bandwidth. Note: this can differ from the
110 // actual encoded bitrate.
111 virtual uint32_t SendBitrateEstimate() = 0;
112
113 // Returns the total estimated receive bandwidth for the call. Note: this can
114 // differ from the actual receive bitrate.
115 virtual uint32_t ReceiveBitrateEstimate() = 0;
116
pbos@webrtc.org9b707ca2014-09-03 16:17:12117 virtual void SignalNetworkState(NetworkState state) = 0;
118
pbos@webrtc.orgbf6d5722013-09-09 15:04:25119 virtual ~Call() {}
mflodman@webrtc.org06e80262013-04-18 12:02:52120};
mflodman@webrtc.org06e80262013-04-18 12:02:52121} // namespace webrtc
122
mflodman@webrtc.org5e0cbcf2013-12-18 09:46:22123#endif // WEBRTC_CALL_H_