Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(424)

Side by Side Diff: media/filters/media_source_state.h

Issue 1843823003: MSE: Protect better against out-of-sequence parser callbacks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_597447_1
Patch Set: Removed patchset dependency - this can land by itself Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | media/filters/media_source_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 bool IsSeekWaitingForData() const; 109 bool IsSeekWaitingForData() const;
110 110
111 typedef std::list<Ranges<TimeDelta>> RangesList; 111 typedef std::list<Ranges<TimeDelta>> RangesList;
112 static Ranges<TimeDelta> ComputeRangesIntersection( 112 static Ranges<TimeDelta> ComputeRangesIntersection(
113 const RangesList& activeRanges, 113 const RangesList& activeRanges,
114 bool ended); 114 bool ended);
115 115
116 void SetTracksWatcher(const Demuxer::MediaTracksUpdatedCB& tracks_updated_cb); 116 void SetTracksWatcher(const Demuxer::MediaTracksUpdatedCB& tracks_updated_cb);
117 117
118 private: 118 private:
119 // State advances through this list. The intent is to ensure at least one
120 // config is received prior to parser calling initialization callback, and
121 // that such initialization callback occurs at most once per parser.
122 enum State {
123 UNINITIALIZED = 0,
124 PENDING_PARSER_CONFIG,
125 PENDING_PARSER_INIT,
126 PARSER_INITIALIZED
127 };
128
119 // Called by the |stream_parser_| when a new initialization segment is 129 // Called by the |stream_parser_| when a new initialization segment is
120 // encountered. 130 // encountered.
121 // 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
122 // processing decoder configurations. 132 // processing decoder configurations.
123 bool OnNewConfigs(bool allow_audio, 133 bool OnNewConfigs(bool allow_audio,
124 bool allow_video, 134 bool allow_video,
125 scoped_ptr<MediaTracks> tracks, 135 scoped_ptr<MediaTracks> tracks,
126 const StreamParser::TextTrackConfigMap& text_configs); 136 const StreamParser::TextTrackConfigMap& text_configs);
127 137
128 // 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.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 ChunkDemuxerStream* audio_; // Not owned by |this|. 195 ChunkDemuxerStream* audio_; // Not owned by |this|.
186 ChunkDemuxerStream* video_; // Not owned by |this|. 196 ChunkDemuxerStream* video_; // Not owned by |this|.
187 197
188 typedef std::map<StreamParser::TrackId, ChunkDemuxerStream*> TextStreamMap; 198 typedef std::map<StreamParser::TrackId, ChunkDemuxerStream*> TextStreamMap;
189 TextStreamMap text_stream_map_; // |this| owns the map's stream pointers. 199 TextStreamMap text_stream_map_; // |this| owns the map's stream pointers.
190 200
191 scoped_ptr<FrameProcessor> frame_processor_; 201 scoped_ptr<FrameProcessor> frame_processor_;
192 scoped_refptr<MediaLog> media_log_; 202 scoped_refptr<MediaLog> media_log_;
193 StreamParser::InitCB init_cb_; 203 StreamParser::InitCB init_cb_;
194 204
205 State state_;
206
195 // During Append(), OnNewConfigs() will trigger the initialization segment 207 // During Append(), OnNewConfigs() will trigger the initialization segment
196 // received algorithm. Note, the MSE spec explicitly disallows this algorithm 208 // received algorithm. Note, the MSE spec explicitly disallows this algorithm
197 // 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
198 // 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
199 // 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
200 // invoke this callback. 212 // invoke this callback.
201 Demuxer::MediaTracksUpdatedCB init_segment_received_cb_; 213 Demuxer::MediaTracksUpdatedCB init_segment_received_cb_;
202 bool append_in_progress_ = false; 214 bool append_in_progress_ = false;
203 215
204 // Indicates that timestampOffset should be updated automatically during 216 // Indicates that timestampOffset should be updated automatically during
205 // OnNewBuffers() based on the earliest end timestamp of the buffers provided. 217 // OnNewBuffers() based on the earliest end timestamp of the buffers provided.
206 // TODO(wolenetz): Refactor this function while integrating April 29, 2014 218 // TODO(wolenetz): Refactor this function while integrating April 29, 2014
207 // changes to MSE spec. See http://crbug.com/371499. 219 // changes to MSE spec. See http://crbug.com/371499.
208 bool auto_update_timestamp_offset_; 220 bool auto_update_timestamp_offset_;
209 221
210 DISALLOW_COPY_AND_ASSIGN(MediaSourceState); 222 DISALLOW_COPY_AND_ASSIGN(MediaSourceState);
211 }; 223 };
212 224
213 } // namespace media 225 } // namespace media
214 226
215 #endif // MEDIA_FILTERS_MEDIA_SOURCE_STATE_H_ 227 #endif // MEDIA_FILTERS_MEDIA_SOURCE_STATE_H_
OLDNEW
« no previous file with comments | « no previous file | media/filters/media_source_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698