| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  348  |  355  | 
|  349   // Aborts pending reads on all DemuxerStreams. |  356   // Aborts pending reads on all DemuxerStreams. | 
|  350   void AbortPendingReads(); |  357   void AbortPendingReads(); | 
|  351  |  358  | 
|  352   // Completes any pending reads if it is possible to do so. |  359   // Completes any pending reads if it is possible to do so. | 
|  353   void CompletePendingReadsIfPossible(); |  360   void CompletePendingReadsIfPossible(); | 
|  354  |  361  | 
|  355   // Seeks all SourceBufferStreams to |seek_time|. |  362   // Seeks all SourceBufferStreams to |seek_time|. | 
|  356   void SeekAllSources(base::TimeDelta seek_time); |  363   void SeekAllSources(base::TimeDelta seek_time); | 
|  357  |  364  | 
 |  365   // Generates and returns a unique media track id. | 
 |  366   static MediaTrack::Id GenerateMediaTrackId(); | 
 |  367  | 
|  358   // Shuts down all DemuxerStreams by calling Shutdown() on |  368   // Shuts down all DemuxerStreams by calling Shutdown() on | 
|  359   // all objects in |source_state_map_|. |  369   // all objects in |source_state_map_|. | 
|  360   void ShutdownAllStreams(); |  370   void ShutdownAllStreams(); | 
|  361  |  371  | 
|  362   mutable base::Lock lock_; |  372   mutable base::Lock lock_; | 
|  363   State state_; |  373   State state_; | 
|  364   bool cancel_next_seek_; |  374   bool cancel_next_seek_; | 
|  365  |  375  | 
|  366   DemuxerHost* host_; |  376   DemuxerHost* host_; | 
|  367   base::Closure open_cb_; |  377   base::Closure open_cb_; | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  413   int detected_audio_track_count_; |  423   int detected_audio_track_count_; | 
|  414   int detected_video_track_count_; |  424   int detected_video_track_count_; | 
|  415   int detected_text_track_count_; |  425   int detected_text_track_count_; | 
|  416  |  426  | 
|  417   DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); |  427   DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); | 
|  418 }; |  428 }; | 
|  419  |  429  | 
|  420 }  // namespace media |  430 }  // namespace media | 
|  421  |  431  | 
|  422 #endif  // MEDIA_FILTERS_CHUNK_DEMUXER_H_ |  432 #endif  // MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 
| OLD | NEW |