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

Side by Side Diff: media/filters/chunk_demuxer.cc

Issue 256583006: Fix possible buffer emission during an abort. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address CR comments. Created 6 years, 7 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 | « media/filters/chunk_demuxer.h ('k') | media/filters/chunk_demuxer_unittest.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) 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 #include "media/filters/chunk_demuxer.h" 5 #include "media/filters/chunk_demuxer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <list> 9 #include <list>
10 10
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 const StreamParser::NeedKeyCB& need_key_cb, 117 const StreamParser::NeedKeyCB& need_key_cb,
118 const NewTextTrackCB& new_text_track_cb); 118 const NewTextTrackCB& new_text_track_cb);
119 119
120 // Appends new data to the StreamParser. 120 // Appends new data to the StreamParser.
121 // Returns true if the data was successfully appended. Returns false if an 121 // Returns true if the data was successfully appended. Returns false if an
122 // error occurred. |*timestamp_offset| is used and possibly updated by the 122 // error occurred. |*timestamp_offset| is used and possibly updated by the
123 // append. |append_window_start| and |append_window_end| correspond to the MSE 123 // append. |append_window_start| and |append_window_end| correspond to the MSE
124 // spec's similarly named source buffer attributes that are used in coded 124 // spec's similarly named source buffer attributes that are used in coded
125 // frame processing. 125 // frame processing.
126 bool Append(const uint8* data, size_t length, 126 bool Append(const uint8* data, size_t length,
127 TimeDelta append_window_start_, 127 TimeDelta append_window_start,
128 TimeDelta append_window_end_, 128 TimeDelta append_window_end,
129 TimeDelta* timestamp_offset); 129 TimeDelta* timestamp_offset);
130 130
131 // Aborts the current append sequence and resets the parser. 131 // Aborts the current append sequence and resets the parser.
132 void Abort(); 132 void Abort(TimeDelta append_window_start,
133 TimeDelta append_window_end,
134 TimeDelta* timestamp_offset);
133 135
134 // Calls Remove(|start|, |end|, |duration|) on all 136 // Calls Remove(|start|, |end|, |duration|) on all
135 // ChunkDemuxerStreams managed by this object. 137 // ChunkDemuxerStreams managed by this object.
136 void Remove(TimeDelta start, TimeDelta end, TimeDelta duration); 138 void Remove(TimeDelta start, TimeDelta end, TimeDelta duration);
137 139
138 // Returns true if currently parsing a media segment, or false otherwise. 140 // Returns true if currently parsing a media segment, or false otherwise.
139 bool parsing_media_segment() const { return parsing_media_segment_; } 141 bool parsing_media_segment() const { return parsing_media_segment_; }
140 142
141 // Sets |frame_processor_|'s sequence mode to |sequence_mode|. 143 // Sets |frame_processor_|'s sequence mode to |sequence_mode|.
142 void SetSequenceMode(bool sequence_mode); 144 void SetSequenceMode(bool sequence_mode);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 append_window_start_during_append_ = append_window_start; 309 append_window_start_during_append_ = append_window_start;
308 append_window_end_during_append_ = append_window_end; 310 append_window_end_during_append_ = append_window_end;
309 311
310 // TODO(wolenetz/acolwell): Curry and pass a NewBuffersCB here bound with 312 // TODO(wolenetz/acolwell): Curry and pass a NewBuffersCB here bound with
311 // append window and timestamp offset pointer. See http://crbug.com/351454. 313 // append window and timestamp offset pointer. See http://crbug.com/351454.
312 bool err = stream_parser_->Parse(data, length); 314 bool err = stream_parser_->Parse(data, length);
313 timestamp_offset_during_append_ = NULL; 315 timestamp_offset_during_append_ = NULL;
314 return err; 316 return err;
315 } 317 }
316 318
317 void SourceState::Abort() { 319 void SourceState::Abort(TimeDelta append_window_start,
320 TimeDelta append_window_end,
321 base::TimeDelta* timestamp_offset) {
322 DCHECK(timestamp_offset);
323 DCHECK(!timestamp_offset_during_append_);
324 timestamp_offset_during_append_ = timestamp_offset;
325 append_window_start_during_append_ = append_window_start;
326 append_window_end_during_append_ = append_window_end;
327
318 stream_parser_->Flush(); 328 stream_parser_->Flush();
329 timestamp_offset_during_append_ = NULL;
330
319 frame_processor_->Reset(); 331 frame_processor_->Reset();
320 parsing_media_segment_ = false; 332 parsing_media_segment_ = false;
321 } 333 }
322 334
323 void SourceState::Remove(TimeDelta start, TimeDelta end, TimeDelta duration) { 335 void SourceState::Remove(TimeDelta start, TimeDelta end, TimeDelta duration) {
324 if (audio_) 336 if (audio_)
325 audio_->Remove(start, end, duration); 337 audio_->Remove(start, end, duration);
326 338
327 if (video_) 339 if (video_)
328 video_->Remove(start, end, duration); 340 video_->Remove(start, end, duration);
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 parsing_media_segment_ = false; 666 parsing_media_segment_ = false;
655 new_media_segment_ = false; 667 new_media_segment_ = false;
656 } 668 }
657 669
658 bool SourceState::OnNewBuffers( 670 bool SourceState::OnNewBuffers(
659 const StreamParser::BufferQueue& audio_buffers, 671 const StreamParser::BufferQueue& audio_buffers,
660 const StreamParser::BufferQueue& video_buffers, 672 const StreamParser::BufferQueue& video_buffers,
661 const StreamParser::TextBufferQueueMap& text_map) { 673 const StreamParser::TextBufferQueueMap& text_map) {
662 DVLOG(2) << "OnNewBuffers()"; 674 DVLOG(2) << "OnNewBuffers()";
663 DCHECK(timestamp_offset_during_append_); 675 DCHECK(timestamp_offset_during_append_);
676 DCHECK(parsing_media_segment_);
664 677
665 const TimeDelta timestamp_offset_before_processing = 678 const TimeDelta timestamp_offset_before_processing =
666 *timestamp_offset_during_append_; 679 *timestamp_offset_during_append_;
667 680
668 // Calculate the new timestamp offset for audio/video tracks if the stream 681 // Calculate the new timestamp offset for audio/video tracks if the stream
669 // parser has requested automatic updates. 682 // parser has requested automatic updates.
670 TimeDelta new_timestamp_offset = timestamp_offset_before_processing; 683 TimeDelta new_timestamp_offset = timestamp_offset_before_processing;
671 if (auto_update_timestamp_offset_) { 684 if (auto_update_timestamp_offset_) {
672 const bool have_audio_buffers = !audio_buffers.empty(); 685 const bool have_audio_buffers = !audio_buffers.empty();
673 const bool have_video_buffers = !video_buffers.empty(); 686 const bool have_video_buffers = !video_buffers.empty();
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK); 1281 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK);
1269 } 1282 }
1270 1283
1271 ranges = GetBufferedRanges_Locked(); 1284 ranges = GetBufferedRanges_Locked();
1272 } 1285 }
1273 1286
1274 for (size_t i = 0; i < ranges.size(); ++i) 1287 for (size_t i = 0; i < ranges.size(); ++i)
1275 host_->AddBufferedTimeRange(ranges.start(i), ranges.end(i)); 1288 host_->AddBufferedTimeRange(ranges.start(i), ranges.end(i));
1276 } 1289 }
1277 1290
1278 void ChunkDemuxer::Abort(const std::string& id) { 1291 void ChunkDemuxer::Abort(const std::string& id,
1292 TimeDelta append_window_start,
1293 TimeDelta append_window_end,
1294 TimeDelta* timestamp_offset) {
1279 DVLOG(1) << "Abort(" << id << ")"; 1295 DVLOG(1) << "Abort(" << id << ")";
1280 base::AutoLock auto_lock(lock_); 1296 base::AutoLock auto_lock(lock_);
1281 DCHECK(!id.empty()); 1297 DCHECK(!id.empty());
1282 CHECK(IsValidId(id)); 1298 CHECK(IsValidId(id));
1283 source_state_map_[id]->Abort(); 1299 source_state_map_[id]->Abort(append_window_start,
1300 append_window_end,
1301 timestamp_offset);
1284 } 1302 }
1285 1303
1286 void ChunkDemuxer::Remove(const std::string& id, TimeDelta start, 1304 void ChunkDemuxer::Remove(const std::string& id, TimeDelta start,
1287 TimeDelta end) { 1305 TimeDelta end) {
1288 DVLOG(1) << "Remove(" << id << ", " << start.InSecondsF() 1306 DVLOG(1) << "Remove(" << id << ", " << start.InSecondsF()
1289 << ", " << end.InSecondsF() << ")"; 1307 << ", " << end.InSecondsF() << ")";
1290 base::AutoLock auto_lock(lock_); 1308 base::AutoLock auto_lock(lock_);
1291 1309
1292 DCHECK(!id.empty()); 1310 DCHECK(!id.empty());
1293 CHECK(IsValidId(id)); 1311 CHECK(IsValidId(id));
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 } 1686 }
1669 1687
1670 void ChunkDemuxer::ShutdownAllStreams() { 1688 void ChunkDemuxer::ShutdownAllStreams() {
1671 for (SourceStateMap::iterator itr = source_state_map_.begin(); 1689 for (SourceStateMap::iterator itr = source_state_map_.begin();
1672 itr != source_state_map_.end(); ++itr) { 1690 itr != source_state_map_.end(); ++itr) {
1673 itr->second->Shutdown(); 1691 itr->second->Shutdown();
1674 } 1692 }
1675 } 1693 }
1676 1694
1677 } // namespace media 1695 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer.h ('k') | media/filters/chunk_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698