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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
79 TEST(RtpDemuxerTest, OnRtpPacketCalledOnCorrectSinkBySsrc) { | 90 TEST(RtpDemuxerTest, OnRtpPacketCalledOnCorrectSinkBySsrc) { |
80 RtpDemuxer demuxer; | 91 RtpDemuxer demuxer; |
81 | 92 |
82 constexpr uint32_t ssrcs[] = {101, 202, 303}; | 93 constexpr uint32_t ssrcs[] = {101, 202, 303}; |
83 MockRtpPacketSink sinks[arraysize(ssrcs)]; | 94 MockRtpPacketSink sinks[arraysize(ssrcs)]; |
84 for (size_t i = 0; i < arraysize(ssrcs); i++) { | 95 for (size_t i = 0; i < arraysize(ssrcs); i++) { |
85 demuxer.AddSink(ssrcs[i], &sinks[i]); | 96 demuxer.AddSink(ssrcs[i], &sinks[i]); |
86 } | 97 } |
87 | 98 |
88 for (size_t i = 0; i < arraysize(ssrcs); i++) { | 99 for (size_t i = 0; i < arraysize(ssrcs); i++) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 } | 148 } |
138 | 149 |
139 for (const auto& packet : packets) { | 150 for (const auto& packet : packets) { |
140 EXPECT_TRUE(demuxer.OnRtpPacket(*packet)); | 151 EXPECT_TRUE(demuxer.OnRtpPacket(*packet)); |
141 } | 152 } |
142 | 153 |
143 // Test tear-down | 154 // Test tear-down |
144 demuxer.RemoveSink(&sink); | 155 demuxer.RemoveSink(&sink); |
145 } | 156 } |
146 | 157 |
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 | |
170 TEST(RtpDemuxerTest, SinkMappedToMultipleSsrcs) { | 158 TEST(RtpDemuxerTest, SinkMappedToMultipleSsrcs) { |
171 RtpDemuxer demuxer; | 159 RtpDemuxer demuxer; |
172 | 160 |
173 constexpr uint32_t ssrcs[] = {404, 505, 606}; | 161 constexpr uint32_t ssrcs[] = {404, 505, 606}; |
174 MockRtpPacketSink sink; | 162 MockRtpPacketSink sink; |
175 for (uint32_t ssrc : ssrcs) { | 163 for (uint32_t ssrc : ssrcs) { |
176 demuxer.AddSink(ssrc, &sink); | 164 demuxer.AddSink(ssrc, &sink); |
177 } | 165 } |
178 | 166 |
179 // The sink which is associated with multiple SSRCs gets the callback | 167 // The sink which is associated with multiple SSRCs gets the callback |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 } | 205 } |
218 | 206 |
219 ASSERT_TRUE(demuxer.RemoveSink(&sink)); | 207 ASSERT_TRUE(demuxer.RemoveSink(&sink)); |
220 | 208 |
221 // The removed sink does not get callbacks. | 209 // The removed sink does not get callbacks. |
222 auto packet = CreateRtpPacketReceived(ssrc, seq_num); | 210 auto packet = CreateRtpPacketReceived(ssrc, seq_num); |
223 EXPECT_CALL(sink, OnRtpPacket(_)).Times(0); // Not called. | 211 EXPECT_CALL(sink, OnRtpPacket(_)).Times(0); // Not called. |
224 EXPECT_FALSE(demuxer.OnRtpPacket(*packet)); | 212 EXPECT_FALSE(demuxer.OnRtpPacket(*packet)); |
225 } | 213 } |
226 | 214 |
227 TEST(RtpDemuxerTest, RepeatedSsrcAssociationsDoNotTriggerRepeatedCallbacks) { | 215 TEST(RtpDemuxerTest, AddSinkFailsIfCalledForTwoSinks) { |
| 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) { |
228 RtpDemuxer demuxer; | 264 RtpDemuxer demuxer; |
229 | 265 |
230 constexpr uint32_t ssrc = 111; | 266 constexpr uint32_t ssrc = 111; |
231 MockRtpPacketSink sink; | 267 MockRtpPacketSink sink; |
232 | 268 |
233 demuxer.AddSink(ssrc, &sink); | 269 ASSERT_TRUE(demuxer.AddSink(ssrc, &sink)); |
234 demuxer.AddSink(ssrc, &sink); | 270 ASSERT_FALSE(demuxer.AddSink(ssrc, &sink)); |
235 | 271 |
236 auto packet = CreateRtpPacketReceived(ssrc); | 272 auto packet = CreateRtpPacketReceived(ssrc); |
237 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1); | 273 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1); |
238 EXPECT_TRUE(demuxer.OnRtpPacket(*packet)); | 274 EXPECT_TRUE(demuxer.OnRtpPacket(*packet)); |
239 | 275 |
240 // Test tear-down | 276 // Test tear-down |
241 demuxer.RemoveSink(&sink); | 277 demuxer.RemoveSink(&sink); |
242 } | 278 } |
243 | 279 |
244 TEST(RtpDemuxerTest, RemoveSinkReturnsFalseForNeverAddedSink) { | 280 TEST(RtpDemuxerTest, RemoveSinkReturnsFalseForNeverAddedSink) { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 auto packet = | 456 auto packet = |
421 CreateRtpPacketReceivedWithRsid(rsids[i], ssrc, sequence_number); | 457 CreateRtpPacketReceivedWithRsid(rsids[i], ssrc, sequence_number); |
422 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1); | 458 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1); |
423 EXPECT_TRUE(demuxer.OnRtpPacket(*packet)); | 459 EXPECT_TRUE(demuxer.OnRtpPacket(*packet)); |
424 } | 460 } |
425 | 461 |
426 // Test tear-down | 462 // Test tear-down |
427 demuxer.RemoveSink(&sink); | 463 demuxer.RemoveSink(&sink); |
428 } | 464 } |
429 | 465 |
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 | |
455 TEST(RtpDemuxerTest, SinkWithBothRsidAndSsrcAssociations) { | 466 TEST(RtpDemuxerTest, SinkWithBothRsidAndSsrcAssociations) { |
456 RtpDemuxer demuxer; | 467 RtpDemuxer demuxer; |
457 | 468 |
458 MockRtpPacketSink sink; | 469 MockRtpPacketSink sink; |
459 constexpr uint32_t standalone_ssrc = 10101; | 470 constexpr uint32_t standalone_ssrc = 10101; |
460 constexpr uint32_t rsid_ssrc = 20202; | 471 constexpr uint32_t rsid_ssrc = 20202; |
461 const std::string rsid = "a"; | 472 const std::string rsid = "a"; |
462 | 473 |
463 demuxer.AddSink(standalone_ssrc, &sink); | 474 demuxer.AddSink(standalone_ssrc, &sink); |
464 demuxer.AddSink(rsid, &sink); | 475 demuxer.AddSink(rsid, &sink); |
(...skipping 24 matching lines...) Expand all Loading... |
489 | 500 |
490 constexpr uint16_t seq_num = 999; | 501 constexpr uint16_t seq_num = 999; |
491 auto packet = CreateRtpPacketReceivedWithRsid(rsid, ssrc, seq_num); | 502 auto packet = CreateRtpPacketReceivedWithRsid(rsid, ssrc, seq_num); |
492 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1); | 503 EXPECT_CALL(sink, OnRtpPacket(SamePacketAs(*packet))).Times(1); |
493 EXPECT_TRUE(demuxer.OnRtpPacket(*packet)); | 504 EXPECT_TRUE(demuxer.OnRtpPacket(*packet)); |
494 | 505 |
495 // Test tear-down | 506 // Test tear-down |
496 demuxer.RemoveSink(&sink); | 507 demuxer.RemoveSink(&sink); |
497 } | 508 } |
498 | 509 |
499 TEST(RtpDemuxerTest, RsidObserversInformedOfResolutions) { | 510 TEST(RtpDemuxerTest, RsidObserversInformedOfResolutionsOfTrackedRsids) { |
500 RtpDemuxer demuxer; | 511 RtpDemuxer demuxer; |
501 | 512 |
502 constexpr uint32_t ssrc = 111; | 513 constexpr uint32_t ssrc = 111; |
503 const std::string rsid = "a"; | 514 const std::string rsid = "a"; |
504 | 515 |
| 516 // Only RSIDs which the demuxer knows may be resolved. |
| 517 NiceMock<MockRtpPacketSink> sink; |
| 518 demuxer.AddSink(rsid, &sink); |
| 519 |
505 MockRsidResolutionObserver rsid_resolution_observers[3]; | 520 MockRsidResolutionObserver rsid_resolution_observers[3]; |
506 for (auto& observer : rsid_resolution_observers) { | 521 for (auto& observer : rsid_resolution_observers) { |
507 demuxer.RegisterRsidResolutionObserver(&observer); | 522 demuxer.RegisterRsidResolutionObserver(&observer); |
508 EXPECT_CALL(observer, OnRsidResolved(rsid, ssrc)).Times(1); | 523 EXPECT_CALL(observer, OnRsidResolved(rsid, ssrc)).Times(1); |
509 } | 524 } |
510 | 525 |
511 // The expected calls to OnRsidResolved() will be triggered by this. | 526 // The expected calls to OnRsidResolved() will be triggered by this. |
512 demuxer.OnRtpPacket(*CreateRtpPacketReceivedWithRsid(rsid, ssrc)); | 527 demuxer.OnRtpPacket(*CreateRtpPacketReceivedWithRsid(rsid, ssrc)); |
513 | 528 |
514 // Test tear-down | 529 // Test tear-down |
515 for (auto& observer : rsid_resolution_observers) { | 530 for (auto& observer : rsid_resolution_observers) { |
516 demuxer.DeregisterRsidResolutionObserver(&observer); | 531 demuxer.DeregisterRsidResolutionObserver(&observer); |
517 } | 532 } |
| 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 } |
518 } | 555 } |
519 | 556 |
| 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 |
520 TEST(RtpDemuxerTest, DeregisteredRsidObserversNotInformedOfResolutions) { | 641 TEST(RtpDemuxerTest, DeregisteredRsidObserversNotInformedOfResolutions) { |
521 RtpDemuxer demuxer; | 642 RtpDemuxer demuxer; |
522 | 643 |
523 constexpr uint32_t ssrc = 111; | 644 constexpr uint32_t ssrc = 111; |
524 const std::string rsid = "a"; | 645 const std::string rsid = "a"; |
525 NiceMock<MockRtpPacketSink> sink; | 646 NiceMock<MockRtpPacketSink> sink; |
526 demuxer.AddSink(rsid, &sink); | 647 demuxer.AddSink(rsid, &sink); |
527 | 648 |
528 // Register several, then deregister only one, to show that not all of the | 649 // Register several, then deregister only one, to show that not all of the |
529 // observers had been forgotten when one was removed. | 650 // observers had been forgotten when one was removed. |
(...skipping 17 matching lines...) Expand all Loading... |
547 // Test tear-down | 668 // Test tear-down |
548 demuxer.RemoveSink(&sink); | 669 demuxer.RemoveSink(&sink); |
549 demuxer.DeregisterRsidResolutionObserver(&observer_1); | 670 demuxer.DeregisterRsidResolutionObserver(&observer_1); |
550 demuxer.DeregisterRsidResolutionObserver(&observer_3); | 671 demuxer.DeregisterRsidResolutionObserver(&observer_3); |
551 } | 672 } |
552 | 673 |
553 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 674 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
554 TEST(RtpDemuxerTest, RsidMustBeNonEmpty) { | 675 TEST(RtpDemuxerTest, RsidMustBeNonEmpty) { |
555 RtpDemuxer demuxer; | 676 RtpDemuxer demuxer; |
556 MockRtpPacketSink sink; | 677 MockRtpPacketSink sink; |
| 678 |
557 EXPECT_DEATH(demuxer.AddSink("", &sink), ""); | 679 EXPECT_DEATH(demuxer.AddSink("", &sink), ""); |
558 } | 680 } |
559 | 681 |
560 TEST(RtpDemuxerTest, RsidMustBeAlphaNumeric) { | 682 TEST(RtpDemuxerTest, RsidMustBeAlphaNumeric) { |
561 RtpDemuxer demuxer; | 683 RtpDemuxer demuxer; |
562 MockRtpPacketSink sink; | 684 MockRtpPacketSink sink; |
| 685 |
563 EXPECT_DEATH(demuxer.AddSink("a_3", &sink), ""); | 686 EXPECT_DEATH(demuxer.AddSink("a_3", &sink), ""); |
564 } | 687 } |
565 | 688 |
566 TEST(RtpDemuxerTest, RsidMustNotExceedMaximumLength) { | 689 TEST(RtpDemuxerTest, RsidMustNotExceedMaximumLength) { |
567 RtpDemuxer demuxer; | 690 RtpDemuxer demuxer; |
568 MockRtpPacketSink sink; | 691 MockRtpPacketSink sink; |
569 std::string rsid(StreamId::kMaxSize + 1, 'a'); | 692 std::string rsid(StreamId::kMaxSize + 1, 'a'); |
| 693 |
570 EXPECT_DEATH(demuxer.AddSink(rsid, &sink), ""); | 694 EXPECT_DEATH(demuxer.AddSink(rsid, &sink), ""); |
571 } | 695 } |
572 | 696 |
573 TEST(RtpDemuxerTest, RepeatedRsidAssociationsDisallowed) { | 697 TEST(RtpDemuxerTest, RepeatedRsidAssociationsDisallowed) { |
574 RtpDemuxer demuxer; | 698 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; |
575 MockRtpPacketSink sink; | 713 MockRtpPacketSink sink; |
576 demuxer.AddSink("a", &sink); | 714 |
577 EXPECT_DEATH(demuxer.AddSink("a", &sink), ""); | 715 const std::string rsid = "a"; |
| 716 demuxer.AddSink(rsid, &sink); |
| 717 |
| 718 EXPECT_DEATH(demuxer.AddSink(rsid, &sink), ""); |
| 719 |
| 720 // Test tear-down |
578 demuxer.RemoveSink(&sink); | 721 demuxer.RemoveSink(&sink); |
579 } | 722 } |
580 | 723 |
581 TEST(RtpDemuxerTest, | 724 TEST(RtpDemuxerTest, DoubleRegisterationOfRsidResolutionObserverDisallowed) { |
582 DoubleRegisterationOfNeverRegisteredRsidResolutionObserverDisallowed) { | |
583 RtpDemuxer demuxer; | 725 RtpDemuxer demuxer; |
584 MockRsidResolutionObserver observer; | 726 MockRsidResolutionObserver observer; |
585 demuxer.RegisterRsidResolutionObserver(&observer); | 727 demuxer.RegisterRsidResolutionObserver(&observer); |
| 728 |
586 EXPECT_DEATH(demuxer.RegisterRsidResolutionObserver(&observer), ""); | 729 EXPECT_DEATH(demuxer.RegisterRsidResolutionObserver(&observer), ""); |
| 730 |
| 731 // Test tear-down |
587 demuxer.DeregisterRsidResolutionObserver(&observer); | 732 demuxer.DeregisterRsidResolutionObserver(&observer); |
588 } | 733 } |
589 | 734 |
590 TEST(RtpDemuxerTest, | 735 TEST(RtpDemuxerTest, |
591 DregisterationOfNeverRegisteredRsidResolutionObserverDisallowed) { | 736 DregisterationOfNeverRegisteredRsidResolutionObserverDisallowed) { |
592 RtpDemuxer demuxer; | 737 RtpDemuxer demuxer; |
593 MockRsidResolutionObserver observer; | 738 MockRsidResolutionObserver observer; |
| 739 |
594 EXPECT_DEATH(demuxer.DeregisterRsidResolutionObserver(&observer), ""); | 740 EXPECT_DEATH(demuxer.DeregisterRsidResolutionObserver(&observer), ""); |
595 } | 741 } |
596 | 742 |
597 #endif | 743 #endif |
598 | 744 |
599 } // namespace | 745 } // namespace |
600 } // namespace webrtc | 746 } // namespace webrtc |
OLD | NEW |