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