2013-04-18 12:02:52 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
*/
|
2013-12-18 09:46:22 +00:00
|
|
|
#ifndef WEBRTC_CALL_H_
|
|
|
|
#define WEBRTC_CALL_H_
|
2013-04-18 12:02:52 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "webrtc/common_types.h"
|
2013-10-28 16:32:01 +00:00
|
|
|
#include "webrtc/video_receive_stream.h"
|
|
|
|
#include "webrtc/video_send_stream.h"
|
2013-04-18 12:02:52 +00:00
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
class VoiceEngine;
|
|
|
|
|
|
|
|
const char* Version();
|
|
|
|
|
|
|
|
class PacketReceiver {
|
|
|
|
public:
|
2014-05-14 13:57:12 +00:00
|
|
|
enum DeliveryStatus {
|
|
|
|
DELIVERY_OK,
|
|
|
|
DELIVERY_UNKNOWN_SSRC,
|
|
|
|
DELIVERY_PACKET_ERROR,
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual DeliveryStatus DeliverPacket(const uint8_t* packet,
|
|
|
|
size_t length) = 0;
|
2013-04-18 12:02:52 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~PacketReceiver() {}
|
|
|
|
};
|
|
|
|
|
2014-01-31 10:05:07 +00:00
|
|
|
// Callback interface for reporting when a system overuse is detected.
|
2014-10-03 11:25:45 +00:00
|
|
|
class LoadObserver {
|
2014-01-31 10:05:07 +00:00
|
|
|
public:
|
2014-10-03 11:25:45 +00:00
|
|
|
enum Load { kOveruse, kUnderuse };
|
|
|
|
|
|
|
|
// Triggered when overuse is detected or when we believe the system can take
|
|
|
|
// more load.
|
|
|
|
virtual void OnLoadUpdate(Load load) = 0;
|
2014-01-31 10:05:07 +00:00
|
|
|
|
|
|
|
protected:
|
2014-10-03 11:25:45 +00:00
|
|
|
virtual ~LoadObserver() {}
|
2014-01-31 10:05:07 +00:00
|
|
|
};
|
|
|
|
|
2013-09-09 15:04:25 +00:00
|
|
|
// A Call instance can contain several send and/or receive streams. All streams
|
|
|
|
// are assumed to have the same remote endpoint and will share bitrate estimates
|
|
|
|
// etc.
|
|
|
|
class Call {
|
2013-04-18 12:02:52 +00:00
|
|
|
public:
|
2014-09-03 16:17:12 +00:00
|
|
|
enum NetworkState {
|
|
|
|
kNetworkUp,
|
|
|
|
kNetworkDown,
|
|
|
|
};
|
2013-07-23 11:35:00 +00:00
|
|
|
struct Config {
|
2013-08-23 09:19:30 +00:00
|
|
|
explicit Config(newapi::Transport* send_transport)
|
2013-12-04 10:24:26 +00:00
|
|
|
: webrtc_config(NULL),
|
|
|
|
send_transport(send_transport),
|
2013-08-14 13:52:52 +00:00
|
|
|
voice_engine(NULL),
|
2014-11-25 14:03:34 +00:00
|
|
|
overuse_callback(NULL) {}
|
2014-10-14 11:52:10 +00:00
|
|
|
|
|
|
|
static const int kDefaultStartBitrateBps;
|
2013-07-23 11:35:00 +00:00
|
|
|
|
2013-12-04 10:24:26 +00:00
|
|
|
webrtc::Config* webrtc_config;
|
|
|
|
|
2013-08-23 09:19:30 +00:00
|
|
|
newapi::Transport* send_transport;
|
2013-08-14 13:52:52 +00:00
|
|
|
|
2013-09-09 15:04:25 +00:00
|
|
|
// VoiceEngine used for audio/video synchronization for this Call.
|
2013-08-14 13:52:52 +00:00
|
|
|
VoiceEngine* voice_engine;
|
|
|
|
|
2014-01-31 10:05:07 +00:00
|
|
|
// Callback for overuse and normal usage based on the jitter of incoming
|
|
|
|
// captured frames. 'NULL' disables the callback.
|
2014-10-03 11:25:45 +00:00
|
|
|
LoadObserver* overuse_callback;
|
2014-06-16 08:57:39 +00:00
|
|
|
|
2014-11-25 14:03:34 +00:00
|
|
|
// Bitrate config used until valid bitrate estimates are calculated. Also
|
|
|
|
// used to cap total bitrate used.
|
2014-10-14 11:52:10 +00:00
|
|
|
// Note: This is currently set only for video and is per-stream rather of
|
|
|
|
// for the entire link.
|
|
|
|
// TODO(pbos): Set start bitrate for entire Call.
|
2014-11-25 14:03:34 +00:00
|
|
|
struct BitrateConfig {
|
|
|
|
BitrateConfig()
|
|
|
|
: min_bitrate_bps(0),
|
|
|
|
start_bitrate_bps(kDefaultStartBitrateBps),
|
|
|
|
max_bitrate_bps(-1) {}
|
|
|
|
int min_bitrate_bps;
|
|
|
|
int start_bitrate_bps;
|
|
|
|
int max_bitrate_bps;
|
|
|
|
} stream_bitrates;
|
2013-07-23 11:35:00 +00:00
|
|
|
};
|
|
|
|
|
2014-11-05 14:05:29 +00:00
|
|
|
struct Stats {
|
2014-12-11 13:26:09 +00:00
|
|
|
Stats()
|
|
|
|
: send_bandwidth_bps(0),
|
|
|
|
recv_bandwidth_bps(0),
|
|
|
|
pacer_delay_ms(0),
|
|
|
|
rtt_ms(-1) {}
|
2014-11-05 14:05:29 +00:00
|
|
|
|
|
|
|
int send_bandwidth_bps;
|
|
|
|
int recv_bandwidth_bps;
|
2015-01-12 21:51:21 +00:00
|
|
|
int64_t pacer_delay_ms;
|
|
|
|
int64_t rtt_ms;
|
2014-11-05 14:05:29 +00:00
|
|
|
};
|
|
|
|
|
2013-09-09 15:04:25 +00:00
|
|
|
static Call* Create(const Call::Config& config);
|
2013-08-14 13:52:52 +00:00
|
|
|
|
2013-12-04 10:24:26 +00:00
|
|
|
static Call* Create(const Call::Config& config,
|
|
|
|
const webrtc::Config& webrtc_config);
|
|
|
|
|
2013-11-20 10:40:25 +00:00
|
|
|
virtual VideoSendStream* CreateVideoSendStream(
|
2014-06-06 10:49:19 +00:00
|
|
|
const VideoSendStream::Config& config,
|
2014-09-19 12:30:25 +00:00
|
|
|
const VideoEncoderConfig& encoder_config) = 0;
|
2013-04-18 12:02:52 +00:00
|
|
|
|
2013-11-21 13:49:43 +00:00
|
|
|
virtual void DestroyVideoSendStream(VideoSendStream* send_stream) = 0;
|
2013-04-18 12:02:52 +00:00
|
|
|
|
2013-11-20 10:40:25 +00:00
|
|
|
virtual VideoReceiveStream* CreateVideoReceiveStream(
|
2013-06-05 11:33:21 +00:00
|
|
|
const VideoReceiveStream::Config& config) = 0;
|
2013-11-21 13:49:43 +00:00
|
|
|
virtual void DestroyVideoReceiveStream(
|
|
|
|
VideoReceiveStream* receive_stream) = 0;
|
2013-04-18 12:02:52 +00:00
|
|
|
|
|
|
|
// All received RTP and RTCP packets for the call should be inserted to this
|
|
|
|
// PacketReceiver. The PacketReceiver pointer is valid as long as the
|
2013-09-09 15:04:25 +00:00
|
|
|
// Call instance exists.
|
2013-04-18 12:02:52 +00:00
|
|
|
virtual PacketReceiver* Receiver() = 0;
|
|
|
|
|
2014-11-05 14:05:29 +00:00
|
|
|
// Returns the call statistics, such as estimated send and receive bandwidth,
|
|
|
|
// pacing delay, etc.
|
|
|
|
virtual Stats GetStats() const = 0;
|
2013-04-18 12:02:52 +00:00
|
|
|
|
2014-11-25 14:03:34 +00:00
|
|
|
// TODO(pbos): Like BitrateConfig above this is currently per-stream instead
|
|
|
|
// of maximum for entire Call. This should be fixed along with the above.
|
|
|
|
// Specifying a start bitrate (>0) will currently reset the current bitrate
|
|
|
|
// estimate. This is due to how the 'x-google-start-bitrate' flag is currently
|
|
|
|
// implemented.
|
|
|
|
virtual void SetBitrateConfig(
|
|
|
|
const Config::BitrateConfig& bitrate_config) = 0;
|
2014-09-03 16:17:12 +00:00
|
|
|
virtual void SignalNetworkState(NetworkState state) = 0;
|
|
|
|
|
2013-09-09 15:04:25 +00:00
|
|
|
virtual ~Call() {}
|
2013-04-18 12:02:52 +00:00
|
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
|
2013-12-18 09:46:22 +00:00
|
|
|
#endif // WEBRTC_CALL_H_
|