Add shortcut to reset video capture/encoding by rom1v · Pull Request #5432 · Genymobile/scrcpy (original) (raw)
marked this pull request as draft
When the capture source becomes "invalid" (because the display size changes for example), a reset request is performed to restart the encoder.
The reset state was stored in SurfaceCapture. The capture implementation set the flag, and the encoder consumed it.
However, this mechanism did not allow a reset request to interrupt the encoder, which may be waiting on a blocking call (until a new frame is produced).
To be able to interrupt the encoder, a reset request must not only set a flag, but run a callback provided by the encoder. For that purpose, introduce the CaptureListener interface, which is notified by the SurfaceCapture implementation whenever the capture is invalidated.
For now, the listener implementation just set a flag as before, so the behavior is unchanged. It lays the groundwork for the next commits.
When the MediaCodec input is a Surface, no EOS (end-of-stream) will never occur automatically: it may only be triggered manually by MediaCodec.signalEndOfInputStream().
Use this signal to interrupt the blocking call to dequeueOutputBuffer() immediately on reset, without waiting for the next frame to be dequeued.
rom1v added a commit that referenced this pull request
Reset video capture/encoding on MOD+Shift+r.
Like on device rotation, this starts a new encoding session which produces a video stream starting by a key frame.
rom1v marked this pull request as ready for review
rom1v added a commit that referenced this pull request
Reset video capture/encoding on MOD+Shift+r.
Like on device rotation, this starts a new encoding session which produces a video stream starting by a key frame.
Reset video capture/encoding on MOD+Shift+r.
Like on device rotation, this starts a new encoding session which produces a video stream starting by a key frame.
bartsaintgermain pushed a commit to bartsaintgermain/scrcpy that referenced this pull request
When the capture source becomes "invalid" (because the display size changes for example), a reset request is performed to restart the encoder.
The reset state was stored in SurfaceCapture. The capture implementation set the flag, and the encoder consumed it.
However, this mechanism did not allow a reset request to interrupt the encoder, which may be waiting on a blocking call (until a new frame is produced).
To be able to interrupt the encoder, a reset request must not only set a flag, but run a callback provided by the encoder. For that purpose, introduce the CaptureListener interface, which is notified by the SurfaceCapture implementation whenever the capture is invalidated.
For now, the listener implementation just set a flag as before, so the behavior is unchanged. It lays the groundwork for the next commits.
PR Genymobile#5432 <Genymobile#5432>
bartsaintgermain pushed a commit to bartsaintgermain/scrcpy that referenced this pull request
When the MediaCodec input is a Surface, no EOS (end-of-stream) will never occur automatically: it may only be triggered manually by MediaCodec.signalEndOfInputStream().
Use this signal to interrupt the blocking call to dequeueOutputBuffer() immediately on reset, without waiting for the next frame to be dequeued.
PR Genymobile#5432 <Genymobile#5432>
bartsaintgermain pushed a commit to bartsaintgermain/scrcpy that referenced this pull request
Reset video capture/encoding on MOD+Shift+r.
Like on device rotation, this starts a new encoding session which produces a video stream starting by a key frame.
PR Genymobile#5432 <Genymobile#5432>
This file contains hidden or 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
[ Show hidden characters]({{ revealButtonHref }})