| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_BASE_AUDIO_SPLICER_H_ | 5 #ifndef MEDIA_BASE_AUDIO_SPLICER_H_ |
| 6 #define MEDIA_BASE_AUDIO_SPLICER_H_ | 6 #define MEDIA_BASE_AUDIO_SPLICER_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "media/audio/audio_parameters.h" | 11 #include "media/audio/audio_parameters.h" |
| 12 #include "media/base/buffers.h" | 12 #include "media/base/buffers.h" |
| 13 #include "media/base/media_export.h" | 13 #include "media/base/media_export.h" |
| 14 | 14 |
| 15 namespace media { | 15 namespace media { |
| 16 | 16 |
| 17 class AudioBuffer; | 17 class AudioBuffer; |
| 18 class AudioBus; | 18 class AudioBus; |
| 19 class AudioStreamSanitizer; | 19 class AudioStreamSanitizer; |
| 20 | 20 |
| 21 // Helper class that handles filling gaps and resolving overlaps. | 21 // Helper class that handles filling gaps and resolving overlaps. |
| 22 class MEDIA_EXPORT AudioSplicer { | 22 class MEDIA_EXPORT AudioSplicer { |
| 23 public: | 23 public: |
| 24 explicit AudioSplicer(int samples_per_second); | 24 explicit AudioSplicer(int samples_per_second); |
| 25 ~AudioSplicer(); | 25 ~AudioSplicer(); |
| 26 | 26 |
| 27 enum { | 27 enum { |
| 28 // The number of ms to crossfade before trimming when buffers overlap. | 28 // The number of ms to crossfade before trimming when buffers overlap. |
| 29 kCrossfadeDurationInMilliseconds = 5, | 29 kCrossfadeDurationInMilliseconds = 5, |
| 30 |
| 31 // Largest gap or overlap allowed between buffers. Anything larger than |
| 32 // this will trigger an error. This is an arbitrary value, but the initial |
| 33 // selection of 50ms roughly represents the duration of 2 compressed AAC or |
| 34 // MP3 frames. |
| 35 kMaxTimeDeltaInMilliseconds = 50, |
| 30 }; | 36 }; |
| 31 | 37 |
| 32 // Resets the splicer state by clearing the output buffers queue and resetting | 38 // Resets the splicer state by clearing the output buffers queue and resetting |
| 33 // the timestamp helper. | 39 // the timestamp helper. |
| 34 void Reset(); | 40 void Reset(); |
| 35 | 41 |
| 36 // Adds a new buffer full of samples or end of stream buffer to the splicer. | 42 // Adds a new buffer full of samples or end of stream buffer to the splicer. |
| 37 // Returns true if the buffer was accepted. False is returned if an error | 43 // Returns true if the buffer was accepted. False is returned if an error |
| 38 // occurred. | 44 // occurred. |
| 39 bool AddInput(const scoped_refptr<AudioBuffer>& input); | 45 bool AddInput(const scoped_refptr<AudioBuffer>& input); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // Whether all buffers which should go into |pre_splice_sanitizer_| have been | 115 // Whether all buffers which should go into |pre_splice_sanitizer_| have been |
| 110 // received. If true, buffers should now be put in |post_splice_sanitizer_|. | 116 // received. If true, buffers should now be put in |post_splice_sanitizer_|. |
| 111 bool have_all_pre_splice_buffers_; | 117 bool have_all_pre_splice_buffers_; |
| 112 | 118 |
| 113 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioSplicer); | 119 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioSplicer); |
| 114 }; | 120 }; |
| 115 | 121 |
| 116 } // namespace media | 122 } // namespace media |
| 117 | 123 |
| 118 #endif | 124 #endif |
| OLD | NEW |