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 <set> | 13 #include <set> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <utility> | 15 #include <utility> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/memory_pressure_listener.h" | |
| 19 #include "base/synchronization/lock.h" | 20 #include "base/synchronization/lock.h" |
| 20 #include "media/base/byte_queue.h" | 21 #include "media/base/byte_queue.h" |
| 21 #include "media/base/demuxer.h" | 22 #include "media/base/demuxer.h" |
| 22 #include "media/base/demuxer_stream.h" | 23 #include "media/base/demuxer_stream.h" |
| 23 #include "media/base/media_tracks.h" | 24 #include "media/base/media_tracks.h" |
| 24 #include "media/base/ranges.h" | 25 #include "media/base/ranges.h" |
| 25 #include "media/base/stream_parser.h" | 26 #include "media/base/stream_parser.h" |
| 26 #include "media/filters/source_buffer_state.h" | 27 #include "media/filters/source_buffer_state.h" |
| 27 #include "media/filters/source_buffer_stream.h" | 28 #include "media/filters/source_buffer_stream.h" |
| 28 | 29 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 53 // Removes buffers between |start| and |end| according to the steps | 54 // Removes buffers between |start| and |end| according to the steps |
| 54 // in the "Coded Frame Removal Algorithm" in the Media Source | 55 // in the "Coded Frame Removal Algorithm" in the Media Source |
| 55 // Extensions Spec. | 56 // Extensions Spec. |
| 56 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sourc e.html#sourcebuffer-coded-frame-removal | 57 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sourc e.html#sourcebuffer-coded-frame-removal |
| 57 // | 58 // |
| 58 // |duration| is the current duration of the presentation. It is | 59 // |duration| is the current duration of the presentation. It is |
| 59 // required by the computation outlined in the spec. | 60 // required by the computation outlined in the spec. |
| 60 void Remove(base::TimeDelta start, base::TimeDelta end, | 61 void Remove(base::TimeDelta start, base::TimeDelta end, |
| 61 base::TimeDelta duration); | 62 base::TimeDelta duration); |
| 62 | 63 |
| 63 // If the buffer is full, attempts to try to free up space, as specified in | 64 // Runs the "Coded Frame Eviction Algorithm" from the Media Source Extensions |
| 64 // the "Coded Frame Eviction Algorithm" in the Media Source Extensions Spec. | 65 // spec: https://w3c.github.io/media-source/#sourcebuffer-coded-frame-eviction |
| 66 // |eviction_size| is an input parameter specifying how much space we want to | |
| 67 // be available in the buffer after eviction. | |
| 68 // |bytes_released| is an optional output parameter, if non-null it will | |
| 69 // indicate how much buffer space was actually released. | |
| 65 // Returns false iff buffer is still full after running eviction. | 70 // Returns false iff buffer is still full after running eviction. |
| 66 // https://w3c.github.io/media-source/#sourcebuffer-coded-frame-eviction | 71 bool EvictCodedFrames(DecodeTimestamp media_time, |
| 67 bool EvictCodedFrames(DecodeTimestamp media_time, size_t newDataSize); | 72 size_t eviction_size, |
| 73 size_t* bytes_released = nullptr); | |
| 68 | 74 |
| 69 // Signal to the stream that duration has changed to |duration|. | 75 // Signal to the stream that duration has changed to |duration|. |
| 70 void OnSetDuration(base::TimeDelta duration); | 76 void OnSetDuration(base::TimeDelta duration); |
| 71 | 77 |
| 72 // Returns the range of buffered data in this stream, capped at |duration|. | 78 // Returns the range of buffered data in this stream, capped at |duration|. |
| 73 Ranges<base::TimeDelta> GetBufferedRanges(base::TimeDelta duration) const; | 79 Ranges<base::TimeDelta> GetBufferedRanges(base::TimeDelta duration) const; |
| 74 | 80 |
| 75 // Returns the highest PTS of the buffered data. | 81 // Returns the highest PTS of the buffered data. |
| 76 // Returns base::TimeDelta() if the stream has no buffered data. | 82 // Returns base::TimeDelta() if the stream has no buffered data. |
| 77 base::TimeDelta GetHighestPresentationTimestamp() const; | 83 base::TimeDelta GetHighestPresentationTimestamp() const; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 bool enabled() const override; | 117 bool enabled() const override; |
| 112 void set_enabled(bool enabled, base::TimeDelta timestamp) override; | 118 void set_enabled(bool enabled, base::TimeDelta timestamp) override; |
| 113 void SetStreamStatusChangeCB(const StreamStatusChangeCB& cb) override; | 119 void SetStreamStatusChangeCB(const StreamStatusChangeCB& cb) override; |
| 114 | 120 |
| 115 // Returns the text track configuration. It is an error to call this method | 121 // Returns the text track configuration. It is an error to call this method |
| 116 // if type() != TEXT. | 122 // if type() != TEXT. |
| 117 TextTrackConfig text_track_config(); | 123 TextTrackConfig text_track_config(); |
| 118 | 124 |
| 119 // Sets the memory limit, in bytes, on the SourceBufferStream. | 125 // Sets the memory limit, in bytes, on the SourceBufferStream. |
| 120 void SetStreamMemoryLimit(size_t memory_limit); | 126 void SetStreamMemoryLimit(size_t memory_limit); |
| 127 size_t stream_memory_limit() const; | |
| 121 | 128 |
| 122 bool supports_partial_append_window_trimming() const { | 129 bool supports_partial_append_window_trimming() const { |
| 123 return partial_append_window_trimming_enabled_; | 130 return partial_append_window_trimming_enabled_; |
| 124 } | 131 } |
| 125 | 132 |
| 126 void SetLiveness(Liveness liveness); | 133 void SetLiveness(Liveness liveness); |
| 127 | 134 |
| 128 MediaTrack::Id media_track_id() const { return media_track_id_; } | 135 MediaTrack::Id media_track_id() const { return media_track_id_; } |
| 129 | 136 |
| 130 private: | 137 private: |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 void ResetParserState(const std::string& id, | 262 void ResetParserState(const std::string& id, |
| 256 base::TimeDelta append_window_start, | 263 base::TimeDelta append_window_start, |
| 257 base::TimeDelta append_window_end, | 264 base::TimeDelta append_window_end, |
| 258 base::TimeDelta* timestamp_offset); | 265 base::TimeDelta* timestamp_offset); |
| 259 | 266 |
| 260 // Remove buffers between |start| and |end| for the source buffer | 267 // Remove buffers between |start| and |end| for the source buffer |
| 261 // associated with |id|. | 268 // associated with |id|. |
| 262 void Remove(const std::string& id, base::TimeDelta start, | 269 void Remove(const std::string& id, base::TimeDelta start, |
| 263 base::TimeDelta end); | 270 base::TimeDelta end); |
| 264 | 271 |
| 265 // If the buffer is full, attempts to try to free up space, as specified in | 272 // Runs the "Coded Frame Eviction Algorithm" from the Media Source Extensions |
| 266 // the "Coded Frame Eviction Algorithm" in the Media Source Extensions Spec. | 273 // spec: https://w3c.github.io/media-source/#sourcebuffer-coded-frame-eviction |
| 274 // |eviction_size| is an input parameter specifying how much space we want to | |
| 275 // be available in the buffer after eviction. | |
| 276 // |bytes_released| is an optional output parameter, if non-null it will | |
|
wolenetz
2017/01/12 22:21:49
Where is this param decl'ed?
servolk
2017/01/12 22:58:41
Oops, I've copy/pasted this comment from ChunkDemu
| |
| 277 // indicate how much buffer space was actually released. | |
| 267 // Returns false iff buffer is still full after running eviction. | 278 // Returns false iff buffer is still full after running eviction. |
| 268 // https://w3c.github.io/media-source/#sourcebuffer-coded-frame-eviction | |
| 269 bool EvictCodedFrames(const std::string& id, | 279 bool EvictCodedFrames(const std::string& id, |
| 270 base::TimeDelta currentMediaTime, | 280 base::TimeDelta currentMediaTime, |
| 271 size_t newDataSize); | 281 size_t eviction_size); |
| 282 | |
| 283 void OnMemoryPressure( | |
| 284 base::TimeDelta currentMediaTime, | |
| 285 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); | |
| 272 | 286 |
| 273 // Returns the current presentation duration. | 287 // Returns the current presentation duration. |
| 274 double GetDuration(); | 288 double GetDuration(); |
| 275 double GetDuration_Locked(); | 289 double GetDuration_Locked(); |
| 276 | 290 |
| 277 // Notifies the demuxer that the duration of the media has changed to | 291 // Notifies the demuxer that the duration of the media has changed to |
| 278 // |duration|. | 292 // |duration|. |
| 279 void SetDuration(double duration); | 293 void SetDuration(double duration); |
| 280 | 294 |
| 281 // Returns true if the source buffer associated with |id| is currently parsing | 295 // Returns true if the source buffer associated with |id| is currently parsing |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 int detected_text_track_count_; | 455 int detected_text_track_count_; |
| 442 | 456 |
| 443 std::map<MediaTrack::Id, DemuxerStream*> track_id_to_demux_stream_map_; | 457 std::map<MediaTrack::Id, DemuxerStream*> track_id_to_demux_stream_map_; |
| 444 | 458 |
| 445 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); | 459 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxer); |
| 446 }; | 460 }; |
| 447 | 461 |
| 448 } // namespace media | 462 } // namespace media |
| 449 | 463 |
| 450 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ | 464 #endif // MEDIA_FILTERS_CHUNK_DEMUXER_H_ |
| OLD | NEW |