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

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

Issue 9632024: Create video and audio decoder threads on demand. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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/message_loop_factory_for_test.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/message_loop.h" 10 #include "base/message_loop.h"
11 #include "media/base/audio_decoder.h" 11 #include "media/base/audio_decoder.h"
12 12
13 struct AVCodecContext; 13 struct AVCodecContext;
14 14
15 namespace media { 15 namespace media {
16 16
17 class DataBuffer; 17 class DataBuffer;
18 class MessageLoopFactory;
18 19
19 class MEDIA_EXPORT FFmpegAudioDecoder : public AudioDecoder { 20 class MEDIA_EXPORT FFmpegAudioDecoder : public AudioDecoder {
20 public: 21 public:
21 explicit FFmpegAudioDecoder(MessageLoop* message_loop); 22 FFmpegAudioDecoder(MessageLoopFactory* loop_factory,
Ami GONE FROM CHROMIUM 2012/03/08 16:32:07 You could avoid the need for the MessageLoopFactor
tommi (sloooow) - chröme 2012/03/09 10:07:15 That's so clever it can't possibly work! hehe, muc
23 const std::string& loop_name);
22 virtual ~FFmpegAudioDecoder(); 24 virtual ~FFmpegAudioDecoder();
23 25
24 // AudioDecoder implementation. 26 // AudioDecoder implementation.
25 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, 27 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream,
26 const PipelineStatusCB& callback, 28 const PipelineStatusCB& callback,
27 const StatisticsCallback& stats_callback) OVERRIDE; 29 const StatisticsCallback& stats_callback) OVERRIDE;
28 virtual void Read(const ReadCB& callback) OVERRIDE; 30 virtual void Read(const ReadCB& callback) OVERRIDE;
29 virtual int bits_per_channel() OVERRIDE; 31 virtual int bits_per_channel() OVERRIDE;
30 virtual ChannelLayout channel_layout() OVERRIDE; 32 virtual ChannelLayout channel_layout() OVERRIDE;
31 virtual int samples_per_second() OVERRIDE; 33 virtual int samples_per_second() OVERRIDE;
(...skipping 16 matching lines...) Expand all
48 // buffer. Will fall back to an estimated timestamp if the input lacks a 50 // buffer. Will fall back to an estimated timestamp if the input lacks a
49 // valid timestamp. 51 // valid timestamp.
50 void UpdateDurationAndTimestamp(const Buffer* input, DataBuffer* output); 52 void UpdateDurationAndTimestamp(const Buffer* input, DataBuffer* output);
51 53
52 // Calculates duration based on size of decoded audio bytes. 54 // Calculates duration based on size of decoded audio bytes.
53 base::TimeDelta CalculateDuration(int size); 55 base::TimeDelta CalculateDuration(int size);
54 56
55 // Delivers decoded samples to |read_cb_| and resets the callback. 57 // Delivers decoded samples to |read_cb_| and resets the callback.
56 void DeliverSamples(const scoped_refptr<Buffer>& samples); 58 void DeliverSamples(const scoped_refptr<Buffer>& samples);
57 59
60 MessageLoop* EnsureMessageLoop();
Ami GONE FROM CHROMIUM 2012/03/08 16:32:07 This idiom seems to me either racy or unnecessary.
tommi (sloooow) - chröme 2012/03/09 10:07:15 Removed EML and now only initialize message_loop_
61
62 MessageLoopFactory* message_loop_factory_;
63 const std::string loop_name_;
58 MessageLoop* message_loop_; 64 MessageLoop* message_loop_;
59 65
60 scoped_refptr<DemuxerStream> demuxer_stream_; 66 scoped_refptr<DemuxerStream> demuxer_stream_;
61 StatisticsCallback stats_callback_; 67 StatisticsCallback stats_callback_;
62 AVCodecContext* codec_context_; 68 AVCodecContext* codec_context_;
63 69
64 // Decoded audio format. 70 // Decoded audio format.
65 int bits_per_channel_; 71 int bits_per_channel_;
66 ChannelLayout channel_layout_; 72 ChannelLayout channel_layout_;
67 int samples_per_second_; 73 int samples_per_second_;
68 74
69 base::TimeDelta estimated_next_timestamp_; 75 base::TimeDelta estimated_next_timestamp_;
70 76
71 // Holds decoded audio. As required by FFmpeg, input/output buffers should 77 // Holds decoded audio. As required by FFmpeg, input/output buffers should
72 // be allocated with suitable padding and alignment. av_malloc() provides 78 // be allocated with suitable padding and alignment. av_malloc() provides
73 // us that guarantee. 79 // us that guarantee.
74 const int decoded_audio_size_; 80 const int decoded_audio_size_;
75 uint8* decoded_audio_; // Allocated via av_malloc(). 81 uint8* decoded_audio_; // Allocated via av_malloc().
76 82
77 ReadCB read_cb_; 83 ReadCB read_cb_;
78 84
79 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder); 85 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder);
80 }; 86 };
81 87
82 } // namespace media 88 } // namespace media
83 89
84 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ 90 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_
OLDNEW
« no previous file with comments | « media/base/message_loop_factory_for_test.cc ('k') | media/filters/ffmpeg_audio_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698