OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2008 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 |
(...skipping 20 matching lines...) Expand all Loading... |
31 AudioCodec(97, "voice", 1, 2, 3), AudioCodec(111, "OPUS", 48000, 32000, 2), | 31 AudioCodec(97, "voice", 1, 2, 3), AudioCodec(111, "OPUS", 48000, 32000, 2), |
32 }; | 32 }; |
33 | 33 |
34 static const VideoCodec kVideoCodecs[] = { | 34 static const VideoCodec kVideoCodecs[] = { |
35 VideoCodec(99, "H264"), VideoCodec(100, "VP8"), VideoCodec(96, "rtx"), | 35 VideoCodec(99, "H264"), VideoCodec(100, "VP8"), VideoCodec(96, "rtx"), |
36 }; | 36 }; |
37 | 37 |
38 class ChannelManagerTest : public testing::Test { | 38 class ChannelManagerTest : public testing::Test { |
39 protected: | 39 protected: |
40 ChannelManagerTest() | 40 ChannelManagerTest() |
41 : fme_(new cricket::FakeMediaEngine()), | 41 : network_(rtc::Thread::CreateWithSocketServer()), |
| 42 worker_(rtc::Thread::Create()), |
| 43 fme_(new cricket::FakeMediaEngine()), |
42 fdme_(new cricket::FakeDataEngine()), | 44 fdme_(new cricket::FakeDataEngine()), |
43 cm_(new cricket::ChannelManager( | 45 cm_(new cricket::ChannelManager( |
44 std::unique_ptr<MediaEngineInterface>(fme_), | 46 std::unique_ptr<MediaEngineInterface>(fme_), |
45 std::unique_ptr<DataEngineInterface>(fdme_), | 47 std::unique_ptr<DataEngineInterface>(fdme_), |
46 rtc::Thread::Current())), | 48 rtc::Thread::Current())), |
47 fake_call_(webrtc::Call::Config(&event_log_)), | 49 fake_call_(webrtc::Call::Config(&event_log_)), |
48 transport_controller_( | 50 transport_controller_( |
49 new cricket::FakeTransportController(ICEROLE_CONTROLLING)) { | 51 new cricket::FakeTransportController(ICEROLE_CONTROLLING)) { |
50 fme_->SetAudioCodecs(MAKE_VECTOR(kAudioCodecs)); | 52 fme_->SetAudioCodecs(MAKE_VECTOR(kAudioCodecs)); |
51 fme_->SetVideoCodecs(MAKE_VECTOR(kVideoCodecs)); | 53 fme_->SetVideoCodecs(MAKE_VECTOR(kVideoCodecs)); |
52 } | 54 } |
53 | 55 |
54 webrtc::RtcEventLogNullImpl event_log_; | 56 webrtc::RtcEventLogNullImpl event_log_; |
55 rtc::Thread network_; | 57 std::unique_ptr<rtc::Thread> network_; |
56 rtc::Thread worker_; | 58 std::unique_ptr<rtc::Thread> worker_; |
57 // |fme_| and |fdme_| are actually owned by |cm_|. | 59 // |fme_| and |fdme_| are actually owned by |cm_|. |
58 cricket::FakeMediaEngine* fme_; | 60 cricket::FakeMediaEngine* fme_; |
59 cricket::FakeDataEngine* fdme_; | 61 cricket::FakeDataEngine* fdme_; |
60 std::unique_ptr<cricket::ChannelManager> cm_; | 62 std::unique_ptr<cricket::ChannelManager> cm_; |
61 cricket::FakeCall fake_call_; | 63 cricket::FakeCall fake_call_; |
62 std::unique_ptr<cricket::FakeTransportController> transport_controller_; | 64 std::unique_ptr<cricket::FakeTransportController> transport_controller_; |
63 }; | 65 }; |
64 | 66 |
65 // Test that we startup/shutdown properly. | 67 // Test that we startup/shutdown properly. |
66 TEST_F(ChannelManagerTest, StartupShutdown) { | 68 TEST_F(ChannelManagerTest, StartupShutdown) { |
67 EXPECT_FALSE(cm_->initialized()); | 69 EXPECT_FALSE(cm_->initialized()); |
68 EXPECT_EQ(rtc::Thread::Current(), cm_->worker_thread()); | 70 EXPECT_EQ(rtc::Thread::Current(), cm_->worker_thread()); |
69 EXPECT_TRUE(cm_->Init()); | 71 EXPECT_TRUE(cm_->Init()); |
70 EXPECT_TRUE(cm_->initialized()); | 72 EXPECT_TRUE(cm_->initialized()); |
71 cm_->Terminate(); | 73 cm_->Terminate(); |
72 EXPECT_FALSE(cm_->initialized()); | 74 EXPECT_FALSE(cm_->initialized()); |
73 } | 75 } |
74 | 76 |
75 // Test that we startup/shutdown properly with a worker thread. | 77 // Test that we startup/shutdown properly with a worker thread. |
76 TEST_F(ChannelManagerTest, StartupShutdownOnThread) { | 78 TEST_F(ChannelManagerTest, StartupShutdownOnThread) { |
77 network_.Start(); | 79 network_->Start(); |
78 worker_.Start(); | 80 worker_->Start(); |
79 EXPECT_FALSE(cm_->initialized()); | 81 EXPECT_FALSE(cm_->initialized()); |
80 EXPECT_EQ(rtc::Thread::Current(), cm_->worker_thread()); | 82 EXPECT_EQ(rtc::Thread::Current(), cm_->worker_thread()); |
81 EXPECT_TRUE(cm_->set_network_thread(&network_)); | 83 EXPECT_TRUE(cm_->set_network_thread(network_.get())); |
82 EXPECT_EQ(&network_, cm_->network_thread()); | 84 EXPECT_EQ(network_.get(), cm_->network_thread()); |
83 EXPECT_TRUE(cm_->set_worker_thread(&worker_)); | 85 EXPECT_TRUE(cm_->set_worker_thread(worker_.get())); |
84 EXPECT_EQ(&worker_, cm_->worker_thread()); | 86 EXPECT_EQ(worker_.get(), cm_->worker_thread()); |
85 EXPECT_TRUE(cm_->Init()); | 87 EXPECT_TRUE(cm_->Init()); |
86 EXPECT_TRUE(cm_->initialized()); | 88 EXPECT_TRUE(cm_->initialized()); |
87 // Setting the network or worker thread while initialized should fail. | 89 // Setting the network or worker thread while initialized should fail. |
88 EXPECT_FALSE(cm_->set_network_thread(rtc::Thread::Current())); | 90 EXPECT_FALSE(cm_->set_network_thread(rtc::Thread::Current())); |
89 EXPECT_FALSE(cm_->set_worker_thread(rtc::Thread::Current())); | 91 EXPECT_FALSE(cm_->set_worker_thread(rtc::Thread::Current())); |
90 cm_->Terminate(); | 92 cm_->Terminate(); |
91 EXPECT_FALSE(cm_->initialized()); | 93 EXPECT_FALSE(cm_->initialized()); |
92 } | 94 } |
93 | 95 |
94 // Test that we can create and destroy a voice and video channel. | 96 // Test that we can create and destroy a voice and video channel. |
(...skipping 19 matching lines...) Expand all Loading... |
114 rtc::Thread::Current(), cricket::CN_DATA, kDefaultSrtpRequired); | 116 rtc::Thread::Current(), cricket::CN_DATA, kDefaultSrtpRequired); |
115 EXPECT_TRUE(rtp_data_channel != nullptr); | 117 EXPECT_TRUE(rtp_data_channel != nullptr); |
116 cm_->DestroyVideoChannel(video_channel); | 118 cm_->DestroyVideoChannel(video_channel); |
117 cm_->DestroyVoiceChannel(voice_channel); | 119 cm_->DestroyVoiceChannel(voice_channel); |
118 cm_->DestroyRtpDataChannel(rtp_data_channel); | 120 cm_->DestroyRtpDataChannel(rtp_data_channel); |
119 cm_->Terminate(); | 121 cm_->Terminate(); |
120 } | 122 } |
121 | 123 |
122 // Test that we can create and destroy a voice and video channel with a worker. | 124 // Test that we can create and destroy a voice and video channel with a worker. |
123 TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) { | 125 TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) { |
124 network_.Start(); | 126 network_->Start(); |
125 worker_.Start(); | 127 worker_->Start(); |
126 EXPECT_TRUE(cm_->set_worker_thread(&worker_)); | 128 EXPECT_TRUE(cm_->set_worker_thread(worker_.get())); |
127 EXPECT_TRUE(cm_->set_network_thread(&network_)); | 129 EXPECT_TRUE(cm_->set_network_thread(network_.get())); |
128 EXPECT_TRUE(cm_->Init()); | 130 EXPECT_TRUE(cm_->Init()); |
129 transport_controller_.reset( | 131 transport_controller_.reset(new cricket::FakeTransportController( |
130 new cricket::FakeTransportController(&network_, ICEROLE_CONTROLLING)); | 132 network_.get(), ICEROLE_CONTROLLING)); |
131 cricket::DtlsTransportInternal* rtp_transport = | 133 cricket::DtlsTransportInternal* rtp_transport = |
132 transport_controller_->CreateDtlsTransport( | 134 transport_controller_->CreateDtlsTransport( |
133 cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP); | 135 cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP); |
134 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( | 136 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( |
135 &fake_call_, cricket::MediaConfig(), | 137 &fake_call_, cricket::MediaConfig(), |
136 rtp_transport, nullptr /*rtcp_transport*/, | 138 rtp_transport, nullptr /*rtcp_transport*/, |
137 rtc::Thread::Current(), cricket::CN_AUDIO, kDefaultSrtpRequired, | 139 rtc::Thread::Current(), cricket::CN_AUDIO, kDefaultSrtpRequired, |
138 AudioOptions()); | 140 AudioOptions()); |
139 EXPECT_TRUE(voice_channel != nullptr); | 141 EXPECT_TRUE(voice_channel != nullptr); |
140 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( | 142 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false)); | 179 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false)); |
178 | 180 |
179 // Can set again after terminate. | 181 // Can set again after terminate. |
180 cm_->Terminate(); | 182 cm_->Terminate(); |
181 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); | 183 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); |
182 cm_->GetSupportedVideoCodecs(&codecs); | 184 cm_->GetSupportedVideoCodecs(&codecs); |
183 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); | 185 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); |
184 } | 186 } |
185 | 187 |
186 } // namespace cricket | 188 } // namespace cricket |
OLD | NEW |