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

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

Issue 2076673005: MSE: Plumb ChunkDemuxer appendData failures into append Error algorithm (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the layout test Created 4 years, 6 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
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 #include <utility> 10 #include <utility>
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 605
606 DCHECK(!id.empty()); 606 DCHECK(!id.empty());
607 MediaSourceStateMap::const_iterator itr = source_state_map_.find(id); 607 MediaSourceStateMap::const_iterator itr = source_state_map_.find(id);
608 if (itr == source_state_map_.end()) { 608 if (itr == source_state_map_.end()) {
609 LOG(WARNING) << __FUNCTION__ << " stream " << id << " not found"; 609 LOG(WARNING) << __FUNCTION__ << " stream " << id << " not found";
610 return false; 610 return false;
611 } 611 }
612 return itr->second->EvictCodedFrames(media_time_dts, newDataSize); 612 return itr->second->EvictCodedFrames(media_time_dts, newDataSize);
613 } 613 }
614 614
615 void ChunkDemuxer::AppendData(const std::string& id, 615 bool ChunkDemuxer::AppendData(const std::string& id,
616 const uint8_t* data, 616 const uint8_t* data,
617 size_t length, 617 size_t length,
618 TimeDelta append_window_start, 618 TimeDelta append_window_start,
619 TimeDelta append_window_end, 619 TimeDelta append_window_end,
620 TimeDelta* timestamp_offset) { 620 TimeDelta* timestamp_offset) {
621 DVLOG(1) << "AppendData(" << id << ", " << length << ")"; 621 DVLOG(1) << "AppendData(" << id << ", " << length << ")";
622 622
623 DCHECK(!id.empty()); 623 DCHECK(!id.empty());
624 DCHECK(timestamp_offset); 624 DCHECK(timestamp_offset);
625 625
626 Ranges<TimeDelta> ranges; 626 Ranges<TimeDelta> ranges;
627 627
628 { 628 {
629 base::AutoLock auto_lock(lock_); 629 base::AutoLock auto_lock(lock_);
630 DCHECK_NE(state_, ENDED); 630 DCHECK_NE(state_, ENDED);
631 631
632 // Capture if any of the SourceBuffers are waiting for data before we start 632 // Capture if any of the SourceBuffers are waiting for data before we start
633 // parsing. 633 // parsing.
634 bool old_waiting_for_data = IsSeekWaitingForData_Locked(); 634 bool old_waiting_for_data = IsSeekWaitingForData_Locked();
635 635
636 if (length == 0u) 636 if (length == 0u)
637 return; 637 return true;
638 638
639 DCHECK(data); 639 DCHECK(data);
640 640
641 switch (state_) { 641 switch (state_) {
642 case INITIALIZING: 642 case INITIALIZING:
643 case INITIALIZED: 643 case INITIALIZED:
644 DCHECK(IsValidId(id)); 644 DCHECK(IsValidId(id));
645 if (!source_state_map_[id]->Append(data, length, append_window_start, 645 if (!source_state_map_[id]->Append(data, length, append_window_start,
646 append_window_end, 646 append_window_end,
647 timestamp_offset)) { 647 timestamp_offset)) {
648 ReportError_Locked(CHUNK_DEMUXER_ERROR_APPEND_FAILED); 648 ReportError_Locked(CHUNK_DEMUXER_ERROR_APPEND_FAILED);
649 return; 649 return false;
650 } 650 }
651 break; 651 break;
652 652
653 case PARSE_ERROR: 653 case PARSE_ERROR:
654 DVLOG(1) << "AppendData(): Ignoring data after a parse error.";
655 return;
656
657 case WAITING_FOR_INIT: 654 case WAITING_FOR_INIT:
658 case ENDED: 655 case ENDED:
659 case SHUTDOWN: 656 case SHUTDOWN:
660 DVLOG(1) << "AppendData(): called in unexpected state " << state_; 657 DVLOG(1) << "AppendData(): called in unexpected state " << state_;
661 return; 658 return false;
662 } 659 }
663 660
664 // Check to see if data was appended at the pending seek point. This 661 // Check to see if data was appended at the pending seek point. This
665 // indicates we have parsed enough data to complete the seek. 662 // indicates we have parsed enough data to complete the seek.
666 if (old_waiting_for_data && !IsSeekWaitingForData_Locked() && 663 if (old_waiting_for_data && !IsSeekWaitingForData_Locked() &&
667 !seek_cb_.is_null()) { 664 !seek_cb_.is_null()) {
668 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK); 665 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK);
669 } 666 }
670 667
671 ranges = GetBufferedRanges_Locked(); 668 ranges = GetBufferedRanges_Locked();
672 } 669 }
673 670
674 host_->OnBufferedTimeRangesChanged(ranges); 671 host_->OnBufferedTimeRangesChanged(ranges);
672 return true;
675 } 673 }
676 674
677 void ChunkDemuxer::ResetParserState(const std::string& id, 675 void ChunkDemuxer::ResetParserState(const std::string& id,
678 TimeDelta append_window_start, 676 TimeDelta append_window_start,
679 TimeDelta append_window_end, 677 TimeDelta append_window_end,
680 TimeDelta* timestamp_offset) { 678 TimeDelta* timestamp_offset) {
681 DVLOG(1) << "ResetParserState(" << id << ")"; 679 DVLOG(1) << "ResetParserState(" << id << ")";
682 base::AutoLock auto_lock(lock_); 680 base::AutoLock auto_lock(lock_);
683 DCHECK(!id.empty()); 681 DCHECK(!id.empty());
684 CHECK(IsValidId(id)); 682 CHECK(IsValidId(id));
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 } 1138 }
1141 1139
1142 void ChunkDemuxer::ShutdownAllStreams() { 1140 void ChunkDemuxer::ShutdownAllStreams() {
1143 for (MediaSourceStateMap::iterator itr = source_state_map_.begin(); 1141 for (MediaSourceStateMap::iterator itr = source_state_map_.begin();
1144 itr != source_state_map_.end(); ++itr) { 1142 itr != source_state_map_.end(); ++itr) {
1145 itr->second->Shutdown(); 1143 itr->second->Shutdown();
1146 } 1144 }
1147 } 1145 }
1148 1146
1149 } // namespace media 1147 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698