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

Unified Diff: media/filters/ffmpeg_demuxer.cc

Issue 2267963002: Add support for cancellation of demuxer reads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Actually abort the data. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: media/filters/ffmpeg_demuxer.cc
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
index b34d8bc3cb784c81bdae8ca48c4c1ee5d77076b5..4df967a51986ccb1d0e3db17ad3cd131eb413266 100644
--- a/media/filters/ffmpeg_demuxer.cc
+++ b/media/filters/ffmpeg_demuxer.cc
@@ -592,6 +592,13 @@ void FFmpegDemuxerStream::FlushBuffers() {
last_packet_duration_ = kNoTimestamp;
}
+void FFmpegDemuxerStream::Abort() {
+ if (!read_cb_.is_null()) {
+ base::ResetAndReturn(&read_cb_).Run(DemuxerStream::kOk,
+ DecoderBuffer::CreateEOSBuffer());
+ }
+}
+
void FFmpegDemuxerStream::Stop() {
DCHECK(task_runner_->BelongsToCurrentThread());
buffer_queue_.Clear();
@@ -881,6 +888,27 @@ void FFmpegDemuxer::Initialize(DemuxerHost* host,
status_cb));
}
+void FFmpegDemuxer::AbortPendingReads() {
+ DCHECK(task_runner_->BelongsToCurrentThread());
+
+ // This should only be called after the demuxer has been initialized.
+ DCHECK(blocking_thread_.IsRunning());
+ DCHECK_GT(streams_.size(), 0u);
+
+ // Abort all outstanding reads by returning EOS buffers (to avoid any errors
+ // being triggered in the pipeline).
+ for (auto* stream : streams_) {
+ if (stream)
+ stream->Abort();
+ }
+
+ // Ordering is important here, we want to ignore any errors that occur during
+ // the Abort() of the data source. Note: We don't abort the URLProtocol here
+ // since that is a permanent action.
+ weak_factory_.InvalidateWeakPtrs();
+ data_source_->Abort();
+}
+
void FFmpegDemuxer::Stop() {
DCHECK(task_runner_->BelongsToCurrentThread());

Powered by Google App Engine
This is Rietveld 408576698