| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 27 matching lines...) Expand all Loading... |
| 38 const int kFrameSize = kWidth * kHeight * 3 / 2; // I420. | 38 const int kFrameSize = kWidth * kHeight * 3 / 2; // I420. |
| 39 const int kFramerate = 30; | 39 const int kFramerate = 30; |
| 40 const int kNumFrames = 2; | 40 const int kNumFrames = 2; |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 class VideoProcessorTest : public testing::Test { | 44 class VideoProcessorTest : public testing::Test { |
| 45 protected: | 45 protected: |
| 46 VideoProcessorTest() { | 46 VideoProcessorTest() { |
| 47 // Get a codec configuration struct and configure it. | 47 // Get a codec configuration struct and configure it. |
| 48 VideoCodingModule::Codec(kVideoCodecVP8, &codec_settings_); | 48 VideoCodingModule::Codec(kVideoCodecVP8, &config_.codec_settings); |
| 49 config_.codec_settings = &codec_settings_; | 49 config_.codec_settings.width = kWidth; |
| 50 config_.codec_settings->startBitrate = 100; | 50 config_.codec_settings.height = kHeight; |
| 51 config_.codec_settings->width = kWidth; | 51 config_.codec_settings.maxFramerate = kFramerate; |
| 52 config_.codec_settings->height = kHeight; | |
| 53 config_.codec_settings->maxFramerate = kFramerate; | |
| 54 | 52 |
| 55 EXPECT_CALL(frame_reader_mock_, NumberOfFrames()) | 53 EXPECT_CALL(frame_reader_mock_, NumberOfFrames()) |
| 56 .WillRepeatedly(Return(kNumFrames)); | 54 .WillRepeatedly(Return(kNumFrames)); |
| 57 EXPECT_CALL(frame_reader_mock_, FrameLength()) | 55 EXPECT_CALL(frame_reader_mock_, FrameLength()) |
| 58 .WillRepeatedly(Return(kFrameSize)); | 56 .WillRepeatedly(Return(kFrameSize)); |
| 59 video_processor_ = rtc::MakeUnique<VideoProcessor>( | 57 video_processor_ = rtc::MakeUnique<VideoProcessor>( |
| 60 &encoder_mock_, &decoder_mock_, &frame_reader_mock_, | 58 &encoder_mock_, &decoder_mock_, &frame_reader_mock_, |
| 61 &frame_writer_mock_, &packet_manipulator_mock_, config_, &stats_, | 59 &frame_writer_mock_, &packet_manipulator_mock_, config_, &stats_, |
| 62 nullptr /* encoded_frame_writer */, nullptr /* decoded_frame_writer */); | 60 nullptr /* encoded_frame_writer */, nullptr /* decoded_frame_writer */); |
| 63 } | 61 } |
| 64 | 62 |
| 65 void ExpectInit() { | 63 void ExpectInit() { |
| 66 EXPECT_CALL(encoder_mock_, InitEncode(_, _, _)).Times(1); | 64 EXPECT_CALL(encoder_mock_, InitEncode(_, _, _)).Times(1); |
| 67 EXPECT_CALL(encoder_mock_, RegisterEncodeCompleteCallback(_)) | 65 EXPECT_CALL(encoder_mock_, RegisterEncodeCompleteCallback(_)) |
| 68 .Times(AtLeast(1)); | 66 .Times(AtLeast(1)); |
| 69 EXPECT_CALL(decoder_mock_, InitDecode(_, _)).Times(1); | 67 EXPECT_CALL(decoder_mock_, InitDecode(_, _)).Times(1); |
| 70 EXPECT_CALL(decoder_mock_, RegisterDecodeCompleteCallback(_)) | 68 EXPECT_CALL(decoder_mock_, RegisterDecodeCompleteCallback(_)) |
| 71 .Times(AtLeast(1)); | 69 .Times(AtLeast(1)); |
| 72 } | 70 } |
| 73 | 71 |
| 72 TestConfig config_; |
| 73 |
| 74 MockVideoEncoder encoder_mock_; | 74 MockVideoEncoder encoder_mock_; |
| 75 MockVideoDecoder decoder_mock_; | 75 MockVideoDecoder decoder_mock_; |
| 76 MockFrameReader frame_reader_mock_; | 76 MockFrameReader frame_reader_mock_; |
| 77 MockFrameWriter frame_writer_mock_; | 77 MockFrameWriter frame_writer_mock_; |
| 78 MockPacketManipulator packet_manipulator_mock_; | 78 MockPacketManipulator packet_manipulator_mock_; |
| 79 VideoCodec codec_settings_; | |
| 80 TestConfig config_; | |
| 81 Stats stats_; | 79 Stats stats_; |
| 82 std::unique_ptr<VideoProcessor> video_processor_; | 80 std::unique_ptr<VideoProcessor> video_processor_; |
| 83 }; | 81 }; |
| 84 | 82 |
| 85 TEST_F(VideoProcessorTest, Init) { | 83 TEST_F(VideoProcessorTest, Init) { |
| 86 ExpectInit(); | 84 ExpectInit(); |
| 87 video_processor_->Init(); | 85 video_processor_->Init(); |
| 88 } | 86 } |
| 89 | 87 |
| 90 TEST_F(VideoProcessorTest, ProcessFrames) { | 88 TEST_F(VideoProcessorTest, ProcessFrames) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 101 | 99 |
| 102 EXPECT_CALL(encoder_mock_, Encode(testing::Property(&VideoFrame::timestamp, | 100 EXPECT_CALL(encoder_mock_, Encode(testing::Property(&VideoFrame::timestamp, |
| 103 2 * 90000 / kFramerate), | 101 2 * 90000 / kFramerate), |
| 104 _, _)) | 102 _, _)) |
| 105 .Times(1); | 103 .Times(1); |
| 106 video_processor_->ProcessFrame(1); | 104 video_processor_->ProcessFrame(1); |
| 107 } | 105 } |
| 108 | 106 |
| 109 } // namespace test | 107 } // namespace test |
| 110 } // namespace webrtc | 108 } // namespace webrtc |
| OLD | NEW |