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

Side by Side Diff: media/filters/ffmpeg_audio_decoder.h

Issue 126793002: Add Stop() to AudioDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Handle stop with pending demuxer read Created 6 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_FILTERS_FFMPEG_AUDIO_DECODER_H_ 5 #ifndef MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_
6 #define MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ 6 #define MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_
7 7
8 #include <list> 8 #include <list>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 27 matching lines...) Expand all
38 38
39 // AudioDecoder implementation. 39 // AudioDecoder implementation.
40 virtual void Initialize(DemuxerStream* stream, 40 virtual void Initialize(DemuxerStream* stream,
41 const PipelineStatusCB& status_cb, 41 const PipelineStatusCB& status_cb,
42 const StatisticsCB& statistics_cb) OVERRIDE; 42 const StatisticsCB& statistics_cb) OVERRIDE;
43 virtual void Read(const ReadCB& read_cb) OVERRIDE; 43 virtual void Read(const ReadCB& read_cb) OVERRIDE;
44 virtual int bits_per_channel() OVERRIDE; 44 virtual int bits_per_channel() OVERRIDE;
45 virtual ChannelLayout channel_layout() OVERRIDE; 45 virtual ChannelLayout channel_layout() OVERRIDE;
46 virtual int samples_per_second() OVERRIDE; 46 virtual int samples_per_second() OVERRIDE;
47 virtual void Reset(const base::Closure& closure) OVERRIDE; 47 virtual void Reset(const base::Closure& closure) OVERRIDE;
48 virtual void Stop(const base::Closure& closure) OVERRIDE;
48 49
49 // Callback called from within FFmpeg to allocate a buffer based on 50 // Callback called from within FFmpeg to allocate a buffer based on
50 // the dimensions of |codec_context|. See AVCodecContext.get_buffer2 51 // the dimensions of |codec_context|. See AVCodecContext.get_buffer2
51 // documentation inside FFmpeg. 52 // documentation inside FFmpeg.
52 int GetAudioBuffer(AVCodecContext* codec, AVFrame* frame, int flags); 53 int GetAudioBuffer(AVCodecContext* codec, AVFrame* frame, int flags);
53 54
54 private: 55 private:
56 void DoStop();
57
55 // Reads from the demuxer stream with corresponding callback method. 58 // Reads from the demuxer stream with corresponding callback method.
56 void ReadFromDemuxerStream(); 59 void ReadFromDemuxerStream();
57 void BufferReady(DemuxerStream::Status status, 60 void BufferReady(DemuxerStream::Status status,
58 const scoped_refptr<DecoderBuffer>& input); 61 const scoped_refptr<DecoderBuffer>& input);
59 62
60 bool ConfigureDecoder(); 63 bool ConfigureDecoder();
61 void ReleaseFFmpegResources(); 64 void ReleaseFFmpegResources();
62 void ResetTimestampState(); 65 void ResetTimestampState();
63 void RunDecodeLoop(const scoped_refptr<DecoderBuffer>& input, 66 void RunDecodeLoop(const scoped_refptr<DecoderBuffer>& input,
64 bool skip_eos_append); 67 bool skip_eos_append);
(...skipping 20 matching lines...) Expand all
85 scoped_ptr<AudioTimestampHelper> output_timestamp_helper_; 88 scoped_ptr<AudioTimestampHelper> output_timestamp_helper_;
86 base::TimeDelta last_input_timestamp_; 89 base::TimeDelta last_input_timestamp_;
87 90
88 // Number of frames to drop before generating output buffers. 91 // Number of frames to drop before generating output buffers.
89 int output_frames_to_drop_; 92 int output_frames_to_drop_;
90 93
91 // Holds decoded audio. 94 // Holds decoded audio.
92 scoped_ptr_malloc<AVFrame, ScopedPtrAVFreeFrame> av_frame_; 95 scoped_ptr_malloc<AVFrame, ScopedPtrAVFreeFrame> av_frame_;
93 96
94 ReadCB read_cb_; 97 ReadCB read_cb_;
98 base::Closure stop_cb_;
95 99
96 // Since multiple frames may be decoded from the same packet we need to queue 100 // Since multiple frames may be decoded from the same packet we need to queue
97 // them up and hand them out as we receive Read() calls. 101 // them up and hand them out as we receive Read() calls.
98 std::list<QueuedAudioBuffer> queued_audio_; 102 std::list<QueuedAudioBuffer> queued_audio_;
99 103
100 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder); 104 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder);
101 }; 105 };
102 106
103 } // namespace media 107 } // namespace media
104 108
105 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ 109 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698