Hold a reference to AndroidVideoTrackSource while calling onFrameCaptured.
This makes it safe to deliver frames to the sink from VideoProcessor even after setSink has been called with null reference without danger of use after free. Bug: b/148063550 Change-Id: Ib78f75ac49fc6117f744c55da1a4e671bbdcdf22 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168160 Reviewed-by: Paulina Hensman <phensman@webrtc.org> Commit-Queue: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30455}
This commit is contained in:
committed by
Commit Bot
parent
215963c759
commit
0f6bcd18b2
@ -135,7 +135,9 @@ public class VideoSource extends MediaSource {
|
||||
}
|
||||
videoProcessor = newVideoProcessor;
|
||||
if (newVideoProcessor != null) {
|
||||
newVideoProcessor.setSink(nativeAndroidVideoTrackSource::onFrameCaptured);
|
||||
newVideoProcessor.setSink(
|
||||
(frame)
|
||||
-> runWithReference(() -> nativeAndroidVideoTrackSource.onFrameCaptured(frame)));
|
||||
if (isCapturerRunning) {
|
||||
newVideoProcessor.onCapturerStarted(/* success= */ true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user