| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 14 matching lines...) Expand all Loading... |
| 25 class CountingFakeEncoder : public VideoEncoder { | 25 class CountingFakeEncoder : public VideoEncoder { |
| 26 public: | 26 public: |
| 27 int32_t InitEncode(const VideoCodec* codec_settings, | 27 int32_t InitEncode(const VideoCodec* codec_settings, |
| 28 int32_t number_of_cores, | 28 int32_t number_of_cores, |
| 29 size_t max_payload_size) override { | 29 size_t max_payload_size) override { |
| 30 ++init_encode_count_; | 30 ++init_encode_count_; |
| 31 return init_encode_return_code_; | 31 return init_encode_return_code_; |
| 32 } | 32 } |
| 33 int32_t Encode(const VideoFrame& frame, | 33 int32_t Encode(const VideoFrame& frame, |
| 34 const CodecSpecificInfo* codec_specific_info, | 34 const CodecSpecificInfo* codec_specific_info, |
| 35 const std::vector<VideoFrameType>* frame_types) override { | 35 const std::vector<FrameType>* frame_types) override { |
| 36 ++encode_count_; | 36 ++encode_count_; |
| 37 return WEBRTC_VIDEO_CODEC_OK; | 37 return WEBRTC_VIDEO_CODEC_OK; |
| 38 } | 38 } |
| 39 | 39 |
| 40 int32_t RegisterEncodeCompleteCallback( | 40 int32_t RegisterEncodeCompleteCallback( |
| 41 EncodedImageCallback* callback) override { | 41 EncodedImageCallback* callback) override { |
| 42 encode_complete_callback_ = callback; | 42 encode_complete_callback_ = callback; |
| 43 return WEBRTC_VIDEO_CODEC_OK; | 43 return WEBRTC_VIDEO_CODEC_OK; |
| 44 } | 44 } |
| 45 | 45 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 frame_.CreateEmptyFrame(kWidth, kHeight, kWidth, (kWidth + 1) / 2, | 114 frame_.CreateEmptyFrame(kWidth, kHeight, kWidth, (kWidth + 1) / 2, |
| 115 (kWidth + 1) / 2); | 115 (kWidth + 1) / 2); |
| 116 memset(frame_.buffer(webrtc::kYPlane), 16, | 116 memset(frame_.buffer(webrtc::kYPlane), 16, |
| 117 frame_.allocated_size(webrtc::kYPlane)); | 117 frame_.allocated_size(webrtc::kYPlane)); |
| 118 memset(frame_.buffer(webrtc::kUPlane), 128, | 118 memset(frame_.buffer(webrtc::kUPlane), 128, |
| 119 frame_.allocated_size(webrtc::kUPlane)); | 119 frame_.allocated_size(webrtc::kUPlane)); |
| 120 memset(frame_.buffer(webrtc::kVPlane), 128, | 120 memset(frame_.buffer(webrtc::kVPlane), 128, |
| 121 frame_.allocated_size(webrtc::kVPlane)); | 121 frame_.allocated_size(webrtc::kVPlane)); |
| 122 | 122 |
| 123 std::vector<VideoFrameType> types(1, kKeyFrame); | 123 std::vector<FrameType> types(1, kKeyFrame); |
| 124 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 124 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
| 125 fallback_wrapper_.Encode(frame_, nullptr, &types)); | 125 fallback_wrapper_.Encode(frame_, nullptr, &types)); |
| 126 EXPECT_EQ(0, fake_encoder_.encode_count_); | 126 EXPECT_EQ(0, fake_encoder_.encode_count_); |
| 127 EXPECT_GT(callback_.callback_count_, 0); | 127 EXPECT_GT(callback_.callback_count_, 0); |
| 128 } | 128 } |
| 129 | 129 |
| 130 TEST_F(VideoEncoderSoftwareFallbackWrapperTest, InitializesEncoder) { | 130 TEST_F(VideoEncoderSoftwareFallbackWrapperTest, InitializesEncoder) { |
| 131 VideoCodec codec = {}; | 131 VideoCodec codec = {}; |
| 132 fallback_wrapper_.InitEncode(&codec, 2, kMaxPayloadSize); | 132 fallback_wrapper_.InitEncode(&codec, 2, kMaxPayloadSize); |
| 133 EXPECT_EQ(1, fake_encoder_.init_encode_count_); | 133 EXPECT_EQ(1, fake_encoder_.init_encode_count_); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 156 TEST_F(VideoEncoderSoftwareFallbackWrapperTest, | 156 TEST_F(VideoEncoderSoftwareFallbackWrapperTest, |
| 157 CanRegisterCallbackWhileUsingFallbackEncoder) { | 157 CanRegisterCallbackWhileUsingFallbackEncoder) { |
| 158 UtilizeFallbackEncoder(); | 158 UtilizeFallbackEncoder(); |
| 159 // Registering an encode-complete callback should still work when fallback | 159 // Registering an encode-complete callback should still work when fallback |
| 160 // encoder is being used. | 160 // encoder is being used. |
| 161 FakeEncodedImageCallback callback2; | 161 FakeEncodedImageCallback callback2; |
| 162 fallback_wrapper_.RegisterEncodeCompleteCallback(&callback2); | 162 fallback_wrapper_.RegisterEncodeCompleteCallback(&callback2); |
| 163 EXPECT_EQ(&callback2, fake_encoder_.encode_complete_callback_); | 163 EXPECT_EQ(&callback2, fake_encoder_.encode_complete_callback_); |
| 164 | 164 |
| 165 // Encoding a frame using the fallback should arrive at the new callback. | 165 // Encoding a frame using the fallback should arrive at the new callback. |
| 166 std::vector<VideoFrameType> types(1, kKeyFrame); | 166 std::vector<FrameType> types(1, kKeyFrame); |
| 167 frame_.set_timestamp(frame_.timestamp() + 1000); | 167 frame_.set_timestamp(frame_.timestamp() + 1000); |
| 168 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 168 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
| 169 fallback_wrapper_.Encode(frame_, nullptr, &types)); | 169 fallback_wrapper_.Encode(frame_, nullptr, &types)); |
| 170 | 170 |
| 171 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release()); | 171 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release()); |
| 172 } | 172 } |
| 173 | 173 |
| 174 TEST_F(VideoEncoderSoftwareFallbackWrapperTest, | 174 TEST_F(VideoEncoderSoftwareFallbackWrapperTest, |
| 175 SetChannelParametersForwardedDuringFallback) { | 175 SetChannelParametersForwardedDuringFallback) { |
| 176 UtilizeFallbackEncoder(); | 176 UtilizeFallbackEncoder(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 211 |
| 212 TEST_F(VideoEncoderSoftwareFallbackWrapperTest, | 212 TEST_F(VideoEncoderSoftwareFallbackWrapperTest, |
| 213 SupportsNativeHandleNotForwardedDuringFallback) { | 213 SupportsNativeHandleNotForwardedDuringFallback) { |
| 214 UtilizeFallbackEncoder(); | 214 UtilizeFallbackEncoder(); |
| 215 fallback_wrapper_.SupportsNativeHandle(); | 215 fallback_wrapper_.SupportsNativeHandle(); |
| 216 EXPECT_EQ(0, fake_encoder_.supports_native_handle_count_); | 216 EXPECT_EQ(0, fake_encoder_.supports_native_handle_count_); |
| 217 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release()); | 217 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release()); |
| 218 } | 218 } |
| 219 | 219 |
| 220 } // namespace webrtc | 220 } // namespace webrtc |
| OLD | NEW |