OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 void SetSendSsrc() { | 1002 void SetSendSsrc() { |
1003 EXPECT_TRUE(SetDefaultCodec()); | 1003 EXPECT_TRUE(SetDefaultCodec()); |
1004 EXPECT_TRUE(SetSendStreamFormat(kSsrc, DefaultCodec())); | 1004 EXPECT_TRUE(SetSendStreamFormat(kSsrc, DefaultCodec())); |
1005 EXPECT_TRUE(SetSend(true)); | 1005 EXPECT_TRUE(SetSend(true)); |
1006 EXPECT_TRUE(SendFrame()); | 1006 EXPECT_TRUE(SendFrame()); |
1007 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); | 1007 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); |
1008 uint32_t ssrc = 0; | 1008 uint32_t ssrc = 0; |
1009 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0)); | 1009 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0)); |
1010 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL); | 1010 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL); |
1011 EXPECT_EQ(kSsrc, ssrc); | 1011 EXPECT_EQ(kSsrc, ssrc); |
1012 EXPECT_EQ(NumRtpPackets(), NumRtpPackets(ssrc)); | 1012 // Packets are being paced out, so these can mismatch between the first and |
1013 EXPECT_EQ(NumRtpBytes(), NumRtpBytes(ssrc)); | 1013 // second call to NumRtpPackets until pending packets are paced out. |
| 1014 EXPECT_EQ_WAIT(NumRtpPackets(), NumRtpPackets(ssrc), kTimeout); |
| 1015 EXPECT_EQ_WAIT(NumRtpBytes(), NumRtpBytes(ssrc), kTimeout); |
1014 EXPECT_EQ(1, NumSentSsrcs()); | 1016 EXPECT_EQ(1, NumSentSsrcs()); |
1015 EXPECT_EQ(0, NumRtpPackets(kSsrc - 1)); | 1017 EXPECT_EQ(0, NumRtpPackets(kSsrc - 1)); |
1016 EXPECT_EQ(0, NumRtpBytes(kSsrc - 1)); | 1018 EXPECT_EQ(0, NumRtpBytes(kSsrc - 1)); |
1017 } | 1019 } |
1018 // Test that we can set the SSRC even after codecs are set. | 1020 // Test that we can set the SSRC even after codecs are set. |
1019 void SetSendSsrcAfterSetCodecs() { | 1021 void SetSendSsrcAfterSetCodecs() { |
1020 // Remove stream added in Setup. | 1022 // Remove stream added in Setup. |
1021 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc)); | 1023 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc)); |
1022 EXPECT_TRUE(SetDefaultCodec()); | 1024 EXPECT_TRUE(SetDefaultCodec()); |
1023 EXPECT_TRUE(channel_->AddSendStream( | 1025 EXPECT_TRUE(channel_->AddSendStream( |
1024 cricket::StreamParams::CreateLegacy(999))); | 1026 cricket::StreamParams::CreateLegacy(999))); |
1025 EXPECT_TRUE(channel_->SetCapturer(999u, video_capturer_.get())); | 1027 EXPECT_TRUE(channel_->SetCapturer(999u, video_capturer_.get())); |
1026 EXPECT_TRUE(SetSendStreamFormat(999u, DefaultCodec())); | 1028 EXPECT_TRUE(SetSendStreamFormat(999u, DefaultCodec())); |
1027 EXPECT_TRUE(SetSend(true)); | 1029 EXPECT_TRUE(SetSend(true)); |
1028 EXPECT_TRUE(WaitAndSendFrame(0)); | 1030 EXPECT_TRUE(WaitAndSendFrame(0)); |
1029 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); | 1031 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); |
1030 uint32_t ssrc = 0; | 1032 uint32_t ssrc = 0; |
1031 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0)); | 1033 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0)); |
1032 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL); | 1034 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL); |
1033 EXPECT_EQ(999u, ssrc); | 1035 EXPECT_EQ(999u, ssrc); |
1034 EXPECT_EQ(NumRtpPackets(), NumRtpPackets(ssrc)); | 1036 // Packets are being paced out, so these can mismatch between the first and |
1035 EXPECT_EQ(NumRtpBytes(), NumRtpBytes(ssrc)); | 1037 // second call to NumRtpPackets until pending packets are paced out. |
| 1038 EXPECT_EQ_WAIT(NumRtpPackets(), NumRtpPackets(ssrc), kTimeout); |
| 1039 EXPECT_EQ_WAIT(NumRtpBytes(), NumRtpBytes(ssrc), kTimeout); |
1036 EXPECT_EQ(1, NumSentSsrcs()); | 1040 EXPECT_EQ(1, NumSentSsrcs()); |
1037 EXPECT_EQ(0, NumRtpPackets(kSsrc)); | 1041 EXPECT_EQ(0, NumRtpPackets(kSsrc)); |
1038 EXPECT_EQ(0, NumRtpBytes(kSsrc)); | 1042 EXPECT_EQ(0, NumRtpBytes(kSsrc)); |
1039 } | 1043 } |
1040 // Test that we can set the default video renderer before and after | 1044 // Test that we can set the default video renderer before and after |
1041 // media is received. | 1045 // media is received. |
1042 void SetRenderer() { | 1046 void SetRenderer() { |
1043 uint8_t data1[] = { | 1047 uint8_t data1[] = { |
1044 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; | 1048 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
1045 | 1049 |
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 rtc::scoped_ptr<C> channel_; | 1810 rtc::scoped_ptr<C> channel_; |
1807 cricket::FakeNetworkInterface network_interface_; | 1811 cricket::FakeNetworkInterface network_interface_; |
1808 cricket::FakeVideoRenderer renderer_; | 1812 cricket::FakeVideoRenderer renderer_; |
1809 cricket::VideoMediaChannel::Error media_error_; | 1813 cricket::VideoMediaChannel::Error media_error_; |
1810 | 1814 |
1811 // Used by test cases where 2 streams are run on the same channel. | 1815 // Used by test cases where 2 streams are run on the same channel. |
1812 cricket::FakeVideoRenderer renderer2_; | 1816 cricket::FakeVideoRenderer renderer2_; |
1813 }; | 1817 }; |
1814 | 1818 |
1815 #endif // TALK_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_ NOLINT | 1819 #endif // TALK_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_ NOLINT |
OLD | NEW |