OLD | NEW |
---|---|
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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_MEDIA_SOURCE_STATE_H_ | 5 #ifndef MEDIA_FILTERS_MEDIA_SOURCE_STATE_H_ |
6 #define MEDIA_FILTERS_MEDIA_SOURCE_STATE_H_ | 6 #define MEDIA_FILTERS_MEDIA_SOURCE_STATE_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 class ChunkDemuxerStream; | 21 class ChunkDemuxerStream; |
22 class FrameProcessor; | 22 class FrameProcessor; |
23 | 23 |
24 // Contains state belonging to a source id. | 24 // Contains state belonging to a source id. |
25 class MEDIA_EXPORT MediaSourceState { | 25 class MEDIA_EXPORT MediaSourceState { |
26 public: | 26 public: |
27 // Callback signature used to create ChunkDemuxerStreams. | 27 // Callback signature used to create ChunkDemuxerStreams. |
28 typedef base::Callback<ChunkDemuxerStream*(DemuxerStream::Type)> | 28 typedef base::Callback<ChunkDemuxerStream*(DemuxerStream::Type)> |
29 CreateDemuxerStreamCB; | 29 CreateDemuxerStreamCB; |
30 | 30 |
31 typedef base::Callback<void(const MediaTracks&)> InitSegmentReceivedCB; | |
32 | |
33 typedef base::Callback<void(ChunkDemuxerStream*, const TextTrackConfig&)> | 31 typedef base::Callback<void(ChunkDemuxerStream*, const TextTrackConfig&)> |
34 NewTextTrackCB; | 32 NewTextTrackCB; |
35 | 33 |
36 MediaSourceState(scoped_ptr<StreamParser> stream_parser, | 34 MediaSourceState(scoped_ptr<StreamParser> stream_parser, |
37 scoped_ptr<FrameProcessor> frame_processor, | 35 scoped_ptr<FrameProcessor> frame_processor, |
38 const CreateDemuxerStreamCB& create_demuxer_stream_cb, | 36 const CreateDemuxerStreamCB& create_demuxer_stream_cb, |
39 const scoped_refptr<MediaLog>& media_log); | 37 const scoped_refptr<MediaLog>& media_log); |
40 | 38 |
41 ~MediaSourceState(); | 39 ~MediaSourceState(); |
42 | 40 |
43 void Init(const StreamParser::InitCB& init_cb, | 41 void Init(const StreamParser::InitCB& init_cb, |
44 bool allow_audio, | 42 bool allow_audio, |
45 bool allow_video, | 43 bool allow_video, |
46 const StreamParser::EncryptedMediaInitDataCB& | 44 const StreamParser::EncryptedMediaInitDataCB& |
47 encrypted_media_init_data_cb, | 45 encrypted_media_init_data_cb, |
48 const NewTextTrackCB& new_text_track_cb); | 46 const NewTextTrackCB& new_text_track_cb); |
49 | 47 |
50 // Appends new data to the StreamParser. | 48 // Appends new data to the StreamParser. |
51 // Returns true if the data was successfully appended. Returns false if an | 49 // Returns true if the data was successfully appended. Returns false if an |
52 // error occurred. |*timestamp_offset| is used and possibly updated by the | 50 // error occurred. |*timestamp_offset| is used and possibly updated by the |
53 // append. |append_window_start| and |append_window_end| correspond to the MSE | 51 // append. |append_window_start| and |append_window_end| correspond to the MSE |
54 // spec's similarly named source buffer attributes that are used in coded | 52 // spec's similarly named source buffer attributes that are used in coded |
55 // frame processing. |init_segment_received_cb| is run for each new fully | 53 // frame processing. |
56 // parsed initialization segment. | |
57 bool Append(const uint8_t* data, | 54 bool Append(const uint8_t* data, |
58 size_t length, | 55 size_t length, |
59 TimeDelta append_window_start, | 56 TimeDelta append_window_start, |
60 TimeDelta append_window_end, | 57 TimeDelta append_window_end, |
61 TimeDelta* timestamp_offset, | 58 TimeDelta* timestamp_offset); |
62 const InitSegmentReceivedCB& init_segment_received_cb); | |
63 | 59 |
64 // Aborts the current append sequence and resets the parser. | 60 // Aborts the current append sequence and resets the parser. |
65 void ResetParserState(TimeDelta append_window_start, | 61 void ResetParserState(TimeDelta append_window_start, |
66 TimeDelta append_window_end, | 62 TimeDelta append_window_end, |
67 TimeDelta* timestamp_offset); | 63 TimeDelta* timestamp_offset); |
68 | 64 |
69 // Calls Remove(|start|, |end|, |duration|) on all | 65 // Calls Remove(|start|, |end|, |duration|) on all |
70 // ChunkDemuxerStreams managed by this object. | 66 // ChunkDemuxerStreams managed by this object. |
71 void Remove(TimeDelta start, TimeDelta end, TimeDelta duration); | 67 void Remove(TimeDelta start, TimeDelta end, TimeDelta duration); |
72 | 68 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 // |memory_limit| is the maximum number of bytes each stream of type |type| | 106 // |memory_limit| is the maximum number of bytes each stream of type |type| |
111 // is allowed to hold in its buffer. | 107 // is allowed to hold in its buffer. |
112 void SetMemoryLimits(DemuxerStream::Type type, size_t memory_limit); | 108 void SetMemoryLimits(DemuxerStream::Type type, size_t memory_limit); |
113 bool IsSeekWaitingForData() const; | 109 bool IsSeekWaitingForData() const; |
114 | 110 |
115 typedef std::list<Ranges<TimeDelta>> RangesList; | 111 typedef std::list<Ranges<TimeDelta>> RangesList; |
116 static Ranges<TimeDelta> ComputeRangesIntersection( | 112 static Ranges<TimeDelta> ComputeRangesIntersection( |
117 const RangesList& activeRanges, | 113 const RangesList& activeRanges, |
118 bool ended); | 114 bool ended); |
119 | 115 |
116 void SetTracksWatcher(const Demuxer::MediaTracksUpdatedCB& tracks_updated_cb); | |
wolenetz
2016/03/05 01:47:43
nit: document what this means; when it should be c
servolk
2016/03/05 01:56:19
Will do, but at this point there are three other C
| |
117 | |
120 private: | 118 private: |
121 // Called by the |stream_parser_| when a new initialization segment is | 119 // Called by the |stream_parser_| when a new initialization segment is |
122 // encountered. | 120 // encountered. |
123 // Returns true on a successful call. Returns false if an error occurred while | 121 // Returns true on a successful call. Returns false if an error occurred while |
124 // processing decoder configurations. | 122 // processing decoder configurations. |
125 bool OnNewConfigs(bool allow_audio, | 123 bool OnNewConfigs(bool allow_audio, |
126 bool allow_video, | 124 bool allow_video, |
127 scoped_ptr<MediaTracks> tracks, | 125 scoped_ptr<MediaTracks> tracks, |
128 const StreamParser::TextTrackConfigMap& text_configs); | 126 const StreamParser::TextTrackConfigMap& text_configs); |
129 | 127 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 ChunkDemuxerStream* video_; // Not owned by |this|. | 186 ChunkDemuxerStream* video_; // Not owned by |this|. |
189 | 187 |
190 typedef std::map<StreamParser::TrackId, ChunkDemuxerStream*> TextStreamMap; | 188 typedef std::map<StreamParser::TrackId, ChunkDemuxerStream*> TextStreamMap; |
191 TextStreamMap text_stream_map_; // |this| owns the map's stream pointers. | 189 TextStreamMap text_stream_map_; // |this| owns the map's stream pointers. |
192 | 190 |
193 scoped_ptr<FrameProcessor> frame_processor_; | 191 scoped_ptr<FrameProcessor> frame_processor_; |
194 scoped_refptr<MediaLog> media_log_; | 192 scoped_refptr<MediaLog> media_log_; |
195 StreamParser::InitCB init_cb_; | 193 StreamParser::InitCB init_cb_; |
196 | 194 |
197 // During Append(), OnNewConfigs() will trigger the initialization segment | 195 // During Append(), OnNewConfigs() will trigger the initialization segment |
198 // received algorithm. This callback is only non-NULL during the lifetime of | 196 // received algorithm. Note, the MSE spec explicitly disallows this algorithm |
199 // an Append() call. Note, the MSE spec explicitly disallows this algorithm | |
200 // during an Abort(), since Abort() is allowed only to emit coded frames, and | 197 // during an Abort(), since Abort() is allowed only to emit coded frames, and |
201 // only if the parser is PARSING_MEDIA_SEGMENT (not an INIT segment). | 198 // only if the parser is PARSING_MEDIA_SEGMENT (not an INIT segment). So we |
202 InitSegmentReceivedCB init_segment_received_cb_; | 199 // also have a flag here that indicates if Append is in progress and we can |
200 // invoke this callback. | |
201 Demuxer::MediaTracksUpdatedCB init_segment_received_cb_; | |
202 bool append_in_progress_ = false; | |
wolenetz
2016/03/05 01:47:43
this flag and associated comment and usage seem un
servolk
2016/03/05 01:56:19
Done.
| |
203 | 203 |
204 // Indicates that timestampOffset should be updated automatically during | 204 // Indicates that timestampOffset should be updated automatically during |
205 // OnNewBuffers() based on the earliest end timestamp of the buffers provided. | 205 // OnNewBuffers() based on the earliest end timestamp of the buffers provided. |
206 // TODO(wolenetz): Refactor this function while integrating April 29, 2014 | 206 // TODO(wolenetz): Refactor this function while integrating April 29, 2014 |
207 // changes to MSE spec. See http://crbug.com/371499. | 207 // changes to MSE spec. See http://crbug.com/371499. |
208 bool auto_update_timestamp_offset_; | 208 bool auto_update_timestamp_offset_; |
209 | 209 |
210 DISALLOW_COPY_AND_ASSIGN(MediaSourceState); | 210 DISALLOW_COPY_AND_ASSIGN(MediaSourceState); |
211 }; | 211 }; |
212 | 212 |
213 } // namespace media | 213 } // namespace media |
214 | 214 |
215 #endif // MEDIA_FILTERS_MEDIA_SOURCE_STATE_H_ | 215 #endif // MEDIA_FILTERS_MEDIA_SOURCE_STATE_H_ |
OLD | NEW |