Remove VideoEngine interface usage from new API.

Instantiates ProcessThread/ChannelGroup inside Call instead of using
VideoEngine or ViEBase. This removes the need for ViEChannelManager,
ViEInputManager and other ViESharedData completely.

Some interface headers are still referenced due to external interfaces
being defined there. Upon interface removal these will be moved to
implementation headers.

BUG=1695
R=mflodman@webrtc.org, stefan@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/50849005

Cr-Commit-Position: refs/heads/master@{#9160}
This commit is contained in:
Peter Boström
2015-05-08 13:54:38 +02:00
parent 208a2294cd
commit 45553aefac
7 changed files with 104 additions and 140 deletions

View File

@@ -21,9 +21,11 @@
#include "webrtc/config.h" #include "webrtc/config.h"
#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
#include "webrtc/modules/rtp_rtcp/source/byte_io.h" #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
#include "webrtc/modules/utility/interface/process_thread.h"
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
#include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
#include "webrtc/modules/video_render/include/video_render.h" #include "webrtc/modules/video_render/include/video_render.h"
#include "webrtc/system_wrappers/interface/cpu_info.h"
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
#include "webrtc/system_wrappers/interface/logging.h" #include "webrtc/system_wrappers/interface/logging.h"
#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
@@ -32,12 +34,6 @@
#include "webrtc/video/audio_receive_stream.h" #include "webrtc/video/audio_receive_stream.h"
#include "webrtc/video/video_receive_stream.h" #include "webrtc/video/video_receive_stream.h"
#include "webrtc/video/video_send_stream.h" #include "webrtc/video/video_send_stream.h"
#include "webrtc/video_engine/vie_shared_data.h"
#include "webrtc/video_engine/include/vie_base.h"
#include "webrtc/video_engine/include/vie_codec.h"
#include "webrtc/video_engine/include/vie_rtp_rtcp.h"
#include "webrtc/video_engine/include/vie_network.h"
#include "webrtc/video_engine/include/vie_rtp_rtcp.h"
namespace webrtc { namespace webrtc {
VideoEncoder* VideoEncoder::Create(VideoEncoder::EncoderType codec_type) { VideoEncoder* VideoEncoder::Create(VideoEncoder::EncoderType codec_type) {
@@ -92,7 +88,7 @@ class CpuOveruseObserverProxy : public webrtc::CpuOveruseObserver {
class Call : public webrtc::Call, public PacketReceiver { class Call : public webrtc::Call, public PacketReceiver {
public: public:
Call(webrtc::VideoEngine* video_engine, const Call::Config& config); explicit Call(const Call::Config& config);
virtual ~Call(); virtual ~Call();
PacketReceiver* Receiver() override; PacketReceiver* Receiver() override;
@@ -127,6 +123,14 @@ class Call : public webrtc::Call, public PacketReceiver {
DeliveryStatus DeliverRtp(MediaType media_type, const uint8_t* packet, DeliveryStatus DeliverRtp(MediaType media_type, const uint8_t* packet,
size_t length); size_t length);
void SetBitrateControllerConfig(
const webrtc::Call::Config::BitrateConfig& bitrate_config);
const int num_cpu_cores_;
const rtc::scoped_ptr<ProcessThread> module_process_thread_;
const rtc::scoped_ptr<ChannelGroup> channel_group_;
const int base_channel_id_;
volatile int next_channel_id_;
Call::Config config_; Call::Config config_;
// Needs to be held while write-locking |receive_crit_| or |send_crit_|. This // Needs to be held while write-locking |receive_crit_| or |send_crit_|. This
@@ -151,40 +155,26 @@ class Call : public webrtc::Call, public PacketReceiver {
VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; VideoSendStream::RtpStateMap suspended_video_send_ssrcs_;
VideoEngine* video_engine_;
ViESharedData* vie_shared_data_;
ViERTP_RTCP* rtp_rtcp_;
ViERender* render_;
ViEBase* base_;
ViENetwork* network_;
int base_channel_id_;
ChannelGroup* channel_group_;
rtc::scoped_ptr<VideoRender> external_render_;
DISALLOW_COPY_AND_ASSIGN(Call); DISALLOW_COPY_AND_ASSIGN(Call);
}; };
} // namespace internal } // namespace internal
Call* Call::Create(const Call::Config& config) { Call* Call::Create(const Call::Config& config) {
VideoEngine* video_engine = VideoEngine::Create(); return new internal::Call(config);
DCHECK(video_engine != nullptr);
return new internal::Call(video_engine, config);
} }
namespace internal { namespace internal {
Call::Call(webrtc::VideoEngine* video_engine, const Call::Config& config) Call::Call(const Call::Config& config)
: config_(config), : num_cpu_cores_(CpuInfo::DetectNumberOfCores()),
module_process_thread_(ProcessThread::Create()),
channel_group_(new ChannelGroup(module_process_thread_.get(), nullptr)),
base_channel_id_(0),
next_channel_id_(base_channel_id_ + 1),
config_(config),
network_enabled_(true), network_enabled_(true),
receive_crit_(RWLockWrapper::CreateRWLock()), receive_crit_(RWLockWrapper::CreateRWLock()),
send_crit_(RWLockWrapper::CreateRWLock()), send_crit_(RWLockWrapper::CreateRWLock()) {
video_engine_(video_engine),
base_channel_id_(-1),
external_render_(
VideoRender::CreateVideoRender(42, nullptr, false, kRenderExternal)) {
DCHECK(video_engine != nullptr);
DCHECK(config.send_transport != nullptr); DCHECK(config.send_transport != nullptr);
DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0);
@@ -195,35 +185,20 @@ Call::Call(webrtc::VideoEngine* video_engine, const Call::Config& config)
config.bitrate_config.start_bitrate_bps); config.bitrate_config.start_bitrate_bps);
} }
Trace::CreateTrace();
module_process_thread_->Start();
// TODO(pbos): Remove base channel when CreateReceiveChannel no longer
// requires one.
CHECK(channel_group_->CreateSendChannel(base_channel_id_, 0, num_cpu_cores_,
true));
if (config.overuse_callback) { if (config.overuse_callback) {
overuse_observer_proxy_.reset( overuse_observer_proxy_.reset(
new CpuOveruseObserverProxy(config.overuse_callback)); new CpuOveruseObserverProxy(config.overuse_callback));
} }
render_ = ViERender::GetInterface(video_engine_); SetBitrateControllerConfig(config_.bitrate_config);
DCHECK(render_ != nullptr);
render_->RegisterVideoRenderModule(*external_render_.get());
rtp_rtcp_ = ViERTP_RTCP::GetInterface(video_engine_);
DCHECK(rtp_rtcp_ != nullptr);
network_ = ViENetwork::GetInterface(video_engine_);
// As a workaround for non-existing calls in the old API, create a base
// channel used as default channel when creating send and receive streams.
base_ = ViEBase::GetInterface(video_engine_);
DCHECK(base_ != nullptr);
base_->CreateChannel(base_channel_id_);
DCHECK(base_channel_id_ != -1);
channel_group_ = base_->GetChannelGroup(base_channel_id_);
vie_shared_data_ = base_->shared_data();
network_->SetBitrateConfig(base_channel_id_,
config_.bitrate_config.min_bitrate_bps,
config_.bitrate_config.start_bitrate_bps,
config_.bitrate_config.max_bitrate_bps);
} }
Call::~Call() { Call::~Call() {
@@ -232,15 +207,10 @@ Call::~Call() {
CHECK_EQ(0u, audio_receive_ssrcs_.size()); CHECK_EQ(0u, audio_receive_ssrcs_.size());
CHECK_EQ(0u, video_receive_ssrcs_.size()); CHECK_EQ(0u, video_receive_ssrcs_.size());
CHECK_EQ(0u, video_receive_streams_.size()); CHECK_EQ(0u, video_receive_streams_.size());
base_->DeleteChannel(base_channel_id_);
render_->DeRegisterVideoRenderModule(*external_render_.get()); channel_group_->DeleteChannel(base_channel_id_);
module_process_thread_->Stop();
base_->Release(); Trace::ReturnTrace();
network_->Release();
render_->Release();
rtp_rtcp_->Release();
CHECK(webrtc::VideoEngine::Delete(video_engine_));
} }
PacketReceiver* Call::Receiver() { return this; } PacketReceiver* Call::Receiver() { return this; }
@@ -285,9 +255,10 @@ webrtc::VideoSendStream* Call::CreateVideoSendStream(
// TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if
// the call has already started. // the call has already started.
VideoSendStream* send_stream = new VideoSendStream( VideoSendStream* send_stream = new VideoSendStream(
config_.send_transport, overuse_observer_proxy_.get(), video_engine_, config_.send_transport, overuse_observer_proxy_.get(), num_cpu_cores_,
channel_group_, vie_shared_data_->module_process_thread(), config, module_process_thread_.get(), channel_group_.get(),
encoder_config, suspended_video_send_ssrcs_, base_channel_id_); rtc::AtomicOps::Increment(&next_channel_id_), config, encoder_config,
suspended_video_send_ssrcs_);
// This needs to be taken before send_crit_ as both locks need to be held // This needs to be taken before send_crit_ as both locks need to be held
// while changing network state. // while changing network state.
@@ -342,8 +313,9 @@ webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream(
TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream");
LOG(LS_INFO) << "CreateVideoReceiveStream: " << config.ToString(); LOG(LS_INFO) << "CreateVideoReceiveStream: " << config.ToString();
VideoReceiveStream* receive_stream = new VideoReceiveStream( VideoReceiveStream* receive_stream = new VideoReceiveStream(
video_engine_, channel_group_, config, config_.send_transport, num_cpu_cores_, base_channel_id_, channel_group_.get(),
config_.voice_engine, base_channel_id_); rtc::AtomicOps::Increment(&next_channel_id_), config,
config_.send_transport, config_.voice_engine);
// This needs to be taken before receive_crit_ as both locks need to be held // This needs to be taken before receive_crit_ as both locks need to be held
// while changing network state. // while changing network state.
@@ -393,12 +365,14 @@ void Call::DestroyVideoReceiveStream(
Call::Stats Call::GetStats() const { Call::Stats Call::GetStats() const {
Stats stats; Stats stats;
// Ignoring return values. // Fetch available send/receive bitrates.
uint32_t send_bandwidth = 0; uint32_t send_bandwidth = 0;
rtp_rtcp_->GetEstimatedSendBandwidth(base_channel_id_, &send_bandwidth); channel_group_->GetBitrateController()->AvailableBandwidth(&send_bandwidth);
stats.send_bandwidth_bps = send_bandwidth; std::vector<unsigned int> ssrcs;
uint32_t recv_bandwidth = 0; uint32_t recv_bandwidth = 0;
rtp_rtcp_->GetEstimatedReceiveBandwidth(base_channel_id_, &recv_bandwidth); channel_group_->GetRemoteBitrateEstimator()->LatestEstimate(&ssrcs,
&recv_bandwidth);
stats.send_bandwidth_bps = send_bandwidth;
stats.recv_bandwidth_bps = recv_bandwidth; stats.recv_bandwidth_bps = recv_bandwidth;
stats.pacer_delay_ms = channel_group_->GetPacerQueuingDelayMs(); stats.pacer_delay_ms = channel_group_->GetPacerQueuingDelayMs();
{ {
@@ -429,8 +403,16 @@ void Call::SetBitrateConfig(
return; return;
} }
config_.bitrate_config = bitrate_config; config_.bitrate_config = bitrate_config;
network_->SetBitrateConfig(base_channel_id_, bitrate_config.min_bitrate_bps, SetBitrateControllerConfig(bitrate_config);
bitrate_config.start_bitrate_bps, }
void Call::SetBitrateControllerConfig(
const webrtc::Call::Config::BitrateConfig& bitrate_config) {
BitrateController* bitrate_controller =
channel_group_->GetBitrateController();
if (bitrate_config.start_bitrate_bps > 0)
bitrate_controller->SetStartBitrate(bitrate_config.start_bitrate_bps);
bitrate_controller->SetMinMaxBitrate(bitrate_config.min_bitrate_bps,
bitrate_config.max_bitrate_bps); bitrate_config.max_bitrate_bps);
} }

View File

@@ -20,7 +20,6 @@
#include "webrtc/modules/remote_bitrate_estimator/rate_statistics.h" #include "webrtc/modules/remote_bitrate_estimator/rate_statistics.h"
#include "webrtc/modules/video_coding/main/interface/video_coding_defines.h" #include "webrtc/modules/video_coding/main/interface/video_coding_defines.h"
#include "webrtc/video_engine/include/vie_codec.h" #include "webrtc/video_engine/include/vie_codec.h"
#include "webrtc/video_engine/include/vie_rtp_rtcp.h"
#include "webrtc/video_engine/report_block_stats.h" #include "webrtc/video_engine/report_block_stats.h"
#include "webrtc/video_receive_stream.h" #include "webrtc/video_receive_stream.h"
#include "webrtc/video_renderer.h" #include "webrtc/video_renderer.h"

View File

@@ -22,7 +22,6 @@
#include "webrtc/modules/video_coding/main/interface/video_coding_defines.h" #include "webrtc/modules/video_coding/main/interface/video_coding_defines.h"
#include "webrtc/system_wrappers/interface/clock.h" #include "webrtc/system_wrappers/interface/clock.h"
#include "webrtc/video_engine/include/vie_base.h" #include "webrtc/video_engine/include/vie_base.h"
#include "webrtc/video_engine/include/vie_capture.h"
#include "webrtc/video_engine/include/vie_codec.h" #include "webrtc/video_engine/include/vie_codec.h"
#include "webrtc/video_send_stream.h" #include "webrtc/video_send_stream.h"

View File

@@ -20,7 +20,6 @@
#include "webrtc/system_wrappers/interface/logging.h" #include "webrtc/system_wrappers/interface/logging.h"
#include "webrtc/video/receive_statistics_proxy.h" #include "webrtc/video/receive_statistics_proxy.h"
#include "webrtc/video_encoder.h" #include "webrtc/video_encoder.h"
#include "webrtc/video_engine/include/vie_base.h"
#include "webrtc/video_receive_stream.h" #include "webrtc/video_receive_stream.h"
namespace webrtc { namespace webrtc {
@@ -124,24 +123,24 @@ VideoCodec CreateDecoderVideoCodec(const VideoReceiveStream::Decoder& decoder) {
} }
} // namespace } // namespace
VideoReceiveStream::VideoReceiveStream(webrtc::VideoEngine* video_engine, VideoReceiveStream::VideoReceiveStream(int num_cpu_cores,
int base_channel_id,
ChannelGroup* channel_group, ChannelGroup* channel_group,
int channel_id,
const VideoReceiveStream::Config& config, const VideoReceiveStream::Config& config,
newapi::Transport* transport, newapi::Transport* transport,
webrtc::VoiceEngine* voice_engine, webrtc::VoiceEngine* voice_engine)
int base_channel)
: transport_adapter_(transport), : transport_adapter_(transport),
encoded_frame_proxy_(config.pre_decode_callback), encoded_frame_proxy_(config.pre_decode_callback),
config_(config), config_(config),
clock_(Clock::GetRealTimeClock()), clock_(Clock::GetRealTimeClock()),
channel_group_(channel_group), channel_group_(channel_group),
voe_sync_interface_(nullptr), channel_id_(channel_id),
channel_(-1) { voe_sync_interface_(nullptr) {
video_engine_base_ = ViEBase::GetInterface(video_engine); CHECK(channel_group_->CreateReceiveChannel(channel_id_, 0, base_channel_id,
video_engine_base_->CreateReceiveChannel(channel_, base_channel); num_cpu_cores, true));
DCHECK(channel_ != -1);
vie_channel_ = video_engine_base_->GetChannel(channel_); vie_channel_ = channel_group_->GetChannel(channel_id_);
// TODO(pbos): This is not fine grained enough... // TODO(pbos): This is not fine grained enough...
vie_channel_->SetNACKStatus(config_.rtp.nack.rtp_history_ms > 0); vie_channel_->SetNACKStatus(config_.rtp.nack.rtp_history_ms > 0);
@@ -237,10 +236,7 @@ VideoReceiveStream::VideoReceiveStream(webrtc::VideoEngine* video_engine,
CHECK_EQ(0, vie_channel_->SetReceiveCodec(codec)); CHECK_EQ(0, vie_channel_->SetReceiveCodec(codec));
} }
// Register a renderer without a window handle, at depth 0, that covers the incoming_video_stream_.reset(new IncomingVideoStream(0));
// entire rendered area (0->1 both axes). This registers a renderer that
// renders the entire video.
incoming_video_stream_.reset(new IncomingVideoStream(channel_));
incoming_video_stream_->SetExpectedRenderDelay(config.render_delay_ms); incoming_video_stream_->SetExpectedRenderDelay(config.render_delay_ms);
incoming_video_stream_->SetExternalCallback(this); incoming_video_stream_->SetExternalCallback(this);
vie_channel_->SetIncomingVideoStream(incoming_video_stream_.get()); vie_channel_->SetIncomingVideoStream(incoming_video_stream_.get());
@@ -273,8 +269,7 @@ VideoReceiveStream::~VideoReceiveStream() {
vie_channel_->RegisterReceiveChannelRtpStatisticsCallback(nullptr); vie_channel_->RegisterReceiveChannelRtpStatisticsCallback(nullptr);
vie_channel_->RegisterReceiveChannelRtcpStatisticsCallback(nullptr); vie_channel_->RegisterReceiveChannelRtcpStatisticsCallback(nullptr);
vie_channel_->RegisterRtcpPacketTypeCounterObserver(nullptr); vie_channel_->RegisterRtcpPacketTypeCounterObserver(nullptr);
video_engine_base_->DeleteChannel(channel_); channel_group_->DeleteChannel(channel_id_);
video_engine_base_->Release();
} }
void VideoReceiveStream::Start() { void VideoReceiveStream::Start() {

View File

@@ -22,7 +22,6 @@
#include "webrtc/video/encoded_frame_callback_adapter.h" #include "webrtc/video/encoded_frame_callback_adapter.h"
#include "webrtc/video/receive_statistics_proxy.h" #include "webrtc/video/receive_statistics_proxy.h"
#include "webrtc/video/transport_adapter.h" #include "webrtc/video/transport_adapter.h"
#include "webrtc/video_engine/include/vie_render.h"
#include "webrtc/video_engine/vie_channel.h" #include "webrtc/video_engine/vie_channel.h"
#include "webrtc/video_engine/vie_channel_group.h" #include "webrtc/video_engine/vie_channel_group.h"
#include "webrtc/video_engine/vie_encoder.h" #include "webrtc/video_engine/vie_encoder.h"
@@ -30,8 +29,6 @@
namespace webrtc { namespace webrtc {
class VideoEngine;
class ViEBase;
class VoiceEngine; class VoiceEngine;
namespace internal { namespace internal {
@@ -40,12 +37,13 @@ class VideoReceiveStream : public webrtc::VideoReceiveStream,
public I420FrameCallback, public I420FrameCallback,
public VideoRenderCallback { public VideoRenderCallback {
public: public:
VideoReceiveStream(webrtc::VideoEngine* video_engine, VideoReceiveStream(int num_cpu_cores,
int base_channel_id,
ChannelGroup* channel_group, ChannelGroup* channel_group,
int channel_id,
const VideoReceiveStream::Config& config, const VideoReceiveStream::Config& config,
newapi::Transport* transport, newapi::Transport* transport,
webrtc::VoiceEngine* voice_engine, webrtc::VoiceEngine* voice_engine);
int base_channel);
virtual ~VideoReceiveStream(); virtual ~VideoReceiveStream();
void Start() override; void Start() override;
@@ -73,16 +71,14 @@ class VideoReceiveStream : public webrtc::VideoReceiveStream,
Clock* const clock_; Clock* const clock_;
ChannelGroup* const channel_group_; ChannelGroup* const channel_group_;
const int channel_id_;
ViEChannel* vie_channel_; ViEChannel* vie_channel_;
rtc::scoped_ptr<IncomingVideoStream> incoming_video_stream_; rtc::scoped_ptr<IncomingVideoStream> incoming_video_stream_;
ViEBase* video_engine_base_;
VoEVideoSync* voe_sync_interface_; VoEVideoSync* voe_sync_interface_;
rtc::scoped_ptr<ReceiveStatisticsProxy> stats_proxy_; rtc::scoped_ptr<ReceiveStatisticsProxy> stats_proxy_;
int channel_;
}; };
} // namespace internal } // namespace internal
} // namespace webrtc } // namespace webrtc

View File

@@ -20,12 +20,11 @@
#include "webrtc/system_wrappers/interface/logging.h" #include "webrtc/system_wrappers/interface/logging.h"
#include "webrtc/system_wrappers/interface/trace_event.h" #include "webrtc/system_wrappers/interface/trace_event.h"
#include "webrtc/video_engine/encoder_state_feedback.h" #include "webrtc/video_engine/encoder_state_feedback.h"
#include "webrtc/video_engine/include/vie_base.h"
#include "webrtc/video_engine/vie_capturer.h" #include "webrtc/video_engine/vie_capturer.h"
#include "webrtc/video_engine/vie_channel.h" #include "webrtc/video_engine/vie_channel.h"
#include "webrtc/video_engine/vie_channel_group.h" #include "webrtc/video_engine/vie_channel_group.h"
#include "webrtc/video_engine/vie_encoder.h"
#include "webrtc/video_engine/vie_defines.h" #include "webrtc/video_engine/vie_defines.h"
#include "webrtc/video_engine/vie_encoder.h"
#include "webrtc/video_send_stream.h" #include "webrtc/video_send_stream.h"
namespace webrtc { namespace webrtc {
@@ -104,30 +103,25 @@ namespace internal {
VideoSendStream::VideoSendStream( VideoSendStream::VideoSendStream(
newapi::Transport* transport, newapi::Transport* transport,
CpuOveruseObserver* overuse_observer, CpuOveruseObserver* overuse_observer,
webrtc::VideoEngine* video_engine, int num_cpu_cores,
ChannelGroup* channel_group,
ProcessThread* module_process_thread, ProcessThread* module_process_thread,
ChannelGroup* channel_group,
int channel_id,
const VideoSendStream::Config& config, const VideoSendStream::Config& config,
const VideoEncoderConfig& encoder_config, const VideoEncoderConfig& encoder_config,
const std::map<uint32_t, RtpState>& suspended_ssrcs, const std::map<uint32_t, RtpState>& suspended_ssrcs)
int base_channel)
: transport_adapter_(transport), : transport_adapter_(transport),
encoded_frame_proxy_(config.post_encode_callback), encoded_frame_proxy_(config.post_encode_callback),
config_(config), config_(config),
suspended_ssrcs_(suspended_ssrcs), suspended_ssrcs_(suspended_ssrcs),
channel_group_(channel_group),
module_process_thread_(module_process_thread), module_process_thread_(module_process_thread),
channel_(-1), channel_group_(channel_group),
channel_id_(channel_id),
use_config_bitrate_(true), use_config_bitrate_(true),
stats_proxy_(Clock::GetRealTimeClock(), config) { stats_proxy_(Clock::GetRealTimeClock(), config) {
// TODO(pbos): Move channel creation out of vie_base as soon as these are no CHECK(channel_group->CreateSendChannel(channel_id_, 0, num_cpu_cores, true));
// longer referenced by channel ids. vie_channel_ = channel_group_->GetChannel(channel_id_);
video_engine_base_ = ViEBase::GetInterface(video_engine); vie_encoder_ = channel_group_->GetEncoder(channel_id_);
video_engine_base_->CreateChannelWithoutDefaultEncoder(channel_,
base_channel);
DCHECK(channel_ != -1);
vie_channel_ = video_engine_base_->GetChannel(channel_);
vie_encoder_ = video_engine_base_->GetEncoder(channel_);
DCHECK(!config_.rtp.ssrcs.empty()); DCHECK(!config_.rtp.ssrcs.empty());
@@ -148,8 +142,7 @@ VideoSendStream::VideoSendStream(
} }
} }
// TODO(pbos): Remove channel_group_ usage from VideoSendStream. This should // TODO(pbos): Consider configuring REMB in Call.
// be configured in call.cc.
channel_group_->SetChannelRembStatus(true, false, vie_channel_); channel_group_->SetChannelRembStatus(true, false, vie_channel_);
// Enable NACK, FEC or both. // Enable NACK, FEC or both.
@@ -187,7 +180,7 @@ VideoSendStream::VideoSendStream(
vie_channel_->SetRTCPCName(rtcp_cname); vie_channel_->SetRTCPCName(rtcp_cname);
vie_capturer_ = ViECapturer::CreateViECapturer(module_process_thread_); vie_capturer_ = ViECapturer::CreateViECapturer(module_process_thread_);
CHECK_EQ(0, vie_capturer_->RegisterFrameCallback(channel_, vie_encoder_)); CHECK_EQ(0, vie_capturer_->RegisterFrameCallback(channel_id_, vie_encoder_));
vie_channel_->RegisterSendTransport(&transport_adapter_); vie_channel_->RegisterSendTransport(&transport_adapter_);
// 28 to match packet overhead in ModuleRtpRtcpImpl. // 28 to match packet overhead in ModuleRtpRtcpImpl.
@@ -210,8 +203,8 @@ VideoSendStream::VideoSendStream(
// Registered regardless of monitoring, used for stats. // Registered regardless of monitoring, used for stats.
vie_capturer_->RegisterCpuOveruseMetricsObserver(&stats_proxy_); vie_capturer_->RegisterCpuOveruseMetricsObserver(&stats_proxy_);
video_engine_base_->RegisterSendSideDelayObserver(channel_, &stats_proxy_); vie_channel_->RegisterSendSideDelayObserver(&stats_proxy_);
video_engine_base_->RegisterSendStatisticsProxy(channel_, &stats_proxy_); vie_encoder_->RegisterSendStatisticsProxy(&stats_proxy_);
vie_encoder_->RegisterPreEncodeCallback(config_.pre_encode_callback); vie_encoder_->RegisterPreEncodeCallback(config_.pre_encode_callback);
if (config_.post_encode_callback) if (config_.post_encode_callback)
@@ -256,9 +249,7 @@ VideoSendStream::~VideoSendStream() {
vie_encoder_->DeRegisterExternalEncoder( vie_encoder_->DeRegisterExternalEncoder(
config_.encoder_settings.payload_type); config_.encoder_settings.payload_type);
video_engine_base_->DeleteChannel(channel_); channel_group_->DeleteChannel(channel_id_);
video_engine_base_->Release();
} }
void VideoSendStream::IncomingCapturedFrame(const I420VideoFrame& frame) { void VideoSendStream::IncomingCapturedFrame(const I420VideoFrame& frame) {
@@ -274,13 +265,19 @@ VideoSendStreamInput* VideoSendStream::Input() { return this; }
void VideoSendStream::Start() { void VideoSendStream::Start() {
transport_adapter_.Enable(); transport_adapter_.Enable();
video_engine_base_->StartSend(channel_); vie_encoder_->Pause();
video_engine_base_->StartReceive(channel_); if (vie_channel_->StartSend() == 0) {
// Was not already started, trigger a keyframe.
vie_encoder_->SendKeyFrame();
}
vie_encoder_->Restart();
vie_channel_->StartReceive();
} }
void VideoSendStream::Stop() { void VideoSendStream::Stop() {
video_engine_base_->StopSend(channel_); // TODO(pbos): Make sure the encoder stops here.
video_engine_base_->StopReceive(channel_); vie_channel_->StopSend();
vie_channel_->StopReceive();
transport_adapter_.Disable(); transport_adapter_.Disable();
} }

View File

@@ -28,11 +28,9 @@ namespace webrtc {
class CpuOveruseObserver; class CpuOveruseObserver;
class ProcessThread; class ProcessThread;
class ViEBase;
class ViECapturer; class ViECapturer;
class ViEChannel; class ViEChannel;
class ViEEncoder; class ViEEncoder;
class VideoEngine;
namespace internal { namespace internal {
@@ -41,13 +39,13 @@ class VideoSendStream : public webrtc::VideoSendStream,
public: public:
VideoSendStream(newapi::Transport* transport, VideoSendStream(newapi::Transport* transport,
CpuOveruseObserver* overuse_observer, CpuOveruseObserver* overuse_observer,
webrtc::VideoEngine* video_engine, int num_cpu_cores,
ChannelGroup* channel_group,
ProcessThread* module_process_thread, ProcessThread* module_process_thread,
ChannelGroup* channel_group,
int channel_id,
const VideoSendStream::Config& config, const VideoSendStream::Config& config,
const VideoEncoderConfig& encoder_config, const VideoEncoderConfig& encoder_config,
const std::map<uint32_t, RtpState>& suspended_ssrcs, const std::map<uint32_t, RtpState>& suspended_ssrcs);
int base_channel);
virtual ~VideoSendStream(); virtual ~VideoSendStream();
@@ -82,16 +80,14 @@ class VideoSendStream : public webrtc::VideoSendStream,
VideoEncoderConfig encoder_config_; VideoEncoderConfig encoder_config_;
std::map<uint32_t, RtpState> suspended_ssrcs_; std::map<uint32_t, RtpState> suspended_ssrcs_;
ChannelGroup* const channel_group_;
ProcessThread* const module_process_thread_; ProcessThread* const module_process_thread_;
ChannelGroup* const channel_group_;
const int channel_id_;
ViEBase* video_engine_base_;
ViEChannel* vie_channel_; ViEChannel* vie_channel_;
ViEEncoder* vie_encoder_; ViEEncoder* vie_encoder_;
ViECapturer* vie_capturer_; ViECapturer* vie_capturer_;
int channel_;
// Used as a workaround to indicate that we should be using the configured // Used as a workaround to indicate that we should be using the configured
// start bitrate initially, instead of the one reported by VideoEngine (which // start bitrate initially, instead of the one reported by VideoEngine (which
// defaults to too high). // defaults to too high).