Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(813)

Unified Diff: media/base/audio_discard_helper.h

Issue 259453003: Introduce AudioDiscardHelper. Refactor audio decoders to use it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplify! Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/base/audio_discard_helper.cc » ('j') | media/base/audio_discard_helper.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | media/base/audio_discard_helper.cc » ('j') | media/base/audio_discard_helper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698