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

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: Fix x64 type. Created 6 years, 7 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 | « media/base/audio_buffer.h ('k') | media/base/audio_discard_helper.cc » ('j') | no next file with comments »
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 positive.
27 size_t TimeDeltaToFrames(base::TimeDelta duration) const;
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. Returns true if |decoded_buffer|
36 // exists after processing discard events. Returns false if |decoded_buffer|
37 // was NULL, is completely discarded, or a processing error occurs.
38 //
39 // If AudioDiscardHelper is not initialized() the timestamp of the first
40 // |encoded_buffer| will be used as the basis for all future timestamps set on
41 // |decoded_buffer|s. If the first buffer has a negative timestamp it will be
42 // clamped to zero.
43 bool ProcessBuffers(const scoped_refptr<DecoderBuffer>& encoded_buffer,
44 const scoped_refptr<AudioBuffer>& decoded_buffer);
45
46 // Whether any buffers have been processed.
47 bool initialized() const {
48 return timestamp_helper_.base_timestamp() != kNoTimestamp();
49 }
50
51 private:
52 const int sample_rate_;
53 AudioTimestampHelper timestamp_helper_;
54
55 size_t discard_frames_;
56 base::TimeDelta last_input_timestamp_;
57
58 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDiscardHelper);
59 };
60
61 } // namespace media
62
63 #endif // MEDIA_BASE_AUDIO_DISCARD_HELPER_H_
OLDNEW
« no previous file with comments | « media/base/audio_buffer.h ('k') | media/base/audio_discard_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698