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

Side by Side Diff: talk/media/base/videocapturer_unittest.cc

Issue 1296113002: Remove cricket::VideoProcessor and AddVideoProcessor() functionality (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « talk/media/base/videocapturer.cc ('k') | talk/media/base/videoprocessor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2008 Google Inc. 3 * Copyright 2008 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 15 matching lines...) Expand all
26 */ 26 */
27 27
28 #include <stdio.h> 28 #include <stdio.h>
29 #include <vector> 29 #include <vector>
30 30
31 #include "talk/media/base/fakemediaprocessor.h" 31 #include "talk/media/base/fakemediaprocessor.h"
32 #include "talk/media/base/fakevideocapturer.h" 32 #include "talk/media/base/fakevideocapturer.h"
33 #include "talk/media/base/fakevideorenderer.h" 33 #include "talk/media/base/fakevideorenderer.h"
34 #include "talk/media/base/testutils.h" 34 #include "talk/media/base/testutils.h"
35 #include "talk/media/base/videocapturer.h" 35 #include "talk/media/base/videocapturer.h"
36 #include "talk/media/base/videoprocessor.h"
37 #include "webrtc/base/gunit.h" 36 #include "webrtc/base/gunit.h"
38 #include "webrtc/base/logging.h" 37 #include "webrtc/base/logging.h"
39 #include "webrtc/base/thread.h" 38 #include "webrtc/base/thread.h"
40 39
41 using cricket::FakeVideoCapturer; 40 using cricket::FakeVideoCapturer;
42 41
43 namespace { 42 namespace {
44 43
45 const int kMsCallbackWait = 500; 44 const int kMsCallbackWait = 500;
46 // For HD only the height matters. 45 // For HD only the height matters.
47 const int kMinHdHeight = 720; 46 const int kMinHdHeight = 720;
48 const uint32 kTimeout = 5000U; 47 const uint32 kTimeout = 5000U;
49 48
50 } // namespace 49 } // namespace
51 50
52 // Sets the elapsed time in the video frame to 0.
53 class VideoProcessor0 : public cricket::VideoProcessor {
54 public:
55 virtual void OnFrame(uint32 /*ssrc*/, cricket::VideoFrame* frame,
56 bool* drop_frame) {
57 frame->SetElapsedTime(0u);
58 }
59 };
60
61 // Adds one to the video frame's elapsed time. Note that VideoProcessor0 and
62 // VideoProcessor1 are not commutative.
63 class VideoProcessor1 : public cricket::VideoProcessor {
64 public:
65 virtual void OnFrame(uint32 /*ssrc*/, cricket::VideoFrame* frame,
66 bool* drop_frame) {
67 int64 elapsed_time = frame->GetElapsedTime();
68 frame->SetElapsedTime(elapsed_time + 1);
69 }
70 };
71
72 class VideoCapturerTest 51 class VideoCapturerTest
73 : public sigslot::has_slots<>, 52 : public sigslot::has_slots<>,
74 public testing::Test { 53 public testing::Test {
75 public: 54 public:
76 VideoCapturerTest() 55 VideoCapturerTest()
77 : capture_state_(cricket::CS_STOPPED), 56 : capture_state_(cricket::CS_STOPPED),
78 num_state_changes_(0), 57 num_state_changes_(0),
79 video_frames_received_(0), 58 video_frames_received_(0),
80 last_frame_elapsed_time_(0), 59 last_frame_elapsed_time_(0),
81 expects_rotation_applied_(true) { 60 expects_rotation_applied_(true) {
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 EXPECT_EQ(cricket::CS_RUNNING, capturer_.Start(cricket::VideoFormat( 778 EXPECT_EQ(cricket::CS_RUNNING, capturer_.Start(cricket::VideoFormat(
800 640, 779 640,
801 480, 780 480,
802 cricket::VideoFormat::FpsToInterval(30), 781 cricket::VideoFormat::FpsToInterval(30),
803 cricket::FOURCC_I420))); 782 cricket::FOURCC_I420)));
804 EXPECT_TRUE(capturer_.IsRunning()); 783 EXPECT_TRUE(capturer_.IsRunning());
805 EXPECT_EQ(0, video_frames_received()); 784 EXPECT_EQ(0, video_frames_received());
806 EXPECT_TRUE(capturer_.CaptureFrame()); 785 EXPECT_TRUE(capturer_.CaptureFrame());
807 EXPECT_EQ(1, video_frames_received()); 786 EXPECT_EQ(1, video_frames_received());
808 } 787 }
809
810 TEST_F(VideoCapturerTest, ProcessorChainTest) {
811 VideoProcessor0 processor0;
812 VideoProcessor1 processor1;
813 EXPECT_EQ(cricket::CS_RUNNING, capturer_.Start(cricket::VideoFormat(
814 640,
815 480,
816 cricket::VideoFormat::FpsToInterval(30),
817 cricket::FOURCC_I420)));
818 EXPECT_TRUE(capturer_.IsRunning());
819 EXPECT_EQ(0, video_frames_received());
820 // First processor sets elapsed time to 0.
821 capturer_.AddVideoProcessor(&processor0);
822 // Second processor adds 1 to the elapsed time. I.e. a frames elapsed time
823 // should now always be 1 (and not 0).
824 capturer_.AddVideoProcessor(&processor1);
825 EXPECT_TRUE(capturer_.CaptureFrame());
826 EXPECT_EQ(1, video_frames_received());
827 EXPECT_EQ(1u, last_frame_elapsed_time());
828 capturer_.RemoveVideoProcessor(&processor1);
829 EXPECT_TRUE(capturer_.CaptureFrame());
830 // Since processor1 has been removed the elapsed time should now be 0.
831 EXPECT_EQ(2, video_frames_received());
832 EXPECT_EQ(0u, last_frame_elapsed_time());
833 }
834
835 TEST_F(VideoCapturerTest, ProcessorDropFrame) {
836 cricket::FakeMediaProcessor dropping_processor_;
837 dropping_processor_.set_drop_frames(true);
838 EXPECT_EQ(cricket::CS_RUNNING, capturer_.Start(cricket::VideoFormat(
839 640,
840 480,
841 cricket::VideoFormat::FpsToInterval(30),
842 cricket::FOURCC_I420)));
843 EXPECT_TRUE(capturer_.IsRunning());
844 EXPECT_EQ(0, video_frames_received());
845 // Install a processor that always drop frames.
846 capturer_.AddVideoProcessor(&dropping_processor_);
847 EXPECT_TRUE(capturer_.CaptureFrame());
848 EXPECT_EQ(0, video_frames_received());
849 }
850 #endif // HAVE_WEBRTC_VIDEO 788 #endif // HAVE_WEBRTC_VIDEO
851 789
852 bool HdFormatInList(const std::vector<cricket::VideoFormat>& formats) { 790 bool HdFormatInList(const std::vector<cricket::VideoFormat>& formats) {
853 for (std::vector<cricket::VideoFormat>::const_iterator found = 791 for (std::vector<cricket::VideoFormat>::const_iterator found =
854 formats.begin(); found != formats.end(); ++found) { 792 formats.begin(); found != formats.end(); ++found) {
855 if (found->height >= kMinHdHeight) { 793 if (found->height >= kMinHdHeight) {
856 return true; 794 return true;
857 } 795 }
858 } 796 }
859 return false; 797 return false;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 capturer_.set_enable_camera_list(true); 844 capturer_.set_enable_camera_list(true);
907 capturer_.ConstrainSupportedFormats(vga_format); 845 capturer_.ConstrainSupportedFormats(vga_format);
908 EXPECT_EQ(2u, capturer_.GetSupportedFormats()->size()); 846 EXPECT_EQ(2u, capturer_.GetSupportedFormats()->size());
909 // To make sure it's not just the camera list being broken, add in VGA and 847 // To make sure it's not just the camera list being broken, add in VGA and
910 // try again. This time, only the VGA format should be there. 848 // try again. This time, only the VGA format should be there.
911 supported_formats.push_back(vga_format); 849 supported_formats.push_back(vga_format);
912 capturer_.ResetSupportedFormats(supported_formats); 850 capturer_.ResetSupportedFormats(supported_formats);
913 ASSERT_EQ(1u, capturer_.GetSupportedFormats()->size()); 851 ASSERT_EQ(1u, capturer_.GetSupportedFormats()->size());
914 EXPECT_EQ(vga_format.height, capturer_.GetSupportedFormats()->at(0).height); 852 EXPECT_EQ(vga_format.height, capturer_.GetSupportedFormats()->at(0).height);
915 } 853 }
OLDNEW
« no previous file with comments | « talk/media/base/videocapturer.cc ('k') | talk/media/base/videoprocessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698