164 lines
5.3 KiB
C
Raw Normal View History

/*
* 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.
*/
#ifndef WEBRTC_CALL_H_
#define WEBRTC_CALL_H_
#include <string>
#include <vector>
#include "webrtc/common_types.h"
#include "webrtc/audio_receive_stream.h"
#include "webrtc/audio_send_stream.h"
#include "webrtc/audio_state.h"
#include "webrtc/base/networkroute.h"
#include "webrtc/base/platform_file.h"
#include "webrtc/base/socket.h"
#include "webrtc/video_receive_stream.h"
#include "webrtc/video_send_stream.h"
namespace webrtc {
class AudioProcessing;
const char* Version();
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,
const uint8_t* packet,
size_t length,
const PacketTime& packet_time) = 0;
protected:
virtual ~PacketReceiver() {}
};
// Callback interface for reporting when a system overuse is detected.
class LoadObserver {
public:
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;
protected:
virtual ~LoadObserver() {}
};
// 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:
struct Config {
static const int kDefaultStartBitrateBps;
// Bitrate config used until valid bitrate estimates are calculated. Also
// used to cap total bitrate used.
struct BitrateConfig {
int min_bitrate_bps = 0;
int start_bitrate_bps = kDefaultStartBitrateBps;
int max_bitrate_bps = -1;
} bitrate_config;
// 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;
};
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);
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(
Revert of Add task queue to Call. (patchset #42 id:840001 of https://codereview.webrtc.org/2060403002/ ) Reason for revert: Failed on Win 10 Chrome FYI. https://build.chromium.org/p/chromium.webrtc.fyi/builders/Win10%20Tester/builds/3847/steps/content_browsertests/logs/stdio # # Fatal error in e:\b\c\b\win_builder\src\third_party\webrtc\base\task_queue_win.cc, line 138 # last system error: 87 # Check failed: ((DWORD)0xFFFFFFFF) != result (4294967295 vs. 4294967295) # WebRtcBrowserTest # Original issue's description: > - Add task queue to Call with the intent of replacing the use of one of the process threads. > > - Split VideoSendStream in two. VideoSendStreamInternal is created and used on the new task queue. > > - BitrateAllocator is now created on libjingle's worker thread but always used on the new task queue instead of both encoder threads and the process thread. > > - VideoEncoderConfig and VideoSendStream::Config support move semantics. > > - The encoder thread is moved from VideoSendStream to ViEEncoder. Frames are forwarded directly to ViEEncoder which is responsible for timestamping ? and encoding the frames. > > BUG=webrtc:5687 > > Committed: https://crrev.com/cc168360f41322332860cb075edeb1cde21aa473 > Cr-Commit-Position: refs/heads/master@{#13767} TBR=tommi@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org,sprang@webrtc.org,pbos@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:5687 Review-Url: https://codereview.webrtc.org/2248713003 Cr-Commit-Position: refs/heads/master@{#13774}
2016-08-16 02:40:55 -07:00
const VideoSendStream::Config& config,
const VideoEncoderConfig& encoder_config) = 0;
virtual void DestroyVideoSendStream(VideoSendStream* send_stream) = 0;
virtual VideoReceiveStream* CreateVideoReceiveStream(
VideoReceiveStream::Config configuration) = 0;
virtual void DestroyVideoReceiveStream(
VideoReceiveStream* 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;
// Returns the call statistics, such as estimated send and receive bandwidth,
// pacing delay, etc.
virtual Stats GetStats() const = 0;
// 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;
// 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 OnNetworkRouteChanged(
const std::string& transport_name,
const rtc::NetworkRoute& network_route) = 0;
virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0;
virtual bool StartEventLog(rtc::PlatformFile log_file,
int64_t max_size_bytes) = 0;
virtual void StopEventLog() = 0;
virtual ~Call() {}
};
} // namespace webrtc
#endif // WEBRTC_CALL_H_