solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #include <list> |
| 12 | |
| 13 | #include "testing/gtest/include/gtest/gtest.h" |
| 14 | |
| 15 | #include "webrtc/call.h" |
| 16 | |
| 17 | namespace { |
| 18 | |
| 19 | struct CallHelper { |
solenberg | 43e83d4 | 2015-10-20 06:41:01 -0700 | [diff] [blame^] | 20 | CallHelper() { |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 21 | webrtc::Call::Config config; |
solenberg | 43e83d4 | 2015-10-20 06:41:01 -0700 | [diff] [blame^] | 22 | // TODO(solenberg): Fill in with VoiceEngine* etc. |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 23 | call_.reset(webrtc::Call::Create(config)); |
| 24 | } |
| 25 | |
| 26 | webrtc::Call* operator->() { return call_.get(); } |
| 27 | |
| 28 | private: |
solenberg | c7a8b08 | 2015-10-16 14:35:07 -0700 | [diff] [blame] | 29 | rtc::scoped_ptr<webrtc::Call> call_; |
| 30 | }; |
| 31 | } // namespace |
| 32 | |
| 33 | namespace webrtc { |
| 34 | |
| 35 | TEST(CallTest, ConstructDestruct) { |
| 36 | CallHelper call; |
| 37 | } |
| 38 | |
| 39 | TEST(CallTest, CreateDestroy_AudioSendStream) { |
| 40 | CallHelper call; |
| 41 | AudioSendStream::Config config(nullptr); |
| 42 | config.rtp.ssrc = 42; |
| 43 | config.voe_channel_id = 123; |
| 44 | AudioSendStream* stream = call->CreateAudioSendStream(config); |
| 45 | EXPECT_NE(stream, nullptr); |
| 46 | call->DestroyAudioSendStream(stream); |
| 47 | } |
| 48 | |
| 49 | TEST(CallTest, CreateDestroy_AudioReceiveStream) { |
| 50 | CallHelper call; |
| 51 | AudioReceiveStream::Config config; |
| 52 | config.rtp.remote_ssrc = 42; |
| 53 | config.voe_channel_id = 123; |
| 54 | AudioReceiveStream* stream = call->CreateAudioReceiveStream(config); |
| 55 | EXPECT_NE(stream, nullptr); |
| 56 | call->DestroyAudioReceiveStream(stream); |
| 57 | } |
| 58 | |
| 59 | TEST(CallTest, CreateDestroy_AudioSendStreams) { |
| 60 | CallHelper call; |
| 61 | AudioSendStream::Config config(nullptr); |
| 62 | config.voe_channel_id = 123; |
| 63 | std::list<AudioSendStream*> streams; |
| 64 | for (int i = 0; i < 2; ++i) { |
| 65 | for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) { |
| 66 | config.rtp.ssrc = ssrc; |
| 67 | AudioSendStream* stream = call->CreateAudioSendStream(config); |
| 68 | EXPECT_NE(stream, nullptr); |
| 69 | if (ssrc & 1) { |
| 70 | streams.push_back(stream); |
| 71 | } else { |
| 72 | streams.push_front(stream); |
| 73 | } |
| 74 | } |
| 75 | for (auto s : streams) { |
| 76 | call->DestroyAudioSendStream(s); |
| 77 | } |
| 78 | streams.clear(); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | TEST(CallTest, CreateDestroy_AudioReceiveStreams) { |
| 83 | CallHelper call; |
| 84 | AudioReceiveStream::Config config; |
| 85 | config.voe_channel_id = 123; |
| 86 | std::list<AudioReceiveStream*> streams; |
| 87 | for (int i = 0; i < 2; ++i) { |
| 88 | for (uint32_t ssrc = 0; ssrc < 1234567; ssrc += 34567) { |
| 89 | config.rtp.remote_ssrc = ssrc; |
| 90 | AudioReceiveStream* stream = call->CreateAudioReceiveStream(config); |
| 91 | EXPECT_NE(stream, nullptr); |
| 92 | if (ssrc & 1) { |
| 93 | streams.push_back(stream); |
| 94 | } else { |
| 95 | streams.push_front(stream); |
| 96 | } |
| 97 | } |
| 98 | for (auto s : streams) { |
| 99 | call->DestroyAudioReceiveStream(s); |
| 100 | } |
| 101 | streams.clear(); |
| 102 | } |
| 103 | } |
| 104 | } // namespace webrtc |