Skip to content
Browse files
Handle case where only a single video frame was appended.

Reviewed by Jer Noble.

Under some circumstances, only a single frame will be appended.
When the queue of pending samples gets flushed we can't rely on the last sample's time
nor the last duration.

* Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp:

Canonical link:
git-svn-id: 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
jyavenard committed Jun 13, 2022
1 parent 11993dc commit ea891d3cb471f43199f7ea5d944dfce563e1a0e0
Showing 1 changed file with 3 additions and 4 deletions.
@@ -1157,17 +1157,16 @@ void WebMParser::VideoTrackData::flushPendingSamples()
// We set its duration to the track's default duration, or if not known the time of the last sample processed.
if (!m_pendingMediaSamples.size())
auto track = this->track();

MediaTime presentationTime = m_lastPresentationTime ? *m_lastPresentationTime : m_pendingMediaSamples.first().presentationTime;
MediaTime duration;
if (track.default_duration.is_present())
duration = MediaTime(track.default_duration.value() * m_lastPresentationTime->timeScale() / k_us_in_seconds, m_lastPresentationTime->timeScale());
duration = MediaTime(track.default_duration.value() * presentationTime.timeScale() / k_us_in_seconds, presentationTime.timeScale());
else if (m_lastDuration)
duration = *m_lastDuration;
processPendingMediaSamples(*m_lastPresentationTime + duration);
processPendingMediaSamples(presentationTime + duration);

void WebMParser::AudioTrackData::resetCompletedFramesState()

0 comments on commit ea891d3

Please sign in to comment.