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 |
(...skipping 42 matching lines...) Loading... |
53 void TearDown() override { | 53 void TearDown() override { |
54 red_.reset(); | 54 red_.reset(); |
55 // Don't expect the red_ object to delete the AudioEncoder object. But it | 55 // Don't expect the red_ object to delete the AudioEncoder object. But it |
56 // will be deleted with the test fixture. This is why we explicitly delete | 56 // will be deleted with the test fixture. This is why we explicitly delete |
57 // the red_ object above, and set expectations on mock_encoder_ afterwards. | 57 // the red_ object above, and set expectations on mock_encoder_ afterwards. |
58 EXPECT_CALL(mock_encoder_, Die()).Times(1); | 58 EXPECT_CALL(mock_encoder_, Die()).Times(1); |
59 } | 59 } |
60 | 60 |
61 void Encode() { | 61 void Encode() { |
62 ASSERT_TRUE(red_.get() != NULL); | 62 ASSERT_TRUE(red_.get() != NULL); |
63 encoded_info_ = red_->Encode(timestamp_, audio_, num_audio_samples_10ms, | 63 encoded_info_ = red_->Encode( |
64 encoded_.size(), &encoded_[0]); | 64 timestamp_, |
| 65 rtc::ArrayView<const int16_t>(audio_, num_audio_samples_10ms), |
| 66 encoded_.size(), &encoded_[0]); |
65 timestamp_ += num_audio_samples_10ms; | 67 timestamp_ += num_audio_samples_10ms; |
66 } | 68 } |
67 | 69 |
68 MockAudioEncoder mock_encoder_; | 70 MockAudioEncoder mock_encoder_; |
69 rtc::scoped_ptr<AudioEncoderCopyRed> red_; | 71 rtc::scoped_ptr<AudioEncoderCopyRed> red_; |
70 uint32_t timestamp_; | 72 uint32_t timestamp_; |
71 int16_t audio_[kMaxNumSamples]; | 73 int16_t audio_[kMaxNumSamples]; |
72 const int sample_rate_hz_; | 74 const int sample_rate_hz_; |
73 size_t num_audio_samples_10ms; | 75 size_t num_audio_samples_10ms; |
74 std::vector<uint8_t> encoded_; | 76 std::vector<uint8_t> encoded_; |
75 AudioEncoder::EncodedInfo encoded_info_; | 77 AudioEncoder::EncodedInfo encoded_info_; |
76 const int red_payload_type_; | 78 const int red_payload_type_; |
77 }; | 79 }; |
78 | 80 |
79 class MockEncodeHelper { | 81 class MockEncodeHelper { |
80 public: | 82 public: |
81 MockEncodeHelper() : write_payload_(false), payload_(NULL) { | 83 MockEncodeHelper() : write_payload_(false), payload_(NULL) { |
82 memset(&info_, 0, sizeof(info_)); | 84 memset(&info_, 0, sizeof(info_)); |
83 } | 85 } |
84 | 86 |
85 AudioEncoder::EncodedInfo Encode(uint32_t timestamp, | 87 AudioEncoder::EncodedInfo Encode(uint32_t timestamp, |
86 const int16_t* audio, | 88 rtc::ArrayView<const int16_t> audio, |
87 size_t max_encoded_bytes, | 89 size_t max_encoded_bytes, |
88 uint8_t* encoded) { | 90 uint8_t* encoded) { |
89 if (write_payload_) { | 91 if (write_payload_) { |
90 RTC_CHECK(encoded); | 92 RTC_CHECK(encoded); |
91 RTC_CHECK_LE(info_.encoded_bytes, max_encoded_bytes); | 93 RTC_CHECK_LE(info_.encoded_bytes, max_encoded_bytes); |
92 memcpy(encoded, payload_, info_.encoded_bytes); | 94 memcpy(encoded, payload_, info_.encoded_bytes); |
93 } | 95 } |
94 return info_; | 96 return info_; |
95 } | 97 } |
96 | 98 |
(...skipping 228 matching lines...) Loading... |
325 config.speech_encoder = NULL; | 327 config.speech_encoder = NULL; |
326 EXPECT_DEATH(red = new AudioEncoderCopyRed(config), | 328 EXPECT_DEATH(red = new AudioEncoderCopyRed(config), |
327 "Speech encoder not provided."); | 329 "Speech encoder not provided."); |
328 // The delete operation is needed to avoid leak reports from memcheck. | 330 // The delete operation is needed to avoid leak reports from memcheck. |
329 delete red; | 331 delete red; |
330 } | 332 } |
331 | 333 |
332 #endif // GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 334 #endif // GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
333 | 335 |
334 } // namespace webrtc | 336 } // namespace webrtc |
OLD | NEW |