OLD | NEW |
---|---|
(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.
| |
OLD | NEW |