Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: webrtc/api/rtpsenderreceiver_unittest.cc

Issue 2514883002: Create //webrtc/api:libjingle_peerconnection_api + refactorings. (Closed)
Patch Set: Added three headers for backwards-compatibility, specifically for building chromium. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2012 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 <memory>
12 #include <string>
13 #include <utility>
14
15 #include "webrtc/api/audiotrack.h"
16 #include "webrtc/api/fakemediacontroller.h"
17 #include "webrtc/api/localaudiosource.h"
18 #include "webrtc/api/mediastream.h"
19 #include "webrtc/api/remoteaudiosource.h"
20 #include "webrtc/api/rtpreceiver.h"
21 #include "webrtc/api/rtpsender.h"
22 #include "webrtc/api/streamcollection.h"
23 #include "webrtc/api/test/fakevideotracksource.h"
24 #include "webrtc/api/videotrack.h"
25 #include "webrtc/api/videotracksource.h"
26 #include "webrtc/base/gunit.h"
27 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
28 #include "webrtc/media/base/fakemediaengine.h"
29 #include "webrtc/media/base/mediachannel.h"
30 #include "webrtc/media/engine/fakewebrtccall.h"
31 #include "webrtc/p2p/base/faketransportcontroller.h"
32 #include "webrtc/pc/channelmanager.h"
33 #include "webrtc/test/gmock.h"
34 #include "webrtc/test/gtest.h"
35
36 using ::testing::_;
37 using ::testing::Exactly;
38 using ::testing::InvokeWithoutArgs;
39 using ::testing::Return;
40
41 static const char kStreamLabel1[] = "local_stream_1";
42 static const char kVideoTrackId[] = "video_1";
43 static const char kAudioTrackId[] = "audio_1";
44 static const uint32_t kVideoSsrc = 98;
45 static const uint32_t kVideoSsrc2 = 100;
46 static const uint32_t kAudioSsrc = 99;
47 static const uint32_t kAudioSsrc2 = 101;
48
49 namespace webrtc {
50
51 class RtpSenderReceiverTest : public testing::Test {
52 public:
53 RtpSenderReceiverTest()
54 : // Create fake media engine/etc. so we can create channels to use to
55 // test RtpSenders/RtpReceivers.
56 media_engine_(new cricket::FakeMediaEngine()),
57 channel_manager_(media_engine_,
58 rtc::Thread::Current(),
59 rtc::Thread::Current()),
60 fake_call_(Call::Config(&event_log_)),
61 fake_media_controller_(&channel_manager_, &fake_call_),
62 stream_(MediaStream::Create(kStreamLabel1)) {
63 // Create channels to be used by the RtpSenders and RtpReceivers.
64 channel_manager_.Init();
65 voice_channel_ = channel_manager_.CreateVoiceChannel(
66 &fake_media_controller_, &fake_transport_controller_, cricket::CN_AUDIO,
67 nullptr, false, cricket::AudioOptions());
68 video_channel_ = channel_manager_.CreateVideoChannel(
69 &fake_media_controller_, &fake_transport_controller_, cricket::CN_VIDEO,
70 nullptr, false, cricket::VideoOptions());
71 voice_media_channel_ = media_engine_->GetVoiceChannel(0);
72 video_media_channel_ = media_engine_->GetVideoChannel(0);
73 RTC_CHECK(voice_channel_);
74 RTC_CHECK(video_channel_);
75 RTC_CHECK(voice_media_channel_);
76 RTC_CHECK(video_media_channel_);
77
78 // Create streams for predefined SSRCs. Streams need to exist in order
79 // for the senders and receievers to apply parameters to them.
80 // Normally these would be created by SetLocalDescription and
81 // SetRemoteDescription.
82 voice_media_channel_->AddSendStream(
83 cricket::StreamParams::CreateLegacy(kAudioSsrc));
84 voice_media_channel_->AddRecvStream(
85 cricket::StreamParams::CreateLegacy(kAudioSsrc));
86 voice_media_channel_->AddSendStream(
87 cricket::StreamParams::CreateLegacy(kAudioSsrc2));
88 voice_media_channel_->AddRecvStream(
89 cricket::StreamParams::CreateLegacy(kAudioSsrc2));
90 video_media_channel_->AddSendStream(
91 cricket::StreamParams::CreateLegacy(kVideoSsrc));
92 video_media_channel_->AddRecvStream(
93 cricket::StreamParams::CreateLegacy(kVideoSsrc));
94 video_media_channel_->AddSendStream(
95 cricket::StreamParams::CreateLegacy(kVideoSsrc2));
96 video_media_channel_->AddRecvStream(
97 cricket::StreamParams::CreateLegacy(kVideoSsrc2));
98 }
99
100 void TearDown() override { channel_manager_.Terminate(); }
101
102 void AddVideoTrack() {
103 rtc::scoped_refptr<VideoTrackSourceInterface> source(
104 FakeVideoTrackSource::Create());
105 video_track_ = VideoTrack::Create(kVideoTrackId, source);
106 EXPECT_TRUE(stream_->AddTrack(video_track_));
107 }
108
109 void CreateAudioRtpSender() { CreateAudioRtpSender(nullptr); }
110
111 void CreateAudioRtpSender(rtc::scoped_refptr<LocalAudioSource> source) {
112 audio_track_ = AudioTrack::Create(kAudioTrackId, source);
113 EXPECT_TRUE(stream_->AddTrack(audio_track_));
114 audio_rtp_sender_ =
115 new AudioRtpSender(stream_->GetAudioTracks()[0], stream_->label(),
116 voice_channel_, nullptr);
117 audio_rtp_sender_->SetSsrc(kAudioSsrc);
118 VerifyVoiceChannelInput();
119 }
120
121 void CreateVideoRtpSender() {
122 AddVideoTrack();
123 video_rtp_sender_ = new VideoRtpSender(stream_->GetVideoTracks()[0],
124 stream_->label(), video_channel_);
125 video_rtp_sender_->SetSsrc(kVideoSsrc);
126 VerifyVideoChannelInput();
127 }
128
129 void DestroyAudioRtpSender() {
130 audio_rtp_sender_ = nullptr;
131 VerifyVoiceChannelNoInput();
132 }
133
134 void DestroyVideoRtpSender() {
135 video_rtp_sender_ = nullptr;
136 VerifyVideoChannelNoInput();
137 }
138
139 void CreateAudioRtpReceiver() {
140 audio_track_ = AudioTrack::Create(
141 kAudioTrackId, RemoteAudioSource::Create(kAudioSsrc, NULL));
142 EXPECT_TRUE(stream_->AddTrack(audio_track_));
143 audio_rtp_receiver_ = new AudioRtpReceiver(stream_, kAudioTrackId,
144 kAudioSsrc, voice_channel_);
145 audio_track_ = audio_rtp_receiver_->audio_track();
146 VerifyVoiceChannelOutput();
147 }
148
149 void CreateVideoRtpReceiver() {
150 video_rtp_receiver_ =
151 new VideoRtpReceiver(stream_, kVideoTrackId, rtc::Thread::Current(),
152 kVideoSsrc, video_channel_);
153 video_track_ = video_rtp_receiver_->video_track();
154 VerifyVideoChannelOutput();
155 }
156
157 void DestroyAudioRtpReceiver() {
158 audio_rtp_receiver_ = nullptr;
159 VerifyVoiceChannelNoOutput();
160 }
161
162 void DestroyVideoRtpReceiver() {
163 video_rtp_receiver_ = nullptr;
164 VerifyVideoChannelNoOutput();
165 }
166
167 void VerifyVoiceChannelInput() { VerifyVoiceChannelInput(kAudioSsrc); }
168
169 void VerifyVoiceChannelInput(uint32_t ssrc) {
170 // Verify that the media channel has an audio source, and the stream isn't
171 // muted.
172 EXPECT_TRUE(voice_media_channel_->HasSource(ssrc));
173 EXPECT_FALSE(voice_media_channel_->IsStreamMuted(ssrc));
174 }
175
176 void VerifyVideoChannelInput() { VerifyVideoChannelInput(kVideoSsrc); }
177
178 void VerifyVideoChannelInput(uint32_t ssrc) {
179 // Verify that the media channel has a video source,
180 EXPECT_TRUE(video_media_channel_->HasSource(ssrc));
181 }
182
183 void VerifyVoiceChannelNoInput() { VerifyVoiceChannelNoInput(kAudioSsrc); }
184
185 void VerifyVoiceChannelNoInput(uint32_t ssrc) {
186 // Verify that the media channel's source is reset.
187 EXPECT_FALSE(voice_media_channel_->HasSource(ssrc));
188 }
189
190 void VerifyVideoChannelNoInput() { VerifyVideoChannelNoInput(kVideoSsrc); }
191
192 void VerifyVideoChannelNoInput(uint32_t ssrc) {
193 // Verify that the media channel's source is reset.
194 EXPECT_FALSE(video_media_channel_->HasSource(ssrc));
195 }
196
197 void VerifyVoiceChannelOutput() {
198 // Verify that the volume is initialized to 1.
199 double volume;
200 EXPECT_TRUE(voice_media_channel_->GetOutputVolume(kAudioSsrc, &volume));
201 EXPECT_EQ(1, volume);
202 }
203
204 void VerifyVideoChannelOutput() {
205 // Verify that the media channel has a sink.
206 EXPECT_TRUE(video_media_channel_->HasSink(kVideoSsrc));
207 }
208
209 void VerifyVoiceChannelNoOutput() {
210 // Verify that the volume is reset to 0.
211 double volume;
212 EXPECT_TRUE(voice_media_channel_->GetOutputVolume(kAudioSsrc, &volume));
213 EXPECT_EQ(0, volume);
214 }
215
216 void VerifyVideoChannelNoOutput() {
217 // Verify that the media channel's sink is reset.
218 EXPECT_FALSE(video_media_channel_->HasSink(kVideoSsrc));
219 }
220
221 protected:
222 webrtc::RtcEventLogNullImpl event_log_;
223 cricket::FakeMediaEngine* media_engine_;
224 cricket::FakeTransportController fake_transport_controller_;
225 cricket::ChannelManager channel_manager_;
226 cricket::FakeCall fake_call_;
227 cricket::FakeMediaController fake_media_controller_;
228 cricket::VoiceChannel* voice_channel_;
229 cricket::VideoChannel* video_channel_;
230 cricket::FakeVoiceMediaChannel* voice_media_channel_;
231 cricket::FakeVideoMediaChannel* video_media_channel_;
232 rtc::scoped_refptr<AudioRtpSender> audio_rtp_sender_;
233 rtc::scoped_refptr<VideoRtpSender> video_rtp_sender_;
234 rtc::scoped_refptr<AudioRtpReceiver> audio_rtp_receiver_;
235 rtc::scoped_refptr<VideoRtpReceiver> video_rtp_receiver_;
236 rtc::scoped_refptr<MediaStreamInterface> stream_;
237 rtc::scoped_refptr<VideoTrackInterface> video_track_;
238 rtc::scoped_refptr<AudioTrackInterface> audio_track_;
239 };
240
241 // Test that |voice_channel_| is updated when an audio track is associated
242 // and disassociated with an AudioRtpSender.
243 TEST_F(RtpSenderReceiverTest, AddAndDestroyAudioRtpSender) {
244 CreateAudioRtpSender();
245 DestroyAudioRtpSender();
246 }
247
248 // Test that |video_channel_| is updated when a video track is associated and
249 // disassociated with a VideoRtpSender.
250 TEST_F(RtpSenderReceiverTest, AddAndDestroyVideoRtpSender) {
251 CreateVideoRtpSender();
252 DestroyVideoRtpSender();
253 }
254
255 // Test that |voice_channel_| is updated when a remote audio track is
256 // associated and disassociated with an AudioRtpReceiver.
257 TEST_F(RtpSenderReceiverTest, AddAndDestroyAudioRtpReceiver) {
258 CreateAudioRtpReceiver();
259 DestroyAudioRtpReceiver();
260 }
261
262 // Test that |video_channel_| is updated when a remote video track is
263 // associated and disassociated with a VideoRtpReceiver.
264 TEST_F(RtpSenderReceiverTest, AddAndDestroyVideoRtpReceiver) {
265 CreateVideoRtpReceiver();
266 DestroyVideoRtpReceiver();
267 }
268
269 // Test that the AudioRtpSender applies options from the local audio source.
270 TEST_F(RtpSenderReceiverTest, LocalAudioSourceOptionsApplied) {
271 cricket::AudioOptions options;
272 options.echo_cancellation = rtc::Optional<bool>(true);
273 auto source = LocalAudioSource::Create(
274 PeerConnectionFactoryInterface::Options(), &options);
275 CreateAudioRtpSender(source.get());
276
277 EXPECT_EQ(rtc::Optional<bool>(true),
278 voice_media_channel_->options().echo_cancellation);
279
280 DestroyAudioRtpSender();
281 }
282
283 // Test that the stream is muted when the track is disabled, and unmuted when
284 // the track is enabled.
285 TEST_F(RtpSenderReceiverTest, LocalAudioTrackDisable) {
286 CreateAudioRtpSender();
287
288 audio_track_->set_enabled(false);
289 EXPECT_TRUE(voice_media_channel_->IsStreamMuted(kAudioSsrc));
290
291 audio_track_->set_enabled(true);
292 EXPECT_FALSE(voice_media_channel_->IsStreamMuted(kAudioSsrc));
293
294 DestroyAudioRtpSender();
295 }
296
297 // Test that the volume is set to 0 when the track is disabled, and back to
298 // 1 when the track is enabled.
299 TEST_F(RtpSenderReceiverTest, RemoteAudioTrackDisable) {
300 CreateAudioRtpReceiver();
301
302 double volume;
303 EXPECT_TRUE(voice_media_channel_->GetOutputVolume(kAudioSsrc, &volume));
304 EXPECT_EQ(1, volume);
305
306 audio_track_->set_enabled(false);
307 EXPECT_TRUE(voice_media_channel_->GetOutputVolume(kAudioSsrc, &volume));
308 EXPECT_EQ(0, volume);
309
310 audio_track_->set_enabled(true);
311 EXPECT_TRUE(voice_media_channel_->GetOutputVolume(kAudioSsrc, &volume));
312 EXPECT_EQ(1, volume);
313
314 DestroyAudioRtpReceiver();
315 }
316
317 // Currently no action is taken when a remote video track is disabled or
318 // enabled, so there's nothing to test here, other than what is normally
319 // verified in DestroyVideoRtpSender.
320 TEST_F(RtpSenderReceiverTest, LocalVideoTrackDisable) {
321 CreateVideoRtpSender();
322
323 video_track_->set_enabled(false);
324 video_track_->set_enabled(true);
325
326 DestroyVideoRtpSender();
327 }
328
329 // Test that the state of the video track created by the VideoRtpReceiver is
330 // updated when the receiver is destroyed.
331 TEST_F(RtpSenderReceiverTest, RemoteVideoTrackState) {
332 CreateVideoRtpReceiver();
333
334 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, video_track_->state());
335 EXPECT_EQ(webrtc::MediaSourceInterface::kLive,
336 video_track_->GetSource()->state());
337
338 DestroyVideoRtpReceiver();
339
340 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kEnded, video_track_->state());
341 EXPECT_EQ(webrtc::MediaSourceInterface::kEnded,
342 video_track_->GetSource()->state());
343 }
344
345 // Currently no action is taken when a remote video track is disabled or
346 // enabled, so there's nothing to test here, other than what is normally
347 // verified in DestroyVideoRtpReceiver.
348 TEST_F(RtpSenderReceiverTest, RemoteVideoTrackDisable) {
349 CreateVideoRtpReceiver();
350
351 video_track_->set_enabled(false);
352 video_track_->set_enabled(true);
353
354 DestroyVideoRtpReceiver();
355 }
356
357 // Test that the AudioRtpReceiver applies volume changes from the track source
358 // to the media channel.
359 TEST_F(RtpSenderReceiverTest, RemoteAudioTrackSetVolume) {
360 CreateAudioRtpReceiver();
361
362 double volume;
363 audio_track_->GetSource()->SetVolume(0.5);
364 EXPECT_TRUE(voice_media_channel_->GetOutputVolume(kAudioSsrc, &volume));
365 EXPECT_EQ(0.5, volume);
366
367 // Disable the audio track, this should prevent setting the volume.
368 audio_track_->set_enabled(false);
369 audio_track_->GetSource()->SetVolume(0.8);
370 EXPECT_TRUE(voice_media_channel_->GetOutputVolume(kAudioSsrc, &volume));
371 EXPECT_EQ(0, volume);
372
373 // When the track is enabled, the previously set volume should take effect.
374 audio_track_->set_enabled(true);
375 EXPECT_TRUE(voice_media_channel_->GetOutputVolume(kAudioSsrc, &volume));
376 EXPECT_EQ(0.8, volume);
377
378 // Try changing volume one more time.
379 audio_track_->GetSource()->SetVolume(0.9);
380 EXPECT_TRUE(voice_media_channel_->GetOutputVolume(kAudioSsrc, &volume));
381 EXPECT_EQ(0.9, volume);
382
383 DestroyAudioRtpReceiver();
384 }
385
386 // Test that the media channel isn't enabled for sending if the audio sender
387 // doesn't have both a track and SSRC.
388 TEST_F(RtpSenderReceiverTest, AudioSenderWithoutTrackAndSsrc) {
389 audio_rtp_sender_ = new AudioRtpSender(voice_channel_, nullptr);
390 rtc::scoped_refptr<AudioTrackInterface> track =
391 AudioTrack::Create(kAudioTrackId, nullptr);
392
393 // Track but no SSRC.
394 EXPECT_TRUE(audio_rtp_sender_->SetTrack(track));
395 VerifyVoiceChannelNoInput();
396
397 // SSRC but no track.
398 EXPECT_TRUE(audio_rtp_sender_->SetTrack(nullptr));
399 audio_rtp_sender_->SetSsrc(kAudioSsrc);
400 VerifyVoiceChannelNoInput();
401 }
402
403 // Test that the media channel isn't enabled for sending if the video sender
404 // doesn't have both a track and SSRC.
405 TEST_F(RtpSenderReceiverTest, VideoSenderWithoutTrackAndSsrc) {
406 video_rtp_sender_ = new VideoRtpSender(video_channel_);
407
408 // Track but no SSRC.
409 EXPECT_TRUE(video_rtp_sender_->SetTrack(video_track_));
410 VerifyVideoChannelNoInput();
411
412 // SSRC but no track.
413 EXPECT_TRUE(video_rtp_sender_->SetTrack(nullptr));
414 video_rtp_sender_->SetSsrc(kVideoSsrc);
415 VerifyVideoChannelNoInput();
416 }
417
418 // Test that the media channel is enabled for sending when the audio sender
419 // has a track and SSRC, when the SSRC is set first.
420 TEST_F(RtpSenderReceiverTest, AudioSenderEarlyWarmupSsrcThenTrack) {
421 audio_rtp_sender_ = new AudioRtpSender(voice_channel_, nullptr);
422 rtc::scoped_refptr<AudioTrackInterface> track =
423 AudioTrack::Create(kAudioTrackId, nullptr);
424 audio_rtp_sender_->SetSsrc(kAudioSsrc);
425 audio_rtp_sender_->SetTrack(track);
426 VerifyVoiceChannelInput();
427
428 DestroyAudioRtpSender();
429 }
430
431 // Test that the media channel is enabled for sending when the audio sender
432 // has a track and SSRC, when the SSRC is set last.
433 TEST_F(RtpSenderReceiverTest, AudioSenderEarlyWarmupTrackThenSsrc) {
434 audio_rtp_sender_ = new AudioRtpSender(voice_channel_, nullptr);
435 rtc::scoped_refptr<AudioTrackInterface> track =
436 AudioTrack::Create(kAudioTrackId, nullptr);
437 audio_rtp_sender_->SetTrack(track);
438 audio_rtp_sender_->SetSsrc(kAudioSsrc);
439 VerifyVoiceChannelInput();
440
441 DestroyAudioRtpSender();
442 }
443
444 // Test that the media channel is enabled for sending when the video sender
445 // has a track and SSRC, when the SSRC is set first.
446 TEST_F(RtpSenderReceiverTest, VideoSenderEarlyWarmupSsrcThenTrack) {
447 AddVideoTrack();
448 video_rtp_sender_ = new VideoRtpSender(video_channel_);
449 video_rtp_sender_->SetSsrc(kVideoSsrc);
450 video_rtp_sender_->SetTrack(video_track_);
451 VerifyVideoChannelInput();
452
453 DestroyVideoRtpSender();
454 }
455
456 // Test that the media channel is enabled for sending when the video sender
457 // has a track and SSRC, when the SSRC is set last.
458 TEST_F(RtpSenderReceiverTest, VideoSenderEarlyWarmupTrackThenSsrc) {
459 AddVideoTrack();
460 video_rtp_sender_ = new VideoRtpSender(video_channel_);
461 video_rtp_sender_->SetTrack(video_track_);
462 video_rtp_sender_->SetSsrc(kVideoSsrc);
463 VerifyVideoChannelInput();
464
465 DestroyVideoRtpSender();
466 }
467
468 // Test that the media channel stops sending when the audio sender's SSRC is set
469 // to 0.
470 TEST_F(RtpSenderReceiverTest, AudioSenderSsrcSetToZero) {
471 CreateAudioRtpSender();
472
473 audio_rtp_sender_->SetSsrc(0);
474 VerifyVoiceChannelNoInput();
475 }
476
477 // Test that the media channel stops sending when the video sender's SSRC is set
478 // to 0.
479 TEST_F(RtpSenderReceiverTest, VideoSenderSsrcSetToZero) {
480 CreateAudioRtpSender();
481
482 audio_rtp_sender_->SetSsrc(0);
483 VerifyVideoChannelNoInput();
484 }
485
486 // Test that the media channel stops sending when the audio sender's track is
487 // set to null.
488 TEST_F(RtpSenderReceiverTest, AudioSenderTrackSetToNull) {
489 CreateAudioRtpSender();
490
491 EXPECT_TRUE(audio_rtp_sender_->SetTrack(nullptr));
492 VerifyVoiceChannelNoInput();
493 }
494
495 // Test that the media channel stops sending when the video sender's track is
496 // set to null.
497 TEST_F(RtpSenderReceiverTest, VideoSenderTrackSetToNull) {
498 CreateVideoRtpSender();
499
500 video_rtp_sender_->SetSsrc(0);
501 VerifyVideoChannelNoInput();
502 }
503
504 // Test that when the audio sender's SSRC is changed, the media channel stops
505 // sending with the old SSRC and starts sending with the new one.
506 TEST_F(RtpSenderReceiverTest, AudioSenderSsrcChanged) {
507 CreateAudioRtpSender();
508
509 audio_rtp_sender_->SetSsrc(kAudioSsrc2);
510 VerifyVoiceChannelNoInput(kAudioSsrc);
511 VerifyVoiceChannelInput(kAudioSsrc2);
512
513 audio_rtp_sender_ = nullptr;
514 VerifyVoiceChannelNoInput(kAudioSsrc2);
515 }
516
517 // Test that when the audio sender's SSRC is changed, the media channel stops
518 // sending with the old SSRC and starts sending with the new one.
519 TEST_F(RtpSenderReceiverTest, VideoSenderSsrcChanged) {
520 CreateVideoRtpSender();
521
522 video_rtp_sender_->SetSsrc(kVideoSsrc2);
523 VerifyVideoChannelNoInput(kVideoSsrc);
524 VerifyVideoChannelInput(kVideoSsrc2);
525
526 video_rtp_sender_ = nullptr;
527 VerifyVideoChannelNoInput(kVideoSsrc2);
528 }
529
530 TEST_F(RtpSenderReceiverTest, AudioSenderCanSetParameters) {
531 CreateAudioRtpSender();
532
533 RtpParameters params = audio_rtp_sender_->GetParameters();
534 EXPECT_EQ(1u, params.encodings.size());
535 EXPECT_TRUE(audio_rtp_sender_->SetParameters(params));
536
537 DestroyAudioRtpSender();
538 }
539
540 TEST_F(RtpSenderReceiverTest, SetAudioMaxSendBitrate) {
541 CreateAudioRtpSender();
542
543 EXPECT_EQ(-1, voice_media_channel_->max_bps());
544 webrtc::RtpParameters params = audio_rtp_sender_->GetParameters();
545 EXPECT_EQ(1, params.encodings.size());
546 EXPECT_EQ(-1, params.encodings[0].max_bitrate_bps);
547 params.encodings[0].max_bitrate_bps = 1000;
548 EXPECT_TRUE(audio_rtp_sender_->SetParameters(params));
549
550 // Read back the parameters and verify they have been changed.
551 params = audio_rtp_sender_->GetParameters();
552 EXPECT_EQ(1, params.encodings.size());
553 EXPECT_EQ(1000, params.encodings[0].max_bitrate_bps);
554
555 // Verify that the audio channel received the new parameters.
556 params = voice_media_channel_->GetRtpSendParameters(kAudioSsrc);
557 EXPECT_EQ(1, params.encodings.size());
558 EXPECT_EQ(1000, params.encodings[0].max_bitrate_bps);
559
560 // Verify that the global bitrate limit has not been changed.
561 EXPECT_EQ(-1, voice_media_channel_->max_bps());
562
563 DestroyAudioRtpSender();
564 }
565
566 TEST_F(RtpSenderReceiverTest, VideoSenderCanSetParameters) {
567 CreateVideoRtpSender();
568
569 RtpParameters params = video_rtp_sender_->GetParameters();
570 EXPECT_EQ(1u, params.encodings.size());
571 EXPECT_TRUE(video_rtp_sender_->SetParameters(params));
572
573 DestroyVideoRtpSender();
574 }
575
576 TEST_F(RtpSenderReceiverTest, SetVideoMaxSendBitrate) {
577 CreateVideoRtpSender();
578
579 EXPECT_EQ(-1, video_media_channel_->max_bps());
580 webrtc::RtpParameters params = video_rtp_sender_->GetParameters();
581 EXPECT_EQ(1, params.encodings.size());
582 EXPECT_EQ(-1, params.encodings[0].max_bitrate_bps);
583 params.encodings[0].max_bitrate_bps = 1000;
584 EXPECT_TRUE(video_rtp_sender_->SetParameters(params));
585
586 // Read back the parameters and verify they have been changed.
587 params = video_rtp_sender_->GetParameters();
588 EXPECT_EQ(1, params.encodings.size());
589 EXPECT_EQ(1000, params.encodings[0].max_bitrate_bps);
590
591 // Verify that the video channel received the new parameters.
592 params = video_media_channel_->GetRtpSendParameters(kVideoSsrc);
593 EXPECT_EQ(1, params.encodings.size());
594 EXPECT_EQ(1000, params.encodings[0].max_bitrate_bps);
595
596 // Verify that the global bitrate limit has not been changed.
597 EXPECT_EQ(-1, video_media_channel_->max_bps());
598
599 DestroyVideoRtpSender();
600 }
601
602 TEST_F(RtpSenderReceiverTest, AudioReceiverCanSetParameters) {
603 CreateAudioRtpReceiver();
604
605 RtpParameters params = audio_rtp_receiver_->GetParameters();
606 EXPECT_EQ(1u, params.encodings.size());
607 EXPECT_TRUE(audio_rtp_receiver_->SetParameters(params));
608
609 DestroyAudioRtpReceiver();
610 }
611
612 TEST_F(RtpSenderReceiverTest, VideoReceiverCanSetParameters) {
613 CreateVideoRtpReceiver();
614
615 RtpParameters params = video_rtp_receiver_->GetParameters();
616 EXPECT_EQ(1u, params.encodings.size());
617 EXPECT_TRUE(video_rtp_receiver_->SetParameters(params));
618
619 DestroyVideoRtpReceiver();
620 }
621
622 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698