| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 |
| 11 #include <memory> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "webrtc/base/scoped_ptr.h" | |
| 15 #include "webrtc/modules/video_coding/include/mock/mock_video_codec_interface.h" | 15 #include "webrtc/modules/video_coding/include/mock/mock_video_codec_interface.h" |
| 16 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" | 16 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" |
| 17 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" | 17 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" |
| 18 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" | 18 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" |
| 19 #include "webrtc/modules/video_coding/include/mock/mock_vcm_callbacks.h" | 19 #include "webrtc/modules/video_coding/include/mock/mock_vcm_callbacks.h" |
| 20 #include "webrtc/modules/video_coding/include/video_coding.h" | 20 #include "webrtc/modules/video_coding/include/video_coding.h" |
| 21 #include "webrtc/modules/video_coding/video_coding_impl.h" | 21 #include "webrtc/modules/video_coding/video_coding_impl.h" |
| 22 #include "webrtc/modules/video_coding/test/test_util.h" | 22 #include "webrtc/modules/video_coding/test/test_util.h" |
| 23 #include "webrtc/system_wrappers/include/clock.h" | 23 #include "webrtc/system_wrappers/include/clock.h" |
| 24 #include "webrtc/test/frame_generator.h" | 24 #include "webrtc/test/frame_generator.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 VideoFrame* NextFrame() override { | 76 VideoFrame* NextFrame() override { |
| 77 frame_.reset(new VideoFrame()); | 77 frame_.reset(new VideoFrame()); |
| 78 frame_->CreateEmptyFrame(width_, height_, width_, (width_ + 1) / 2, | 78 frame_->CreateEmptyFrame(width_, height_, width_, (width_ + 1) / 2, |
| 79 (width_ + 1) / 2); | 79 (width_ + 1) / 2); |
| 80 return frame_.get(); | 80 return frame_.get(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 const int width_; | 84 const int width_; |
| 85 const int height_; | 85 const int height_; |
| 86 rtc::scoped_ptr<VideoFrame> frame_; | 86 std::unique_ptr<VideoFrame> frame_; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 class PacketizationCallback : public VCMPacketizationCallback { | 89 class PacketizationCallback : public VCMPacketizationCallback { |
| 90 public: | 90 public: |
| 91 explicit PacketizationCallback(Clock* clock) | 91 explicit PacketizationCallback(Clock* clock) |
| 92 : clock_(clock), start_time_ms_(clock_->TimeInMilliseconds()) {} | 92 : clock_(clock), start_time_ms_(clock_->TimeInMilliseconds()) {} |
| 93 | 93 |
| 94 virtual ~PacketizationCallback() {} | 94 virtual ~PacketizationCallback() {} |
| 95 | 95 |
| 96 int32_t SendData(uint8_t payload_type, | 96 int32_t SendData(uint8_t payload_type, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 186 |
| 187 void AddFrame() { | 187 void AddFrame() { |
| 188 assert(generator_.get()); | 188 assert(generator_.get()); |
| 189 sender_->AddVideoFrame(*generator_->NextFrame(), NULL, NULL); | 189 sender_->AddVideoFrame(*generator_->NextFrame(), NULL, NULL); |
| 190 } | 190 } |
| 191 | 191 |
| 192 SimulatedClock clock_; | 192 SimulatedClock clock_; |
| 193 PacketizationCallback packetization_callback_; | 193 PacketizationCallback packetization_callback_; |
| 194 MockEncodedImageCallback post_encode_callback_; | 194 MockEncodedImageCallback post_encode_callback_; |
| 195 // Used by subclassing tests, need to outlive sender_. | 195 // Used by subclassing tests, need to outlive sender_. |
| 196 rtc::scoped_ptr<VideoEncoder> encoder_; | 196 std::unique_ptr<VideoEncoder> encoder_; |
| 197 rtc::scoped_ptr<VideoSender> sender_; | 197 std::unique_ptr<VideoSender> sender_; |
| 198 rtc::scoped_ptr<FrameGenerator> generator_; | 198 std::unique_ptr<FrameGenerator> generator_; |
| 199 }; | 199 }; |
| 200 | 200 |
| 201 class TestVideoSenderWithMockEncoder : public TestVideoSender { | 201 class TestVideoSenderWithMockEncoder : public TestVideoSender { |
| 202 protected: | 202 protected: |
| 203 void SetUp() override { | 203 void SetUp() override { |
| 204 TestVideoSender::SetUp(); | 204 TestVideoSender::SetUp(); |
| 205 sender_->RegisterExternalEncoder(&encoder_, kUnusedPayloadType, false); | 205 sender_->RegisterExternalEncoder(&encoder_, kUnusedPayloadType, false); |
| 206 VideoCodingModule::Codec(kVideoCodecVP8, &settings_); | 206 VideoCodingModule::Codec(kVideoCodecVP8, &settings_); |
| 207 settings_.numberOfSimulcastStreams = kNumberOfStreams; | 207 settings_.numberOfSimulcastStreams = kNumberOfStreams; |
| 208 ConfigureStream(kDefaultWidth / 4, kDefaultHeight / 4, 100, | 208 ConfigureStream(kDefaultWidth / 4, kDefaultHeight / 4, 100, |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 } | 490 } |
| 491 { | 491 { |
| 492 // TODO(andresp): Find out why this fails with framerate = 7.5 | 492 // TODO(andresp): Find out why this fails with framerate = 7.5 |
| 493 Vp8StreamInfo expected = {{7.0, 7.0, 7.0}, {high_b, high_b, high_b}}; | 493 Vp8StreamInfo expected = {{7.0, 7.0, 7.0}, {high_b, high_b, high_b}}; |
| 494 EXPECT_THAT(SimulateWithFramerate(7.0), MatchesVp8StreamInfo(expected)); | 494 EXPECT_THAT(SimulateWithFramerate(7.0), MatchesVp8StreamInfo(expected)); |
| 495 } | 495 } |
| 496 } | 496 } |
| 497 } // namespace | 497 } // namespace |
| 498 } // namespace vcm | 498 } // namespace vcm |
| 499 } // namespace webrtc | 499 } // namespace webrtc |
| OLD | NEW |