| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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/checks.h" | 15 #include "webrtc/base/checks.h" |
| 15 #include "webrtc/base/scoped_ptr.h" | |
| 16 #include "webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h" | 16 #include "webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h" |
| 17 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h" | 17 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h" |
| 18 | 18 |
| 19 using ::testing::Return; | 19 using ::testing::Return; |
| 20 using ::testing::_; | 20 using ::testing::_; |
| 21 using ::testing::SetArgPointee; | 21 using ::testing::SetArgPointee; |
| 22 using ::testing::InSequence; | 22 using ::testing::InSequence; |
| 23 using ::testing::Invoke; | 23 using ::testing::Invoke; |
| 24 using ::testing::MockFunction; | 24 using ::testing::MockFunction; |
| 25 | 25 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 void Encode() { | 61 void Encode() { |
| 62 ASSERT_TRUE(red_.get() != NULL); | 62 ASSERT_TRUE(red_.get() != NULL); |
| 63 encoded_info_ = red_->Encode( | 63 encoded_info_ = red_->Encode( |
| 64 timestamp_, | 64 timestamp_, |
| 65 rtc::ArrayView<const int16_t>(audio_, num_audio_samples_10ms), | 65 rtc::ArrayView<const int16_t>(audio_, num_audio_samples_10ms), |
| 66 encoded_.size(), &encoded_[0]); | 66 encoded_.size(), &encoded_[0]); |
| 67 timestamp_ += num_audio_samples_10ms; | 67 timestamp_ += num_audio_samples_10ms; |
| 68 } | 68 } |
| 69 | 69 |
| 70 MockAudioEncoder mock_encoder_; | 70 MockAudioEncoder mock_encoder_; |
| 71 rtc::scoped_ptr<AudioEncoderCopyRed> red_; | 71 std::unique_ptr<AudioEncoderCopyRed> red_; |
| 72 uint32_t timestamp_; | 72 uint32_t timestamp_; |
| 73 int16_t audio_[kMaxNumSamples]; | 73 int16_t audio_[kMaxNumSamples]; |
| 74 const int sample_rate_hz_; | 74 const int sample_rate_hz_; |
| 75 size_t num_audio_samples_10ms; | 75 size_t num_audio_samples_10ms; |
| 76 std::vector<uint8_t> encoded_; | 76 std::vector<uint8_t> encoded_; |
| 77 AudioEncoder::EncodedInfo encoded_info_; | 77 AudioEncoder::EncodedInfo encoded_info_; |
| 78 const int red_payload_type_; | 78 const int red_payload_type_; |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 class MockEncodeHelper { | 81 class MockEncodeHelper { |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 config.speech_encoder = NULL; | 327 config.speech_encoder = NULL; |
| 328 EXPECT_DEATH(red = new AudioEncoderCopyRed(config), | 328 EXPECT_DEATH(red = new AudioEncoderCopyRed(config), |
| 329 "Speech encoder not provided."); | 329 "Speech encoder not provided."); |
| 330 // The delete operation is needed to avoid leak reports from memcheck. | 330 // The delete operation is needed to avoid leak reports from memcheck. |
| 331 delete red; | 331 delete red; |
| 332 } | 332 } |
| 333 | 333 |
| 334 #endif // GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 334 #endif // GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
| 335 | 335 |
| 336 } // namespace webrtc | 336 } // namespace webrtc |
| OLD | NEW |