| 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 Result OnEncodedImage(const EncodedImage& encoded_frame_, | 46 virtual int Encoded(const EncodedImage& encoded_frame_, |
| 47 const CodecSpecificInfo* codec_specific_info, | 47 const CodecSpecificInfo* codecSpecificInfo, |
| 48 const RTPFragmentationHeader* fragmentation) override; | 48 const RTPFragmentationHeader*); |
| 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 webrtc::EncodedImageCallback::Result | 57 int Vp8UnitTestEncodeCompleteCallback::Encoded( |
| 58 Vp8UnitTestEncodeCompleteCallback::OnEncodedImage( | |
| 59 const EncodedImage& encoded_frame, | 58 const EncodedImage& encoded_frame, |
| 60 const CodecSpecificInfo* codec_specific_info, | 59 const CodecSpecificInfo* codecSpecificInfo, |
| 61 const RTPFragmentationHeader* fragmentation) { | 60 const RTPFragmentationHeader* fragmentation) { |
| 62 if (encoded_frame_->_size < encoded_frame._length) { | 61 if (encoded_frame_->_size < encoded_frame._length) { |
| 63 delete[] encoded_frame_->_buffer; | 62 delete[] encoded_frame_->_buffer; |
| 64 frame_buffer_.reset(new uint8_t[encoded_frame._length]); | 63 frame_buffer_.reset(new uint8_t[encoded_frame._length]); |
| 65 encoded_frame_->_buffer = frame_buffer_.get(); | 64 encoded_frame_->_buffer = frame_buffer_.get(); |
| 66 encoded_frame_->_size = encoded_frame._length; | 65 encoded_frame_->_size = encoded_frame._length; |
| 67 } | 66 } |
| 68 memcpy(encoded_frame_->_buffer, encoded_frame._buffer, encoded_frame._length); | 67 memcpy(encoded_frame_->_buffer, encoded_frame._buffer, encoded_frame._length); |
| 69 encoded_frame_->_length = encoded_frame._length; | 68 encoded_frame_->_length = encoded_frame._length; |
| 70 encoded_frame_->_encodedWidth = encoded_frame._encodedWidth; | 69 encoded_frame_->_encodedWidth = encoded_frame._encodedWidth; |
| 71 encoded_frame_->_encodedHeight = encoded_frame._encodedHeight; | 70 encoded_frame_->_encodedHeight = encoded_frame._encodedHeight; |
| 72 encoded_frame_->_timeStamp = encoded_frame._timeStamp; | 71 encoded_frame_->_timeStamp = encoded_frame._timeStamp; |
| 73 encoded_frame_->_frameType = encoded_frame._frameType; | 72 encoded_frame_->_frameType = encoded_frame._frameType; |
| 74 encoded_frame_->_completeFrame = encoded_frame._completeFrame; | 73 encoded_frame_->_completeFrame = encoded_frame._completeFrame; |
| 75 encode_complete_ = true; | 74 encode_complete_ = true; |
| 76 return Result(Result::OK, 0); | 75 return 0; |
| 77 } | 76 } |
| 78 | 77 |
| 79 bool Vp8UnitTestEncodeCompleteCallback::EncodeComplete() { | 78 bool Vp8UnitTestEncodeCompleteCallback::EncodeComplete() { |
| 80 if (encode_complete_) { | 79 if (encode_complete_) { |
| 81 encode_complete_ = false; | 80 encode_complete_ = false; |
| 82 return true; | 81 return true; |
| 83 } | 82 } |
| 84 return false; | 83 return false; |
| 85 } | 84 } |
| 86 | 85 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, | 269 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, |
| 271 decoder_->Decode(encoded_frame_, false, NULL)); | 270 decoder_->Decode(encoded_frame_, false, NULL)); |
| 272 // Now setting a key frame. | 271 // Now setting a key frame. |
| 273 encoded_frame_._frameType = kVideoFrameKey; | 272 encoded_frame_._frameType = kVideoFrameKey; |
| 274 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 273 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
| 275 decoder_->Decode(encoded_frame_, false, NULL)); | 274 decoder_->Decode(encoded_frame_, false, NULL)); |
| 276 EXPECT_GT(I420PSNR(&input_frame_, &decoded_frame_), 36); | 275 EXPECT_GT(I420PSNR(&input_frame_, &decoded_frame_), 36); |
| 277 } | 276 } |
| 278 | 277 |
| 279 } // namespace webrtc | 278 } // namespace webrtc |
| OLD | NEW |