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

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: Switched to base::Bind() and reverted gyp change+new files 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
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/message_loop.h" 11 #include "base/message_loop.h"
11 #include "media/base/audio_decoder.h" 12 #include "media/base/audio_decoder.h"
12 13
13 struct AVCodecContext; 14 struct AVCodecContext;
14 15
15 namespace media { 16 namespace media {
16 17
17 class DataBuffer; 18 class DataBuffer;
19 class MessageLoopFactory;
Ami GONE FROM CHROMIUM 2012/03/09 16:15:06 Unnecessary
tommi (sloooow) - chröme 2012/03/11 18:49:36 Done.
18 20
19 class MEDIA_EXPORT FFmpegAudioDecoder : public AudioDecoder { 21 class MEDIA_EXPORT FFmpegAudioDecoder : public AudioDecoder {
20 public: 22 public:
21 explicit FFmpegAudioDecoder(MessageLoop* message_loop); 23 FFmpegAudioDecoder(const base::Callback<MessageLoop*()>& message_loop_cb);
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 base::Callback<MessageLoop*()> message_loop_cb_;
58 MessageLoop* message_loop_; 61 MessageLoop* message_loop_;
59 62
60 scoped_refptr<DemuxerStream> demuxer_stream_; 63 scoped_refptr<DemuxerStream> demuxer_stream_;
61 StatisticsCallback stats_callback_; 64 StatisticsCallback stats_callback_;
62 AVCodecContext* codec_context_; 65 AVCodecContext* codec_context_;
63 66
64 // Decoded audio format. 67 // Decoded audio format.
65 int bits_per_channel_; 68 int bits_per_channel_;
66 ChannelLayout channel_layout_; 69 ChannelLayout channel_layout_;
67 int samples_per_second_; 70 int samples_per_second_;
68 71
69 base::TimeDelta estimated_next_timestamp_; 72 base::TimeDelta estimated_next_timestamp_;
70 73
71 // Holds decoded audio. As required by FFmpeg, input/output buffers should 74 // Holds decoded audio. As required by FFmpeg, input/output buffers should
72 // be allocated with suitable padding and alignment. av_malloc() provides 75 // be allocated with suitable padding and alignment. av_malloc() provides
73 // us that guarantee. 76 // us that guarantee.
74 const int decoded_audio_size_; 77 const int decoded_audio_size_;
75 uint8* decoded_audio_; // Allocated via av_malloc(). 78 uint8* decoded_audio_; // Allocated via av_malloc().
76 79
77 ReadCB read_cb_; 80 ReadCB read_cb_;
78 81
79 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder); 82 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder);
80 }; 83 };
81 84
82 } // namespace media 85 } // namespace media
83 86
84 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ 87 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_
OLDNEW
« no previous file with comments | « no previous file | media/filters/ffmpeg_audio_decoder.cc » ('j') | media/filters/ffmpeg_audio_decoder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698