| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 109   void FallbackFromEncodeRequest(); | 109   void FallbackFromEncodeRequest(); | 
| 110   void EncodeFrame(); | 110   void EncodeFrame(); | 
| 111   void CheckLastEncoderName(const char* expected_name) { | 111   void CheckLastEncoderName(const char* expected_name) { | 
| 112     EXPECT_STREQ(expected_name, callback_.last_codec_name_.c_str()); | 112     EXPECT_STREQ(expected_name, callback_.last_codec_name_.c_str()); | 
| 113   } | 113   } | 
| 114 | 114 | 
| 115   FakeEncodedImageCallback callback_; | 115   FakeEncodedImageCallback callback_; | 
| 116   CountingFakeEncoder fake_encoder_; | 116   CountingFakeEncoder fake_encoder_; | 
| 117   VideoEncoderSoftwareFallbackWrapper fallback_wrapper_; | 117   VideoEncoderSoftwareFallbackWrapper fallback_wrapper_; | 
| 118   VideoCodec codec_ = {}; | 118   VideoCodec codec_ = {}; | 
| 119   VideoFrame frame_; | 119   std::unique_ptr<VideoFrame> frame_; | 
| 120 }; | 120 }; | 
| 121 | 121 | 
| 122 void VideoEncoderSoftwareFallbackWrapperTest::EncodeFrame() { | 122 void VideoEncoderSoftwareFallbackWrapperTest::EncodeFrame() { | 
| 123   frame_.CreateEmptyFrame(kWidth, kHeight, kWidth, (kWidth + 1) / 2, | 123   rtc::scoped_refptr<I420Buffer> buffer = I420Buffer::Create( | 
| 124                           (kWidth + 1) / 2); | 124       kWidth, kHeight, kWidth, (kWidth + 1) / 2, (kWidth + 1) / 2); | 
| 125   memset(frame_.video_frame_buffer()->MutableDataY(), 16, | 125   buffer->SetToBlack(); | 
| 126          frame_.allocated_size(webrtc::kYPlane)); | 126   std::vector<FrameType> types(1, kVideoFrameKey); | 
| 127   memset(frame_.video_frame_buffer()->MutableDataU(), 128, |  | 
| 128          frame_.allocated_size(webrtc::kUPlane)); |  | 
| 129   memset(frame_.video_frame_buffer()->MutableDataV(), 128, |  | 
| 130          frame_.allocated_size(webrtc::kVPlane)); |  | 
| 131 | 127 | 
| 132   std::vector<FrameType> types(1, kVideoFrameKey); | 128   frame_.reset(new VideoFrame(buffer, 0, 0, webrtc::kVideoRotation_0)); | 
| 133   EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 129   EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 
| 134             fallback_wrapper_.Encode(frame_, nullptr, &types)); | 130             fallback_wrapper_.Encode(*frame_, nullptr, &types)); | 
| 135 } | 131 } | 
| 136 | 132 | 
| 137 void VideoEncoderSoftwareFallbackWrapperTest::UtilizeFallbackEncoder() { | 133 void VideoEncoderSoftwareFallbackWrapperTest::UtilizeFallbackEncoder() { | 
| 138   fallback_wrapper_.RegisterEncodeCompleteCallback(&callback_); | 134   fallback_wrapper_.RegisterEncodeCompleteCallback(&callback_); | 
| 139   EXPECT_EQ(&callback_, fake_encoder_.encode_complete_callback_); | 135   EXPECT_EQ(&callback_, fake_encoder_.encode_complete_callback_); | 
| 140 | 136 | 
| 141   // Register with failing fake encoder. Should succeed with VP8 fallback. | 137   // Register with failing fake encoder. Should succeed with VP8 fallback. | 
| 142   codec_.codecType = kVideoCodecVP8; | 138   codec_.codecType = kVideoCodecVP8; | 
| 143   codec_.maxFramerate = 30; | 139   codec_.maxFramerate = 30; | 
| 144   codec_.width = kWidth; | 140   codec_.width = kWidth; | 
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 218        CanRegisterCallbackWhileUsingFallbackEncoder) { | 214        CanRegisterCallbackWhileUsingFallbackEncoder) { | 
| 219   UtilizeFallbackEncoder(); | 215   UtilizeFallbackEncoder(); | 
| 220   // Registering an encode-complete callback should still work when fallback | 216   // Registering an encode-complete callback should still work when fallback | 
| 221   // encoder is being used. | 217   // encoder is being used. | 
| 222   FakeEncodedImageCallback callback2; | 218   FakeEncodedImageCallback callback2; | 
| 223   fallback_wrapper_.RegisterEncodeCompleteCallback(&callback2); | 219   fallback_wrapper_.RegisterEncodeCompleteCallback(&callback2); | 
| 224   EXPECT_EQ(&callback2, fake_encoder_.encode_complete_callback_); | 220   EXPECT_EQ(&callback2, fake_encoder_.encode_complete_callback_); | 
| 225 | 221 | 
| 226   // Encoding a frame using the fallback should arrive at the new callback. | 222   // Encoding a frame using the fallback should arrive at the new callback. | 
| 227   std::vector<FrameType> types(1, kVideoFrameKey); | 223   std::vector<FrameType> types(1, kVideoFrameKey); | 
| 228   frame_.set_timestamp(frame_.timestamp() + 1000); | 224   frame_->set_timestamp(frame_->timestamp() + 1000); | 
| 229   EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 225   EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 
| 230             fallback_wrapper_.Encode(frame_, nullptr, &types)); | 226             fallback_wrapper_.Encode(*frame_, nullptr, &types)); | 
| 231 | 227 | 
| 232   EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release()); | 228   EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release()); | 
| 233 } | 229 } | 
| 234 | 230 | 
| 235 TEST_F(VideoEncoderSoftwareFallbackWrapperTest, | 231 TEST_F(VideoEncoderSoftwareFallbackWrapperTest, | 
| 236        SetChannelParametersForwardedDuringFallback) { | 232        SetChannelParametersForwardedDuringFallback) { | 
| 237   UtilizeFallbackEncoder(); | 233   UtilizeFallbackEncoder(); | 
| 238   EXPECT_EQ(0, fake_encoder_.set_channel_parameters_count_); | 234   EXPECT_EQ(0, fake_encoder_.set_channel_parameters_count_); | 
| 239   fallback_wrapper_.SetChannelParameters(1, 1); | 235   fallback_wrapper_.SetChannelParameters(1, 1); | 
| 240   EXPECT_EQ(1, fake_encoder_.set_channel_parameters_count_); | 236   EXPECT_EQ(1, fake_encoder_.set_channel_parameters_count_); | 
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 288 | 284 | 
| 289 TEST_F(VideoEncoderSoftwareFallbackWrapperTest, | 285 TEST_F(VideoEncoderSoftwareFallbackWrapperTest, | 
| 290        ReportsFallbackImplementationName) { | 286        ReportsFallbackImplementationName) { | 
| 291   UtilizeFallbackEncoder(); | 287   UtilizeFallbackEncoder(); | 
| 292   // Hard coded expected value since libvpx is the software implementation name | 288   // Hard coded expected value since libvpx is the software implementation name | 
| 293   // for VP8. Change accordingly if the underlying implementation does. | 289   // for VP8. Change accordingly if the underlying implementation does. | 
| 294   CheckLastEncoderName("libvpx"); | 290   CheckLastEncoderName("libvpx"); | 
| 295 } | 291 } | 
| 296 | 292 | 
| 297 }  // namespace webrtc | 293 }  // namespace webrtc | 
| OLD | NEW | 
|---|