Chromium Code Reviews| 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" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 // occurred. | 38 // occurred. |
| 39 bool AddInput(const scoped_refptr<AudioBuffer>& input); | 39 bool AddInput(const scoped_refptr<AudioBuffer>& input); |
| 40 | 40 |
| 41 // Returns true if the splicer has a buffer to return. | 41 // Returns true if the splicer has a buffer to return. |
| 42 bool HasNextBuffer() const; | 42 bool HasNextBuffer() const; |
| 43 | 43 |
| 44 // Removes the next buffer from the output buffer queue and returns it; this | 44 // Removes the next buffer from the output buffer queue and returns it; this |
| 45 // should only be called if HasNextBuffer() returns true. | 45 // should only be called if HasNextBuffer() returns true. |
| 46 scoped_refptr<AudioBuffer> GetNextBuffer(); | 46 scoped_refptr<AudioBuffer> GetNextBuffer(); |
| 47 | 47 |
| 48 // Indicates that overlapping buffers are coming up and should be crossfaded. | 48 // Indicates an upcoming splice point. All buffers overlapping or after the |
| 49 // Once set, all buffers encountered after |splice_timestamp| will be queued | 49 // |splice_timestamp| will be considered as "before the splice." Clients must |
| 50 // internally until at least 5ms of overlapping buffers are received (or end | 50 // then call SetSpliceTimestamp(kNoTimestamp()) to signal that future buffers |
| 51 // of stream, whichever comes first). | 51 // should be considered as "after the splice." |
| 52 // | |
| 53 // Once |kCrossfadeDurationInMilliseconds| of buffers "after the splice" or | |
| 54 // end of stream has been received, the "after" buffers will be crossfaded | |
| 55 // with all "before" buffers which overlap them. "before" buffers outside | |
| 56 // of the overlap range will be discarded. | |
|
wolenetz
2014/04/17 22:29:30
This "discard" logic: where is it? I see that l.28
DaleCurtis
2014/04/17 23:52:33
The discard of unused pre splice buffers happens o
| |
| 52 void SetSpliceTimestamp(base::TimeDelta splice_timestamp); | 57 void SetSpliceTimestamp(base::TimeDelta splice_timestamp); |
| 53 | 58 |
| 54 private: | 59 private: |
| 55 friend class AudioSplicerTest; | 60 friend class AudioSplicerTest; |
| 56 | 61 |
| 57 // Extracts frames to be crossfaded from |pre_splice_sanitizer_|. Transfers | 62 // Extracts frames to be crossfaded from |pre_splice_sanitizer_|. Transfers |
| 58 // all frames before |splice_timestamp_| into |output_sanitizer_| and drops | 63 // all frames before |splice_timestamp_| into |output_sanitizer_| and drops |
| 59 // frames outside of the crossfade duration. | 64 // frames outside of the crossfade duration. |
| 60 // | 65 // |
| 61 // The size of the returned AudioBus is the crossfade duration in frames. | 66 // The size of the returned AudioBus is the crossfade duration in frames. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 // crossfading are received the pre and post sanitizers are drained into | 99 // crossfading are received the pre and post sanitizers are drained into |
| 95 // |output_sanitizer_| by the two ExtractCrossfadeFromXXX methods above. | 100 // |output_sanitizer_| by the two ExtractCrossfadeFromXXX methods above. |
| 96 // | 101 // |
| 97 // |pre_splice_sanitizer_| is not constructed until the first splice frame is | 102 // |pre_splice_sanitizer_| is not constructed until the first splice frame is |
| 98 // encountered. At which point it is constructed based on the timestamp state | 103 // encountered. At which point it is constructed based on the timestamp state |
| 99 // of |output_sanitizer_|. It is destructed once the splice is finished. | 104 // of |output_sanitizer_|. It is destructed once the splice is finished. |
| 100 scoped_ptr<AudioStreamSanitizer> output_sanitizer_; | 105 scoped_ptr<AudioStreamSanitizer> output_sanitizer_; |
| 101 scoped_ptr<AudioStreamSanitizer> pre_splice_sanitizer_; | 106 scoped_ptr<AudioStreamSanitizer> pre_splice_sanitizer_; |
| 102 scoped_ptr<AudioStreamSanitizer> post_splice_sanitizer_; | 107 scoped_ptr<AudioStreamSanitizer> post_splice_sanitizer_; |
| 103 | 108 |
| 109 // 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_|. | |
| 111 bool have_all_pre_splice_buffers_; | |
| 112 | |
| 104 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioSplicer); | 113 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioSplicer); |
| 105 }; | 114 }; |
| 106 | 115 |
| 107 } // namespace media | 116 } // namespace media |
| 108 | 117 |
| 109 #endif | 118 #endif |
| OLD | NEW |