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

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

Issue 65803002: Replace MessageLoopProxy with SingleThreadTaskRunner for media/filters/ + associated code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 // Implements the Demuxer interface using FFmpeg's libavformat. At this time 5 // Implements the Demuxer interface using FFmpeg's libavformat. At this time
6 // will support demuxing any audio/video format thrown at it. The streams 6 // will support demuxing any audio/video format thrown at it. The streams
7 // output mime types audio/x-ffmpeg and video/x-ffmpeg and include an integer 7 // output mime types audio/x-ffmpeg and video/x-ffmpeg and include an integer
8 // key FFmpegCodecID which contains the CodecID enumeration value. The CodecIDs 8 // key FFmpegCodecID which contains the CodecID enumeration value. The CodecIDs
9 // can be used to create and initialize the corresponding FFmpeg decoder. 9 // can be used to create and initialize the corresponding FFmpeg decoder.
10 // 10 //
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 class FFmpegGlue; 49 class FFmpegGlue;
50 class FFmpegH264ToAnnexBBitstreamConverter; 50 class FFmpegH264ToAnnexBBitstreamConverter;
51 class ScopedPtrAVFreePacket; 51 class ScopedPtrAVFreePacket;
52 52
53 typedef scoped_ptr_malloc<AVPacket, ScopedPtrAVFreePacket> ScopedAVPacket; 53 typedef scoped_ptr_malloc<AVPacket, ScopedPtrAVFreePacket> ScopedAVPacket;
54 54
55 class FFmpegDemuxerStream : public DemuxerStream { 55 class FFmpegDemuxerStream : public DemuxerStream {
56 public: 56 public:
57 // Keeps a copy of |demuxer| and initializes itself using information 57 // Keeps a copy of |demuxer| and initializes itself using information
58 // inside |stream|. Both parameters must outlive |this|. 58 // inside |stream|. Both parameters must outlive |this|.
59 FFmpegDemuxerStream(FFmpegDemuxer* demuxer, AVStream* stream); 59 FFmpegDemuxerStream(
60 FFmpegDemuxer* demuxer,
61 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
62 AVStream* stream);
60 virtual ~FFmpegDemuxerStream(); 63 virtual ~FFmpegDemuxerStream();
61 64
62 // Enqueues the given AVPacket. It is invalid to queue a |packet| after 65 // Enqueues the given AVPacket. It is invalid to queue a |packet| after
63 // SetEndOfStream() has been called. 66 // SetEndOfStream() has been called.
64 void EnqueuePacket(ScopedAVPacket packet); 67 void EnqueuePacket(ScopedAVPacket packet);
65 68
66 // Enters the end of stream state. After delivering remaining queued buffers 69 // Enters the end of stream state. After delivering remaining queued buffers
67 // only end of stream buffers will be delivered. 70 // only end of stream buffers will be delivered.
68 void SetEndOfStream(); 71 void SetEndOfStream();
69 72
(...skipping 28 matching lines...) Expand all
98 101
99 // Runs |read_cb_| if present with the front of |buffer_queue_|, calling 102 // Runs |read_cb_| if present with the front of |buffer_queue_|, calling
100 // NotifyCapacityAvailable() if capacity is still available. 103 // NotifyCapacityAvailable() if capacity is still available.
101 void SatisfyPendingRead(); 104 void SatisfyPendingRead();
102 105
103 // Converts an FFmpeg stream timestamp into a base::TimeDelta. 106 // Converts an FFmpeg stream timestamp into a base::TimeDelta.
104 static base::TimeDelta ConvertStreamTimestamp(const AVRational& time_base, 107 static base::TimeDelta ConvertStreamTimestamp(const AVRational& time_base,
105 int64 timestamp); 108 int64 timestamp);
106 109
107 FFmpegDemuxer* demuxer_; 110 FFmpegDemuxer* demuxer_;
108 scoped_refptr<base::MessageLoopProxy> message_loop_; 111 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
109 AVStream* stream_; 112 AVStream* stream_;
110 AudioDecoderConfig audio_config_; 113 AudioDecoderConfig audio_config_;
111 VideoDecoderConfig video_config_; 114 VideoDecoderConfig video_config_;
112 Type type_; 115 Type type_;
113 base::TimeDelta duration_; 116 base::TimeDelta duration_;
114 bool end_of_stream_; 117 bool end_of_stream_;
115 base::TimeDelta last_packet_timestamp_; 118 base::TimeDelta last_packet_timestamp_;
116 Ranges<base::TimeDelta> buffered_ranges_; 119 Ranges<base::TimeDelta> buffered_ranges_;
117 120
118 DecoderBufferQueue buffer_queue_; 121 DecoderBufferQueue buffer_queue_;
119 ReadCB read_cb_; 122 ReadCB read_cb_;
120 123
121 scoped_ptr<FFmpegH264ToAnnexBBitstreamConverter> bitstream_converter_; 124 scoped_ptr<FFmpegH264ToAnnexBBitstreamConverter> bitstream_converter_;
122 bool bitstream_converter_enabled_; 125 bool bitstream_converter_enabled_;
123 126
124 std::string encryption_key_id_; 127 std::string encryption_key_id_;
125 128
126 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerStream); 129 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerStream);
127 }; 130 };
128 131
129 class MEDIA_EXPORT FFmpegDemuxer : public Demuxer { 132 class MEDIA_EXPORT FFmpegDemuxer : public Demuxer {
130 public: 133 public:
131 FFmpegDemuxer(const scoped_refptr<base::MessageLoopProxy>& message_loop, 134 FFmpegDemuxer(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
132 DataSource* data_source, 135 DataSource* data_source,
133 const NeedKeyCB& need_key_cb, 136 const NeedKeyCB& need_key_cb,
134 const scoped_refptr<MediaLog>& media_log); 137 const scoped_refptr<MediaLog>& media_log);
135 virtual ~FFmpegDemuxer(); 138 virtual ~FFmpegDemuxer();
136 139
137 // Demuxer implementation. 140 // Demuxer implementation.
138 virtual void Initialize(DemuxerHost* host, 141 virtual void Initialize(DemuxerHost* host,
139 const PipelineStatusCB& status_cb) OVERRIDE; 142 const PipelineStatusCB& status_cb) OVERRIDE;
140 virtual void Stop(const base::Closure& callback) OVERRIDE; 143 virtual void Stop(const base::Closure& callback) OVERRIDE;
141 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; 144 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 182
180 // Called by |url_protocol_| whenever |data_source_| returns a read error. 183 // Called by |url_protocol_| whenever |data_source_| returns a read error.
181 void OnDataSourceError(); 184 void OnDataSourceError();
182 185
183 // Returns the stream from |streams_| that matches |type| as an 186 // Returns the stream from |streams_| that matches |type| as an
184 // FFmpegDemuxerStream. 187 // FFmpegDemuxerStream.
185 FFmpegDemuxerStream* GetFFmpegStream(DemuxerStream::Type type) const; 188 FFmpegDemuxerStream* GetFFmpegStream(DemuxerStream::Type type) const;
186 189
187 DemuxerHost* host_; 190 DemuxerHost* host_;
188 191
189 scoped_refptr<base::MessageLoopProxy> message_loop_; 192 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
190 base::WeakPtrFactory<FFmpegDemuxer> weak_factory_; 193 base::WeakPtrFactory<FFmpegDemuxer> weak_factory_;
191 base::WeakPtr<FFmpegDemuxer> weak_this_; 194 base::WeakPtr<FFmpegDemuxer> weak_this_;
192 195
193 // Thread on which all blocking FFmpeg operations are executed. 196 // Thread on which all blocking FFmpeg operations are executed.
194 base::Thread blocking_thread_; 197 base::Thread blocking_thread_;
195 198
196 // Tracks if there's an outstanding av_read_frame() operation. 199 // Tracks if there's an outstanding av_read_frame() operation.
197 // 200 //
198 // TODO(scherkus): Allow more than one read in flight for higher read 201 // TODO(scherkus): Allow more than one read in flight for higher read
199 // throughput using demuxer_bench to verify improvements. 202 // throughput using demuxer_bench to verify improvements.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 scoped_ptr<FFmpegGlue> glue_; 245 scoped_ptr<FFmpegGlue> glue_;
243 246
244 const NeedKeyCB need_key_cb_; 247 const NeedKeyCB need_key_cb_;
245 248
246 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); 249 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer);
247 }; 250 };
248 251
249 } // namespace media 252 } // namespace media
250 253
251 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ 254 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698