| 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 #ifndef MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 5 #ifndef MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
| 6 #define MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 6 #define MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 ChunkDemuxer(const base::Closure& open_cb, const NeedKeyCB& need_key_cb, | 46 ChunkDemuxer(const base::Closure& open_cb, const NeedKeyCB& need_key_cb, |
| 47 const LogCB& log_cb); | 47 const LogCB& log_cb); |
| 48 virtual ~ChunkDemuxer(); | 48 virtual ~ChunkDemuxer(); |
| 49 | 49 |
| 50 // Demuxer implementation. | 50 // Demuxer implementation. |
| 51 virtual void Initialize(DemuxerHost* host, | 51 virtual void Initialize(DemuxerHost* host, |
| 52 const PipelineStatusCB& cb) OVERRIDE; | 52 const PipelineStatusCB& cb) OVERRIDE; |
| 53 virtual void Stop(const base::Closure& callback) OVERRIDE; | 53 virtual void Stop(const base::Closure& callback) OVERRIDE; |
| 54 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; | 54 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE; |
| 55 virtual void OnAudioRendererDisabled() OVERRIDE; | 55 virtual void OnAudioRendererDisabled() OVERRIDE; |
| 56 virtual scoped_refptr<DemuxerStream> GetStream( | 56 virtual DemuxerStream* GetStream(DemuxerStream::Type type) OVERRIDE; |
| 57 DemuxerStream::Type type) OVERRIDE; | |
| 58 virtual base::TimeDelta GetStartTime() const OVERRIDE; | 57 virtual base::TimeDelta GetStartTime() const OVERRIDE; |
| 59 | 58 |
| 60 // Methods used by an external object to control this demuxer. | 59 // Methods used by an external object to control this demuxer. |
| 61 void StartWaitingForSeek(); | 60 void StartWaitingForSeek(); |
| 62 void CancelPendingSeek(); | 61 void CancelPendingSeek(); |
| 63 | 62 |
| 64 // Registers a new |id| to use for AppendData() calls. |type| indicates | 63 // Registers a new |id| to use for AppendData() calls. |type| indicates |
| 65 // the MIME type for the data that we intend to append for this ID. | 64 // the MIME type for the data that we intend to append for this ID. |
| 66 // kOk is returned if the demuxer has enough resources to support another ID | 65 // kOk is returned if the demuxer has enough resources to support another ID |
| 67 // and supports the format indicated by |type|. | 66 // and supports the format indicated by |type|. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 base::TimeDelta timestamp_offset); | 149 base::TimeDelta timestamp_offset); |
| 151 | 150 |
| 152 // Returns true if |source_id| is valid, false otherwise. | 151 // Returns true if |source_id| is valid, false otherwise. |
| 153 bool IsValidId(const std::string& source_id) const; | 152 bool IsValidId(const std::string& source_id) const; |
| 154 | 153 |
| 155 // Increases |duration_| if the newly appended |buffers| exceed the current | 154 // Increases |duration_| if the newly appended |buffers| exceed the current |
| 156 // |duration_|. The |duration_| is set to the end buffered timestamp of | 155 // |duration_|. The |duration_| is set to the end buffered timestamp of |
| 157 // |stream|. | 156 // |stream|. |
| 158 void IncreaseDurationIfNecessary( | 157 void IncreaseDurationIfNecessary( |
| 159 const StreamParser::BufferQueue& buffers, | 158 const StreamParser::BufferQueue& buffers, |
| 160 const scoped_refptr<ChunkDemuxerStream>& stream); | 159 ChunkDemuxerStream* stream); |
| 161 | 160 |
| 162 // Decreases |duration_| if the buffered region is less than |duration_| when | 161 // Decreases |duration_| if the buffered region is less than |duration_| when |
| 163 // EndOfStream() is called. | 162 // EndOfStream() is called. |
| 164 void DecreaseDurationIfNecessary(); | 163 void DecreaseDurationIfNecessary(); |
| 165 | 164 |
| 166 // Sets |duration_| to |new_duration|, sets |user_specified_duration_| to -1 | 165 // Sets |duration_| to |new_duration|, sets |user_specified_duration_| to -1 |
| 167 // and notifies |host_|. | 166 // and notifies |host_|. |
| 168 void UpdateDuration(base::TimeDelta new_duration); | 167 void UpdateDuration(base::TimeDelta new_duration); |
| 169 | 168 |
| 170 // Returns the ranges representing the buffered data in the demuxer. | 169 // Returns the ranges representing the buffered data in the demuxer. |
| 171 Ranges<base::TimeDelta> GetBufferedRanges() const; | 170 Ranges<base::TimeDelta> GetBufferedRanges() const; |
| 172 | 171 |
| 173 mutable base::Lock lock_; | 172 mutable base::Lock lock_; |
| 174 State state_; | 173 State state_; |
| 175 | 174 |
| 176 DemuxerHost* host_; | 175 DemuxerHost* host_; |
| 177 base::Closure open_cb_; | 176 base::Closure open_cb_; |
| 178 NeedKeyCB need_key_cb_; | 177 NeedKeyCB need_key_cb_; |
| 179 // Callback used to report error strings that can help the web developer | 178 // Callback used to report error strings that can help the web developer |
| 180 // figure out what is wrong with the content. | 179 // figure out what is wrong with the content. |
| 181 LogCB log_cb_; | 180 LogCB log_cb_; |
| 182 | 181 |
| 183 PipelineStatusCB init_cb_; | 182 PipelineStatusCB init_cb_; |
| 184 PipelineStatusCB seek_cb_; | 183 PipelineStatusCB seek_cb_; |
| 185 | 184 |
| 186 scoped_refptr<ChunkDemuxerStream> audio_; | 185 scoped_ptr<ChunkDemuxerStream> audio_; |
| 187 scoped_refptr<ChunkDemuxerStream> video_; | 186 scoped_ptr<ChunkDemuxerStream> video_; |
| 187 |
| 188 // Keeps |audio_| alive when audio has been disabled. |
| 189 scoped_ptr<ChunkDemuxerStream> disabled_audio_; |
| 188 | 190 |
| 189 base::TimeDelta duration_; | 191 base::TimeDelta duration_; |
| 190 | 192 |
| 191 // The duration passed to the last SetDuration(). If | 193 // The duration passed to the last SetDuration(). If |
| 192 // SetDuration() is never called or an AppendData() call or | 194 // SetDuration() is never called or an AppendData() call or |
| 193 // a EndOfStream() call changes |duration_|, then this | 195 // a EndOfStream() call changes |duration_|, then this |
| 194 // variable is set to < 0 to indicate that the |duration_| represents | 196 // variable is set to < 0 to indicate that the |duration_| represents |
| 195 // the actual duration instead of a user specified value. | 197 // the actual duration instead of a user specified value. |
| 196 double user_specified_duration_; | 198 double user_specified_duration_; |
| 197 | 199 |
| 198 typedef std::map<std::string, SourceState*> SourceStateMap; | 200 typedef std::map<std::string, SourceState*> SourceStateMap; |
| 199 SourceStateMap source_state_map_; | 201 SourceStateMap source_state_map_; |
| 200 | 202 |
| 201 // Used to ensure that (1) config data matches the type and codec provided in | 203 // Used to ensure that (1) config data matches the type and codec provided in |
| 202 // AddId(), (2) only 1 audio and 1 video sources are added, and (3) ids may be | 204 // AddId(), (2) only 1 audio and 1 video sources are added, and (3) ids may be |
| 203 // removed with RemoveID() but can not be re-added (yet). | 205 // removed with RemoveID() but can not be re-added (yet). |
| 204 std::string source_id_audio_; | 206 std::string source_id_audio_; |
| 205 std::string source_id_video_; | 207 std::string source_id_video_; |
| 206 | 208 |
| 207 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); | 209 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); |
| 208 }; | 210 }; |
| 209 | 211 |
| 210 } // namespace media | 212 } // namespace media |
| 211 | 213 |
| 212 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 214 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
| OLD | NEW |