OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 for (size_t i = 0; i < arraysize(sinks); i++) { |
| 241 const bool is_first_add = (i == 0); |
| 242 ASSERT_EQ(is_first_add, demuxer.AddSink(ssrc, &sinks[i])); |
| 243 } |
| 244 |
| 245 // The first sink associated with the SSRC remains active; other sinks |
| 246 // were not really added, and so do not get OnRtpPacket() called. |
| 247 auto packet = CreateRtpPacketReceived(ssrc); |
| 248 EXPECT_CALL(sinks[0], OnRtpPacket(SamePacketAs(*packet))); |
| 249 ASSERT_TRUE(demuxer.OnRtpPacket(*packet)); |
| 250 |
| 251 // Test tear-down |
| 252 demuxer.RemoveSink(&sinks[0]); |
| 253 } |
| 254 |
| 255 TEST(RtpDemuxerTest, AddSinkFailsIfCalledTwiceEvenIfBothTimesAreForSameSink) { |
| 256 RtpDemuxer demuxer; |
| 257 MockRtpPacketSink sink; |
| 258 constexpr uint32_t ssrc = 1; |
| 259 ASSERT_TRUE(demuxer.AddSink(ssrc, &sink)); |
| 260 |
| 261 EXPECT_FALSE(demuxer.AddSink(ssrc, &sink)); |
| 262 |
| 263 // Test tear-down |
| 264 demuxer.RemoveSink(&sink); |
| 265 } |
| 266 |
| 267 TEST(RtpDemuxerTest, NoRepeatedCallbackOnRepeatedAddSinkForSameSink) { |
233 RtpDemuxer demuxer; | 268 RtpDemuxer demuxer; |
234 | 269 |
235 constexpr uint32_t ssrc = 111; | 270 constexpr uint32_t ssrc = 111; |
236 MockRtpPacketSink sink; | 271 MockRtpPacketSink sink; |
237 | 272 |
238 demuxer.AddSink(ssrc, &sink); | 273 ASSERT_TRUE(demuxer.AddSink(ssrc, &sink)); |
239 demuxer.AddSink(ssrc, &sink); | 274 ASSERT_FALSE(demuxer.AddSink(ssrc, &sink)); |
240 | 275 |
241 auto packet = CreateRtpPacketReceived(ssrc); | 276 auto packet = CreateRtpPacketReceived(ssrc); |
242 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1); | 277 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1); |
243 EXPECT_TRUE(demuxer.OnRtpPacket(*packet)); | 278 EXPECT_TRUE(demuxer.OnRtpPacket(*packet)); |
244 | 279 |
245 // Test tear-down | 280 // Test tear-down |
246 demuxer.RemoveSink(&sink); | 281 demuxer.RemoveSink(&sink); |
247 } | 282 } |
248 | 283 |
249 TEST(RtpDemuxerTest, RemoveSinkReturnsFalseForNeverAddedSink) { | 284 TEST(RtpDemuxerTest, RemoveSinkReturnsFalseForNeverAddedSink) { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 auto packet = | 460 auto packet = |
426 CreateRtpPacketReceivedWithRsid(rsids[i], ssrc, sequence_number); | 461 CreateRtpPacketReceivedWithRsid(rsids[i], ssrc, sequence_number); |
427 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1); | 462 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1); |
428 EXPECT_TRUE(demuxer.OnRtpPacket(*packet)); | 463 EXPECT_TRUE(demuxer.OnRtpPacket(*packet)); |
429 } | 464 } |
430 | 465 |
431 // Test tear-down | 466 // Test tear-down |
432 demuxer.RemoveSink(&sink); | 467 demuxer.RemoveSink(&sink); |
433 } | 468 } |
434 | 469 |
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) { | 470 TEST(RtpDemuxerTest, SinkWithBothRsidAndSsrcAssociations) { |
461 RtpDemuxer demuxer; | 471 RtpDemuxer demuxer; |
462 | 472 |
463 MockRtpPacketSink sink; | 473 MockRtpPacketSink sink; |
464 constexpr uint32_t standalone_ssrc = 10101; | 474 constexpr uint32_t standalone_ssrc = 10101; |
465 constexpr uint32_t rsid_ssrc = 20202; | 475 constexpr uint32_t rsid_ssrc = 20202; |
466 const std::string rsid = "a"; | 476 const std::string rsid = "a"; |
467 | 477 |
468 demuxer.AddSink(standalone_ssrc, &sink); | 478 demuxer.AddSink(standalone_ssrc, &sink); |
469 demuxer.AddSink(rsid, &sink); | 479 demuxer.AddSink(rsid, &sink); |
(...skipping 24 matching lines...) Expand all Loading... |
494 | 504 |
495 constexpr uint16_t seq_num = 999; | 505 constexpr uint16_t seq_num = 999; |
496 auto packet = CreateRtpPacketReceivedWithRsid(rsid, ssrc, seq_num); | 506 auto packet = CreateRtpPacketReceivedWithRsid(rsid, ssrc, seq_num); |
497 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1); | 507 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1); |
498 EXPECT_TRUE(demuxer.OnRtpPacket(*packet)); | 508 EXPECT_TRUE(demuxer.OnRtpPacket(*packet)); |
499 | 509 |
500 // Test tear-down | 510 // Test tear-down |
501 demuxer.RemoveSink(&sink); | 511 demuxer.RemoveSink(&sink); |
502 } | 512 } |
503 | 513 |
504 TEST(RtpDemuxerTest, RsidObserversInformedOfResolutions) { | 514 TEST(RtpDemuxerTest, RsidObserversInformedOfResolutionsOfTrackedRsids) { |
505 RtpDemuxer demuxer; | 515 RtpDemuxer demuxer; |
506 | 516 |
507 constexpr uint32_t ssrc = 111; | 517 constexpr uint32_t ssrc = 111; |
508 const std::string rsid = "a"; | 518 const std::string rsid = "a"; |
509 | 519 |
| 520 // Only RSIDs which the demuxer knows may be resolved. |
| 521 NiceMock<MockRtpPacketSink> sink; |
| 522 demuxer.AddSink(rsid, &sink); |
| 523 |
510 MockRsidResolutionObserver rsid_resolution_observers[3]; | 524 MockRsidResolutionObserver rsid_resolution_observers[3]; |
511 for (auto& observer : rsid_resolution_observers) { | 525 for (auto& observer : rsid_resolution_observers) { |
512 demuxer.RegisterRsidResolutionObserver(&observer); | 526 demuxer.RegisterRsidResolutionObserver(&observer); |
513 EXPECT_CALL(observer, OnRsidResolved(rsid, ssrc)).Times(1); | 527 EXPECT_CALL(observer, OnRsidResolved(rsid, ssrc)).Times(1); |
514 } | 528 } |
515 | 529 |
516 // The expected calls to OnRsidResolved() will be triggered by this. | 530 // The expected calls to OnRsidResolved() will be triggered by this. |
517 demuxer.OnRtpPacket(*CreateRtpPacketReceivedWithRsid(rsid, ssrc)); | 531 demuxer.OnRtpPacket(*CreateRtpPacketReceivedWithRsid(rsid, ssrc)); |
518 | 532 |
519 // Test tear-down | 533 // Test tear-down |
520 for (auto& observer : rsid_resolution_observers) { | 534 for (auto& observer : rsid_resolution_observers) { |
521 demuxer.DeregisterRsidResolutionObserver(&observer); | 535 demuxer.DeregisterRsidResolutionObserver(&observer); |
522 } | 536 } |
| 537 demuxer.RemoveSink(&sink); |
| 538 } |
| 539 |
| 540 TEST(RtpDemuxerTest, RsidObserversNotInformedOfResolutionsOfUntrackedRsids) { |
| 541 RtpDemuxer demuxer; |
| 542 |
| 543 constexpr uint32_t ssrc = 111; |
| 544 const std::string rsid = "a"; |
| 545 |
| 546 MockRsidResolutionObserver rsid_resolution_observers[3]; |
| 547 for (auto& observer : rsid_resolution_observers) { |
| 548 demuxer.RegisterRsidResolutionObserver(&observer); |
| 549 EXPECT_CALL(observer, OnRsidResolved(rsid, ssrc)).Times(0); |
| 550 } |
| 551 |
| 552 // The expected calls to OnRsidResolved() will be triggered by this. |
| 553 demuxer.OnRtpPacket(*CreateRtpPacketReceivedWithRsid(rsid, ssrc)); |
| 554 |
| 555 // Test tear-down |
| 556 for (auto& observer : rsid_resolution_observers) { |
| 557 demuxer.DeregisterRsidResolutionObserver(&observer); |
| 558 } |
523 } | 559 } |
524 | 560 |
| 561 // If one sink is associated with SSRC x, and another sink with RSID y, we |
| 562 // should never observe RSID x being resolved to SSRC x, or else we'd end |
| 563 // up with one SSRC mapped to two sinks. However, if such faulty input |
| 564 // ever reaches us, we should handle it gracefully - not crash, and keep the |
| 565 // packets routed only to the SSRC sink. |
| 566 TEST(RtpDemuxerTest, PacketFittingBothRsidSinkAndSsrcSinkGivenOnlyToSsrcSink) { |
| 567 RtpDemuxer demuxer; |
| 568 |
| 569 constexpr uint32_t ssrc = 111; |
| 570 MockRtpPacketSink ssrc_sink; |
| 571 demuxer.AddSink(ssrc, &ssrc_sink); |
| 572 |
| 573 const std::string rsid = "a"; |
| 574 MockRtpPacketSink rsid_sink; |
| 575 demuxer.AddSink(rsid, &rsid_sink); |
| 576 |
| 577 auto packet = CreateRtpPacketReceivedWithRsid(rsid, ssrc); |
| 578 EXPECT_CALL(ssrc_sink, OnRtpPacket(SamePacketAs(*packet))).Times(1); |
| 579 EXPECT_CALL(rsid_sink, OnRtpPacket(SamePacketAs(*packet))).Times(0); |
| 580 demuxer.OnRtpPacket(*packet); |
| 581 |
| 582 // Test tear-down |
| 583 demuxer.RemoveSink(&ssrc_sink); |
| 584 demuxer.RemoveSink(&rsid_sink); |
| 585 } |
| 586 |
| 587 TEST(RtpDemuxerTest, |
| 588 PacketFittingBothRsidSinkAndSsrcSinkDoesNotTriggerResolutionCallbacks) { |
| 589 RtpDemuxer demuxer; |
| 590 |
| 591 constexpr uint32_t ssrc = 111; |
| 592 NiceMock<MockRtpPacketSink> ssrc_sink; |
| 593 demuxer.AddSink(ssrc, &ssrc_sink); |
| 594 |
| 595 const std::string rsid = "a"; |
| 596 NiceMock<MockRtpPacketSink> rsid_sink; |
| 597 demuxer.AddSink(rsid, &rsid_sink); |
| 598 |
| 599 MockRsidResolutionObserver observer; |
| 600 demuxer.RegisterRsidResolutionObserver(&observer); |
| 601 |
| 602 auto packet = CreateRtpPacketReceivedWithRsid(rsid, ssrc); |
| 603 EXPECT_CALL(observer, OnRsidResolved(_, _)).Times(0); |
| 604 demuxer.OnRtpPacket(*packet); |
| 605 |
| 606 // Test tear-down |
| 607 demuxer.RemoveSink(&ssrc_sink); |
| 608 demuxer.RemoveSink(&rsid_sink); |
| 609 } |
| 610 |
| 611 // We're not expecting RSIDs to be resolved to SSRCs which were previously |
| 612 // mapped to sinks, and make no guarantees except for graceful handling. |
| 613 TEST(RtpDemuxerTest, GracefullyHandleRsidBeingMappedToPrevouslyAssociatedSsrc) { |
| 614 RtpDemuxer demuxer; |
| 615 |
| 616 constexpr uint32_t ssrc = 111; |
| 617 NiceMock<MockRtpPacketSink> ssrc_sink; |
| 618 demuxer.AddSink(ssrc, &ssrc_sink); |
| 619 |
| 620 const std::string rsid = "a"; |
| 621 MockRtpPacketSink rsid_sink; |
| 622 demuxer.AddSink(rsid, &rsid_sink); |
| 623 |
| 624 MockRsidResolutionObserver observer; |
| 625 demuxer.RegisterRsidResolutionObserver(&observer); |
| 626 |
| 627 // The SSRC was mapped to an SSRC sink, but was even active (packets flowed |
| 628 // over it). |
| 629 auto packet = CreateRtpPacketReceivedWithRsid(rsid, ssrc); |
| 630 demuxer.OnRtpPacket(*packet); |
| 631 |
| 632 // If the SSRC sink is ever removed, the RSID sink *might* receive indications |
| 633 // of packets, and observers *might* be informed. Only graceful handling |
| 634 // is guaranteed. |
| 635 demuxer.RemoveSink(&ssrc_sink); |
| 636 EXPECT_CALL(rsid_sink, OnRtpPacket(SamePacketAs(*packet))).Times(AtLeast(0)); |
| 637 EXPECT_CALL(observer, OnRsidResolved(rsid, ssrc)).Times(AtLeast(0)); |
| 638 demuxer.OnRtpPacket(*packet); |
| 639 |
| 640 // Test tear-down |
| 641 demuxer.DeregisterRsidResolutionObserver(&observer); |
| 642 demuxer.RemoveSink(&rsid_sink); |
| 643 } |
| 644 |
525 TEST(RtpDemuxerTest, DeregisteredRsidObserversNotInformedOfResolutions) { | 645 TEST(RtpDemuxerTest, DeregisteredRsidObserversNotInformedOfResolutions) { |
526 RtpDemuxer demuxer; | 646 RtpDemuxer demuxer; |
527 | 647 |
528 constexpr uint32_t ssrc = 111; | 648 constexpr uint32_t ssrc = 111; |
529 const std::string rsid = "a"; | 649 const std::string rsid = "a"; |
530 NiceMock<MockRtpPacketSink> sink; | 650 NiceMock<MockRtpPacketSink> sink; |
531 demuxer.AddSink(rsid, &sink); | 651 demuxer.AddSink(rsid, &sink); |
532 | 652 |
533 // Register several, then deregister only one, to show that not all of the | 653 // Register several, then deregister only one, to show that not all of the |
534 // observers had been forgotten when one was removed. | 654 // observers had been forgotten when one was removed. |
(...skipping 17 matching lines...) Expand all Loading... |
552 // Test tear-down | 672 // Test tear-down |
553 demuxer.RemoveSink(&sink); | 673 demuxer.RemoveSink(&sink); |
554 demuxer.DeregisterRsidResolutionObserver(&observer_1); | 674 demuxer.DeregisterRsidResolutionObserver(&observer_1); |
555 demuxer.DeregisterRsidResolutionObserver(&observer_3); | 675 demuxer.DeregisterRsidResolutionObserver(&observer_3); |
556 } | 676 } |
557 | 677 |
558 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 678 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
559 TEST(RtpDemuxerTest, RsidMustBeNonEmpty) { | 679 TEST(RtpDemuxerTest, RsidMustBeNonEmpty) { |
560 RtpDemuxer demuxer; | 680 RtpDemuxer demuxer; |
561 MockRtpPacketSink sink; | 681 MockRtpPacketSink sink; |
| 682 |
562 EXPECT_DEATH(demuxer.AddSink("", &sink), ""); | 683 EXPECT_DEATH(demuxer.AddSink("", &sink), ""); |
563 } | 684 } |
564 | 685 |
565 TEST(RtpDemuxerTest, RsidMustBeAlphaNumeric) { | 686 TEST(RtpDemuxerTest, RsidMustBeAlphaNumeric) { |
566 RtpDemuxer demuxer; | 687 RtpDemuxer demuxer; |
567 MockRtpPacketSink sink; | 688 MockRtpPacketSink sink; |
| 689 |
568 EXPECT_DEATH(demuxer.AddSink("a_3", &sink), ""); | 690 EXPECT_DEATH(demuxer.AddSink("a_3", &sink), ""); |
569 } | 691 } |
570 | 692 |
571 TEST(RtpDemuxerTest, RsidMustNotExceedMaximumLength) { | 693 TEST(RtpDemuxerTest, RsidMustNotExceedMaximumLength) { |
572 RtpDemuxer demuxer; | 694 RtpDemuxer demuxer; |
573 MockRtpPacketSink sink; | 695 MockRtpPacketSink sink; |
574 std::string rsid(StreamId::kMaxSize + 1, 'a'); | 696 std::string rsid(StreamId::kMaxSize + 1, 'a'); |
| 697 |
575 EXPECT_DEATH(demuxer.AddSink(rsid, &sink), ""); | 698 EXPECT_DEATH(demuxer.AddSink(rsid, &sink), ""); |
576 } | 699 } |
577 | 700 |
578 TEST(RtpDemuxerTest, RepeatedRsidAssociationsDisallowed) { | 701 TEST(RtpDemuxerTest, RepeatedRsidAssociationsDisallowed) { |
579 RtpDemuxer demuxer; | 702 RtpDemuxer demuxer; |
| 703 MockRtpPacketSink sink_a; |
| 704 MockRtpPacketSink sink_b; |
| 705 |
| 706 const std::string rsid = "a"; |
| 707 demuxer.AddSink(rsid, &sink_a); |
| 708 |
| 709 EXPECT_DEATH(demuxer.AddSink(rsid, &sink_b), ""); |
| 710 |
| 711 // Test tear-down |
| 712 demuxer.RemoveSink(&sink_a); |
| 713 } |
| 714 |
| 715 TEST(RtpDemuxerTest, RepeatedRsidAssociationsDisallowedEvenIfSameSink) { |
| 716 RtpDemuxer demuxer; |
580 MockRtpPacketSink sink; | 717 MockRtpPacketSink sink; |
581 demuxer.AddSink("a", &sink); | 718 |
582 EXPECT_DEATH(demuxer.AddSink("a", &sink), ""); | 719 const std::string rsid = "a"; |
| 720 demuxer.AddSink(rsid, &sink); |
| 721 |
| 722 EXPECT_DEATH(demuxer.AddSink(rsid, &sink), ""); |
| 723 |
| 724 // Test tear-down |
583 demuxer.RemoveSink(&sink); | 725 demuxer.RemoveSink(&sink); |
584 } | 726 } |
585 | 727 |
586 TEST(RtpDemuxerTest, | 728 TEST(RtpDemuxerTest, DoubleRegisterationOfRsidResolutionObserverDisallowed) { |
587 DoubleRegisterationOfNeverRegisteredRsidResolutionObserverDisallowed) { | |
588 RtpDemuxer demuxer; | 729 RtpDemuxer demuxer; |
589 MockRsidResolutionObserver observer; | 730 MockRsidResolutionObserver observer; |
590 demuxer.RegisterRsidResolutionObserver(&observer); | 731 demuxer.RegisterRsidResolutionObserver(&observer); |
| 732 |
591 EXPECT_DEATH(demuxer.RegisterRsidResolutionObserver(&observer), ""); | 733 EXPECT_DEATH(demuxer.RegisterRsidResolutionObserver(&observer), ""); |
| 734 |
| 735 // Test tear-down |
592 demuxer.DeregisterRsidResolutionObserver(&observer); | 736 demuxer.DeregisterRsidResolutionObserver(&observer); |
593 } | 737 } |
594 | 738 |
595 TEST(RtpDemuxerTest, | 739 TEST(RtpDemuxerTest, |
596 DregisterationOfNeverRegisteredRsidResolutionObserverDisallowed) { | 740 DregisterationOfNeverRegisteredRsidResolutionObserverDisallowed) { |
597 RtpDemuxer demuxer; | 741 RtpDemuxer demuxer; |
598 MockRsidResolutionObserver observer; | 742 MockRsidResolutionObserver observer; |
| 743 |
599 EXPECT_DEATH(demuxer.DeregisterRsidResolutionObserver(&observer), ""); | 744 EXPECT_DEATH(demuxer.DeregisterRsidResolutionObserver(&observer), ""); |
600 } | 745 } |
601 | 746 |
602 #endif | 747 #endif |
603 | 748 |
604 } // namespace | 749 } // namespace |
605 } // namespace webrtc | 750 } // namespace webrtc |
OLD | NEW |