| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // already been demuxed without having the demuxer thread sending the | 123 // already been demuxed without having the demuxer thread sending the |
| 124 // buffers. |lock_| must be acquired before any access to |buffer_queue_|, | 124 // buffers. |lock_| must be acquired before any access to |buffer_queue_|, |
| 125 // |read_queue_|, or |stopped_|. | 125 // |read_queue_|, or |stopped_|. |
| 126 base::Lock lock_; | 126 base::Lock lock_; |
| 127 | 127 |
| 128 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerStream); | 128 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerStream); |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 class MEDIA_EXPORT FFmpegDemuxer : public Demuxer, public FFmpegURLProtocol { | 131 class MEDIA_EXPORT FFmpegDemuxer : public Demuxer, public FFmpegURLProtocol { |
| 132 public: | 132 public: |
| 133 FFmpegDemuxer(MessageLoop* message_loop, bool local_source); | 133 FFmpegDemuxer(MessageLoop* message_loop, |
| 134 const scoped_refptr<DataSource>& data_source, |
| 135 bool local_source); |
| 134 virtual ~FFmpegDemuxer(); | 136 virtual ~FFmpegDemuxer(); |
| 135 | 137 |
| 136 // Posts a task to perform additional demuxing. | 138 // Posts a task to perform additional demuxing. |
| 137 virtual void PostDemuxTask(); | 139 virtual void PostDemuxTask(); |
| 138 | 140 |
| 139 void Initialize( | |
| 140 DataSource* data_source, const PipelineStatusCB& status_cb); | |
| 141 | |
| 142 // Demuxer implementation. | 141 // Demuxer implementation. |
| 142 virtual void Initialize(const PipelineStatusCB& status_cb) OVERRIDE; |
| 143 virtual void Stop(const base::Closure& callback) OVERRIDE; | 143 virtual void Stop(const base::Closure& callback) OVERRIDE; |
| 144 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; | 144 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; |
| 145 virtual void OnAudioRendererDisabled() OVERRIDE; | 145 virtual void OnAudioRendererDisabled() OVERRIDE; |
| 146 virtual void set_host(DemuxerHost* demuxer_host) OVERRIDE; | 146 virtual void set_host(DemuxerHost* demuxer_host) OVERRIDE; |
| 147 virtual void SetPlaybackRate(float playback_rate) OVERRIDE; | 147 virtual void SetPlaybackRate(float playback_rate) OVERRIDE; |
| 148 virtual scoped_refptr<DemuxerStream> GetStream( | 148 virtual scoped_refptr<DemuxerStream> GetStream( |
| 149 DemuxerStream::Type type) OVERRIDE; | 149 DemuxerStream::Type type) OVERRIDE; |
| 150 virtual base::TimeDelta GetStartTime() const OVERRIDE; | 150 virtual base::TimeDelta GetStartTime() const OVERRIDE; |
| 151 virtual int GetBitrate() OVERRIDE; | 151 virtual int GetBitrate() OVERRIDE; |
| 152 virtual bool IsLocalSource() OVERRIDE; | 152 virtual bool IsLocalSource() OVERRIDE; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 164 | 164 |
| 165 // For testing purposes. | 165 // For testing purposes. |
| 166 void disable_first_seek_hack_for_testing() { first_seek_hack_ = false; } | 166 void disable_first_seek_hack_for_testing() { first_seek_hack_ = false; } |
| 167 | 167 |
| 168 private: | 168 private: |
| 169 // Only allow a factory to create this class. | 169 // Only allow a factory to create this class. |
| 170 friend class MockFFmpegDemuxer; | 170 friend class MockFFmpegDemuxer; |
| 171 FRIEND_TEST_ALL_PREFIXES(FFmpegDemuxerTest, ProtocolRead); | 171 FRIEND_TEST_ALL_PREFIXES(FFmpegDemuxerTest, ProtocolRead); |
| 172 | 172 |
| 173 // Carries out initialization on the demuxer thread. | 173 // Carries out initialization on the demuxer thread. |
| 174 void InitializeTask( | 174 void InitializeTask(const PipelineStatusCB& status_cb); |
| 175 DataSource* data_source, const PipelineStatusCB& status_cb); | |
| 176 | 175 |
| 177 // Carries out a seek on the demuxer thread. | 176 // Carries out a seek on the demuxer thread. |
| 178 void SeekTask(base::TimeDelta time, const PipelineStatusCB& cb); | 177 void SeekTask(base::TimeDelta time, const PipelineStatusCB& cb); |
| 179 | 178 |
| 180 // Carries out demuxing and satisfying stream reads on the demuxer thread. | 179 // Carries out demuxing and satisfying stream reads on the demuxer thread. |
| 181 void DemuxTask(); | 180 void DemuxTask(); |
| 182 | 181 |
| 183 // Carries out stopping the demuxer streams on the demuxer thread. | 182 // Carries out stopping the demuxer streams on the demuxer thread. |
| 184 void StopTask(const base::Closure& callback); | 183 void StopTask(const base::Closure& callback); |
| 185 | 184 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 // Whether audio has been disabled for this demuxer (in which case this class | 258 // Whether audio has been disabled for this demuxer (in which case this class |
| 260 // drops packets destined for AUDIO demuxer streams on the floor). | 259 // drops packets destined for AUDIO demuxer streams on the floor). |
| 261 bool audio_disabled_; | 260 bool audio_disabled_; |
| 262 | 261 |
| 263 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); | 262 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); |
| 264 }; | 263 }; |
| 265 | 264 |
| 266 } // namespace media | 265 } // namespace media |
| 267 | 266 |
| 268 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 267 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |
| OLD | NEW |