Commit d27792da authored by Matt Wolenetz's avatar Matt Wolenetz Committed by Commit Bot

MSE: Use TimeDelta for PTS in SourceBufferStream

With recent removal of LegacyByDts buffering logic, this change does
the last of the major cleanup to SourceBufferStream such that it now
uses base::TimeDelta for presentation time, removes the now-unnecessary
wrappers of SourceBufferRange that converted time type from/to
DecodeTimestamp, and updates the callers and tests of
SourceBufferStream's API.

Also adds a TODO around tangential compliance work remaining to fix
https://crbug.com/623729.

BUG=771349,623729

Change-Id: Ib87004719319ca34e917d54b1004ed111eab609c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1597544Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#658857}
parent dc098142
...@@ -166,16 +166,13 @@ bool ChunkDemuxerStream::EvictCodedFrames(base::TimeDelta media_time, ...@@ -166,16 +166,13 @@ bool ChunkDemuxerStream::EvictCodedFrames(base::TimeDelta media_time,
if (!is_enabled_) if (!is_enabled_)
stream_->Seek(media_time); stream_->Seek(media_time);
// Note: The direct conversion from PTS to DTS is safe here, since we don't // |media_time| is allowed to be a little imprecise here. GC only needs to
// need to know currentTime precisely for GC. GC only needs to know which GOP // know which GOP currentTime points to.
// currentTime points to. return stream_->GarbageCollectIfNeeded(media_time, newDataSize);
DecodeTimestamp media_time_dts =
DecodeTimestamp::FromPresentationTime(media_time);
return stream_->GarbageCollectIfNeeded(media_time_dts, newDataSize);
} }
void ChunkDemuxerStream::OnMemoryPressure( void ChunkDemuxerStream::OnMemoryPressure(
DecodeTimestamp media_time, base::TimeDelta media_time,
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level, base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level,
bool force_instant_gc) { bool force_instant_gc) {
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
...@@ -240,7 +237,7 @@ void ChunkDemuxerStream::OnStartOfCodedFrameGroup(DecodeTimestamp start_dts, ...@@ -240,7 +237,7 @@ void ChunkDemuxerStream::OnStartOfCodedFrameGroup(DecodeTimestamp start_dts,
group_start_observer_cb_.Run(start_dts, start_pts); group_start_observer_cb_.Run(start_dts, start_pts);
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
stream_->OnStartOfCodedFrameGroup(start_dts, start_pts); stream_->OnStartOfCodedFrameGroup(start_pts);
} }
bool ChunkDemuxerStream::UpdateAudioConfig(const AudioDecoderConfig& config, bool ChunkDemuxerStream::UpdateAudioConfig(const AudioDecoderConfig& config,
...@@ -808,11 +805,9 @@ void ChunkDemuxer::OnMemoryPressure( ...@@ -808,11 +805,9 @@ void ChunkDemuxer::OnMemoryPressure(
base::TimeDelta currentMediaTime, base::TimeDelta currentMediaTime,
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level, base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level,
bool force_instant_gc) { bool force_instant_gc) {
DecodeTimestamp media_time_dts =
DecodeTimestamp::FromPresentationTime(currentMediaTime);
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
for (const auto& itr : source_state_map_) { for (const auto& itr : source_state_map_) {
itr.second->OnMemoryPressure(media_time_dts, memory_pressure_level, itr.second->OnMemoryPressure(currentMediaTime, memory_pressure_level,
force_instant_gc); force_instant_gc);
} }
} }
......
...@@ -72,7 +72,7 @@ class MEDIA_EXPORT ChunkDemuxerStream : public DemuxerStream { ...@@ -72,7 +72,7 @@ class MEDIA_EXPORT ChunkDemuxerStream : public DemuxerStream {
bool EvictCodedFrames(base::TimeDelta media_time, size_t newDataSize); bool EvictCodedFrames(base::TimeDelta media_time, size_t newDataSize);
void OnMemoryPressure( void OnMemoryPressure(
DecodeTimestamp media_time, base::TimeDelta media_time,
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level, base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level,
bool force_instant_gc); bool force_instant_gc);
...@@ -94,8 +94,10 @@ class MEDIA_EXPORT ChunkDemuxerStream : public DemuxerStream { ...@@ -94,8 +94,10 @@ class MEDIA_EXPORT ChunkDemuxerStream : public DemuxerStream {
size_t GetBufferedSize() const; size_t GetBufferedSize() const;
// Signal to the stream that buffers handed in through subsequent calls to // Signal to the stream that buffers handed in through subsequent calls to
// Append() belong to a coded frame group that starts at |start_dts| and // Append() belong to a coded frame group that starts at |start_pts|.
// |start_pts|. // |start_dts| is used only to help tests verify correctness of calls to this
// method. If |group_start_observer_cb_| is set, first invokes this test-only
// callback with |start_dts| and |start_pts| to assist test verification.
void OnStartOfCodedFrameGroup(DecodeTimestamp start_dts, void OnStartOfCodedFrameGroup(DecodeTimestamp start_dts,
base::TimeDelta start_pts); base::TimeDelta start_pts);
...@@ -173,6 +175,8 @@ class MEDIA_EXPORT ChunkDemuxerStream : public DemuxerStream { ...@@ -173,6 +175,8 @@ class MEDIA_EXPORT ChunkDemuxerStream : public DemuxerStream {
const MediaTrack::Id media_track_id_; const MediaTrack::Id media_track_id_;
// Test-only callbacks to assist verification of Append() and
// OnStartOfCodedFrameGroup() calls, respectively.
AppendObserverCB append_observer_cb_; AppendObserverCB append_observer_cb_;
GroupStartObserverCB group_start_observer_cb_; GroupStartObserverCB group_start_observer_cb_;
......
...@@ -313,7 +313,7 @@ bool SourceBufferState::EvictCodedFrames(base::TimeDelta media_time, ...@@ -313,7 +313,7 @@ bool SourceBufferState::EvictCodedFrames(base::TimeDelta media_time,
} }
void SourceBufferState::OnMemoryPressure( void SourceBufferState::OnMemoryPressure(
DecodeTimestamp media_time, base::TimeDelta media_time,
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level, base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level,
bool force_instant_gc) { bool force_instant_gc) {
// Notify video streams about memory pressure first, since video typically // Notify video streams about memory pressure first, since video typically
......
...@@ -86,11 +86,11 @@ class MEDIA_EXPORT SourceBufferState { ...@@ -86,11 +86,11 @@ class MEDIA_EXPORT SourceBufferState {
// Gets invoked when the system is experiencing memory pressure, i.e. there's // Gets invoked when the system is experiencing memory pressure, i.e. there's
// not enough free memory. The |media_time| is the media playback position at // not enough free memory. The |media_time| is the media playback position at
// the time of memory pressure notification (needed for accurate GC). The // the time of memory pressure notification (needed for accurate GC). The
// |memory_pressure_listener| indicates memory pressure severity. The // |memory_pressure_level| indicates memory pressure severity. The
// |force_instant_gc| is used to force the MSE garbage collection algorithm to // |force_instant_gc| is used to force the MSE garbage collection algorithm to
// be run right away, without waiting for the next append. // be run right away, without waiting for the next append.
void OnMemoryPressure( void OnMemoryPressure(
DecodeTimestamp media_time, base::TimeDelta media_time,
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level, base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level,
bool force_instant_gc); bool force_instant_gc);
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment