-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[M90] Add CloseOnClone flag to VideoFrameHandle
This CL temporary adds a flag that allows VideoFrameHandles to be closed automatically after clone() is called. This is used by MediaStreamVideoTrackUnderlyingSource to mark frames for closure before posting them to a endpoint has has been transferred. Without this, posted VideoFrames cannot be closed, and this results in stalls (see attached bug). To detect whether or not a stream endpoint has been transferred, we use a ReadableStreamTransferringOptimizer which doesn't attempt to perform any optimizations, but notifies the original MSVTUS that there was an attempt to optimize stream transfers. (cherry picked from commit 27a978b) Bug: 1182497 Change-Id: Ibbd5017b973cf2736b9bda7cdacd9b789a1173f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2729456 Reviewed-by: Thomas Guilbert <tguilbert@chromium.org> Reviewed-by: Guido Urdaneta <guidou@chromium.org> Reviewed-by: Dan Sanders <sandersd@chromium.org> Commit-Queue: Thomas Guilbert <tguilbert@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#859630} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2739870 Auto-Submit: Thomas Guilbert <tguilbert@chromium.org> Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Cr-Commit-Position: refs/branch-heads/4430@{#163} Cr-Branched-From: e5ce7dc-refs/heads/master@{#857950}
- Loading branch information
1 parent
3b27e8a
commit 4ce84de
Showing
7 changed files
with
168 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
third_party/blink/web_tests/wpt_internal/mediastream/frame-reader-worker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var frameCount = 0; | ||
|
||
self.addEventListener('message', function(e) { | ||
|
||
const frameStream = e.data.stream; | ||
const frameReader = frameStream.getReader(); | ||
|
||
const framesToRead = 20; | ||
|
||
var closeStream = function() { | ||
frameReader.releaseLock(); | ||
frameStream.cancel(); | ||
} | ||
|
||
frameReader.read().then(function processFrame({done, value}) { | ||
if(done) { | ||
self.postMessage({ success: false, message: "Stream is ended before we could read enough frames" }); | ||
closeStream(); | ||
return; | ||
} | ||
|
||
if (value.codedWitdh == 0) { | ||
self.postMessage({ success: false, message: "Video frame is invalid" }); | ||
closeStream(); | ||
value.close(); | ||
return; | ||
} | ||
|
||
value.close(); | ||
|
||
if(++frameCount == framesToRead) { | ||
self.postMessage({ success: true, message: "Ran as expected" }); | ||
closeStream(); | ||
return; | ||
} | ||
|
||
frameReader.read().then(processFrame); | ||
}) | ||
}, false); |
35 changes: 35 additions & 0 deletions
35
...link/web_tests/wpt_internal/mediastream/mediastreamtrackprocessor-transfer-to-worker.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<title>Transferring Streams from MediaStreamTrackProcessor.</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
<script src="frame-reader-worker.js"></script> | ||
<script> | ||
|
||
promise_test(async t => { | ||
var video = document.createElement('video'); | ||
video.src = "/media/400x300-red-resize-200x150-green.mp4"; | ||
await test_driver.bless("Play video element", () => { | ||
return video.play(); | ||
}); | ||
|
||
var track = video.captureStream().getVideoTracks()[0]; | ||
t.add_cleanup(() => track.stop()); | ||
|
||
var processor = new MediaStreamTrackProcessor(track); | ||
var worker = new Worker("frame-reader-worker.js"); | ||
|
||
var testSuccess = new Promise(resolve => { | ||
worker.addEventListener('message', resolve); | ||
}).then(message => { | ||
assert_true(message.data.success, message.data.message); | ||
}); | ||
|
||
var readable = processor.readable; | ||
worker.postMessage({ stream: readable }, [readable]); | ||
|
||
return testSuccess; | ||
}, "Test we can transfer a Video MediaStreamTrackProcessor stream"); | ||
|
||
</script> |