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"
|
2015-04-29 15:24:01 +02:00
|
|
|
#include "webrtc/audio_receive_stream.h"
|
2015-06-08 13:04:56 +02:00
|
|
|
#include "webrtc/audio_send_stream.h"
|
2015-11-06 15:34:49 -08:00
|
|
|
#include "webrtc/audio_state.h"
|
2015-10-15 07:26:07 -07:00
|
|
|
#include "webrtc/base/socket.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 {
|
|
|
|
|
|
2015-06-08 13:04:56 +02:00
|
|
|
class AudioProcessing;
|
2013-04-18 12:02:52 +00:00
|
|
|
|
|
|
|
|
const char* Version();
|
|
|
|
|
|
2015-04-29 15:24:01 +02:00
|
|
|
enum class MediaType {
|
|
|
|
|
ANY,
|
|
|
|
|
AUDIO,
|
|
|
|
|
VIDEO,
|
|
|
|
|
DATA
|
|
|
|
|
};
|
|
|
|
|
|
2013-04-18 12:02:52 +00:00
|
|
|
class PacketReceiver {
|
|
|
|
|
public:
|
2014-05-14 13:57:12 +00:00
|
|
|
enum DeliveryStatus {
|
|
|
|
|
DELIVERY_OK,
|
|
|
|
|
DELIVERY_UNKNOWN_SSRC,
|
|
|
|
|
DELIVERY_PACKET_ERROR,
|
|
|
|
|
};
|
|
|
|
|
|
2015-04-29 15:24:01 +02:00
|
|
|
virtual DeliveryStatus DeliverPacket(MediaType media_type,
|
|
|
|
|
const uint8_t* packet,
|
2015-09-08 05:36:15 -07:00
|
|
|
size_t length,
|
|
|
|
|
const PacketTime& packet_time) = 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:
|
2013-07-23 11:35:00 +00:00
|
|
|
struct Config {
|
2014-10-14 11:52:10 +00:00
|
|
|
static const int kDefaultStartBitrateBps;
|
2013-07-23 11:35:00 +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.
|
|
|
|
|
struct BitrateConfig {
|
2015-06-11 12:38:38 +02:00
|
|
|
int min_bitrate_bps = 0;
|
|
|
|
|
int start_bitrate_bps = kDefaultStartBitrateBps;
|
|
|
|
|
int max_bitrate_bps = -1;
|
2015-03-26 11:11:06 +01:00
|
|
|
} bitrate_config;
|
2015-06-08 13:04:56 +02:00
|
|
|
|
2015-11-06 15:34:49 -08:00
|
|
|
// AudioState which is possibly shared between multiple calls.
|
|
|
|
|
// TODO(solenberg): Change this to a shared_ptr once we can use C++11.
|
|
|
|
|
rtc::scoped_refptr<AudioState> audio_state;
|
|
|
|
|
|
|
|
|
|
// Audio Processing Module to be used in this call.
|
|
|
|
|
// TODO(solenberg): Change this to a shared_ptr once we can use C++11.
|
|
|
|
|
AudioProcessing* audio_processing = nullptr;
|
2013-07-23 11:35:00 +00:00
|
|
|
};
|
|
|
|
|
|
2014-11-05 14:05:29 +00:00
|
|
|
struct Stats {
|
2015-06-11 12:38:38 +02:00
|
|
|
int send_bandwidth_bps = 0;
|
|
|
|
|
int recv_bandwidth_bps = 0;
|
|
|
|
|
int64_t pacer_delay_ms = 0;
|
|
|
|
|
int64_t rtt_ms = -1;
|
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
|
|
|
|
2015-06-08 13:04:56 +02:00
|
|
|
virtual AudioSendStream* CreateAudioSendStream(
|
|
|
|
|
const AudioSendStream::Config& config) = 0;
|
|
|
|
|
virtual void DestroyAudioSendStream(AudioSendStream* send_stream) = 0;
|
|
|
|
|
|
2015-04-29 15:24:01 +02:00
|
|
|
virtual AudioReceiveStream* CreateAudioReceiveStream(
|
|
|
|
|
const AudioReceiveStream::Config& config) = 0;
|
|
|
|
|
virtual void DestroyAudioReceiveStream(
|
|
|
|
|
AudioReceiveStream* receive_stream) = 0;
|
|
|
|
|
|
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-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;
|
2016-03-22 15:32:27 -07:00
|
|
|
|
|
|
|
|
// TODO(skvlad): When the unbundled case with multiple streams for the same
|
|
|
|
|
// media type going over different networks is supported, track the state
|
|
|
|
|
// for each stream separately. Right now it's global per media type.
|
|
|
|
|
virtual void SignalChannelNetworkState(MediaType media,
|
|
|
|
|
NetworkState state) = 0;
|
2014-09-03 16:17:12 +00:00
|
|
|
|
2015-10-15 07:26:07 -07:00
|
|
|
virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0;
|
|
|
|
|
|
2013-09-09 15:04:25 +00:00
|
|
|
virtual ~Call() {}
|
2013-04-18 12:02:52 +00:00
|
|
|
};
|
2015-07-16 09:30:09 +02:00
|
|
|
|
2013-04-18 12:02:52 +00:00
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2013-12-18 09:46:22 +00:00
|
|
|
#endif // WEBRTC_CALL_H_
|