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

Side by Side Diff: media/base/audio_discard_helper.h

Issue 251893002: Support start trimming post-decoding. Use it with FFmpegDemuxer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_BASE_AUDIO_DISCARD_HELPER_H_ 5 #ifndef MEDIA_BASE_AUDIO_DISCARD_HELPER_H_
6 #define MEDIA_BASE_AUDIO_DISCARD_HELPER_H_ 6 #define MEDIA_BASE_AUDIO_DISCARD_HELPER_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "media/base/audio_timestamp_helper.h" 10 #include "media/base/audio_timestamp_helper.h"
11 #include "media/base/buffers.h" 11 #include "media/base/buffers.h"
12 #include "media/base/media_export.h" 12 #include "media/base/media_export.h"
13 13
14 namespace media { 14 namespace media {
15 15
16 class AudioBuffer; 16 class AudioBuffer;
17 class DecoderBuffer; 17 class DecoderBuffer;
18 18
19 // Helper class for managing timestamps and discard events around decoding. 19 // Helper class for managing timestamps and discard events around decoding.
20 class MEDIA_EXPORT AudioDiscardHelper { 20 class MEDIA_EXPORT AudioDiscardHelper {
21 public: 21 public:
22 explicit AudioDiscardHelper(int sample_rate); 22 // |sample_rate| is the sample rate of decode data which will be handed into
23 // the ProcessBuffers() call.
24 //
25 // |codec_delay| is used to figure out the the start of decoded data from each
26 // corresponding encoded buffer. End discard is only supported when there is
27 // no |codec_delay|.
28 AudioDiscardHelper(int sample_rate, size_t codec_delay);
23 ~AudioDiscardHelper(); 29 ~AudioDiscardHelper();
24 30
25 // Converts a TimeDelta to a frame count based on the constructed sample rate. 31 // Converts a TimeDelta to a frame count based on the constructed sample rate.
26 // |duration| must be positive. 32 // |duration| must be positive.
27 size_t TimeDeltaToFrames(base::TimeDelta duration) const; 33 size_t TimeDeltaToFrames(base::TimeDelta duration) const;
28 34
29 // Resets internal state and indicates that |initial_discard| of upcoming 35 // Resets internal state and indicates that |initial_discard| of upcoming
30 // frames should be discarded. 36 // frames should be discarded.
31 void Reset(size_t initial_discard); 37 void Reset(size_t initial_discard);
32 38
(...skipping 10 matching lines...) Expand all
43 bool ProcessBuffers(const scoped_refptr<DecoderBuffer>& encoded_buffer, 49 bool ProcessBuffers(const scoped_refptr<DecoderBuffer>& encoded_buffer,
44 const scoped_refptr<AudioBuffer>& decoded_buffer); 50 const scoped_refptr<AudioBuffer>& decoded_buffer);
45 51
46 // Whether any buffers have been processed. 52 // Whether any buffers have been processed.
47 bool initialized() const { 53 bool initialized() const {
48 return timestamp_helper_.base_timestamp() != kNoTimestamp(); 54 return timestamp_helper_.base_timestamp() != kNoTimestamp();
49 } 55 }
50 56
51 private: 57 private:
52 const int sample_rate_; 58 const int sample_rate_;
59 const size_t codec_delay_;
53 AudioTimestampHelper timestamp_helper_; 60 AudioTimestampHelper timestamp_helper_;
54 61
55 size_t discard_frames_; 62 size_t discard_frames_;
56 base::TimeDelta last_input_timestamp_; 63 base::TimeDelta last_input_timestamp_;
64 scoped_refptr<DecoderBuffer> delayed_discard_;
57 65
58 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDiscardHelper); 66 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioDiscardHelper);
59 }; 67 };
60 68
61 } // namespace media 69 } // namespace media
62 70
63 #endif // MEDIA_BASE_AUDIO_DISCARD_HELPER_H_ 71 #endif // MEDIA_BASE_AUDIO_DISCARD_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698