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 13 matching lines...) Expand all Loading... |
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(ChunkDemuxerStream*, const TextTrackConfig&)> | 31 typedef base::Callback<void(ChunkDemuxerStream*, const TextTrackConfig&)> |
32 NewTextTrackCB; | 32 NewTextTrackCB; |
33 | 33 |
34 MediaSourceState(scoped_ptr<StreamParser> stream_parser, | 34 MediaSourceState(std::unique_ptr<StreamParser> stream_parser, |
35 scoped_ptr<FrameProcessor> frame_processor, | 35 std::unique_ptr<FrameProcessor> frame_processor, |
36 const CreateDemuxerStreamCB& create_demuxer_stream_cb, | 36 const CreateDemuxerStreamCB& create_demuxer_stream_cb, |
37 const scoped_refptr<MediaLog>& media_log); | 37 const scoped_refptr<MediaLog>& media_log); |
38 | 38 |
39 ~MediaSourceState(); | 39 ~MediaSourceState(); |
40 | 40 |
41 void Init(const StreamParser::InitCB& init_cb, | 41 void Init(const StreamParser::InitCB& init_cb, |
42 bool allow_audio, | 42 bool allow_audio, |
43 bool allow_video, | 43 bool allow_video, |
44 const StreamParser::EncryptedMediaInitDataCB& | 44 const StreamParser::EncryptedMediaInitDataCB& |
45 encrypted_media_init_data_cb, | 45 encrypted_media_init_data_cb, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 PENDING_PARSER_INIT, | 125 PENDING_PARSER_INIT, |
126 PARSER_INITIALIZED | 126 PARSER_INITIALIZED |
127 }; | 127 }; |
128 | 128 |
129 // Called by the |stream_parser_| when a new initialization segment is | 129 // Called by the |stream_parser_| when a new initialization segment is |
130 // encountered. | 130 // encountered. |
131 // Returns true on a successful call. Returns false if an error occurred while | 131 // Returns true on a successful call. Returns false if an error occurred while |
132 // processing decoder configurations. | 132 // processing decoder configurations. |
133 bool OnNewConfigs(bool allow_audio, | 133 bool OnNewConfigs(bool allow_audio, |
134 bool allow_video, | 134 bool allow_video, |
135 scoped_ptr<MediaTracks> tracks, | 135 std::unique_ptr<MediaTracks> tracks, |
136 const StreamParser::TextTrackConfigMap& text_configs); | 136 const StreamParser::TextTrackConfigMap& text_configs); |
137 | 137 |
138 // Called by the |stream_parser_| at the beginning of a new media segment. | 138 // Called by the |stream_parser_| at the beginning of a new media segment. |
139 void OnNewMediaSegment(); | 139 void OnNewMediaSegment(); |
140 | 140 |
141 // Called by the |stream_parser_| at the end of a media segment. | 141 // Called by the |stream_parser_| at the end of a media segment. |
142 void OnEndOfMediaSegment(); | 142 void OnEndOfMediaSegment(); |
143 | 143 |
144 // Called by the |stream_parser_| when new buffers have been parsed. | 144 // Called by the |stream_parser_| when new buffers have been parsed. |
145 // It processes the new buffers using |frame_processor_|, which includes | 145 // It processes the new buffers using |frame_processor_|, which includes |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 // Keeps track of whether a media segment is being parsed. | 181 // Keeps track of whether a media segment is being parsed. |
182 bool parsing_media_segment_; | 182 bool parsing_media_segment_; |
183 | 183 |
184 // Valid only while |parsing_media_segment_| is true. These flags enable | 184 // Valid only while |parsing_media_segment_| is true. These flags enable |
185 // warning when at least one frame for each A/V track is not in a parsed media | 185 // warning when at least one frame for each A/V track is not in a parsed media |
186 // segment. | 186 // segment. |
187 bool media_segment_contained_audio_frame_; | 187 bool media_segment_contained_audio_frame_; |
188 bool media_segment_contained_video_frame_; | 188 bool media_segment_contained_video_frame_; |
189 | 189 |
190 // The object used to parse appended data. | 190 // The object used to parse appended data. |
191 scoped_ptr<StreamParser> stream_parser_; | 191 std::unique_ptr<StreamParser> stream_parser_; |
192 | 192 |
193 scoped_ptr<MediaTracks> media_tracks_; | 193 std::unique_ptr<MediaTracks> media_tracks_; |
194 | 194 |
195 ChunkDemuxerStream* audio_; // Not owned by |this|. | 195 ChunkDemuxerStream* audio_; // Not owned by |this|. |
196 ChunkDemuxerStream* video_; // Not owned by |this|. | 196 ChunkDemuxerStream* video_; // Not owned by |this|. |
197 | 197 |
198 typedef std::map<StreamParser::TrackId, ChunkDemuxerStream*> TextStreamMap; | 198 typedef std::map<StreamParser::TrackId, ChunkDemuxerStream*> TextStreamMap; |
199 TextStreamMap text_stream_map_; // |this| owns the map's stream pointers. | 199 TextStreamMap text_stream_map_; // |this| owns the map's stream pointers. |
200 | 200 |
201 scoped_ptr<FrameProcessor> frame_processor_; | 201 std::unique_ptr<FrameProcessor> frame_processor_; |
202 scoped_refptr<MediaLog> media_log_; | 202 scoped_refptr<MediaLog> media_log_; |
203 StreamParser::InitCB init_cb_; | 203 StreamParser::InitCB init_cb_; |
204 | 204 |
205 State state_; | 205 State state_; |
206 | 206 |
207 // During Append(), OnNewConfigs() will trigger the initialization segment | 207 // During Append(), OnNewConfigs() will trigger the initialization segment |
208 // received algorithm. Note, the MSE spec explicitly disallows this algorithm | 208 // received algorithm. Note, the MSE spec explicitly disallows this algorithm |
209 // during an Abort(), since Abort() is allowed only to emit coded frames, and | 209 // during an Abort(), since Abort() is allowed only to emit coded frames, and |
210 // only if the parser is PARSING_MEDIA_SEGMENT (not an INIT segment). So we | 210 // only if the parser is PARSING_MEDIA_SEGMENT (not an INIT segment). So we |
211 // also have a flag here that indicates if Append is in progress and we can | 211 // also have a flag here that indicates if Append is in progress and we can |
212 // invoke this callback. | 212 // invoke this callback. |
213 Demuxer::MediaTracksUpdatedCB init_segment_received_cb_; | 213 Demuxer::MediaTracksUpdatedCB init_segment_received_cb_; |
214 bool append_in_progress_ = false; | 214 bool append_in_progress_ = false; |
215 | 215 |
216 // Indicates that timestampOffset should be updated automatically during | 216 // Indicates that timestampOffset should be updated automatically during |
217 // OnNewBuffers() based on the earliest end timestamp of the buffers provided. | 217 // OnNewBuffers() based on the earliest end timestamp of the buffers provided. |
218 // TODO(wolenetz): Refactor this function while integrating April 29, 2014 | 218 // TODO(wolenetz): Refactor this function while integrating April 29, 2014 |
219 // changes to MSE spec. See http://crbug.com/371499. | 219 // changes to MSE spec. See http://crbug.com/371499. |
220 bool auto_update_timestamp_offset_; | 220 bool auto_update_timestamp_offset_; |
221 | 221 |
222 DISALLOW_COPY_AND_ASSIGN(MediaSourceState); | 222 DISALLOW_COPY_AND_ASSIGN(MediaSourceState); |
223 }; | 223 }; |
224 | 224 |
225 } // namespace media | 225 } // namespace media |
226 | 226 |
227 #endif // MEDIA_FILTERS_MEDIA_SOURCE_STATE_H_ | 227 #endif // MEDIA_FILTERS_MEDIA_SOURCE_STATE_H_ |
OLD | NEW |