| 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 |
| 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_SYNC_BUFFER_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_SYNC_BUFFER_H_ |
| 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_SYNC_BUFFER_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_SYNC_BUFFER_H_ |
| 13 | 13 |
| 14 #include "webrtc/base/constructormagic.h" | 14 #include "webrtc/base/constructormagic.h" |
| 15 #include "webrtc/modules/audio_coding/neteq/audio_multi_vector.h" | 15 #include "webrtc/modules/audio_coding/neteq/audio_multi_vector.h" |
| 16 #include "webrtc/modules/include/module_common_types.h" |
| 16 #include "webrtc/typedefs.h" | 17 #include "webrtc/typedefs.h" |
| 17 | 18 |
| 18 namespace webrtc { | 19 namespace webrtc { |
| 19 | 20 |
| 20 class SyncBuffer : public AudioMultiVector { | 21 class SyncBuffer : public AudioMultiVector { |
| 21 public: | 22 public: |
| 22 SyncBuffer(size_t channels, size_t length) | 23 SyncBuffer(size_t channels, size_t length) |
| 23 : AudioMultiVector(channels, length), | 24 : AudioMultiVector(channels, length), |
| 24 next_index_(length), | 25 next_index_(length), |
| 25 end_timestamp_(0), | 26 end_timestamp_(0), |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 size_t length, | 59 size_t length, |
| 59 size_t position); | 60 size_t position); |
| 60 | 61 |
| 61 // Same as the above method, but where all of |insert_this| is written (with | 62 // Same as the above method, but where all of |insert_this| is written (with |
| 62 // the same constraints as above, that the SyncBuffer is not extended). | 63 // the same constraints as above, that the SyncBuffer is not extended). |
| 63 virtual void ReplaceAtIndex(const AudioMultiVector& insert_this, | 64 virtual void ReplaceAtIndex(const AudioMultiVector& insert_this, |
| 64 size_t position); | 65 size_t position); |
| 65 | 66 |
| 66 // Reads |requested_len| samples from each channel and writes them interleaved | 67 // Reads |requested_len| samples from each channel and writes them interleaved |
| 67 // into |output|. The |next_index_| is updated to point to the sample to read | 68 // into |output|. The |next_index_| is updated to point to the sample to read |
| 68 // next time. | 69 // next time. The AudioFrame |output| is first reset, and the |data_|, |
| 69 size_t GetNextAudioInterleaved(size_t requested_len, int16_t* output); | 70 // |interleaved_|, |num_channels_|, and |samples_per_channel_| fields are |
| 71 // updated. |
| 72 void GetNextAudioInterleaved(size_t requested_len, AudioFrame* output); |
| 70 | 73 |
| 71 // Adds |increment| to |end_timestamp_|. | 74 // Adds |increment| to |end_timestamp_|. |
| 72 void IncreaseEndTimestamp(uint32_t increment); | 75 void IncreaseEndTimestamp(uint32_t increment); |
| 73 | 76 |
| 74 // Flushes the buffer. The buffer will contain only zeros after the flush, and | 77 // Flushes the buffer. The buffer will contain only zeros after the flush, and |
| 75 // |next_index_| will point to the end, like when the buffer was first | 78 // |next_index_| will point to the end, like when the buffer was first |
| 76 // created. | 79 // created. |
| 77 void Flush(); | 80 void Flush(); |
| 78 | 81 |
| 79 const AudioVector& Channel(size_t n) const { return *channels_[n]; } | 82 const AudioVector& Channel(size_t n) const { return *channels_[n]; } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 90 private: | 93 private: |
| 91 size_t next_index_; | 94 size_t next_index_; |
| 92 uint32_t end_timestamp_; // The timestamp of the last sample in the buffer. | 95 uint32_t end_timestamp_; // The timestamp of the last sample in the buffer. |
| 93 size_t dtmf_index_; // Index to the first non-DTMF sample in the buffer. | 96 size_t dtmf_index_; // Index to the first non-DTMF sample in the buffer. |
| 94 | 97 |
| 95 RTC_DISALLOW_COPY_AND_ASSIGN(SyncBuffer); | 98 RTC_DISALLOW_COPY_AND_ASSIGN(SyncBuffer); |
| 96 }; | 99 }; |
| 97 | 100 |
| 98 } // namespace webrtc | 101 } // namespace webrtc |
| 99 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_SYNC_BUFFER_H_ | 102 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_SYNC_BUFFER_H_ |
| OLD | NEW |