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

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: Rebase 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
« 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 #include <utility> 10 #include <utility>
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 608
609 DCHECK(!id.empty()); 609 DCHECK(!id.empty());
610 MediaSourceStateMap::const_iterator itr = source_state_map_.find(id); 610 MediaSourceStateMap::const_iterator itr = source_state_map_.find(id);
611 if (itr == source_state_map_.end()) { 611 if (itr == source_state_map_.end()) {
612 LOG(WARNING) << __FUNCTION__ << " stream " << id << " not found"; 612 LOG(WARNING) << __FUNCTION__ << " stream " << id << " not found";
613 return false; 613 return false;
614 } 614 }
615 return itr->second->EvictCodedFrames(media_time_dts, newDataSize); 615 return itr->second->EvictCodedFrames(media_time_dts, newDataSize);
616 } 616 }
617 617
618 void ChunkDemuxer::AppendData(const std::string& id, 618 bool ChunkDemuxer::AppendData(const std::string& id,
619 const uint8_t* data, 619 const uint8_t* data,
620 size_t length, 620 size_t length,
621 TimeDelta append_window_start, 621 TimeDelta append_window_start,
622 TimeDelta append_window_end, 622 TimeDelta append_window_end,
623 TimeDelta* timestamp_offset) { 623 TimeDelta* timestamp_offset) {
624 DVLOG(1) << "AppendData(" << id << ", " << length << ")"; 624 DVLOG(1) << "AppendData(" << id << ", " << length << ")";
625 625
626 DCHECK(!id.empty()); 626 DCHECK(!id.empty());
627 DCHECK(timestamp_offset); 627 DCHECK(timestamp_offset);
628 628
629 Ranges<TimeDelta> ranges; 629 Ranges<TimeDelta> ranges;
630 630
631 { 631 {
632 base::AutoLock auto_lock(lock_); 632 base::AutoLock auto_lock(lock_);
633 DCHECK_NE(state_, ENDED); 633 DCHECK_NE(state_, ENDED);
634 634
635 // Capture if any of the SourceBuffers are waiting for data before we start 635 // Capture if any of the SourceBuffers are waiting for data before we start
636 // parsing. 636 // parsing.
637 bool old_waiting_for_data = IsSeekWaitingForData_Locked(); 637 bool old_waiting_for_data = IsSeekWaitingForData_Locked();
638 638
639 if (length == 0u) 639 if (length == 0u)
640 return; 640 return true;
641 641
642 DCHECK(data); 642 DCHECK(data);
643 643
644 switch (state_) { 644 switch (state_) {
645 case INITIALIZING: 645 case INITIALIZING:
646 case INITIALIZED: 646 case INITIALIZED:
647 DCHECK(IsValidId(id)); 647 DCHECK(IsValidId(id));
648 if (!source_state_map_[id]->Append(data, length, append_window_start, 648 if (!source_state_map_[id]->Append(data, length, append_window_start,
649 append_window_end, 649 append_window_end,
650 timestamp_offset)) { 650 timestamp_offset)) {
651 ReportError_Locked(CHUNK_DEMUXER_ERROR_APPEND_FAILED); 651 ReportError_Locked(CHUNK_DEMUXER_ERROR_APPEND_FAILED);
652 return; 652 return false;
653 } 653 }
654 break; 654 break;
655 655
656 case PARSE_ERROR: 656 case PARSE_ERROR:
657 DVLOG(1) << "AppendData(): Ignoring data after a parse error.";
658 return;
659
660 case WAITING_FOR_INIT: 657 case WAITING_FOR_INIT:
661 case ENDED: 658 case ENDED:
662 case SHUTDOWN: 659 case SHUTDOWN:
663 DVLOG(1) << "AppendData(): called in unexpected state " << state_; 660 DVLOG(1) << "AppendData(): called in unexpected state " << state_;
664 return; 661 return false;
665 } 662 }
666 663
667 // Check to see if data was appended at the pending seek point. This 664 // Check to see if data was appended at the pending seek point. This
668 // indicates we have parsed enough data to complete the seek. 665 // indicates we have parsed enough data to complete the seek.
669 if (old_waiting_for_data && !IsSeekWaitingForData_Locked() && 666 if (old_waiting_for_data && !IsSeekWaitingForData_Locked() &&
670 !seek_cb_.is_null()) { 667 !seek_cb_.is_null()) {
671 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK); 668 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK);
672 } 669 }
673 670
674 ranges = GetBufferedRanges_Locked(); 671 ranges = GetBufferedRanges_Locked();
675 } 672 }
676 673
677 host_->OnBufferedTimeRangesChanged(ranges); 674 host_->OnBufferedTimeRangesChanged(ranges);
675 return true;
678 } 676 }
679 677
680 void ChunkDemuxer::ResetParserState(const std::string& id, 678 void ChunkDemuxer::ResetParserState(const std::string& id,
681 TimeDelta append_window_start, 679 TimeDelta append_window_start,
682 TimeDelta append_window_end, 680 TimeDelta append_window_end,
683 TimeDelta* timestamp_offset) { 681 TimeDelta* timestamp_offset) {
684 DVLOG(1) << "ResetParserState(" << id << ")"; 682 DVLOG(1) << "ResetParserState(" << id << ")";
685 base::AutoLock auto_lock(lock_); 683 base::AutoLock auto_lock(lock_);
686 DCHECK(!id.empty()); 684 DCHECK(!id.empty());
687 CHECK(IsValidId(id)); 685 CHECK(IsValidId(id));
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 } 1154 }
1157 1155
1158 void ChunkDemuxer::ShutdownAllStreams() { 1156 void ChunkDemuxer::ShutdownAllStreams() {
1159 for (MediaSourceStateMap::iterator itr = source_state_map_.begin(); 1157 for (MediaSourceStateMap::iterator itr = source_state_map_.begin();
1160 itr != source_state_map_.end(); ++itr) { 1158 itr != source_state_map_.end(); ++itr) {
1161 itr->second->Shutdown(); 1159 itr->second->Shutdown();
1162 } 1160 }
1163 } 1161 }
1164 1162
1165 } // namespace media 1163 } // 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