| 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 <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
| 15 #include "media/base/byte_queue.h" | 15 #include "media/base/byte_queue.h" |
| 16 #include "media/base/demuxer.h" | 16 #include "media/base/demuxer.h" |
| 17 #include "media/base/demuxer_stream.h" |
| 17 #include "media/base/ranges.h" | 18 #include "media/base/ranges.h" |
| 18 #include "media/base/stream_parser.h" | 19 #include "media/base/stream_parser.h" |
| 19 #include "media/filters/source_buffer_stream.h" | 20 #include "media/filters/source_buffer_stream.h" |
| 20 | 21 |
| 21 namespace media { | 22 namespace media { |
| 22 | 23 |
| 23 class FFmpegURLProtocol; | 24 class FFmpegURLProtocol; |
| 24 class SourceState; | 25 class SourceState; |
| 25 | 26 |
| 26 class MEDIA_EXPORT ChunkDemuxerStream : public DemuxerStream { | 27 class MEDIA_EXPORT ChunkDemuxerStream : public DemuxerStream { |
| 27 public: | 28 public: |
| 28 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; | 29 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; |
| 29 | 30 |
| 30 explicit ChunkDemuxerStream(Type type, bool splice_frames_enabled); | 31 ChunkDemuxerStream(Type type, Liveness liveness, bool splice_frames_enabled); |
| 31 ~ChunkDemuxerStream() override; | 32 ~ChunkDemuxerStream() override; |
| 32 | 33 |
| 33 // ChunkDemuxerStream control methods. | 34 // ChunkDemuxerStream control methods. |
| 34 void StartReturningData(); | 35 void StartReturningData(); |
| 35 void AbortReads(); | 36 void AbortReads(); |
| 36 void CompletePendingReadIfPossible(); | 37 void CompletePendingReadIfPossible(); |
| 37 void Shutdown(); | 38 void Shutdown(); |
| 38 | 39 |
| 39 // SourceBufferStream manipulation methods. | 40 // SourceBufferStream manipulation methods. |
| 40 void Seek(base::TimeDelta time); | 41 void Seek(base::TimeDelta time); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // Returns false if the new config should trigger an error. | 75 // Returns false if the new config should trigger an error. |
| 75 bool UpdateAudioConfig(const AudioDecoderConfig& config, const LogCB& log_cb); | 76 bool UpdateAudioConfig(const AudioDecoderConfig& config, const LogCB& log_cb); |
| 76 bool UpdateVideoConfig(const VideoDecoderConfig& config, const LogCB& log_cb); | 77 bool UpdateVideoConfig(const VideoDecoderConfig& config, const LogCB& log_cb); |
| 77 void UpdateTextConfig(const TextTrackConfig& config, const LogCB& log_cb); | 78 void UpdateTextConfig(const TextTrackConfig& config, const LogCB& log_cb); |
| 78 | 79 |
| 79 void MarkEndOfStream(); | 80 void MarkEndOfStream(); |
| 80 void UnmarkEndOfStream(); | 81 void UnmarkEndOfStream(); |
| 81 | 82 |
| 82 // DemuxerStream methods. | 83 // DemuxerStream methods. |
| 83 void Read(const ReadCB& read_cb) override; | 84 void Read(const ReadCB& read_cb) override; |
| 84 Type type() override; | 85 Type type() const override; |
| 86 Liveness liveness() const override; |
| 85 AudioDecoderConfig audio_decoder_config() override; | 87 AudioDecoderConfig audio_decoder_config() override; |
| 86 VideoDecoderConfig video_decoder_config() override; | 88 VideoDecoderConfig video_decoder_config() override; |
| 87 bool SupportsConfigChanges() override; | 89 bool SupportsConfigChanges() override; |
| 88 VideoRotation video_rotation() override; | 90 VideoRotation video_rotation() override; |
| 89 | 91 |
| 90 // Returns the text track configuration. It is an error to call this method | 92 // Returns the text track configuration. It is an error to call this method |
| 91 // if type() != TEXT. | 93 // if type() != TEXT. |
| 92 TextTrackConfig text_track_config(); | 94 TextTrackConfig text_track_config(); |
| 93 | 95 |
| 94 // Sets the memory limit, in bytes, on the SourceBufferStream. | 96 // Sets the memory limit, in bytes, on the SourceBufferStream. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 109 }; | 111 }; |
| 110 | 112 |
| 111 // Assigns |state_| to |state| | 113 // Assigns |state_| to |state| |
| 112 void ChangeState_Locked(State state); | 114 void ChangeState_Locked(State state); |
| 113 | 115 |
| 114 void CompletePendingReadIfPossible_Locked(); | 116 void CompletePendingReadIfPossible_Locked(); |
| 115 | 117 |
| 116 // Specifies the type of the stream. | 118 // Specifies the type of the stream. |
| 117 Type type_; | 119 Type type_; |
| 118 | 120 |
| 121 Liveness liveness_; |
| 122 |
| 119 scoped_ptr<SourceBufferStream> stream_; | 123 scoped_ptr<SourceBufferStream> stream_; |
| 120 | 124 |
| 121 mutable base::Lock lock_; | 125 mutable base::Lock lock_; |
| 122 State state_; | 126 State state_; |
| 123 ReadCB read_cb_; | 127 ReadCB read_cb_; |
| 124 bool splice_frames_enabled_; | 128 bool splice_frames_enabled_; |
| 125 bool partial_append_window_trimming_enabled_; | 129 bool partial_append_window_trimming_enabled_; |
| 126 | 130 |
| 127 DISALLOW_IMPLICIT_CONSTRUCTORS(ChunkDemuxerStream); | 131 DISALLOW_IMPLICIT_CONSTRUCTORS(ChunkDemuxerStream); |
| 128 }; | 132 }; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 158 | 162 |
| 159 // Demuxer implementation. | 163 // Demuxer implementation. |
| 160 void Initialize(DemuxerHost* host, | 164 void Initialize(DemuxerHost* host, |
| 161 const PipelineStatusCB& cb, | 165 const PipelineStatusCB& cb, |
| 162 bool enable_text_tracks) override; | 166 bool enable_text_tracks) override; |
| 163 void Stop() override; | 167 void Stop() override; |
| 164 void Seek(base::TimeDelta time, const PipelineStatusCB& cb) override; | 168 void Seek(base::TimeDelta time, const PipelineStatusCB& cb) override; |
| 165 base::Time GetTimelineOffset() const override; | 169 base::Time GetTimelineOffset() const override; |
| 166 DemuxerStream* GetStream(DemuxerStream::Type type) override; | 170 DemuxerStream* GetStream(DemuxerStream::Type type) override; |
| 167 base::TimeDelta GetStartTime() const override; | 171 base::TimeDelta GetStartTime() const override; |
| 168 Liveness GetLiveness() const override; | |
| 169 | 172 |
| 170 // Methods used by an external object to control this demuxer. | 173 // Methods used by an external object to control this demuxer. |
| 171 // | 174 // |
| 172 // Indicates that a new Seek() call is on its way. Any pending Reads on the | 175 // Indicates that a new Seek() call is on its way. Any pending Reads on the |
| 173 // DemuxerStream objects should be aborted immediately inside this call and | 176 // DemuxerStream objects should be aborted immediately inside this call and |
| 174 // future Read calls should return kAborted until the Seek() call occurs. | 177 // future Read calls should return kAborted until the Seek() call occurs. |
| 175 // This method MUST ALWAYS be called before Seek() is called to signal that | 178 // This method MUST ALWAYS be called before Seek() is called to signal that |
| 176 // the next Seek() call represents the seek point we actually want to return | 179 // the next Seek() call represents the seek point we actually want to return |
| 177 // data for. | 180 // data for. |
| 178 // |seek_time| - The presentation timestamp for the seek that triggered this | 181 // |seek_time| - The presentation timestamp for the seek that triggered this |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 base::TimeDelta duration_; | 375 base::TimeDelta duration_; |
| 373 | 376 |
| 374 // The duration passed to the last SetDuration(). If | 377 // The duration passed to the last SetDuration(). If |
| 375 // SetDuration() is never called or an AppendData() call or | 378 // SetDuration() is never called or an AppendData() call or |
| 376 // a EndOfStream() call changes |duration_|, then this | 379 // a EndOfStream() call changes |duration_|, then this |
| 377 // variable is set to < 0 to indicate that the |duration_| represents | 380 // variable is set to < 0 to indicate that the |duration_| represents |
| 378 // the actual duration instead of a user specified value. | 381 // the actual duration instead of a user specified value. |
| 379 double user_specified_duration_; | 382 double user_specified_duration_; |
| 380 | 383 |
| 381 base::Time timeline_offset_; | 384 base::Time timeline_offset_; |
| 382 Liveness liveness_; | 385 DemuxerStream::Liveness liveness_; |
| 383 | 386 |
| 384 typedef std::map<std::string, SourceState*> SourceStateMap; | 387 typedef std::map<std::string, SourceState*> SourceStateMap; |
| 385 SourceStateMap source_state_map_; | 388 SourceStateMap source_state_map_; |
| 386 | 389 |
| 387 // Used to ensure that (1) config data matches the type and codec provided in | 390 // Used to ensure that (1) config data matches the type and codec provided in |
| 388 // AddId(), (2) only 1 audio and 1 video sources are added, and (3) ids may be | 391 // AddId(), (2) only 1 audio and 1 video sources are added, and (3) ids may be |
| 389 // removed with RemoveID() but can not be re-added (yet). | 392 // removed with RemoveID() but can not be re-added (yet). |
| 390 std::string source_id_audio_; | 393 std::string source_id_audio_; |
| 391 std::string source_id_video_; | 394 std::string source_id_video_; |
| 392 | 395 |
| 393 // Indicates that splice frame generation is enabled. | 396 // Indicates that splice frame generation is enabled. |
| 394 const bool splice_frames_enabled_; | 397 const bool splice_frames_enabled_; |
| 395 | 398 |
| 396 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); | 399 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); |
| 397 }; | 400 }; |
| 398 | 401 |
| 399 } // namespace media | 402 } // namespace media |
| 400 | 403 |
| 401 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 404 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
| OLD | NEW |