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 <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "media/base/byte_queue.h" | 14 #include "media/base/byte_queue.h" |
| 15 #include "media/base/demuxer.h" | 15 #include "media/base/demuxer.h" |
| 16 #include "media/base/ranges.h" | 16 #include "media/base/ranges.h" |
| 17 #include "media/base/stream_parser.h" | 17 #include "media/base/stream_parser.h" |
| 18 #include "media/filters/source_buffer_stream.h" | 18 #include "media/filters/source_buffer_stream.h" |
| 19 | 19 |
| 20 namespace media { | 20 namespace media { |
| 21 | 21 |
| 22 class ChunkDemuxerStream; | 22 class ChunkDemuxerStream; |
| 23 class SourceState; | |
|
scherkus (not reviewing)
2013/04/05 18:58:26
A->Z
acolwell GONE FROM CHROMIUM
2013/04/05 19:14:37
Done.
| |
| 23 class FFmpegURLProtocol; | 24 class FFmpegURLProtocol; |
| 24 | 25 |
| 25 // Demuxer implementation that allows chunks of media data to be passed | 26 // Demuxer implementation that allows chunks of media data to be passed |
| 26 // from JavaScript to the media stack. | 27 // from JavaScript to the media stack. |
| 27 class MEDIA_EXPORT ChunkDemuxer : public Demuxer { | 28 class MEDIA_EXPORT ChunkDemuxer : public Demuxer { |
| 28 public: | 29 public: |
| 29 enum Status { | 30 enum Status { |
| 30 kOk, // ID added w/o error. | 31 kOk, // ID added w/o error. |
| 31 kNotSupported, // Type specified is not supported. | 32 kNotSupported, // Type specified is not supported. |
| 32 kReachedIdLimit, // Reached ID limit. We can't handle any more IDs. | 33 kReachedIdLimit, // Reached ID limit. We can't handle any more IDs. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 // data. | 123 // data. |
| 123 void ReportError_Locked(PipelineStatus error); | 124 void ReportError_Locked(PipelineStatus error); |
| 124 | 125 |
| 125 // Returns true if any stream has seeked to a time without buffered data. | 126 // Returns true if any stream has seeked to a time without buffered data. |
| 126 bool IsSeekPending_Locked() const; | 127 bool IsSeekPending_Locked() const; |
| 127 | 128 |
| 128 // Returns true if all streams can successfully call EndOfStream, | 129 // Returns true if all streams can successfully call EndOfStream, |
| 129 // false if any can not. | 130 // false if any can not. |
| 130 bool CanEndOfStream_Locked() const; | 131 bool CanEndOfStream_Locked() const; |
| 131 | 132 |
| 132 // StreamParser callbacks. | 133 // SourceState callbacks. |
| 133 void OnStreamParserInitDone(bool success, base::TimeDelta duration); | 134 void OnSourceInitDone(bool success, base::TimeDelta duration); |
| 134 bool OnNewConfigs(bool has_audio, bool has_video, | 135 bool OnNewConfigs(bool has_audio, bool has_video, |
| 135 const AudioDecoderConfig& audio_config, | 136 const AudioDecoderConfig& audio_config, |
| 136 const VideoDecoderConfig& video_config); | 137 const VideoDecoderConfig& video_config); |
| 137 bool OnAudioBuffers(const StreamParser::BufferQueue& buffers); | 138 bool OnAudioBuffers(const StreamParser::BufferQueue& buffers); |
| 138 bool OnVideoBuffers(const StreamParser::BufferQueue& buffers); | 139 bool OnVideoBuffers(const StreamParser::BufferQueue& buffers); |
| 139 bool OnNeedKey(const std::string& type, | 140 bool OnNeedKey(const std::string& type, |
| 140 scoped_array<uint8> init_data, | 141 scoped_array<uint8> init_data, |
| 141 int init_data_size); | 142 int init_data_size); |
| 142 void OnNewMediaSegment(const std::string& source_id, | 143 void OnNewMediaSegment(const std::string& source_id, |
| 143 base::TimeDelta start_timestamp); | 144 base::TimeDelta start_timestamp); |
| 144 void OnEndOfMediaSegment(const std::string& source_id); | |
| 145 | 145 |
| 146 // Computes the intersection between the video & audio | 146 // Computes the intersection between the video & audio |
| 147 // buffered ranges. | 147 // buffered ranges. |
| 148 Ranges<base::TimeDelta> ComputeIntersection() const; | 148 Ranges<base::TimeDelta> ComputeIntersection() const; |
| 149 | 149 |
| 150 // Applies |time_offset| to the timestamps of |buffers|. | 150 // Applies |time_offset| to the timestamps of |buffers|. |
| 151 void AdjustBufferTimestamps(const StreamParser::BufferQueue& buffers, | 151 void AdjustBufferTimestamps(const StreamParser::BufferQueue& buffers, |
| 152 base::TimeDelta timestamp_offset); | 152 base::TimeDelta timestamp_offset); |
| 153 | 153 |
| 154 // Returns true if |source_id| is valid, false otherwise. | 154 // Returns true if |source_id| is valid, false otherwise. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 | 190 |
| 191 base::TimeDelta duration_; | 191 base::TimeDelta duration_; |
| 192 | 192 |
| 193 // The duration passed to the last SetDuration(). If | 193 // The duration passed to the last SetDuration(). If |
| 194 // SetDuration() is never called or an AppendData() call or | 194 // SetDuration() is never called or an AppendData() call or |
| 195 // a EndOfStream() call changes |duration_|, then this | 195 // a EndOfStream() call changes |duration_|, then this |
| 196 // variable is set to < 0 to indicate that the |duration_| represents | 196 // variable is set to < 0 to indicate that the |duration_| represents |
| 197 // the actual duration instead of a user specified value. | 197 // the actual duration instead of a user specified value. |
| 198 double user_specified_duration_; | 198 double user_specified_duration_; |
| 199 | 199 |
| 200 typedef std::map<std::string, StreamParser*> StreamParserMap; | 200 typedef std::map<std::string, SourceState*> SourceStateMap; |
| 201 StreamParserMap stream_parser_map_; | 201 SourceStateMap source_state_map_; |
| 202 | |
| 203 // Contains state belonging to a source id. | |
| 204 struct SourceInfo { | |
| 205 base::TimeDelta timestamp_offset; | |
| 206 bool can_update_offset; | |
| 207 }; | |
| 208 typedef std::map<std::string, SourceInfo> SourceInfoMap; | |
| 209 SourceInfoMap source_info_map_; | |
| 210 | 202 |
| 211 // Used to ensure that (1) config data matches the type and codec provided in | 203 // Used to ensure that (1) config data matches the type and codec provided in |
| 212 // AddId(), (2) only 1 audio and 1 video sources are added, and (3) ids may be | 204 // AddId(), (2) only 1 audio and 1 video sources are added, and (3) ids may be |
| 213 // removed with RemoveID() but can not be re-added (yet). | 205 // removed with RemoveID() but can not be re-added (yet). |
| 214 std::string source_id_audio_; | 206 std::string source_id_audio_; |
| 215 std::string source_id_video_; | 207 std::string source_id_video_; |
| 216 | 208 |
| 217 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); | 209 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); |
| 218 }; | 210 }; |
| 219 | 211 |
| 220 } // namespace media | 212 } // namespace media |
| 221 | 213 |
| 222 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 214 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
| OLD | NEW |