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

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

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

Powered by Google App Engine
This is Rietveld 408576698