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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | media/base/audio_discard_helper.cc » ('j') | media/base/audio_discard_helper.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_BASE_AUDIO_DISCARD_HELPER_H_
6 #define MEDIA_BASE_AUDIO_DISCARD_HELPER_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "base/time/time.h"
10 #include "media/base/audio_timestamp_helper.h"
11 #include "media/base/buffers.h"
12 #include "media/base/media_export.h"
13
14 namespace media {
15
16 class AudioBuffer;
17 class DecoderBuffer;
18
19 // Helper class for managing timestamps and discard events around decoding.
20 class MEDIA_EXPORT AudioDiscardHelper {
21 public:
22 explicit AudioDiscardHelper(int sample_rate);
23 ~AudioDiscardHelper();
24
25 // Converts a TimeDelta to a frame count based on the constructed sample rate.
26 // |duration| must be postive.
wolenetz 2014/04/28 21:52:07 nit: s/postive/positive
DaleCurtis 2014/04/28 23:09:03 Done.
27 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.
28
29 // Resets internal state and indicates that |initial_discard| of upcoming
30 // frames should be discarded.
31 void Reset(size_t initial_discard);
32
33 // Applies discard padding from the encoded buffer along with any initial
34 // discards. |decoded_buffer| may be NULL, if not the timestamp and duration
35 // will be set after discards are applied.
36 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.
37 const scoped_refptr<AudioBuffer>& decoded_buffer);
38
39 // Whether any buffers have been processed.
40 bool initialized() const {
41 return timestamp_helper_.base_timestamp() != kNoTimestamp();
42 }
43
44 private:
45 const int sample_rate_;
46 AudioTimestampHelper timestamp_helper_;
47
48 size_t discard_frames_;
49 base::TimeDelta last_input_timestamp_;
50
51 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDiscardHelper);
52 };
53
54 } // namespace media
55
56 #endif
wolenetz 2014/04/28 21:52:07 nit: include // MEDIA_BASE_AUDIO_DISCARD_HELPER_H_
DaleCurtis 2014/04/28 23:09:03 Done.
OLDNEW
« 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