 Chromium Code Reviews
 Chromium Code Reviews Issue 1459083007:
  Open backdoor in VoiceEngineImpl to get at the actual voe::Channel objects from an ID.  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master
    
  
    Issue 1459083007:
  Open backdoor in VoiceEngineImpl to get at the actual voe::Channel objects from an ID.  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master| OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 
| 3 * | 3 * | 
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license | 
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source | 
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found | 
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may | 
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. | 
| 9 */ | 9 */ | 
| 10 | 10 | 
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" | 
| 12 | 12 | 
| 13 #include "webrtc/audio/audio_send_stream.h" | 13 #include "webrtc/audio/audio_send_stream.h" | 
| 14 #include "webrtc/audio/audio_state.h" | 14 #include "webrtc/audio/audio_state.h" | 
| 15 #include "webrtc/audio/conversion.h" | 15 #include "webrtc/audio/conversion.h" | 
| 16 #include "webrtc/test/mock_voe_channel_proxy.h" | |
| 16 #include "webrtc/test/mock_voice_engine.h" | 17 #include "webrtc/test/mock_voice_engine.h" | 
| 17 | 18 | 
| 18 namespace webrtc { | 19 namespace webrtc { | 
| 19 namespace test { | 20 namespace test { | 
| 20 namespace { | 21 namespace { | 
| 21 | 22 | 
| 22 using testing::_; | 23 using testing::_; | 
| 23 using testing::Return; | 24 using testing::Return; | 
| 24 | 25 | 
| 25 const int kChannelId = 1; | 26 const int kChannelId = 1; | 
| 26 const uint32_t kSsrc = 1234; | 27 const uint32_t kSsrc = 1234; | 
| 27 const char* kCName = "foo_name"; | 28 const char* kCName = "foo_name"; | 
| 28 const int kAudioLevelId = 2; | 29 const int kAudioLevelId = 2; | 
| 29 const int kAbsSendTimeId = 3; | 30 const int kAbsSendTimeId = 3; | 
| 30 const int kEchoDelayMedian = 254; | 31 const int kEchoDelayMedian = 254; | 
| 31 const int kEchoDelayStdDev = -3; | 32 const int kEchoDelayStdDev = -3; | 
| 32 const int kEchoReturnLoss = -65; | 33 const int kEchoReturnLoss = -65; | 
| 33 const int kEchoReturnLossEnhancement = 101; | 34 const int kEchoReturnLossEnhancement = 101; | 
| 34 const unsigned int kSpeechInputLevel = 96; | 35 const unsigned int kSpeechInputLevel = 96; | 
| 35 const CallStatistics kCallStats = { | 36 const CallStatistics kCallStats = { | 
| 36 1345, 1678, 1901, 1234, 112, 13456, 17890, 1567, -1890, -1123}; | 37 1345, 1678, 1901, 1234, 112, 13456, 17890, 1567, -1890, -1123}; | 
| 37 const CodecInst kCodecInst = {-121, "codec_name_send", 48000, -231, -451, -671}; | 38 const CodecInst kCodecInst = {-121, "codec_name_send", 48000, -231, -451, -671}; | 
| 38 const ReportBlock kReportBlock = {456, 780, 123, 567, 890, 132, 143, 13354}; | 39 const ReportBlock kReportBlock = {456, 780, 123, 567, 890, 132, 143, 13354}; | 
| 39 | 40 | 
| 40 struct ConfigHelper { | 41 struct ConfigHelper { | 
| 41 ConfigHelper() : stream_config_(nullptr) { | 42 ConfigHelper() : stream_config_(nullptr) { | 
| 42 using testing::StrEq; | 43 using testing::Invoke; | 
| 43 | 44 | 
| 44 EXPECT_CALL(voice_engine_, | 45 EXPECT_CALL(voice_engine_, | 
| 45 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); | 46 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); | 
| 46 EXPECT_CALL(voice_engine_, | 47 EXPECT_CALL(voice_engine_, | 
| 47 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); | 48 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); | 
| 48 AudioState::Config config; | 49 AudioState::Config config; | 
| 49 config.voice_engine = &voice_engine_; | 50 config.voice_engine = &voice_engine_; | 
| 50 audio_state_ = AudioState::Create(config); | 51 audio_state_ = AudioState::Create(config); | 
| 51 | 52 | 
| 52 EXPECT_CALL(voice_engine_, SetRTCPStatus(kChannelId, true)) | 53 EXPECT_CALL(voice_engine_, GetChannelProxy(kChannelId)) | 
| 53 .WillOnce(Return(0)); | 54 .WillOnce(Invoke(this, &ConfigHelper::CreateChannelProxy)); | 
| 
kwiberg-webrtc
2015/11/25 10:44:59
See earlier comment about lambda and whether chann
 
the sun
2015/11/25 12:28:01
channel_proxy_ *will* be needed. Once the methods
 | |
| 54 EXPECT_CALL(voice_engine_, SetLocalSSRC(kChannelId, kSsrc)) | |
| 55 .WillOnce(Return(0)); | |
| 56 EXPECT_CALL(voice_engine_, SetRTCP_CNAME(kChannelId, StrEq(kCName))) | |
| 57 .WillOnce(Return(0)); | |
| 58 EXPECT_CALL(voice_engine_, | 55 EXPECT_CALL(voice_engine_, | 
| 59 SetSendAbsoluteSenderTimeStatus(kChannelId, true, kAbsSendTimeId)) | 56 SetSendAbsoluteSenderTimeStatus(kChannelId, true, kAbsSendTimeId)) | 
| 60 .WillOnce(Return(0)); | 57 .WillOnce(Return(0)); | 
| 61 EXPECT_CALL(voice_engine_, | 58 EXPECT_CALL(voice_engine_, | 
| 62 SetSendAudioLevelIndicationStatus(kChannelId, true, kAudioLevelId)) | 59 SetSendAudioLevelIndicationStatus(kChannelId, true, kAudioLevelId)) | 
| 63 .WillOnce(Return(0)); | 60 .WillOnce(Return(0)); | 
| 64 stream_config_.voe_channel_id = kChannelId; | 61 stream_config_.voe_channel_id = kChannelId; | 
| 65 stream_config_.rtp.ssrc = kSsrc; | 62 stream_config_.rtp.ssrc = kSsrc; | 
| 66 stream_config_.rtp.c_name = kCName; | 63 stream_config_.rtp.c_name = kCName; | 
| 67 stream_config_.rtp.extensions.push_back( | 64 stream_config_.rtp.extensions.push_back( | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 EXPECT_CALL(voice_engine_, GetEchoMetrics(_, _, _, _)) | 96 EXPECT_CALL(voice_engine_, GetEchoMetrics(_, _, _, _)) | 
| 100 .WillRepeatedly(DoAll(SetArgReferee<0>(kEchoReturnLoss), | 97 .WillRepeatedly(DoAll(SetArgReferee<0>(kEchoReturnLoss), | 
| 101 SetArgReferee<1>(kEchoReturnLossEnhancement), | 98 SetArgReferee<1>(kEchoReturnLossEnhancement), | 
| 102 Return(0))); | 99 Return(0))); | 
| 103 EXPECT_CALL(voice_engine_, GetEcDelayMetrics(_, _, _)) | 100 EXPECT_CALL(voice_engine_, GetEcDelayMetrics(_, _, _)) | 
| 104 .WillRepeatedly(DoAll(SetArgReferee<0>(kEchoDelayMedian), | 101 .WillRepeatedly(DoAll(SetArgReferee<0>(kEchoDelayMedian), | 
| 105 SetArgReferee<1>(kEchoDelayStdDev), Return(0))); | 102 SetArgReferee<1>(kEchoDelayStdDev), Return(0))); | 
| 106 } | 103 } | 
| 107 | 104 | 
| 108 private: | 105 private: | 
| 106 voe::ChannelProxy* CreateChannelProxy(int channel_id) { | |
| 107 using testing::StrEq; | |
| 108 | |
| 109 EXPECT_FALSE(channel_proxy_); | |
| 110 channel_proxy_ = new testing::StrictMock<MockVoEChannelProxy>(); | |
| 111 EXPECT_CALL(*channel_proxy_, SetRTCPStatus(true)).Times(1); | |
| 112 EXPECT_CALL(*channel_proxy_, SetLocalSSRC(kSsrc)).Times(1); | |
| 113 EXPECT_CALL(*channel_proxy_, SetRTCP_CNAME(StrEq(kCName))).Times(1); | |
| 114 return channel_proxy_; | |
| 115 } | |
| 116 | |
| 109 testing::StrictMock<MockVoiceEngine> voice_engine_; | 117 testing::StrictMock<MockVoiceEngine> voice_engine_; | 
| 110 rtc::scoped_refptr<AudioState> audio_state_; | 118 rtc::scoped_refptr<AudioState> audio_state_; | 
| 111 AudioSendStream::Config stream_config_; | 119 AudioSendStream::Config stream_config_; | 
| 120 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; | |
| 112 }; | 121 }; | 
| 113 } // namespace | 122 } // namespace | 
| 114 | 123 | 
| 115 TEST(AudioSendStreamTest, ConfigToString) { | 124 TEST(AudioSendStreamTest, ConfigToString) { | 
| 116 AudioSendStream::Config config(nullptr); | 125 AudioSendStream::Config config(nullptr); | 
| 117 config.rtp.ssrc = kSsrc; | 126 config.rtp.ssrc = kSsrc; | 
| 118 config.rtp.extensions.push_back( | 127 config.rtp.extensions.push_back( | 
| 119 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeId)); | 128 RtpExtension(RtpExtension::kAbsSendTime, kAbsSendTimeId)); | 
| 120 config.rtp.c_name = kCName; | 129 config.rtp.c_name = kCName; | 
| 121 config.voe_channel_id = kChannelId; | 130 config.voe_channel_id = kChannelId; | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 static_cast<internal::AudioState*>(helper.audio_state().get()); | 180 static_cast<internal::AudioState*>(helper.audio_state().get()); | 
| 172 VoiceEngineObserver* voe_observer = | 181 VoiceEngineObserver* voe_observer = | 
| 173 static_cast<VoiceEngineObserver*>(internal_audio_state); | 182 static_cast<VoiceEngineObserver*>(internal_audio_state); | 
| 174 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_WARNING); | 183 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_WARNING); | 
| 175 EXPECT_TRUE(send_stream.GetStats().typing_noise_detected); | 184 EXPECT_TRUE(send_stream.GetStats().typing_noise_detected); | 
| 176 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING); | 185 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING); | 
| 177 EXPECT_FALSE(send_stream.GetStats().typing_noise_detected); | 186 EXPECT_FALSE(send_stream.GetStats().typing_noise_detected); | 
| 178 } | 187 } | 
| 179 } // namespace test | 188 } // namespace test | 
| 180 } // namespace webrtc | 189 } // namespace webrtc | 
| OLD | NEW |