| OLD | NEW |
| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 // the tasks if there is no work to do. | 192 // the tasks if there is no work to do. |
| 193 // | 193 // |
| 194 // Must be called on the demuxer thread. | 194 // Must be called on the demuxer thread. |
| 195 bool StreamsHavePendingReads(); | 195 bool StreamsHavePendingReads(); |
| 196 | 196 |
| 197 // Signal all FFmpegDemuxerStream that the stream has ended. | 197 // Signal all FFmpegDemuxerStream that the stream has ended. |
| 198 // | 198 // |
| 199 // Must be called on the demuxer thread. | 199 // Must be called on the demuxer thread. |
| 200 void StreamHasEnded(); | 200 void StreamHasEnded(); |
| 201 | 201 |
| 202 // Read callback method to be passed to DataSource. When the asynchronous | 202 // Wait for asynchronous read to complete and return number of bytes read. |
| 203 // read has completed, this method will be called from DataSource with | 203 virtual int WaitForRead(); |
| 204 // number of bytes read or kDataSource in case of error. | |
| 205 void OnReadCompleted(size_t size); | |
| 206 | 204 |
| 207 // Wait for asynchronous read to complete and return number of bytes read. | 205 // Signal the blocked thread that the read has completed, with |size| bytes |
| 208 virtual size_t WaitForRead(); | 206 // read or kReadError in case of error. |
| 209 | 207 virtual void SignalReadCompleted(int size); |
| 210 // Signal that read has completed, and |size| bytes have been read. | |
| 211 virtual void SignalReadCompleted(size_t size); | |
| 212 | 208 |
| 213 MessageLoop* message_loop_; | 209 MessageLoop* message_loop_; |
| 214 | 210 |
| 215 // True if the media is a local resource, false if the media require network | 211 // True if the media is a local resource, false if the media require network |
| 216 // access to be loaded. | 212 // access to be loaded. |
| 217 bool local_source_; | 213 bool local_source_; |
| 218 | 214 |
| 219 // FFmpeg context handle. | 215 // FFmpeg context handle. |
| 220 AVFormatContext* format_context_; | 216 AVFormatContext* format_context_; |
| 221 | 217 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 237 | 233 |
| 238 // This member is used to block on read method calls from FFmpeg and wait | 234 // This member is used to block on read method calls from FFmpeg and wait |
| 239 // until the asynchronous reads in the data source to complete. It is also | 235 // until the asynchronous reads in the data source to complete. It is also |
| 240 // signaled when the demuxer is being stopped. | 236 // signaled when the demuxer is being stopped. |
| 241 base::WaitableEvent read_event_; | 237 base::WaitableEvent read_event_; |
| 242 | 238 |
| 243 // Flag to indicate if read has ever failed. Once set to true, it will | 239 // Flag to indicate if read has ever failed. Once set to true, it will |
| 244 // never be reset. This flag is set true and accessed in Read(). | 240 // never be reset. This flag is set true and accessed in Read(). |
| 245 bool read_has_failed_; | 241 bool read_has_failed_; |
| 246 | 242 |
| 247 size_t last_read_bytes_; | 243 int last_read_bytes_; |
| 248 int64 read_position_; | 244 int64 read_position_; |
| 249 | 245 |
| 250 // Initialization can happen before set_host() is called, in which case we | 246 // Initialization can happen before set_host() is called, in which case we |
| 251 // store these bits for deferred reporting to the DemuxerHost when we get one. | 247 // store these bits for deferred reporting to the DemuxerHost when we get one. |
| 252 base::TimeDelta max_duration_; | 248 base::TimeDelta max_duration_; |
| 253 PipelineStatus deferred_status_; | 249 PipelineStatus deferred_status_; |
| 254 | 250 |
| 255 // Used to skip the implicit "first seek" to avoid resetting FFmpeg's internal | 251 // Used to skip the implicit "first seek" to avoid resetting FFmpeg's internal |
| 256 // state. | 252 // state. |
| 257 bool first_seek_hack_; | 253 bool first_seek_hack_; |
| 258 | 254 |
| 259 // The first timestamp of the opened media file. This is used to set the | 255 // The first timestamp of the opened media file. This is used to set the |
| 260 // starting clock value to match the timestamps in the media file. Default | 256 // starting clock value to match the timestamps in the media file. Default |
| 261 // is 0. | 257 // is 0. |
| 262 base::TimeDelta start_time_; | 258 base::TimeDelta start_time_; |
| 263 | 259 |
| 264 // Whether audio has been disabled for this demuxer (in which case this class | 260 // Whether audio has been disabled for this demuxer (in which case this class |
| 265 // drops packets destined for AUDIO demuxer streams on the floor). | 261 // drops packets destined for AUDIO demuxer streams on the floor). |
| 266 bool audio_disabled_; | 262 bool audio_disabled_; |
| 267 | 263 |
| 268 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); | 264 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); |
| 269 }; | 265 }; |
| 270 | 266 |
| 271 } // namespace media | 267 } // namespace media |
| 272 | 268 |
| 273 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 269 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |
| OLD | NEW |