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

Side by Side Diff: third_party/WebKit/Source/modules/mediasource/SourceBuffer.cpp

Issue 1491813002: Clamp currentTime to buffered ranges for MSE GC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sbs-gc-fix
Patch Set: Add a clarifying comment Created 5 years 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 577
578 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::prepareAppend", this); 578 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::prepareAppend", this);
579 return true; 579 return true;
580 } 580 }
581 581
582 bool SourceBuffer::evictCodedFrames(size_t newDataSize) 582 bool SourceBuffer::evictCodedFrames(size_t newDataSize)
583 { 583 {
584 ASSERT(m_source); 584 ASSERT(m_source);
585 ASSERT(m_source->mediaElement()); 585 ASSERT(m_source->mediaElement());
586 double currentTime = m_source->mediaElement()->currentTime(); 586 double currentTime = m_source->mediaElement()->currentTime();
587
588 // Strictly speaking currentTime should always be in the buffered ranges,
589 // but media::Pipeline uses audio stream as the main time source. When audio
wolenetz 2015/12/02 23:11:00 nit: (when there is an audio stream)
590 // and video streams have different buffered ranges, then the currentTime
591 // value might be slightly outside of the video stream buffered range. In
592 // those cases we need to clamp currentTime value to the current stream
593 // buffered ranges, to ensure the MSE garbage collection algorithm works
594 // correctly (see crbug.com/563292 for details).
595 Member<TimeRanges> bufferedRanges(buffered(ASSERT_NO_EXCEPTION));
596 if (!bufferedRanges->contain(currentTime)) {
597 double nearest = bufferedRanges->nearest(currentTime, currentTime);
wolenetz 2015/12/02 23:11:00 Two strongly related comments: 1) This fix-up is s
598 WTF_LOG(Media, "SourceBuffer::evictCodedFrames %p currentTime %f outside of buffered ranges, adjusting currentTime to %f", this, currentTime, nearest);
599 currentTime = nearest;
600 }
601
587 return m_webSourceBuffer->evictCodedFrames(currentTime, newDataSize); 602 return m_webSourceBuffer->evictCodedFrames(currentTime, newDataSize);
588 } 603 }
589 604
590 void SourceBuffer::appendBufferInternal(const unsigned char* data, unsigned size , ExceptionState& exceptionState) 605 void SourceBuffer::appendBufferInternal(const unsigned char* data, unsigned size , ExceptionState& exceptionState)
591 { 606 {
592 TRACE_EVENT_ASYNC_BEGIN1("media", "SourceBuffer::appendBuffer", this, "size" , size); 607 TRACE_EVENT_ASYNC_BEGIN1("media", "SourceBuffer::appendBuffer", this, "size" , size);
593 // Section 3.2 appendBuffer() 608 // Section 3.2 appendBuffer()
594 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data 609 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data
595 610
596 // 1. Run the prepare append algorithm. 611 // 1. Run the prepare append algorithm.
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 { 872 {
858 visitor->trace(m_source); 873 visitor->trace(m_source);
859 visitor->trace(m_stream); 874 visitor->trace(m_stream);
860 visitor->trace(m_trackDefaults); 875 visitor->trace(m_trackDefaults);
861 visitor->trace(m_asyncEventQueue); 876 visitor->trace(m_asyncEventQueue);
862 RefCountedGarbageCollectedEventTargetWithInlineData<SourceBuffer>::trace(vis itor); 877 RefCountedGarbageCollectedEventTargetWithInlineData<SourceBuffer>::trace(vis itor);
863 ActiveDOMObject::trace(visitor); 878 ActiveDOMObject::trace(visitor);
864 } 879 }
865 880
866 } // namespace blink 881 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698