| 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 25 matching lines...) Expand all Loading... |
| 36 static const int64_t kTestNtpTimeMs = 456; | 36 static const int64_t kTestNtpTimeMs = 456; |
| 37 | 37 |
| 38 // TODO(mikhal): Replace these with mocks. | 38 // TODO(mikhal): Replace these with mocks. |
| 39 class Vp8UnitTestEncodeCompleteCallback : public webrtc::EncodedImageCallback { | 39 class Vp8UnitTestEncodeCompleteCallback : public webrtc::EncodedImageCallback { |
| 40 public: | 40 public: |
| 41 Vp8UnitTestEncodeCompleteCallback(EncodedImage* frame, | 41 Vp8UnitTestEncodeCompleteCallback(EncodedImage* frame, |
| 42 unsigned int decoderSpecificSize, | 42 unsigned int decoderSpecificSize, |
| 43 void* decoderSpecificInfo) | 43 void* decoderSpecificInfo) |
| 44 : encoded_frame_(frame), encode_complete_(false) {} | 44 : encoded_frame_(frame), encode_complete_(false) {} |
| 45 | 45 |
| 46 virtual int Encoded(const EncodedImage& encoded_frame_, | 46 Result OnEncodedImage(const EncodedImage& encoded_frame_, |
| 47 const CodecSpecificInfo* codecSpecificInfo, | 47 const CodecSpecificInfo* codec_specific_info, |
| 48 const RTPFragmentationHeader*); | 48 const RTPFragmentationHeader* fragmentation) override; |
| 49 bool EncodeComplete(); | 49 bool EncodeComplete(); |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 EncodedImage* const encoded_frame_; | 52 EncodedImage* const encoded_frame_; |
| 53 std::unique_ptr<uint8_t[]> frame_buffer_; | 53 std::unique_ptr<uint8_t[]> frame_buffer_; |
| 54 bool encode_complete_; | 54 bool encode_complete_; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 int Vp8UnitTestEncodeCompleteCallback::Encoded( | 57 webrtc::EncodedImageCallback::Result |
| 58 Vp8UnitTestEncodeCompleteCallback::OnEncodedImage( |
| 58 const EncodedImage& encoded_frame, | 59 const EncodedImage& encoded_frame, |
| 59 const CodecSpecificInfo* codecSpecificInfo, | 60 const CodecSpecificInfo* codec_specific_info, |
| 60 const RTPFragmentationHeader* fragmentation) { | 61 const RTPFragmentationHeader* fragmentation) { |
| 61 if (encoded_frame_->_size < encoded_frame._length) { | 62 if (encoded_frame_->_size < encoded_frame._length) { |
| 62 delete[] encoded_frame_->_buffer; | 63 delete[] encoded_frame_->_buffer; |
| 63 frame_buffer_.reset(new uint8_t[encoded_frame._length]); | 64 frame_buffer_.reset(new uint8_t[encoded_frame._length]); |
| 64 encoded_frame_->_buffer = frame_buffer_.get(); | 65 encoded_frame_->_buffer = frame_buffer_.get(); |
| 65 encoded_frame_->_size = encoded_frame._length; | 66 encoded_frame_->_size = encoded_frame._length; |
| 66 } | 67 } |
| 67 memcpy(encoded_frame_->_buffer, encoded_frame._buffer, encoded_frame._length); | 68 memcpy(encoded_frame_->_buffer, encoded_frame._buffer, encoded_frame._length); |
| 68 encoded_frame_->_length = encoded_frame._length; | 69 encoded_frame_->_length = encoded_frame._length; |
| 69 encoded_frame_->_encodedWidth = encoded_frame._encodedWidth; | 70 encoded_frame_->_encodedWidth = encoded_frame._encodedWidth; |
| 70 encoded_frame_->_encodedHeight = encoded_frame._encodedHeight; | 71 encoded_frame_->_encodedHeight = encoded_frame._encodedHeight; |
| 71 encoded_frame_->_timeStamp = encoded_frame._timeStamp; | 72 encoded_frame_->_timeStamp = encoded_frame._timeStamp; |
| 72 encoded_frame_->_frameType = encoded_frame._frameType; | 73 encoded_frame_->_frameType = encoded_frame._frameType; |
| 73 encoded_frame_->_completeFrame = encoded_frame._completeFrame; | 74 encoded_frame_->_completeFrame = encoded_frame._completeFrame; |
| 74 encode_complete_ = true; | 75 encode_complete_ = true; |
| 75 return 0; | 76 return Result(Result::OK, 0); |
| 76 } | 77 } |
| 77 | 78 |
| 78 bool Vp8UnitTestEncodeCompleteCallback::EncodeComplete() { | 79 bool Vp8UnitTestEncodeCompleteCallback::EncodeComplete() { |
| 79 if (encode_complete_) { | 80 if (encode_complete_) { |
| 80 encode_complete_ = false; | 81 encode_complete_ = false; |
| 81 return true; | 82 return true; |
| 82 } | 83 } |
| 83 return false; | 84 return false; |
| 84 } | 85 } |
| 85 | 86 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, | 270 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, |
| 270 decoder_->Decode(encoded_frame_, false, NULL)); | 271 decoder_->Decode(encoded_frame_, false, NULL)); |
| 271 // Now setting a key frame. | 272 // Now setting a key frame. |
| 272 encoded_frame_._frameType = kVideoFrameKey; | 273 encoded_frame_._frameType = kVideoFrameKey; |
| 273 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 274 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
| 274 decoder_->Decode(encoded_frame_, false, NULL)); | 275 decoder_->Decode(encoded_frame_, false, NULL)); |
| 275 EXPECT_GT(I420PSNR(&input_frame_, &decoded_frame_), 36); | 276 EXPECT_GT(I420PSNR(&input_frame_, &decoded_frame_), 36); |
| 276 } | 277 } |
| 277 | 278 |
| 278 } // namespace webrtc | 279 } // namespace webrtc |
| OLD | NEW |