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

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

Issue 8661002: Fire CanPlayThrough immediately for local and streaming media files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase ToT Created 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // already been demuxed without having the demuxer thread sending the 121 // already been demuxed without having the demuxer thread sending the
122 // buffers. |lock_| must be acquired before any access to |buffer_queue_|, 122 // buffers. |lock_| must be acquired before any access to |buffer_queue_|,
123 // |read_queue_|, or |stopped_|. 123 // |read_queue_|, or |stopped_|.
124 base::Lock lock_; 124 base::Lock lock_;
125 125
126 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerStream); 126 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerStream);
127 }; 127 };
128 128
129 class MEDIA_EXPORT FFmpegDemuxer : public Demuxer, public FFmpegURLProtocol { 129 class MEDIA_EXPORT FFmpegDemuxer : public Demuxer, public FFmpegURLProtocol {
130 public: 130 public:
131 explicit FFmpegDemuxer(MessageLoop* message_loop); 131 FFmpegDemuxer(MessageLoop* message_loop, bool local_source);
132 virtual ~FFmpegDemuxer(); 132 virtual ~FFmpegDemuxer();
133 133
134 // Posts a task to perform additional demuxing. 134 // Posts a task to perform additional demuxing.
135 virtual void PostDemuxTask(); 135 virtual void PostDemuxTask();
136 136
137 void Initialize( 137 void Initialize(
138 DataSource* data_source, const PipelineStatusCB& callback); 138 DataSource* data_source, const PipelineStatusCB& callback);
139 139
140 // Demuxer implementation. 140 // Demuxer implementation.
141 virtual void Stop(const base::Closure& callback) OVERRIDE; 141 virtual void Stop(const base::Closure& callback) OVERRIDE;
142 virtual void Seek(base::TimeDelta time, const FilterStatusCB& cb) OVERRIDE; 142 virtual void Seek(base::TimeDelta time, const FilterStatusCB& cb) OVERRIDE;
143 virtual void OnAudioRendererDisabled() OVERRIDE; 143 virtual void OnAudioRendererDisabled() OVERRIDE;
144 virtual void set_host(FilterHost* filter_host) OVERRIDE; 144 virtual void set_host(FilterHost* filter_host) OVERRIDE;
145 virtual void SetPlaybackRate(float playback_rate) OVERRIDE; 145 virtual void SetPlaybackRate(float playback_rate) OVERRIDE;
146 virtual scoped_refptr<DemuxerStream> GetStream( 146 virtual scoped_refptr<DemuxerStream> GetStream(
147 DemuxerStream::Type type) OVERRIDE; 147 DemuxerStream::Type type) OVERRIDE;
148 virtual void SetPreload(Preload preload) OVERRIDE; 148 virtual void SetPreload(Preload preload) OVERRIDE;
149 virtual base::TimeDelta GetStartTime() const OVERRIDE; 149 virtual base::TimeDelta GetStartTime() const OVERRIDE;
150 virtual int GetBitrate() OVERRIDE; 150 virtual int GetBitrate() OVERRIDE;
151 virtual bool IsLocalSource() OVERRIDE;
152 virtual bool IsSeekable() OVERRIDE;
151 153
152 // FFmpegURLProtocol implementation. 154 // FFmpegURLProtocol implementation.
153 virtual size_t Read(size_t size, uint8* data) OVERRIDE; 155 virtual size_t Read(size_t size, uint8* data) OVERRIDE;
154 virtual bool GetPosition(int64* position_out) OVERRIDE; 156 virtual bool GetPosition(int64* position_out) OVERRIDE;
155 virtual bool SetPosition(int64 position) OVERRIDE; 157 virtual bool SetPosition(int64 position) OVERRIDE;
156 virtual bool GetSize(int64* size_out) OVERRIDE; 158 virtual bool GetSize(int64* size_out) OVERRIDE;
157 virtual bool IsStreaming() OVERRIDE; 159 virtual bool IsStreaming() OVERRIDE;
158 160
159 // Provide access to FFmpegDemuxerStream. 161 // Provide access to FFmpegDemuxerStream.
160 MessageLoop* message_loop(); 162 MessageLoop* message_loop();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 void OnReadCompleted(size_t size); 203 void OnReadCompleted(size_t size);
202 204
203 // Wait for asynchronous read to complete and return number of bytes read. 205 // Wait for asynchronous read to complete and return number of bytes read.
204 virtual size_t WaitForRead(); 206 virtual size_t WaitForRead();
205 207
206 // Signal that read has completed, and |size| bytes have been read. 208 // Signal that read has completed, and |size| bytes have been read.
207 virtual void SignalReadCompleted(size_t size); 209 virtual void SignalReadCompleted(size_t size);
208 210
209 MessageLoop* message_loop_; 211 MessageLoop* message_loop_;
210 212
213 // True if the media is a local resource, false if the media require network
214 // access to be loaded.
215 bool local_source_;
216
211 // FFmpeg context handle. 217 // FFmpeg context handle.
212 AVFormatContext* format_context_; 218 AVFormatContext* format_context_;
213 219
214 // Two vector of streams: 220 // Two vector of streams:
215 // - |streams_| is indexed by type for the Demuxer interface GetStream(), 221 // - |streams_| is indexed by type for the Demuxer interface GetStream(),
216 // and contains NULLs for types which aren't present. 222 // and contains NULLs for types which aren't present.
217 // - |packet_streams_| is indexed to mirror AVFormatContext when dealing 223 // - |packet_streams_| is indexed to mirror AVFormatContext when dealing
218 // with AVPackets returned from av_read_frame() and contain NULL entries 224 // with AVPackets returned from av_read_frame() and contain NULL entries
219 // representing unsupported streams where we throw away the data. 225 // representing unsupported streams where we throw away the data.
220 // 226 //
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // starting clock value to match the timestamps in the media file. Default 261 // starting clock value to match the timestamps in the media file. Default
256 // is 0. 262 // is 0.
257 base::TimeDelta start_time_; 263 base::TimeDelta start_time_;
258 264
259 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); 265 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer);
260 }; 266 };
261 267
262 } // namespace media 268 } // namespace media
263 269
264 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ 270 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698