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

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

Issue 65803002: Replace MessageLoopProxy with SingleThreadTaskRunner for media/filters/ + associated code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years 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/filters/fake_video_decoder.cc ('k') | media/filters/ffmpeg_audio_decoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "media/base/audio_decoder.h" 14 #include "media/base/audio_decoder.h"
15 #include "media/base/demuxer_stream.h" 15 #include "media/base/demuxer_stream.h"
16 #include "media/base/sample_format.h" 16 #include "media/base/sample_format.h"
17 17
18 struct AVCodecContext; 18 struct AVCodecContext;
19 struct AVFrame; 19 struct AVFrame;
20 20
21 namespace base { 21 namespace base {
22 class MessageLoopProxy; 22 class SingleThreadTaskRunner;
23 } 23 }
24 24
25 namespace media { 25 namespace media {
26 26
27 class AudioTimestampHelper; 27 class AudioTimestampHelper;
28 class DecoderBuffer; 28 class DecoderBuffer;
29 struct QueuedAudioBuffer; 29 struct QueuedAudioBuffer;
30 class ScopedPtrAVFreeContext; 30 class ScopedPtrAVFreeContext;
31 class ScopedPtrAVFreeFrame; 31 class ScopedPtrAVFreeFrame;
32 32
33 class MEDIA_EXPORT FFmpegAudioDecoder : public AudioDecoder { 33 class MEDIA_EXPORT FFmpegAudioDecoder : public AudioDecoder {
34 public: 34 public:
35 explicit FFmpegAudioDecoder( 35 explicit FFmpegAudioDecoder(
36 const scoped_refptr<base::MessageLoopProxy>& message_loop); 36 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
37 virtual ~FFmpegAudioDecoder(); 37 virtual ~FFmpegAudioDecoder();
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 48
49 // Callback called from within FFmpeg to allocate a buffer based on 49 // Callback called from within FFmpeg to allocate a buffer based on
50 // the dimensions of |codec_context|. See AVCodecContext.get_buffer2 50 // the dimensions of |codec_context|. See AVCodecContext.get_buffer2
51 // documentation inside FFmpeg. 51 // documentation inside FFmpeg.
52 int GetAudioBuffer(AVCodecContext* codec, AVFrame* frame, int flags); 52 int GetAudioBuffer(AVCodecContext* codec, AVFrame* frame, int flags);
53 53
54 private: 54 private:
55 // Reads from the demuxer stream with corresponding callback method. 55 // Reads from the demuxer stream with corresponding callback method.
56 void ReadFromDemuxerStream(); 56 void ReadFromDemuxerStream();
57 void BufferReady(DemuxerStream::Status status, 57 void BufferReady(DemuxerStream::Status status,
58 const scoped_refptr<DecoderBuffer>& input); 58 const scoped_refptr<DecoderBuffer>& input);
59 59
60 bool ConfigureDecoder(); 60 bool ConfigureDecoder();
61 void ReleaseFFmpegResources(); 61 void ReleaseFFmpegResources();
62 void ResetTimestampState(); 62 void ResetTimestampState();
63 void RunDecodeLoop(const scoped_refptr<DecoderBuffer>& input, 63 void RunDecodeLoop(const scoped_refptr<DecoderBuffer>& input,
64 bool skip_eos_append); 64 bool skip_eos_append);
65 65
66 scoped_refptr<base::MessageLoopProxy> message_loop_; 66 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
67 base::WeakPtrFactory<FFmpegAudioDecoder> weak_factory_; 67 base::WeakPtrFactory<FFmpegAudioDecoder> weak_factory_;
68 base::WeakPtr<FFmpegAudioDecoder> weak_this_; 68 base::WeakPtr<FFmpegAudioDecoder> weak_this_;
69 69
70 DemuxerStream* demuxer_stream_; 70 DemuxerStream* demuxer_stream_;
71 StatisticsCB statistics_cb_; 71 StatisticsCB statistics_cb_;
72 scoped_ptr_malloc<AVCodecContext, ScopedPtrAVFreeContext> codec_context_; 72 scoped_ptr_malloc<AVCodecContext, ScopedPtrAVFreeContext> codec_context_;
73 73
74 // Decoded audio format. 74 // Decoded audio format.
75 int bytes_per_channel_; 75 int bytes_per_channel_;
76 ChannelLayout channel_layout_; 76 ChannelLayout channel_layout_;
(...skipping 19 matching lines...) Expand all
96 // Since multiple frames may be decoded from the same packet we need to queue 96 // 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. 97 // them up and hand them out as we receive Read() calls.
98 std::list<QueuedAudioBuffer> queued_audio_; 98 std::list<QueuedAudioBuffer> queued_audio_;
99 99
100 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder); 100 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder);
101 }; 101 };
102 102
103 } // namespace media 103 } // namespace media
104 104
105 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ 105 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_
OLDNEW
« no previous file with comments | « media/filters/fake_video_decoder.cc ('k') | media/filters/ffmpeg_audio_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698