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 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1640 video_capturer.Start( | 1640 video_capturer.Start( |
1641 cricket::VideoFormat( | 1641 cricket::VideoFormat( |
1642 640, 480, | 1642 640, 480, |
1643 cricket::VideoFormat::FpsToInterval(30), | 1643 cricket::VideoFormat::FpsToInterval(30), |
1644 cricket::FOURCC_I420)); | 1644 cricket::FOURCC_I420)); |
1645 EXPECT_TRUE(channel_->SetCapturer(kSsrc, &video_capturer)); | 1645 EXPECT_TRUE(channel_->SetCapturer(kSsrc, &video_capturer)); |
1646 EXPECT_TRUE(SetSend(true)); | 1646 EXPECT_TRUE(SetSend(true)); |
1647 EXPECT_TRUE(channel_->SetRender(true)); | 1647 EXPECT_TRUE(channel_->SetRender(true)); |
1648 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_)); | 1648 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_)); |
1649 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 1649 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
1650 | |
1651 // Mute the channel and expect black output frame. | 1650 // Mute the channel and expect black output frame. |
1652 int frame_count = 0; | 1651 int frame_count = 0; |
1653 EXPECT_TRUE(channel_->MuteStream(kSsrc, true)); | 1652 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr)); |
1654 EXPECT_TRUE(video_capturer.CaptureFrame()); | 1653 EXPECT_TRUE(video_capturer.CaptureFrame()); |
1655 ++frame_count; | 1654 ++frame_count; |
1656 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout); | 1655 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout); |
1657 EXPECT_TRUE(renderer_.black_frame()); | 1656 EXPECT_TRUE(renderer_.black_frame()); |
1658 | |
1659 // Unmute the channel and expect non-black output frame. | 1657 // Unmute the channel and expect non-black output frame. |
1660 EXPECT_TRUE(channel_->MuteStream(kSsrc, false)); | 1658 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, false, nullptr)); |
1661 EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30)); | 1659 EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30)); |
1662 EXPECT_TRUE(video_capturer.CaptureFrame()); | 1660 EXPECT_TRUE(video_capturer.CaptureFrame()); |
1663 ++frame_count; | 1661 ++frame_count; |
1664 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout); | 1662 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout); |
1665 EXPECT_FALSE(renderer_.black_frame()); | 1663 EXPECT_FALSE(renderer_.black_frame()); |
1666 | |
1667 // Test that we can also Mute using the correct send stream SSRC. | 1664 // Test that we can also Mute using the correct send stream SSRC. |
1668 EXPECT_TRUE(channel_->MuteStream(kSsrc, true)); | 1665 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr)); |
1669 EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30)); | 1666 EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30)); |
1670 EXPECT_TRUE(video_capturer.CaptureFrame()); | 1667 EXPECT_TRUE(video_capturer.CaptureFrame()); |
1671 ++frame_count; | 1668 ++frame_count; |
1672 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout); | 1669 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout); |
1673 EXPECT_TRUE(renderer_.black_frame()); | 1670 EXPECT_TRUE(renderer_.black_frame()); |
1674 | 1671 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, false, nullptr)); |
1675 EXPECT_TRUE(channel_->MuteStream(kSsrc, false)); | |
1676 EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30)); | 1672 EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30)); |
1677 EXPECT_TRUE(video_capturer.CaptureFrame()); | 1673 EXPECT_TRUE(video_capturer.CaptureFrame()); |
1678 ++frame_count; | 1674 ++frame_count; |
1679 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout); | 1675 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout); |
1680 EXPECT_FALSE(renderer_.black_frame()); | 1676 EXPECT_FALSE(renderer_.black_frame()); |
1681 | |
1682 // Test that muting an existing stream succeeds even if it's muted. | 1677 // Test that muting an existing stream succeeds even if it's muted. |
1683 EXPECT_TRUE(channel_->MuteStream(kSsrc, true)); | 1678 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr)); |
1684 EXPECT_TRUE(channel_->MuteStream(kSsrc, true)); | 1679 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr)); |
1685 | |
1686 // Test that unmuting an existing stream succeeds even if it's not muted. | 1680 // Test that unmuting an existing stream succeeds even if it's not muted. |
1687 EXPECT_TRUE(channel_->MuteStream(kSsrc, false)); | 1681 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, false, nullptr)); |
1688 EXPECT_TRUE(channel_->MuteStream(kSsrc, false)); | 1682 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, false, nullptr)); |
1689 | |
1690 // Test that muting an invalid stream fails. | 1683 // Test that muting an invalid stream fails. |
1691 EXPECT_FALSE(channel_->MuteStream(kSsrc+1, true)); | 1684 EXPECT_FALSE(channel_->SetVideoSend(kSsrc+1, true, nullptr)); |
1692 EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL)); | 1685 EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL)); |
1693 } | 1686 } |
1694 | 1687 |
1695 // Test that multiple send streams can be created and deleted properly. | 1688 // Test that multiple send streams can be created and deleted properly. |
1696 void MultipleSendStreams() { | 1689 void MultipleSendStreams() { |
1697 // Remove stream added in Setup. I.e. remove stream corresponding to default | 1690 // Remove stream added in Setup. I.e. remove stream corresponding to default |
1698 // channel. | 1691 // channel. |
1699 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc)); | 1692 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc)); |
1700 const unsigned int kSsrcsSize = sizeof(kSsrcs4)/sizeof(kSsrcs4[0]); | 1693 const unsigned int kSsrcsSize = sizeof(kSsrcs4)/sizeof(kSsrcs4[0]); |
1701 for (unsigned int i = 0; i < kSsrcsSize; ++i) { | 1694 for (unsigned int i = 0; i < kSsrcsSize; ++i) { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1880 rtc::scoped_ptr<C> channel_; | 1873 rtc::scoped_ptr<C> channel_; |
1881 cricket::FakeNetworkInterface network_interface_; | 1874 cricket::FakeNetworkInterface network_interface_; |
1882 cricket::FakeVideoRenderer renderer_; | 1875 cricket::FakeVideoRenderer renderer_; |
1883 cricket::VideoMediaChannel::Error media_error_; | 1876 cricket::VideoMediaChannel::Error media_error_; |
1884 | 1877 |
1885 // Used by test cases where 2 streams are run on the same channel. | 1878 // Used by test cases where 2 streams are run on the same channel. |
1886 cricket::FakeVideoRenderer renderer2_; | 1879 cricket::FakeVideoRenderer renderer2_; |
1887 }; | 1880 }; |
1888 | 1881 |
1889 #endif // TALK_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_ NOLINT | 1882 #endif // TALK_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_ NOLINT |
OLD | NEW |