2016-12-07 04:52:58 -08: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.
|
|
|
|
|
*/
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef CALL_CALL_H_
|
|
|
|
|
#define CALL_CALL_H_
|
2016-12-07 04:52:58 -08:00
|
|
|
|
2017-06-14 11:41:48 -07:00
|
|
|
#include <algorithm>
|
2017-05-08 11:52:38 -07:00
|
|
|
#include <memory>
|
2016-12-07 04:52:58 -08:00
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2018-01-19 17:58:57 +01:00
|
|
|
#include "api/fec_controller.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/rtcerror.h"
|
|
|
|
|
#include "call/audio_receive_stream.h"
|
|
|
|
|
#include "call/audio_send_stream.h"
|
|
|
|
|
#include "call/audio_state.h"
|
2018-02-21 09:52:06 +01:00
|
|
|
#include "call/bitrate_constraints.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "call/flexfec_receive_stream.h"
|
|
|
|
|
#include "call/rtp_transport_controller_send_interface.h"
|
|
|
|
|
#include "call/video_receive_stream.h"
|
|
|
|
|
#include "call/video_send_stream.h"
|
2017-09-15 13:58:09 +02:00
|
|
|
#include "common_types.h" // NOLINT(build/include)
|
2017-10-20 10:37:47 +02:00
|
|
|
#include "rtc_base/bitrateallocationstrategy.h"
|
2017-12-07 17:00:40 +01:00
|
|
|
#include "rtc_base/copyonwritebuffer.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/networkroute.h"
|
|
|
|
|
#include "rtc_base/platform_file.h"
|
|
|
|
|
#include "rtc_base/socket.h"
|
2016-12-07 04:52:58 -08:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class AudioProcessing;
|
|
|
|
|
class RtcEventLog;
|
|
|
|
|
|
|
|
|
|
enum class MediaType {
|
|
|
|
|
ANY,
|
|
|
|
|
AUDIO,
|
|
|
|
|
VIDEO,
|
|
|
|
|
DATA
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class PacketReceiver {
|
|
|
|
|
public:
|
|
|
|
|
enum DeliveryStatus {
|
|
|
|
|
DELIVERY_OK,
|
|
|
|
|
DELIVERY_UNKNOWN_SSRC,
|
|
|
|
|
DELIVERY_PACKET_ERROR,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
virtual DeliveryStatus DeliverPacket(MediaType media_type,
|
2017-12-07 17:00:40 +01:00
|
|
|
rtc::CopyOnWriteBuffer packet,
|
2016-12-07 04:52:58 -08:00
|
|
|
const PacketTime& packet_time) = 0;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual ~PacketReceiver() {}
|
|
|
|
|
};
|
|
|
|
|
|
2018-02-14 12:20:13 +01:00
|
|
|
struct CallConfig {
|
|
|
|
|
explicit CallConfig(RtcEventLog* event_log) : event_log(event_log) {
|
|
|
|
|
RTC_DCHECK(event_log);
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-21 09:52:06 +01:00
|
|
|
RTC_DEPRECATED static constexpr int kDefaultStartBitrateBps = 300000;
|
2018-02-20 19:16:26 +00:00
|
|
|
|
2018-02-14 12:20:13 +01:00
|
|
|
// Bitrate config used until valid bitrate estimates are calculated. Also
|
|
|
|
|
// used to cap total bitrate used. This comes from the remote connection.
|
2018-02-21 09:52:06 +01:00
|
|
|
BitrateConstraints bitrate_config;
|
2018-02-14 12:20:13 +01: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;
|
|
|
|
|
|
|
|
|
|
// RtcEventLog to use for this call. Required.
|
|
|
|
|
// Use webrtc::RtcEventLog::CreateNull() for a null implementation.
|
|
|
|
|
RtcEventLog* event_log = nullptr;
|
Revert "Revert "Enables PeerConnectionFactory using external fec controller""
This reverts commit 00733015fafbbc61ddc12dfdc88b21a9fcd9d122.
Reason for revert: The reason for a downstream test failure on the original commit and a workaround has been found. Solution is to keep a PeerConnectionFactory constructor implementation as the same as before.
Original change's description:
> Revert "Enables PeerConnectionFactory using external fec controller"
>
> This reverts commit 4f07bdb25567d8ef528311e0b50a62c61d543fc3.
>
> Reason for revert: Speculatively reverting, because downstream test is now hitting "PeerConnectionFactory.initialize was not called before creating a PeerConnectionFactory" error, even though it did call initialize. I don't see how any change in this CL could cause that, but it's the only CL on the blamelist, and it does modify PeerConnectionFactory.java
>
> Original change's description:
> > Enables PeerConnectionFactory using external fec controller
> >
> > Bug: webrtc:8799
> > Change-Id: Ieb2cf6163b9a83844ab9ed4822b4a7f1db4c24b8
> > Reviewed-on: https://webrtc-review.googlesource.com/43961
> > Commit-Queue: Ying Wang <yinwa@webrtc.org>
> > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> > Reviewed-by: Niels Moller <nisse@webrtc.org>
> > Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#22038}
>
> TBR=sakal@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org,stefan@webrtc.org,yinwa@webrtc.org
>
> Change-Id: I95868c35d6f9973e0ebf563814cd71d0fcbd433d
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:8799
> Reviewed-on: https://webrtc-review.googlesource.com/54080
> Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
> Commit-Queue: Taylor Brandstetter <deadbeef@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#22040}
TBR=deadbeef@webrtc.org,sakal@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org,stefan@webrtc.org,yinwa@webrtc.org
Bug: webrtc:8799
Change-Id: If9f3292bfcc739782967530c49f006d0abbc38a8
Reviewed-on: https://webrtc-review.googlesource.com/55400
Commit-Queue: Ying Wang <yinwa@webrtc.org>
Reviewed-by: Ying Wang <yinwa@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22100}
2018-02-20 12:50:27 +01:00
|
|
|
|
|
|
|
|
// FecController to use for this call.
|
|
|
|
|
FecControllerFactoryInterface* fec_controller_factory = nullptr;
|
2018-02-14 12:20:13 +01:00
|
|
|
};
|
|
|
|
|
|
2016-12-07 04:52:58 -08: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 {
|
|
|
|
|
public:
|
2018-02-14 12:20:13 +01:00
|
|
|
using Config = CallConfig;
|
2016-12-07 04:52:58 -08:00
|
|
|
|
|
|
|
|
struct Stats {
|
|
|
|
|
std::string ToString(int64_t time_ms) const;
|
|
|
|
|
|
|
|
|
|
int send_bandwidth_bps = 0; // Estimated available send bandwidth.
|
|
|
|
|
int max_padding_bitrate_bps = 0; // Cumulative configured max padding.
|
|
|
|
|
int recv_bandwidth_bps = 0; // Estimated available receive bandwidth.
|
|
|
|
|
int64_t pacer_delay_ms = 0;
|
|
|
|
|
int64_t rtt_ms = -1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static Call* Create(const Call::Config& config);
|
|
|
|
|
|
2017-05-08 11:52:38 -07:00
|
|
|
// Allows mocking |transport_send| for testing.
|
|
|
|
|
static Call* Create(
|
|
|
|
|
const Call::Config& config,
|
|
|
|
|
std::unique_ptr<RtpTransportControllerSendInterface> transport_send);
|
|
|
|
|
|
2016-12-07 04:52:58 -08:00
|
|
|
virtual AudioSendStream* CreateAudioSendStream(
|
|
|
|
|
const AudioSendStream::Config& config) = 0;
|
|
|
|
|
virtual void DestroyAudioSendStream(AudioSendStream* send_stream) = 0;
|
|
|
|
|
|
|
|
|
|
virtual AudioReceiveStream* CreateAudioReceiveStream(
|
|
|
|
|
const AudioReceiveStream::Config& config) = 0;
|
|
|
|
|
virtual void DestroyAudioReceiveStream(
|
|
|
|
|
AudioReceiveStream* receive_stream) = 0;
|
|
|
|
|
|
|
|
|
|
virtual VideoSendStream* CreateVideoSendStream(
|
|
|
|
|
VideoSendStream::Config config,
|
|
|
|
|
VideoEncoderConfig encoder_config) = 0;
|
2018-01-19 17:58:57 +01:00
|
|
|
virtual VideoSendStream* CreateVideoSendStream(
|
|
|
|
|
VideoSendStream::Config config,
|
|
|
|
|
VideoEncoderConfig encoder_config,
|
|
|
|
|
std::unique_ptr<FecController> fec_controller);
|
2016-12-07 04:52:58 -08:00
|
|
|
virtual void DestroyVideoSendStream(VideoSendStream* send_stream) = 0;
|
|
|
|
|
|
|
|
|
|
virtual VideoReceiveStream* CreateVideoReceiveStream(
|
|
|
|
|
VideoReceiveStream::Config configuration) = 0;
|
|
|
|
|
virtual void DestroyVideoReceiveStream(
|
|
|
|
|
VideoReceiveStream* receive_stream) = 0;
|
|
|
|
|
|
2017-01-27 06:47:55 -08:00
|
|
|
// In order for a created VideoReceiveStream to be aware that it is
|
|
|
|
|
// protected by a FlexfecReceiveStream, the latter should be created before
|
|
|
|
|
// the former.
|
2016-12-07 04:52:58 -08:00
|
|
|
virtual FlexfecReceiveStream* CreateFlexfecReceiveStream(
|
2016-12-08 04:14:24 -08:00
|
|
|
const FlexfecReceiveStream::Config& config) = 0;
|
2016-12-07 04:52:58 -08:00
|
|
|
virtual void DestroyFlexfecReceiveStream(
|
|
|
|
|
FlexfecReceiveStream* receive_stream) = 0;
|
|
|
|
|
|
|
|
|
|
// All received RTP and RTCP packets for the call should be inserted to this
|
|
|
|
|
// PacketReceiver. The PacketReceiver pointer is valid as long as the
|
|
|
|
|
// Call instance exists.
|
|
|
|
|
virtual PacketReceiver* Receiver() = 0;
|
|
|
|
|
|
2018-02-21 13:07:13 +01:00
|
|
|
// This is used to access the transport controller send instance owned by
|
|
|
|
|
// Call. The send transport controller is currently owned by Call for legacy
|
|
|
|
|
// reasons. (for instance variants of call tests are built on this assumtion)
|
|
|
|
|
// TODO(srte): Move ownership of transport controller send out of Call and
|
|
|
|
|
// remove this method interface.
|
|
|
|
|
virtual RtpTransportControllerSendInterface* GetTransportControllerSend() = 0;
|
|
|
|
|
|
2016-12-07 04:52:58 -08:00
|
|
|
// Returns the call statistics, such as estimated send and receive bandwidth,
|
|
|
|
|
// pacing delay, etc.
|
|
|
|
|
virtual Stats GetStats() const = 0;
|
|
|
|
|
|
2017-10-20 10:37:47 +02:00
|
|
|
virtual void SetBitrateAllocationStrategy(
|
|
|
|
|
std::unique_ptr<rtc::BitrateAllocationStrategy>
|
|
|
|
|
bitrate_allocation_strategy) = 0;
|
|
|
|
|
|
2016-12-07 04:52:58 -08: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;
|
|
|
|
|
|
|
|
|
|
virtual void OnTransportOverheadChanged(
|
|
|
|
|
MediaType media,
|
|
|
|
|
int transport_overhead_per_packet) = 0;
|
|
|
|
|
|
|
|
|
|
virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0;
|
|
|
|
|
|
|
|
|
|
virtual ~Call() {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // CALL_CALL_H_
|