Chromium Code Reviews| 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" | |
| 22 #include "media/base/ranges.h" | 23 #include "media/base/ranges.h" |
| 23 #include "media/base/stream_parser.h" | 24 #include "media/base/stream_parser.h" |
| 24 #include "media/filters/media_source_state.h" | 25 #include "media/filters/media_source_state.h" |
| 25 #include "media/filters/source_buffer_stream.h" | 26 #include "media/filters/source_buffer_stream.h" |
| 26 | 27 |
| 27 namespace media { | 28 namespace media { |
| 28 | 29 |
| 29 class FFmpegURLProtocol; | 30 class FFmpegURLProtocol; |
| 30 | 31 |
| 31 class MEDIA_EXPORT ChunkDemuxerStream : public DemuxerStream { | 32 class MEDIA_EXPORT ChunkDemuxerStream : public DemuxerStream { |
| 32 public: | 33 public: |
| 33 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; | 34 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; |
| 34 | 35 |
| 35 ChunkDemuxerStream(Type type, bool splice_frames_enabled); | 36 ChunkDemuxerStream(Type type, |
| 37 bool splice_frames_enabled, | |
| 38 MediaTrack::Id media_track_id); | |
| 36 ~ChunkDemuxerStream() override; | 39 ~ChunkDemuxerStream() override; |
| 37 | 40 |
| 38 // ChunkDemuxerStream control methods. | 41 // ChunkDemuxerStream control methods. |
| 39 void StartReturningData(); | 42 void StartReturningData(); |
| 40 void AbortReads(); | 43 void AbortReads(); |
| 41 void CompletePendingReadIfPossible(); | 44 void CompletePendingReadIfPossible(); |
| 42 void Shutdown(); | 45 void Shutdown(); |
| 43 | 46 |
| 44 // SourceBufferStream manipulation methods. | 47 // SourceBufferStream manipulation methods. |
| 45 void Seek(base::TimeDelta time); | 48 void Seek(base::TimeDelta time); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 | 114 |
| 112 // Sets the memory limit, in bytes, on the SourceBufferStream. | 115 // Sets the memory limit, in bytes, on the SourceBufferStream. |
| 113 void SetStreamMemoryLimit(size_t memory_limit); | 116 void SetStreamMemoryLimit(size_t memory_limit); |
| 114 | 117 |
| 115 bool supports_partial_append_window_trimming() const { | 118 bool supports_partial_append_window_trimming() const { |
| 116 return partial_append_window_trimming_enabled_; | 119 return partial_append_window_trimming_enabled_; |
| 117 } | 120 } |
| 118 | 121 |
| 119 void SetLiveness(Liveness liveness); | 122 void SetLiveness(Liveness liveness); |
| 120 | 123 |
| 124 MediaTrack::Id media_track_id() const { return media_track_id_; } | |
| 125 | |
| 121 private: | 126 private: |
| 122 enum State { | 127 enum State { |
| 123 UNINITIALIZED, | 128 UNINITIALIZED, |
| 124 RETURNING_DATA_FOR_READS, | 129 RETURNING_DATA_FOR_READS, |
| 125 RETURNING_ABORT_FOR_READS, | 130 RETURNING_ABORT_FOR_READS, |
| 126 SHUTDOWN, | 131 SHUTDOWN, |
| 127 }; | 132 }; |
| 128 | 133 |
| 129 // Assigns |state_| to |state| | 134 // Assigns |state_| to |state| |
| 130 void ChangeState_Locked(State state); | 135 void ChangeState_Locked(State state); |
| 131 | 136 |
| 132 void CompletePendingReadIfPossible_Locked(); | 137 void CompletePendingReadIfPossible_Locked(); |
| 133 | 138 |
| 134 // Specifies the type of the stream. | 139 // Specifies the type of the stream. |
| 135 Type type_; | 140 Type type_; |
| 136 | 141 |
| 137 Liveness liveness_; | 142 Liveness liveness_; |
| 138 | 143 |
| 139 std::unique_ptr<SourceBufferStream> stream_; | 144 std::unique_ptr<SourceBufferStream> stream_; |
| 140 | 145 |
| 146 const MediaTrack::Id media_track_id_; | |
| 147 | |
| 141 mutable base::Lock lock_; | 148 mutable base::Lock lock_; |
| 142 State state_; | 149 State state_; |
| 143 ReadCB read_cb_; | 150 ReadCB read_cb_; |
| 144 bool splice_frames_enabled_; | 151 bool splice_frames_enabled_; |
| 145 bool partial_append_window_trimming_enabled_; | 152 bool partial_append_window_trimming_enabled_; |
| 146 | 153 |
| 147 DISALLOW_IMPLICIT_CONSTRUCTORS(ChunkDemuxerStream); | 154 DISALLOW_IMPLICIT_CONSTRUCTORS(ChunkDemuxerStream); |
| 148 }; | 155 }; |
| 149 | 156 |
| 150 // Demuxer implementation that allows chunks of media data to be passed | 157 // Demuxer implementation that allows chunks of media data to be passed |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 void OnSourceInitDone(const StreamParser::InitParameters& params); | 326 void OnSourceInitDone(const StreamParser::InitParameters& params); |
| 320 | 327 |
| 321 // Creates a DemuxerStream for the specified |type|. | 328 // Creates a DemuxerStream for the specified |type|. |
| 322 // Returns a new ChunkDemuxerStream instance if a stream of this type | 329 // Returns a new ChunkDemuxerStream instance if a stream of this type |
| 323 // has not been created before. Returns NULL otherwise. | 330 // has not been created before. Returns NULL otherwise. |
| 324 ChunkDemuxerStream* CreateDemuxerStream(DemuxerStream::Type type); | 331 ChunkDemuxerStream* CreateDemuxerStream(DemuxerStream::Type type); |
| 325 | 332 |
| 326 void OnNewTextTrack(ChunkDemuxerStream* text_stream, | 333 void OnNewTextTrack(ChunkDemuxerStream* text_stream, |
| 327 const TextTrackConfig& config); | 334 const TextTrackConfig& config); |
| 328 | 335 |
| 336 void OnInitSegmentReported(const MediaTracksUpdatedCB& tracks_updated_cb, | |
|
chcunningham
2016/06/13 19:30:43
Is this being used somewhere? I think you mean to
servolk
2016/06/13 22:00:15
Done.
| |
| 337 std::unique_ptr<MediaTracks> tracks); | |
| 338 | |
| 329 // Returns true if |source_id| is valid, false otherwise. | 339 // Returns true if |source_id| is valid, false otherwise. |
| 330 bool IsValidId(const std::string& source_id) const; | 340 bool IsValidId(const std::string& source_id) const; |
| 331 | 341 |
| 332 // Increases |duration_| to |new_duration|, if |new_duration| is higher. | 342 // Increases |duration_| to |new_duration|, if |new_duration| is higher. |
| 333 void IncreaseDurationIfNecessary(base::TimeDelta new_duration); | 343 void IncreaseDurationIfNecessary(base::TimeDelta new_duration); |
| 334 | 344 |
| 335 // Decreases |duration_| if the buffered region is less than |duration_| when | 345 // Decreases |duration_| if the buffered region is less than |duration_| when |
| 336 // EndOfStream() is called. | 346 // EndOfStream() is called. |
| 337 void DecreaseDurationIfNecessary(); | 347 void DecreaseDurationIfNecessary(); |
| 338 | 348 |
| 339 // Sets |duration_| to |new_duration|, sets |user_specified_duration_| to -1 | 349 // Sets |duration_| to |new_duration|, sets |user_specified_duration_| to -1 |
| 340 // and notifies |host_|. | 350 // and notifies |host_|. |
| 341 void UpdateDuration(base::TimeDelta new_duration); | 351 void UpdateDuration(base::TimeDelta new_duration); |
| 342 | 352 |
| 343 // Returns the ranges representing the buffered data in the demuxer. | 353 // Returns the ranges representing the buffered data in the demuxer. |
| 344 Ranges<base::TimeDelta> GetBufferedRanges_Locked() const; | 354 Ranges<base::TimeDelta> GetBufferedRanges_Locked() const; |
| 345 | 355 |
| 346 // Start returning data on all DemuxerStreams. | 356 // Start returning data on all DemuxerStreams. |
| 347 void StartReturningData(); | 357 void StartReturningData(); |
| 348 | 358 |
| 349 // Aborts pending reads on all DemuxerStreams. | 359 // Aborts pending reads on all DemuxerStreams. |
| 350 void AbortPendingReads(); | 360 void AbortPendingReads(); |
| 351 | 361 |
| 352 // Completes any pending reads if it is possible to do so. | 362 // Completes any pending reads if it is possible to do so. |
| 353 void CompletePendingReadsIfPossible(); | 363 void CompletePendingReadsIfPossible(); |
| 354 | 364 |
| 355 // Seeks all SourceBufferStreams to |seek_time|. | 365 // Seeks all SourceBufferStreams to |seek_time|. |
| 356 void SeekAllSources(base::TimeDelta seek_time); | 366 void SeekAllSources(base::TimeDelta seek_time); |
| 357 | 367 |
| 368 // Generates and returns a unique media track id. | |
| 369 static MediaTrack::Id GenerateMediaTrackId(); | |
| 370 | |
| 358 // Shuts down all DemuxerStreams by calling Shutdown() on | 371 // Shuts down all DemuxerStreams by calling Shutdown() on |
| 359 // all objects in |source_state_map_|. | 372 // all objects in |source_state_map_|. |
| 360 void ShutdownAllStreams(); | 373 void ShutdownAllStreams(); |
| 361 | 374 |
| 362 mutable base::Lock lock_; | 375 mutable base::Lock lock_; |
| 363 State state_; | 376 State state_; |
| 364 bool cancel_next_seek_; | 377 bool cancel_next_seek_; |
| 365 | 378 |
| 366 DemuxerHost* host_; | 379 DemuxerHost* host_; |
| 367 base::Closure open_cb_; | 380 base::Closure open_cb_; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 413 int detected_audio_track_count_; | 426 int detected_audio_track_count_; |
| 414 int detected_video_track_count_; | 427 int detected_video_track_count_; |
| 415 int detected_text_track_count_; | 428 int detected_text_track_count_; |
| 416 | 429 |
| 417 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); | 430 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); |
| 418 }; | 431 }; |
| 419 | 432 |
| 420 } // namespace media | 433 } // namespace media |
| 421 | 434 |
| 422 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 435 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
| OLD | NEW |