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

Side by Side Diff: webrtc/call/rtp_demuxer_unittest.cc

Issue 2993633002: Revert of SSRC and RSID may only refer to one sink each in RtpDemuxer (Closed)
Patch Set: Created 3 years, 4 months 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
« no previous file with comments | « webrtc/call/rtp_demuxer.cc ('k') | webrtc/call/rtp_rtcp_demuxer_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 const int rsid_extension_id = 6; 69 const int rsid_extension_id = 6;
70 RtpPacketReceived::ExtensionManager extension_manager; 70 RtpPacketReceived::ExtensionManager extension_manager;
71 extension_manager.Register<RtpStreamId>(rsid_extension_id); 71 extension_manager.Register<RtpStreamId>(rsid_extension_id);
72 auto packet = rtc::MakeUnique<RtpPacketReceived>(&extension_manager); 72 auto packet = rtc::MakeUnique<RtpPacketReceived>(&extension_manager);
73 packet->SetExtension<RtpStreamId>(rsid); 73 packet->SetExtension<RtpStreamId>(rsid);
74 packet->SetSsrc(ssrc); 74 packet->SetSsrc(ssrc);
75 packet->SetSequenceNumber(static_cast<uint16_t>(sequence_number)); 75 packet->SetSequenceNumber(static_cast<uint16_t>(sequence_number));
76 return packet; 76 return packet;
77 } 77 }
78 78
79 TEST(RtpDemuxerTest, CanAddSinkBySsrc) {
80 RtpDemuxer demuxer;
81 MockRtpPacketSink sink;
82 constexpr uint32_t ssrc = 1;
83
84 EXPECT_TRUE(demuxer.AddSink(ssrc, &sink));
85
86 // Test tear-down
87 demuxer.RemoveSink(&sink);
88 }
89
90 TEST(RtpDemuxerTest, OnRtpPacketCalledOnCorrectSinkBySsrc) { 79 TEST(RtpDemuxerTest, OnRtpPacketCalledOnCorrectSinkBySsrc) {
91 RtpDemuxer demuxer; 80 RtpDemuxer demuxer;
92 81
93 constexpr uint32_t ssrcs[] = {101, 202, 303}; 82 constexpr uint32_t ssrcs[] = {101, 202, 303};
94 MockRtpPacketSink sinks[arraysize(ssrcs)]; 83 MockRtpPacketSink sinks[arraysize(ssrcs)];
95 for (size_t i = 0; i < arraysize(ssrcs); i++) { 84 for (size_t i = 0; i < arraysize(ssrcs); i++) {
96 demuxer.AddSink(ssrcs[i], &sinks[i]); 85 demuxer.AddSink(ssrcs[i], &sinks[i]);
97 } 86 }
98 87
99 for (size_t i = 0; i < arraysize(ssrcs); i++) { 88 for (size_t i = 0; i < arraysize(ssrcs); i++) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 137 }
149 138
150 for (const auto& packet : packets) { 139 for (const auto& packet : packets) {
151 EXPECT_TRUE(demuxer.OnRtpPacket(*packet)); 140 EXPECT_TRUE(demuxer.OnRtpPacket(*packet));
152 } 141 }
153 142
154 // Test tear-down 143 // Test tear-down
155 demuxer.RemoveSink(&sink); 144 demuxer.RemoveSink(&sink);
156 } 145 }
157 146
147 TEST(RtpDemuxerTest, MultipleSinksMappedToSameSsrc) {
148 RtpDemuxer demuxer;
149
150 MockRtpPacketSink sinks[3];
151 constexpr uint32_t ssrc = 404;
152 for (auto& sink : sinks) {
153 demuxer.AddSink(ssrc, &sink);
154 }
155
156 // Reception of an RTP packet associated with the shared SSRC triggers the
157 // callback on all of the sinks associated with it.
158 auto packet = CreateRtpPacketReceived(ssrc);
159 for (auto& sink : sinks) {
160 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet)));
161 }
162 EXPECT_TRUE(demuxer.OnRtpPacket(*packet));
163
164 // Test tear-down
165 for (const auto& sink : sinks) {
166 demuxer.RemoveSink(&sink);
167 }
168 }
169
158 TEST(RtpDemuxerTest, SinkMappedToMultipleSsrcs) { 170 TEST(RtpDemuxerTest, SinkMappedToMultipleSsrcs) {
159 RtpDemuxer demuxer; 171 RtpDemuxer demuxer;
160 172
161 constexpr uint32_t ssrcs[] = {404, 505, 606}; 173 constexpr uint32_t ssrcs[] = {404, 505, 606};
162 MockRtpPacketSink sink; 174 MockRtpPacketSink sink;
163 for (uint32_t ssrc : ssrcs) { 175 for (uint32_t ssrc : ssrcs) {
164 demuxer.AddSink(ssrc, &sink); 176 demuxer.AddSink(ssrc, &sink);
165 } 177 }
166 178
167 // The sink which is associated with multiple SSRCs gets the callback 179 // The sink which is associated with multiple SSRCs gets the callback
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 217 }
206 218
207 ASSERT_TRUE(demuxer.RemoveSink(&sink)); 219 ASSERT_TRUE(demuxer.RemoveSink(&sink));
208 220
209 // The removed sink does not get callbacks. 221 // The removed sink does not get callbacks.
210 auto packet = CreateRtpPacketReceived(ssrc, seq_num); 222 auto packet = CreateRtpPacketReceived(ssrc, seq_num);
211 EXPECT_CALL(sink, OnRtpPacket(_)).Times(0); // Not called. 223 EXPECT_CALL(sink, OnRtpPacket(_)).Times(0); // Not called.
212 EXPECT_FALSE(demuxer.OnRtpPacket(*packet)); 224 EXPECT_FALSE(demuxer.OnRtpPacket(*packet));
213 } 225 }
214 226
215 TEST(RtpDemuxerTest, AddSinkFailsIfCalledForTwoSinks) { 227 TEST(RtpDemuxerTest, RepeatedSsrcAssociationsDoNotTriggerRepeatedCallbacks) {
216 RtpDemuxer demuxer;
217 MockRtpPacketSink sink_a;
218 MockRtpPacketSink sink_b;
219 constexpr uint32_t ssrc = 1;
220 ASSERT_TRUE(demuxer.AddSink(ssrc, &sink_a));
221
222 EXPECT_FALSE(demuxer.AddSink(ssrc, &sink_b));
223
224 // Test tear-down
225 demuxer.RemoveSink(&sink_a);
226 }
227
228 // An SSRC may only be mapped to a single sink. However, since configuration
229 // of this associations might come from the network, we need to fail gracefully.
230 TEST(RtpDemuxerTest, OnlyOneSinkPerSsrcGetsOnRtpPacketTriggered) {
231 RtpDemuxer demuxer;
232
233 MockRtpPacketSink sinks[3];
234 constexpr uint32_t ssrc = 404;
235 ASSERT_TRUE(demuxer.AddSink(ssrc, &sinks[0]));
236 ASSERT_FALSE(demuxer.AddSink(ssrc, &sinks[1]));
237 ASSERT_FALSE(demuxer.AddSink(ssrc, &sinks[2]));
238
239 // The first sink associated with the SSRC remains active; other sinks
240 // were not really added, and so do not get OnRtpPacket() called.
241 auto packet = CreateRtpPacketReceived(ssrc);
242 EXPECT_CALL(sinks[0], OnRtpPacket(SamePacketAs(*packet))).Times(1);
243 EXPECT_CALL(sinks[1], OnRtpPacket(_)).Times(0);
244 EXPECT_CALL(sinks[2], OnRtpPacket(_)).Times(0);
245 ASSERT_TRUE(demuxer.OnRtpPacket(*packet));
246
247 // Test tear-down
248 demuxer.RemoveSink(&sinks[0]);
249 }
250
251 TEST(RtpDemuxerTest, AddSinkFailsIfCalledTwiceEvenIfSameSink) {
252 RtpDemuxer demuxer;
253 MockRtpPacketSink sink;
254 constexpr uint32_t ssrc = 1;
255 ASSERT_TRUE(demuxer.AddSink(ssrc, &sink));
256
257 EXPECT_FALSE(demuxer.AddSink(ssrc, &sink));
258
259 // Test tear-down
260 demuxer.RemoveSink(&sink);
261 }
262
263 TEST(RtpDemuxerTest, NoRepeatedCallbackOnRepeatedAddSinkForSameSink) {
264 RtpDemuxer demuxer; 228 RtpDemuxer demuxer;
265 229
266 constexpr uint32_t ssrc = 111; 230 constexpr uint32_t ssrc = 111;
267 MockRtpPacketSink sink; 231 MockRtpPacketSink sink;
268 232
269 ASSERT_TRUE(demuxer.AddSink(ssrc, &sink)); 233 demuxer.AddSink(ssrc, &sink);
270 ASSERT_FALSE(demuxer.AddSink(ssrc, &sink)); 234 demuxer.AddSink(ssrc, &sink);
271 235
272 auto packet = CreateRtpPacketReceived(ssrc); 236 auto packet = CreateRtpPacketReceived(ssrc);
273 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1); 237 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1);
274 EXPECT_TRUE(demuxer.OnRtpPacket(*packet)); 238 EXPECT_TRUE(demuxer.OnRtpPacket(*packet));
275 239
276 // Test tear-down 240 // Test tear-down
277 demuxer.RemoveSink(&sink); 241 demuxer.RemoveSink(&sink);
278 } 242 }
279 243
280 TEST(RtpDemuxerTest, RemoveSinkReturnsFalseForNeverAddedSink) { 244 TEST(RtpDemuxerTest, RemoveSinkReturnsFalseForNeverAddedSink) {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 auto packet = 420 auto packet =
457 CreateRtpPacketReceivedWithRsid(rsids[i], ssrc, sequence_number); 421 CreateRtpPacketReceivedWithRsid(rsids[i], ssrc, sequence_number);
458 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1); 422 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1);
459 EXPECT_TRUE(demuxer.OnRtpPacket(*packet)); 423 EXPECT_TRUE(demuxer.OnRtpPacket(*packet));
460 } 424 }
461 425
462 // Test tear-down 426 // Test tear-down
463 demuxer.RemoveSink(&sink); 427 demuxer.RemoveSink(&sink);
464 } 428 }
465 429
430 TEST(RtpDemuxerTest, RsidUsedByMultipleSinks) {
431 RtpDemuxer demuxer;
432
433 MockRtpPacketSink sinks[3];
434 const std::string shared_rsid = "a";
435
436 for (MockRtpPacketSink& sink : sinks) {
437 demuxer.AddSink(shared_rsid, &sink);
438 }
439
440 constexpr uint32_t shared_ssrc = 888;
441 auto packet = CreateRtpPacketReceivedWithRsid(shared_rsid, shared_ssrc);
442
443 for (auto& sink : sinks) {
444 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1);
445 }
446
447 EXPECT_TRUE(demuxer.OnRtpPacket(*packet));
448
449 // Test tear-down
450 for (MockRtpPacketSink& sink : sinks) {
451 demuxer.RemoveSink(&sink);
452 }
453 }
454
466 TEST(RtpDemuxerTest, SinkWithBothRsidAndSsrcAssociations) { 455 TEST(RtpDemuxerTest, SinkWithBothRsidAndSsrcAssociations) {
467 RtpDemuxer demuxer; 456 RtpDemuxer demuxer;
468 457
469 MockRtpPacketSink sink; 458 MockRtpPacketSink sink;
470 constexpr uint32_t standalone_ssrc = 10101; 459 constexpr uint32_t standalone_ssrc = 10101;
471 constexpr uint32_t rsid_ssrc = 20202; 460 constexpr uint32_t rsid_ssrc = 20202;
472 const std::string rsid = "a"; 461 const std::string rsid = "a";
473 462
474 demuxer.AddSink(standalone_ssrc, &sink); 463 demuxer.AddSink(standalone_ssrc, &sink);
475 demuxer.AddSink(rsid, &sink); 464 demuxer.AddSink(rsid, &sink);
(...skipping 24 matching lines...) Expand all
500 489
501 constexpr uint16_t seq_num = 999; 490 constexpr uint16_t seq_num = 999;
502 auto packet = CreateRtpPacketReceivedWithRsid(rsid, ssrc, seq_num); 491 auto packet = CreateRtpPacketReceivedWithRsid(rsid, ssrc, seq_num);
503 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1); 492 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1);
504 EXPECT_TRUE(demuxer.OnRtpPacket(*packet)); 493 EXPECT_TRUE(demuxer.OnRtpPacket(*packet));
505 494
506 // Test tear-down 495 // Test tear-down
507 demuxer.RemoveSink(&sink); 496 demuxer.RemoveSink(&sink);
508 } 497 }
509 498
510 TEST(RtpDemuxerTest, RsidObserversInformedOfResolutionsOfTrackedRsids) { 499 TEST(RtpDemuxerTest, RsidObserversInformedOfResolutions) {
511 RtpDemuxer demuxer; 500 RtpDemuxer demuxer;
512 501
513 constexpr uint32_t ssrc = 111; 502 constexpr uint32_t ssrc = 111;
514 const std::string rsid = "a"; 503 const std::string rsid = "a";
515 504
516 // Only RSIDs which the demuxer knows may be resolved.
517 NiceMock<MockRtpPacketSink> sink;
518 demuxer.AddSink(rsid, &sink);
519
520 MockRsidResolutionObserver rsid_resolution_observers[3]; 505 MockRsidResolutionObserver rsid_resolution_observers[3];
521 for (auto& observer : rsid_resolution_observers) { 506 for (auto& observer : rsid_resolution_observers) {
522 demuxer.RegisterRsidResolutionObserver(&observer); 507 demuxer.RegisterRsidResolutionObserver(&observer);
523 EXPECT_CALL(observer, OnRsidResolved(rsid, ssrc)).Times(1); 508 EXPECT_CALL(observer, OnRsidResolved(rsid, ssrc)).Times(1);
524 } 509 }
525 510
526 // The expected calls to OnRsidResolved() will be triggered by this. 511 // The expected calls to OnRsidResolved() will be triggered by this.
527 demuxer.OnRtpPacket(*CreateRtpPacketReceivedWithRsid(rsid, ssrc)); 512 demuxer.OnRtpPacket(*CreateRtpPacketReceivedWithRsid(rsid, ssrc));
528 513
529 // Test tear-down 514 // Test tear-down
530 for (auto& observer : rsid_resolution_observers) { 515 for (auto& observer : rsid_resolution_observers) {
531 demuxer.DeregisterRsidResolutionObserver(&observer); 516 demuxer.DeregisterRsidResolutionObserver(&observer);
532 } 517 }
533 demuxer.RemoveSink(&sink);
534 }
535
536 TEST(RtpDemuxerTest, RsidObserversNotInformedOfResolutionsOfUntrackedRsids) {
537 RtpDemuxer demuxer;
538
539 constexpr uint32_t ssrc = 111;
540 const std::string rsid = "a";
541
542 MockRsidResolutionObserver rsid_resolution_observers[3];
543 for (auto& observer : rsid_resolution_observers) {
544 demuxer.RegisterRsidResolutionObserver(&observer);
545 EXPECT_CALL(observer, OnRsidResolved(rsid, ssrc)).Times(0);
546 }
547
548 // The expected calls to OnRsidResolved() will be triggered by this.
549 demuxer.OnRtpPacket(*CreateRtpPacketReceivedWithRsid(rsid, ssrc));
550
551 // Test tear-down
552 for (auto& observer : rsid_resolution_observers) {
553 demuxer.DeregisterRsidResolutionObserver(&observer);
554 }
555 } 518 }
556 519
557 // If one sink is associated with SSRC x, and another sink with RSID y, we
558 // should never observe RSID x being resolved to SSRC x, or else we'd end
559 // up with one SSRC mapped to two sinks. However, if such faulty input
560 // ever reaches us, we should handle it gracefully - not crash, and keep the
561 // packets routed only to the SSRC sink.
562 TEST(RtpDemuxerTest, PacketFittingBothRsidSinkAndSsrcSinkGivenOnlyToSsrcSink) {
563 RtpDemuxer demuxer;
564
565 constexpr uint32_t ssrc = 111;
566 MockRtpPacketSink ssrc_sink;
567 demuxer.AddSink(ssrc, &ssrc_sink);
568
569 const std::string rsid = "a";
570 MockRtpPacketSink rsid_sink;
571 demuxer.AddSink(rsid, &rsid_sink);
572
573 auto packet = CreateRtpPacketReceivedWithRsid(rsid, ssrc);
574 EXPECT_CALL(ssrc_sink, OnRtpPacket(SamePacketAs(*packet))).Times(1);
575 EXPECT_CALL(rsid_sink, OnRtpPacket(SamePacketAs(*packet))).Times(0);
576 demuxer.OnRtpPacket(*packet);
577
578 // Test tear-down
579 demuxer.RemoveSink(&ssrc_sink);
580 demuxer.RemoveSink(&rsid_sink);
581 }
582
583 TEST(RtpDemuxerTest,
584 PacketFittingBothRsidSinkAndSsrcSinkDoesNotTriggerResolutionCallbacks) {
585 RtpDemuxer demuxer;
586
587 constexpr uint32_t ssrc = 111;
588 NiceMock<MockRtpPacketSink> ssrc_sink;
589 demuxer.AddSink(ssrc, &ssrc_sink);
590
591 const std::string rsid = "a";
592 NiceMock<MockRtpPacketSink> rsid_sink;
593 demuxer.AddSink(rsid, &rsid_sink);
594
595 MockRsidResolutionObserver observer;
596 demuxer.RegisterRsidResolutionObserver(&observer);
597
598 auto packet = CreateRtpPacketReceivedWithRsid(rsid, ssrc);
599 EXPECT_CALL(observer, OnRsidResolved(_, _)).Times(0);
600 demuxer.OnRtpPacket(*packet);
601
602 // Test tear-down
603 demuxer.RemoveSink(&ssrc_sink);
604 demuxer.RemoveSink(&rsid_sink);
605 }
606
607 // We're not expecting RSIDs to be resolved to SSRCs which were previously
608 // mapped to sinks, and make no guarantees except for graceful handling.
609 TEST(RtpDemuxerTest, GracefullyHandleRsidBeingMappedToPrevouslyAssociatedSsrc) {
610 RtpDemuxer demuxer;
611
612 constexpr uint32_t ssrc = 111;
613 NiceMock<MockRtpPacketSink> ssrc_sink;
614 demuxer.AddSink(ssrc, &ssrc_sink);
615
616 const std::string rsid = "a";
617 MockRtpPacketSink rsid_sink;
618 demuxer.AddSink(rsid, &rsid_sink);
619
620 MockRsidResolutionObserver observer;
621 demuxer.RegisterRsidResolutionObserver(&observer);
622
623 // The SSRC was mapped to an SSRC sink, but was even active (packets flowed
624 // over it).
625 auto packet = CreateRtpPacketReceivedWithRsid(rsid, ssrc);
626 demuxer.OnRtpPacket(*packet);
627
628 // If the SSRC sink is ever removed, the RSID sink *might* receive indications
629 // of packets, and observers *might* be informed. Only graceful handling
630 // is guaranteed.
631 demuxer.RemoveSink(&ssrc_sink);
632 EXPECT_CALL(rsid_sink, OnRtpPacket(SamePacketAs(*packet))).Times(AtLeast(0));
633 EXPECT_CALL(observer, OnRsidResolved(rsid, ssrc)).Times(AtLeast(0));
634 demuxer.OnRtpPacket(*packet);
635
636 // Test tear-down
637 demuxer.DeregisterRsidResolutionObserver(&observer);
638 demuxer.RemoveSink(&rsid_sink);
639 }
640
641 TEST(RtpDemuxerTest, DeregisteredRsidObserversNotInformedOfResolutions) { 520 TEST(RtpDemuxerTest, DeregisteredRsidObserversNotInformedOfResolutions) {
642 RtpDemuxer demuxer; 521 RtpDemuxer demuxer;
643 522
644 constexpr uint32_t ssrc = 111; 523 constexpr uint32_t ssrc = 111;
645 const std::string rsid = "a"; 524 const std::string rsid = "a";
646 NiceMock<MockRtpPacketSink> sink; 525 NiceMock<MockRtpPacketSink> sink;
647 demuxer.AddSink(rsid, &sink); 526 demuxer.AddSink(rsid, &sink);
648 527
649 // Register several, then deregister only one, to show that not all of the 528 // Register several, then deregister only one, to show that not all of the
650 // observers had been forgotten when one was removed. 529 // observers had been forgotten when one was removed.
(...skipping 17 matching lines...) Expand all
668 // Test tear-down 547 // Test tear-down
669 demuxer.RemoveSink(&sink); 548 demuxer.RemoveSink(&sink);
670 demuxer.DeregisterRsidResolutionObserver(&observer_1); 549 demuxer.DeregisterRsidResolutionObserver(&observer_1);
671 demuxer.DeregisterRsidResolutionObserver(&observer_3); 550 demuxer.DeregisterRsidResolutionObserver(&observer_3);
672 } 551 }
673 552
674 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 553 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
675 TEST(RtpDemuxerTest, RsidMustBeNonEmpty) { 554 TEST(RtpDemuxerTest, RsidMustBeNonEmpty) {
676 RtpDemuxer demuxer; 555 RtpDemuxer demuxer;
677 MockRtpPacketSink sink; 556 MockRtpPacketSink sink;
678
679 EXPECT_DEATH(demuxer.AddSink("", &sink), ""); 557 EXPECT_DEATH(demuxer.AddSink("", &sink), "");
680 } 558 }
681 559
682 TEST(RtpDemuxerTest, RsidMustBeAlphaNumeric) { 560 TEST(RtpDemuxerTest, RsidMustBeAlphaNumeric) {
683 RtpDemuxer demuxer; 561 RtpDemuxer demuxer;
684 MockRtpPacketSink sink; 562 MockRtpPacketSink sink;
685
686 EXPECT_DEATH(demuxer.AddSink("a_3", &sink), ""); 563 EXPECT_DEATH(demuxer.AddSink("a_3", &sink), "");
687 } 564 }
688 565
689 TEST(RtpDemuxerTest, RsidMustNotExceedMaximumLength) { 566 TEST(RtpDemuxerTest, RsidMustNotExceedMaximumLength) {
690 RtpDemuxer demuxer; 567 RtpDemuxer demuxer;
691 MockRtpPacketSink sink; 568 MockRtpPacketSink sink;
692 std::string rsid(StreamId::kMaxSize + 1, 'a'); 569 std::string rsid(StreamId::kMaxSize + 1, 'a');
693
694 EXPECT_DEATH(demuxer.AddSink(rsid, &sink), ""); 570 EXPECT_DEATH(demuxer.AddSink(rsid, &sink), "");
695 } 571 }
696 572
697 TEST(RtpDemuxerTest, RepeatedRsidAssociationsDisallowed) { 573 TEST(RtpDemuxerTest, RepeatedRsidAssociationsDisallowed) {
698 RtpDemuxer demuxer; 574 RtpDemuxer demuxer;
699 MockRtpPacketSink sink_a;
700 MockRtpPacketSink sink_b;
701
702 const std::string rsid = "a";
703 demuxer.AddSink(rsid, &sink_a);
704
705 EXPECT_DEATH(demuxer.AddSink(rsid, &sink_b), "");
706
707 // Test tear-down
708 demuxer.RemoveSink(&sink_a);
709 }
710
711 TEST(RtpDemuxerTest, RepeatedRsidAssociationsDisallowedEvenIfSameSink) {
712 RtpDemuxer demuxer;
713 MockRtpPacketSink sink; 575 MockRtpPacketSink sink;
714 576 demuxer.AddSink("a", &sink);
715 const std::string rsid = "a"; 577 EXPECT_DEATH(demuxer.AddSink("a", &sink), "");
716 demuxer.AddSink(rsid, &sink);
717
718 EXPECT_DEATH(demuxer.AddSink(rsid, &sink), "");
719
720 // Test tear-down
721 demuxer.RemoveSink(&sink); 578 demuxer.RemoveSink(&sink);
722 } 579 }
723 580
724 TEST(RtpDemuxerTest, DoubleRegisterationOfRsidResolutionObserverDisallowed) { 581 TEST(RtpDemuxerTest,
582 DoubleRegisterationOfNeverRegisteredRsidResolutionObserverDisallowed) {
725 RtpDemuxer demuxer; 583 RtpDemuxer demuxer;
726 MockRsidResolutionObserver observer; 584 MockRsidResolutionObserver observer;
727 demuxer.RegisterRsidResolutionObserver(&observer); 585 demuxer.RegisterRsidResolutionObserver(&observer);
728
729 EXPECT_DEATH(demuxer.RegisterRsidResolutionObserver(&observer), ""); 586 EXPECT_DEATH(demuxer.RegisterRsidResolutionObserver(&observer), "");
730
731 // Test tear-down
732 demuxer.DeregisterRsidResolutionObserver(&observer); 587 demuxer.DeregisterRsidResolutionObserver(&observer);
733 } 588 }
734 589
735 TEST(RtpDemuxerTest, 590 TEST(RtpDemuxerTest,
736 DregisterationOfNeverRegisteredRsidResolutionObserverDisallowed) { 591 DregisterationOfNeverRegisteredRsidResolutionObserverDisallowed) {
737 RtpDemuxer demuxer; 592 RtpDemuxer demuxer;
738 MockRsidResolutionObserver observer; 593 MockRsidResolutionObserver observer;
739
740 EXPECT_DEATH(demuxer.DeregisterRsidResolutionObserver(&observer), ""); 594 EXPECT_DEATH(demuxer.DeregisterRsidResolutionObserver(&observer), "");
741 } 595 }
742 596
743 #endif 597 #endif
744 598
745 } // namespace 599 } // namespace
746 } // namespace webrtc 600 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/call/rtp_demuxer.cc ('k') | webrtc/call/rtp_rtcp_demuxer_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698