Index: webrtc/video/video_quality_test.cc |
diff --git a/webrtc/video/video_quality_test.cc b/webrtc/video/video_quality_test.cc |
index 66210d08643e62fc93bccff52f0eea2ba70f8b04..ed0aae51928058f04068bcd6a21f21f6b3246750 100644 |
--- a/webrtc/video/video_quality_test.cc |
+++ b/webrtc/video/video_quality_test.cc |
@@ -34,6 +34,8 @@ |
#include "webrtc/test/testsupport/fileutils.h" |
#include "webrtc/test/video_renderer.h" |
#include "webrtc/video/video_quality_test.h" |
+#include "webrtc/voice_engine/include/voe_base.h" |
+#include "webrtc/voice_engine/include/voe_codec.h" |
namespace webrtc { |
@@ -1110,6 +1112,12 @@ void VideoQualityTest::RunWithVideoRenderer(const Params& params) { |
// match the full stack tests. |
Call::Config call_config; |
call_config.bitrate_config = params_.common.call_bitrate_config; |
+ |
+ CreateVoiceEngine(); |
stefan-webrtc
2016/07/11 15:01:10
I think we should add an option to configure with
minyue-webrtc
2016/07/12 10:09:36
Done.
|
+ AudioState::Config audio_state_config; |
+ audio_state_config.voice_engine = voe_.voice_engine; |
+ call_config.audio_state = AudioState::Create(audio_state_config); |
+ |
std::unique_ptr<Call> call(Call::Create(call_config)); |
test::LayerFilteringTransport transport( |
@@ -1124,6 +1132,7 @@ void VideoQualityTest::RunWithVideoRenderer(const Params& params) { |
video_send_config_.local_renderer = local_preview.get(); |
video_receive_configs_[stream_id].renderer = loopback_video.get(); |
+ // video_receive_configs_[stream_id].sync_group = kSyncGroup; |
stefan-webrtc
2016/07/11 15:01:10
Would be good to be able to test sync. Maybe have
minyue-webrtc
2016/07/12 10:09:36
Done. So we can use the actually device instead of
|
video_send_config_.suspend_below_min_bitrate = |
params_.common.suspend_below_min_bitrate; |
@@ -1142,24 +1151,98 @@ void VideoQualityTest::RunWithVideoRenderer(const Params& params) { |
video_send_stream_ = |
call->CreateVideoSendStream(video_send_config_, video_encoder_config_); |
- VideoReceiveStream* receive_stream = |
+ VideoReceiveStream* video_receive_stream = |
call->CreateVideoReceiveStream(video_receive_configs_[stream_id].Copy()); |
CreateCapturer(video_send_stream_->Input()); |
- receive_stream->Start(); |
+ audio_send_config_ = AudioSendStream::Config(&transport); |
+ audio_send_config_.voe_channel_id = voe_.send_channel_id; |
+ audio_send_config_.rtp.ssrc = kAudioSendSsrc; |
+ audio_send_stream_ = call->CreateAudioSendStream(audio_send_config_); |
+ |
+ AudioReceiveStream::Config audio_config; |
+ audio_config.rtp.local_ssrc = kReceiverLocalAudioSsrc; |
+ audio_config.rtcp_send_transport = &transport; |
+ audio_config.voe_channel_id = voe_.receive_channel_id; |
+ audio_config.rtp.remote_ssrc = audio_send_config_.rtp.ssrc; |
+ audio_config.decoder_factory = decoder_factory_; |
+ audio_receive_configs_.push_back(audio_config); |
+ AudioReceiveStream* audio_receive_stream = |
+ call->CreateAudioReceiveStream(audio_receive_configs_[0]); |
+ |
+ const CodecInst kOpusInst = {120, "OPUS", 48000, 960, 2, 64000}; |
+ EXPECT_EQ(0, voe_.codec->SetSendCodec(voe_.send_channel_id, kOpusInst)); |
+ |
+ // Start sending and receiving video. |
+ video_receive_stream->Start(); |
video_send_stream_->Start(); |
capturer_->Start(); |
+ // Start receiving audio. |
+ audio_receive_stream->Start(); |
+ EXPECT_EQ(0, voe_.base->StartPlayout(voe_.receive_channel_id)); |
+ EXPECT_EQ(0, voe_.base->StartReceive(voe_.receive_channel_id)); |
+ |
+ // Start sending audio. |
+ audio_send_stream_->Start(); |
+ EXPECT_EQ(0, voe_.base->StartSend(voe_.send_channel_id)); |
+ fake_audio_device_->Start(); |
+ |
test::PressEnterToContinue(); |
+ // Stop sending audio. |
+ fake_audio_device_->Stop(); |
+ EXPECT_EQ(0, voe_.base->StopSend(voe_.send_channel_id)); |
+ audio_send_stream_->Stop(); |
+ |
+ // Stop receiving audio. |
+ EXPECT_EQ(0, voe_.base->StopReceive(voe_.receive_channel_id)); |
+ EXPECT_EQ(0, voe_.base->StopPlayout(voe_.receive_channel_id)); |
+ audio_receive_stream->Stop(); |
+ |
+ // Stop receiving and sending video. |
capturer_->Stop(); |
video_send_stream_->Stop(); |
- receive_stream->Stop(); |
+ video_receive_stream->Stop(); |
- call->DestroyVideoReceiveStream(receive_stream); |
+ call->DestroyVideoReceiveStream(video_receive_stream); |
call->DestroyVideoSendStream(video_send_stream_); |
+ call->DestroyAudioSendStream(audio_send_stream_); |
+ call->DestroyAudioReceiveStream(audio_receive_stream); |
transport.StopSending(); |
+ DestroyVoiceEngine(); |
+} |
+ |
+void VideoQualityTest::CreateVoiceEngine() { |
+ fake_audio_device_.reset(new test::FakeAudioDevice( |
+ clock_, test::ResourcePath("voice_engine/audio_long16", "pcm"), |
+ test::DriftingClock::kNoDrift)); |
+ voe_.voice_engine = VoiceEngine::Create(); |
+ voe_.base = VoEBase::GetInterface(voe_.voice_engine); |
+ voe_.codec = VoECodec::GetInterface(voe_.voice_engine); |
+ EXPECT_EQ(0, voe_.base->Init(fake_audio_device_.get(), nullptr, |
+ decoder_factory_)); |
+ Config voe_config; |
+ voe_config.Set<VoicePacing>(new VoicePacing(true)); |
+ voe_.send_channel_id = voe_.base->CreateChannel(voe_config); |
+ EXPECT_GE(voe_.send_channel_id, 0); |
+ voe_.receive_channel_id = voe_.base->CreateChannel(); |
+ EXPECT_GE(voe_.receive_channel_id, 0); |
+} |
+ |
+void VideoQualityTest::DestroyVoiceEngine() { |
+ voe_.base->DeleteChannel(voe_.send_channel_id); |
+ voe_.send_channel_id = -1; |
+ voe_.base->DeleteChannel(voe_.receive_channel_id); |
+ voe_.receive_channel_id = -1; |
+ voe_.base->Release(); |
+ voe_.base = nullptr; |
+ voe_.codec->Release(); |
+ voe_.codec = nullptr; |
+ |
+ VoiceEngine::Delete(voe_.voice_engine); |
+ voe_.voice_engine = nullptr; |
} |
} // namespace webrtc |