Chromium Code Reviews| Index: media/base/audio_discard_helper.h |
| diff --git a/media/base/audio_discard_helper.h b/media/base/audio_discard_helper.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6a49239381bf4be7b7eaf5186cd55d7629efb336 |
| --- /dev/null |
| +++ b/media/base/audio_discard_helper.h |
| @@ -0,0 +1,56 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MEDIA_BASE_AUDIO_DISCARD_HELPER_H_ |
| +#define MEDIA_BASE_AUDIO_DISCARD_HELPER_H_ |
| + |
| +#include "base/memory/ref_counted.h" |
| +#include "base/time/time.h" |
| +#include "media/base/audio_timestamp_helper.h" |
| +#include "media/base/buffers.h" |
| +#include "media/base/media_export.h" |
| + |
| +namespace media { |
| + |
| +class AudioBuffer; |
| +class DecoderBuffer; |
| + |
| +// Helper class for managing timestamps and discard events around decoding. |
| +class MEDIA_EXPORT AudioDiscardHelper { |
| + public: |
| + explicit AudioDiscardHelper(int sample_rate); |
| + ~AudioDiscardHelper(); |
| + |
| + // Converts a TimeDelta to a frame count based on the constructed sample rate. |
| + // |duration| must be postive. |
|
wolenetz
2014/04/28 21:52:07
nit: s/postive/positive
DaleCurtis
2014/04/28 23:09:03
Done.
|
| + int TimeDeltaToFrames(base::TimeDelta duration) const; |
|
wolenetz
2014/04/28 21:52:07
nit: why int? seems possible it could hit overflow
DaleCurtis
2014/04/28 23:09:03
Done.
|
| + |
| + // Resets internal state and indicates that |initial_discard| of upcoming |
| + // frames should be discarded. |
| + void Reset(size_t initial_discard); |
| + |
| + // Applies discard padding from the encoded buffer along with any initial |
| + // discards. |decoded_buffer| may be NULL, if not the timestamp and duration |
| + // will be set after discards are applied. |
| + bool ProcessBuffers(const scoped_refptr<DecoderBuffer>& encoded_buffer, |
|
wolenetz
2014/04/28 21:52:07
What does the bool return value signify?
DaleCurtis
2014/04/28 23:09:03
Docs updated.
|
| + const scoped_refptr<AudioBuffer>& decoded_buffer); |
| + |
| + // Whether any buffers have been processed. |
| + bool initialized() const { |
| + return timestamp_helper_.base_timestamp() != kNoTimestamp(); |
| + } |
| + |
| + private: |
| + const int sample_rate_; |
| + AudioTimestampHelper timestamp_helper_; |
| + |
| + size_t discard_frames_; |
| + base::TimeDelta last_input_timestamp_; |
| + |
| + DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDiscardHelper); |
| +}; |
| + |
| +} // namespace media |
| + |
| +#endif |
|
wolenetz
2014/04/28 21:52:07
nit: include // MEDIA_BASE_AUDIO_DISCARD_HELPER_H_
DaleCurtis
2014/04/28 23:09:03
Done.
|