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 |
11 #include "webrtc/api/fakemediacontroller.h" | 11 #include "webrtc/api/fakemediacontroller.h" |
12 #include "webrtc/base/gunit.h" | 12 #include "webrtc/base/gunit.h" |
13 #include "webrtc/base/logging.h" | 13 #include "webrtc/base/logging.h" |
14 #include "webrtc/base/thread.h" | 14 #include "webrtc/base/thread.h" |
15 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 15 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
16 #include "webrtc/media/base/fakemediaengine.h" | 16 #include "webrtc/media/base/fakemediaengine.h" |
17 #include "webrtc/media/base/fakevideocapturer.h" | 17 #include "webrtc/media/base/fakevideocapturer.h" |
18 #include "webrtc/media/base/testutils.h" | 18 #include "webrtc/media/base/testutils.h" |
19 #include "webrtc/media/engine/fakewebrtccall.h" | 19 #include "webrtc/media/engine/fakewebrtccall.h" |
20 #include "webrtc/p2p/base/faketransportcontroller.h" | 20 #include "webrtc/p2p/base/faketransportcontroller.h" |
21 #include "webrtc/pc/channelmanager.h" | 21 #include "webrtc/pc/channelmanager.h" |
22 | 22 |
23 namespace cricket { | 23 namespace cricket { |
24 const bool kDefaultRtcpMuxRequired = true; | 24 const bool kDefaultRtcpEnabled = false; |
25 const bool kDefaultSrtpRequired = true; | 25 const bool kDefaultSrtpRequired = true; |
26 } | 26 } |
27 | 27 |
28 namespace cricket { | 28 namespace cricket { |
29 | 29 |
30 static const AudioCodec kAudioCodecs[] = { | 30 static const AudioCodec kAudioCodecs[] = { |
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[] = { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 100 } |
101 | 101 |
102 // Test that we can create and destroy a voice and video channel. | 102 // Test that we can create and destroy a voice and video channel. |
103 TEST_F(ChannelManagerTest, CreateDestroyChannels) { | 103 TEST_F(ChannelManagerTest, CreateDestroyChannels) { |
104 EXPECT_TRUE(cm_->Init()); | 104 EXPECT_TRUE(cm_->Init()); |
105 cricket::TransportChannel* rtp_transport = | 105 cricket::TransportChannel* rtp_transport = |
106 transport_controller_->CreateTransportChannel( | 106 transport_controller_->CreateTransportChannel( |
107 cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP); | 107 cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP); |
108 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( | 108 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( |
109 &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, | 109 &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, |
110 rtc::Thread::Current(), cricket::CN_AUDIO, nullptr, | 110 rtc::Thread::Current(), cricket::CN_AUDIO, nullptr, kDefaultRtcpEnabled, |
111 kDefaultRtcpMuxRequired, kDefaultSrtpRequired, AudioOptions()); | 111 kDefaultSrtpRequired, AudioOptions()); |
112 EXPECT_TRUE(voice_channel != nullptr); | 112 EXPECT_TRUE(voice_channel != nullptr); |
113 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( | 113 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( |
114 &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, | 114 &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, |
115 rtc::Thread::Current(), cricket::CN_VIDEO, nullptr, | 115 rtc::Thread::Current(), cricket::CN_VIDEO, nullptr, kDefaultRtcpEnabled, |
116 kDefaultRtcpMuxRequired, kDefaultSrtpRequired, VideoOptions()); | 116 kDefaultSrtpRequired, VideoOptions()); |
117 EXPECT_TRUE(video_channel != nullptr); | 117 EXPECT_TRUE(video_channel != nullptr); |
118 cricket::RtpDataChannel* rtp_data_channel = cm_->CreateRtpDataChannel( | 118 cricket::RtpDataChannel* rtp_data_channel = cm_->CreateRtpDataChannel( |
119 &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, | 119 &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, |
120 rtc::Thread::Current(), cricket::CN_DATA, nullptr, | 120 rtc::Thread::Current(), cricket::CN_DATA, nullptr, kDefaultRtcpEnabled, |
121 kDefaultRtcpMuxRequired, kDefaultSrtpRequired); | 121 kDefaultSrtpRequired); |
122 EXPECT_TRUE(rtp_data_channel != nullptr); | 122 EXPECT_TRUE(rtp_data_channel != nullptr); |
123 cm_->DestroyVideoChannel(video_channel); | 123 cm_->DestroyVideoChannel(video_channel); |
124 cm_->DestroyVoiceChannel(voice_channel); | 124 cm_->DestroyVoiceChannel(voice_channel); |
125 cm_->DestroyRtpDataChannel(rtp_data_channel); | 125 cm_->DestroyRtpDataChannel(rtp_data_channel); |
126 cm_->Terminate(); | 126 cm_->Terminate(); |
127 } | 127 } |
128 | 128 |
129 // Test that we can create and destroy a voice and video channel with a worker. | 129 // Test that we can create and destroy a voice and video channel with a worker. |
130 TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) { | 130 TEST_F(ChannelManagerTest, CreateDestroyChannelsOnThread) { |
131 network_.Start(); | 131 network_.Start(); |
132 worker_.Start(); | 132 worker_.Start(); |
133 EXPECT_TRUE(cm_->set_worker_thread(&worker_)); | 133 EXPECT_TRUE(cm_->set_worker_thread(&worker_)); |
134 EXPECT_TRUE(cm_->set_network_thread(&network_)); | 134 EXPECT_TRUE(cm_->set_network_thread(&network_)); |
135 EXPECT_TRUE(cm_->Init()); | 135 EXPECT_TRUE(cm_->Init()); |
136 delete transport_controller_; | 136 delete transport_controller_; |
137 transport_controller_ = | 137 transport_controller_ = |
138 new cricket::FakeTransportController(&network_, ICEROLE_CONTROLLING); | 138 new cricket::FakeTransportController(&network_, ICEROLE_CONTROLLING); |
139 cricket::TransportChannel* rtp_transport = | 139 cricket::TransportChannel* rtp_transport = |
140 transport_controller_->CreateTransportChannel( | 140 transport_controller_->CreateTransportChannel( |
141 cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP); | 141 cricket::CN_AUDIO, cricket::ICE_CANDIDATE_COMPONENT_RTP); |
142 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( | 142 cricket::VoiceChannel* voice_channel = cm_->CreateVoiceChannel( |
143 &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, | 143 &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, |
144 rtc::Thread::Current(), cricket::CN_AUDIO, nullptr, | 144 rtc::Thread::Current(), cricket::CN_AUDIO, nullptr, kDefaultRtcpEnabled, |
145 kDefaultRtcpMuxRequired, kDefaultSrtpRequired, AudioOptions()); | 145 kDefaultSrtpRequired, AudioOptions()); |
146 EXPECT_TRUE(voice_channel != nullptr); | 146 EXPECT_TRUE(voice_channel != nullptr); |
147 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( | 147 cricket::VideoChannel* video_channel = cm_->CreateVideoChannel( |
148 &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, | 148 &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, |
149 rtc::Thread::Current(), cricket::CN_VIDEO, nullptr, | 149 rtc::Thread::Current(), cricket::CN_VIDEO, nullptr, kDefaultRtcpEnabled, |
150 kDefaultRtcpMuxRequired, kDefaultSrtpRequired, VideoOptions()); | 150 kDefaultSrtpRequired, VideoOptions()); |
151 EXPECT_TRUE(video_channel != nullptr); | 151 EXPECT_TRUE(video_channel != nullptr); |
152 cricket::RtpDataChannel* rtp_data_channel = cm_->CreateRtpDataChannel( | 152 cricket::RtpDataChannel* rtp_data_channel = cm_->CreateRtpDataChannel( |
153 &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, | 153 &fake_mc_, rtp_transport, nullptr /*rtcp_transport*/, |
154 rtc::Thread::Current(), cricket::CN_DATA, nullptr, | 154 rtc::Thread::Current(), cricket::CN_DATA, nullptr, kDefaultRtcpEnabled, |
155 kDefaultRtcpMuxRequired, kDefaultSrtpRequired); | 155 kDefaultSrtpRequired); |
156 EXPECT_TRUE(rtp_data_channel != nullptr); | 156 EXPECT_TRUE(rtp_data_channel != nullptr); |
157 cm_->DestroyVideoChannel(video_channel); | 157 cm_->DestroyVideoChannel(video_channel); |
158 cm_->DestroyVoiceChannel(voice_channel); | 158 cm_->DestroyVoiceChannel(voice_channel); |
159 cm_->DestroyRtpDataChannel(rtp_data_channel); | 159 cm_->DestroyRtpDataChannel(rtp_data_channel); |
160 cm_->Terminate(); | 160 cm_->Terminate(); |
161 } | 161 } |
162 | 162 |
163 TEST_F(ChannelManagerTest, SetVideoRtxEnabled) { | 163 TEST_F(ChannelManagerTest, SetVideoRtxEnabled) { |
164 std::vector<VideoCodec> codecs; | 164 std::vector<VideoCodec> codecs; |
165 const VideoCodec rtx_codec(96, "rtx"); | 165 const VideoCodec rtx_codec(96, "rtx"); |
(...skipping 18 matching lines...) Expand all Loading... |
184 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false)); | 184 EXPECT_FALSE(cm_->SetVideoRtxEnabled(false)); |
185 | 185 |
186 // Can set again after terminate. | 186 // Can set again after terminate. |
187 cm_->Terminate(); | 187 cm_->Terminate(); |
188 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); | 188 EXPECT_TRUE(cm_->SetVideoRtxEnabled(true)); |
189 cm_->GetSupportedVideoCodecs(&codecs); | 189 cm_->GetSupportedVideoCodecs(&codecs); |
190 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); | 190 EXPECT_TRUE(ContainsMatchingCodec(codecs, rtx_codec)); |
191 } | 191 } |
192 | 192 |
193 } // namespace cricket | 193 } // namespace cricket |
OLD | NEW |