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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <deque> | 11 #include <deque> |
12 #include <map> | 12 #include <map> |
13 #include <string> | 13 #include <string> |
14 #include <utility> | 14 #include <utility> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
19 #include "media/base/byte_queue.h" | 19 #include "media/base/byte_queue.h" |
20 #include "media/base/demuxer.h" | 20 #include "media/base/demuxer.h" |
21 #include "media/base/demuxer_stream.h" | 21 #include "media/base/demuxer_stream.h" |
22 #include "media/base/media_tracks.h" | |
23 #include "media/base/ranges.h" | 22 #include "media/base/ranges.h" |
24 #include "media/base/stream_parser.h" | 23 #include "media/base/stream_parser.h" |
25 #include "media/filters/media_source_state.h" | 24 #include "media/filters/media_source_state.h" |
26 #include "media/filters/source_buffer_stream.h" | 25 #include "media/filters/source_buffer_stream.h" |
27 | 26 |
28 namespace media { | 27 namespace media { |
29 | 28 |
30 class FFmpegURLProtocol; | 29 class FFmpegURLProtocol; |
31 | 30 |
32 class MEDIA_EXPORT ChunkDemuxerStream : public DemuxerStream { | 31 class MEDIA_EXPORT ChunkDemuxerStream : public DemuxerStream { |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 // kReachedIdLimit is returned if the demuxer cannot handle another ID right | 201 // kReachedIdLimit is returned if the demuxer cannot handle another ID right |
203 // now. | 202 // now. |
204 Status AddId(const std::string& id, const std::string& type, | 203 Status AddId(const std::string& id, const std::string& type, |
205 std::vector<std::string>& codecs); | 204 std::vector<std::string>& codecs); |
206 | 205 |
207 // Notifies a caller via |tracks_updated_cb| that the set of media tracks | 206 // Notifies a caller via |tracks_updated_cb| that the set of media tracks |
208 // for a given |id| has changed. | 207 // for a given |id| has changed. |
209 void SetTracksWatcher(const std::string& id, | 208 void SetTracksWatcher(const std::string& id, |
210 const MediaTracksUpdatedCB& tracks_updated_cb); | 209 const MediaTracksUpdatedCB& tracks_updated_cb); |
211 | 210 |
212 // Notifies the demuxer that track ids has been assigned to a media tracks. | |
213 void OnTrackIdsAssigned(const MediaTracks& tracks, | |
214 const std::vector<unsigned>& track_ids) override; | |
215 | |
216 // Finds a DemuxerStream corresponding to the given blink |track_id|. Note | |
217 // that the input track id is blink track id and not bytestream track id. | |
218 const DemuxerStream* GetDemuxerStreamByTrackId( | |
219 unsigned track_id) const override; | |
220 | |
221 // Removed an ID & associated resources that were previously added with | 211 // Removed an ID & associated resources that were previously added with |
222 // AddId(). | 212 // AddId(). |
223 void RemoveId(const std::string& id); | 213 void RemoveId(const std::string& id); |
224 | 214 |
225 // Gets the currently buffered ranges for the specified ID. | 215 // Gets the currently buffered ranges for the specified ID. |
226 Ranges<base::TimeDelta> GetBufferedRanges(const std::string& id) const; | 216 Ranges<base::TimeDelta> GetBufferedRanges(const std::string& id) const; |
227 | 217 |
228 // Appends media data to the source buffer associated with |id|, applying | 218 // Appends media data to the source buffer associated with |id|, applying |
229 // and possibly updating |*timestamp_offset| during coded frame processing. | 219 // and possibly updating |*timestamp_offset| during coded frame processing. |
230 // |append_window_start| and |append_window_end| correspond to the MSE spec's | 220 // |append_window_start| and |append_window_end| correspond to the MSE spec's |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 // Returns true if any stream has seeked to a time without buffered data. | 311 // Returns true if any stream has seeked to a time without buffered data. |
322 bool IsSeekWaitingForData_Locked() const; | 312 bool IsSeekWaitingForData_Locked() const; |
323 | 313 |
324 // Returns true if all streams can successfully call EndOfStream, | 314 // Returns true if all streams can successfully call EndOfStream, |
325 // false if any can not. | 315 // false if any can not. |
326 bool CanEndOfStream_Locked() const; | 316 bool CanEndOfStream_Locked() const; |
327 | 317 |
328 // MediaSourceState callbacks. | 318 // MediaSourceState callbacks. |
329 void OnSourceInitDone(const StreamParser::InitParameters& params); | 319 void OnSourceInitDone(const StreamParser::InitParameters& params); |
330 | 320 |
331 // Creates a DemuxerStream for the specified |media_track|. | 321 // Creates a DemuxerStream for the specified |type|. |
332 // Returns a new ChunkDemuxerStream instance if a stream of this type | 322 // Returns a new ChunkDemuxerStream instance if a stream of this type |
333 // has not been created before. Returns NULL otherwise. | 323 // has not been created before. Returns NULL otherwise. |
334 ChunkDemuxerStream* CreateDemuxerStream(const MediaTrack& media_track); | 324 ChunkDemuxerStream* CreateDemuxerStream(DemuxerStream::Type type); |
335 | 325 |
336 void OnNewTextTrack(ChunkDemuxerStream* text_stream, | 326 void OnNewTextTrack(ChunkDemuxerStream* text_stream, |
337 const TextTrackConfig& config); | 327 const TextTrackConfig& config); |
338 | 328 |
339 // Returns true if |source_id| is valid, false otherwise. | 329 // Returns true if |source_id| is valid, false otherwise. |
340 bool IsValidId(const std::string& source_id) const; | 330 bool IsValidId(const std::string& source_id) const; |
341 | 331 |
342 // Increases |duration_| to |new_duration|, if |new_duration| is higher. | 332 // Increases |duration_| to |new_duration|, if |new_duration| is higher. |
343 void IncreaseDurationIfNecessary(base::TimeDelta new_duration); | 333 void IncreaseDurationIfNecessary(base::TimeDelta new_duration); |
344 | 334 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 // http://crbug.com/308226 | 378 // http://crbug.com/308226 |
389 PipelineStatusCB seek_cb_; | 379 PipelineStatusCB seek_cb_; |
390 | 380 |
391 scoped_ptr<ChunkDemuxerStream> audio_; | 381 scoped_ptr<ChunkDemuxerStream> audio_; |
392 scoped_ptr<ChunkDemuxerStream> video_; | 382 scoped_ptr<ChunkDemuxerStream> video_; |
393 | 383 |
394 // Counter to ensure that we do not transition too early to INITIALIZED. | 384 // Counter to ensure that we do not transition too early to INITIALIZED. |
395 // Incremented in AddId(), decremented in OnSourceInitDone(). | 385 // Incremented in AddId(), decremented in OnSourceInitDone(). |
396 int pending_source_init_done_count_; | 386 int pending_source_init_done_count_; |
397 | 387 |
398 MediaTracks::TrackIdToDemuxStreamMap track_id_to_demux_stream_; | |
399 | |
400 base::TimeDelta duration_; | 388 base::TimeDelta duration_; |
401 | 389 |
402 // The duration passed to the last SetDuration(). If | 390 // The duration passed to the last SetDuration(). If |
403 // SetDuration() is never called or an AppendData() call or | 391 // SetDuration() is never called or an AppendData() call or |
404 // a EndOfStream() call changes |duration_|, then this | 392 // a EndOfStream() call changes |duration_|, then this |
405 // variable is set to < 0 to indicate that the |duration_| represents | 393 // variable is set to < 0 to indicate that the |duration_| represents |
406 // the actual duration instead of a user specified value. | 394 // the actual duration instead of a user specified value. |
407 double user_specified_duration_; | 395 double user_specified_duration_; |
408 | 396 |
409 base::Time timeline_offset_; | 397 base::Time timeline_offset_; |
(...skipping 15 matching lines...) Expand all Loading... |
425 int detected_audio_track_count_; | 413 int detected_audio_track_count_; |
426 int detected_video_track_count_; | 414 int detected_video_track_count_; |
427 int detected_text_track_count_; | 415 int detected_text_track_count_; |
428 | 416 |
429 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); | 417 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); |
430 }; | 418 }; |
431 | 419 |
432 } // namespace media | 420 } // namespace media |
433 | 421 |
434 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 422 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
OLD | NEW |