| 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 <list> | 11 #include <list> |
| 12 #include <memory> | 12 #include <memory> |
| 13 | 13 |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 #include "webrtc/audio_state.h" | 16 #include "webrtc/audio_state.h" |
| 17 #include "webrtc/call.h" | 17 #include "webrtc/call.h" |
| 18 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_decoder_factory.h" |
| 18 #include "webrtc/test/mock_voice_engine.h" | 19 #include "webrtc/test/mock_voice_engine.h" |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 struct CallHelper { | 23 struct CallHelper { |
| 23 CallHelper() { | 24 explicit CallHelper( |
| 25 rtc::scoped_refptr<webrtc::AudioDecoderFactory> decoder_factory = nullptr) |
| 26 : voice_engine_(decoder_factory) { |
| 24 webrtc::AudioState::Config audio_state_config; | 27 webrtc::AudioState::Config audio_state_config; |
| 25 audio_state_config.voice_engine = &voice_engine_; | 28 audio_state_config.voice_engine = &voice_engine_; |
| 26 webrtc::Call::Config config; | 29 webrtc::Call::Config config; |
| 27 config.audio_state = webrtc::AudioState::Create(audio_state_config); | 30 config.audio_state = webrtc::AudioState::Create(audio_state_config); |
| 28 call_.reset(webrtc::Call::Create(config)); | 31 call_.reset(webrtc::Call::Create(config)); |
| 29 } | 32 } |
| 30 | 33 |
| 31 webrtc::Call* operator->() { return call_.get(); } | 34 webrtc::Call* operator->() { return call_.get(); } |
| 32 | 35 |
| 33 private: | 36 private: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 46 CallHelper call; | 49 CallHelper call; |
| 47 AudioSendStream::Config config(nullptr); | 50 AudioSendStream::Config config(nullptr); |
| 48 config.rtp.ssrc = 42; | 51 config.rtp.ssrc = 42; |
| 49 config.voe_channel_id = 123; | 52 config.voe_channel_id = 123; |
| 50 AudioSendStream* stream = call->CreateAudioSendStream(config); | 53 AudioSendStream* stream = call->CreateAudioSendStream(config); |
| 51 EXPECT_NE(stream, nullptr); | 54 EXPECT_NE(stream, nullptr); |
| 52 call->DestroyAudioSendStream(stream); | 55 call->DestroyAudioSendStream(stream); |
| 53 } | 56 } |
| 54 | 57 |
| 55 TEST(CallTest, CreateDestroy_AudioReceiveStream) { | 58 TEST(CallTest, CreateDestroy_AudioReceiveStream) { |
| 56 CallHelper call; | 59 rtc::scoped_refptr<webrtc::AudioDecoderFactory> decoder_factory( |
| 60 new rtc::RefCountedObject<webrtc::MockAudioDecoderFactory>); |
| 61 CallHelper call(decoder_factory); |
| 57 AudioReceiveStream::Config config; | 62 AudioReceiveStream::Config config; |
| 58 config.rtp.remote_ssrc = 42; | 63 config.rtp.remote_ssrc = 42; |
| 59 config.voe_channel_id = 123; | 64 config.voe_channel_id = 123; |
| 65 config.decoder_factory = decoder_factory; |
| 60 AudioReceiveStream* stream = call->CreateAudioReceiveStream(config); | 66 AudioReceiveStream* stream = call->CreateAudioReceiveStream(config); |
| 61 EXPECT_NE(stream, nullptr); | 67 EXPECT_NE(stream, nullptr); |
| 62 call->DestroyAudioReceiveStream(stream); | 68 call->DestroyAudioReceiveStream(stream); |
| 63 } | 69 } |
| 64 | 70 |
| 65 TEST(CallTest, CreateDestroy_AudioSendStreams) { | 71 TEST(CallTest, CreateDestroy_AudioSendStreams) { |
| 66 CallHelper call; | 72 CallHelper call; |
| 67 AudioSendStream::Config config(nullptr); | 73 AudioSendStream::Config config(nullptr); |
| 68 config.voe_channel_id = 123; | 74 config.voe_channel_id = 123; |
| 69 std::list<AudioSendStream*> streams; | 75 std::list<AudioSendStream*> streams; |
| 70 for (int i = 0; i < 2; ++i) { | 76 for (int i = 0; i < 2; ++i) { |
| 71 for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) { | 77 for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) { |
| 72 config.rtp.ssrc = ssrc; | 78 config.rtp.ssrc = ssrc; |
| 73 AudioSendStream* stream = call->CreateAudioSendStream(config); | 79 AudioSendStream* stream = call->CreateAudioSendStream(config); |
| 74 EXPECT_NE(stream, nullptr); | 80 EXPECT_NE(stream, nullptr); |
| 75 if (ssrc & 1) { | 81 if (ssrc & 1) { |
| 76 streams.push_back(stream); | 82 streams.push_back(stream); |
| 77 } else { | 83 } else { |
| 78 streams.push_front(stream); | 84 streams.push_front(stream); |
| 79 } | 85 } |
| 80 } | 86 } |
| 81 for (auto s : streams) { | 87 for (auto s : streams) { |
| 82 call->DestroyAudioSendStream(s); | 88 call->DestroyAudioSendStream(s); |
| 83 } | 89 } |
| 84 streams.clear(); | 90 streams.clear(); |
| 85 } | 91 } |
| 86 } | 92 } |
| 87 | 93 |
| 88 TEST(CallTest, CreateDestroy_AudioReceiveStreams) { | 94 TEST(CallTest, CreateDestroy_AudioReceiveStreams) { |
| 89 CallHelper call; | 95 rtc::scoped_refptr<webrtc::AudioDecoderFactory> decoder_factory( |
| 96 new rtc::RefCountedObject<webrtc::MockAudioDecoderFactory>); |
| 97 CallHelper call(decoder_factory); |
| 90 AudioReceiveStream::Config config; | 98 AudioReceiveStream::Config config; |
| 91 config.voe_channel_id = 123; | 99 config.voe_channel_id = 123; |
| 100 config.decoder_factory = decoder_factory; |
| 92 std::list<AudioReceiveStream*> streams; | 101 std::list<AudioReceiveStream*> streams; |
| 93 for (int i = 0; i < 2; ++i) { | 102 for (int i = 0; i < 2; ++i) { |
| 94 for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) { | 103 for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) { |
| 95 config.rtp.remote_ssrc = ssrc; | 104 config.rtp.remote_ssrc = ssrc; |
| 96 AudioReceiveStream* stream = call->CreateAudioReceiveStream(config); | 105 AudioReceiveStream* stream = call->CreateAudioReceiveStream(config); |
| 97 EXPECT_NE(stream, nullptr); | 106 EXPECT_NE(stream, nullptr); |
| 98 if (ssrc & 1) { | 107 if (ssrc & 1) { |
| 99 streams.push_back(stream); | 108 streams.push_back(stream); |
| 100 } else { | 109 } else { |
| 101 streams.push_front(stream); | 110 streams.push_front(stream); |
| 102 } | 111 } |
| 103 } | 112 } |
| 104 for (auto s : streams) { | 113 for (auto s : streams) { |
| 105 call->DestroyAudioReceiveStream(s); | 114 call->DestroyAudioReceiveStream(s); |
| 106 } | 115 } |
| 107 streams.clear(); | 116 streams.clear(); |
| 108 } | 117 } |
| 109 } | 118 } |
| 110 } // namespace webrtc | 119 } // namespace webrtc |
| OLD | NEW |