Repository navigation
fix: harden track listeners and the media recorder - #536
Merged
Merged
Conversation
MediaReader opened the source even if av_dict_set failed, without the limit on what it may reach. It now returns the error before avformat_open_input and frees the context.
The track got a bare pointer to the observer before addNativeRef stored its shared_ptr, so a failure there freed an observer WebRTC still called. It now leaves the track first, and addNativeRef reports a global reference that could not be created instead of storing a null one.
The writer started before the tracks were attached, and a failed attach went unnoticed. Tracks are now attached first and the writer started last, so that a failure takes the observers off again and leaves the recorder idle and startable. encoded_observer_add allocates its handle first, and returns null instead of throwing through the C interface.
A recorder emptied an existing file, and deleted it when it got no media, so an aborted attempt could cost an earlier recording. This changes the documented behavior: the constructor now throws FileAlreadyExistsException, and MediaRecorder(Path, boolean) replaces the file through a temporary file that takes its place only once finished.
COMPLETE speaks of what the recorder took, so applications could not tell how much it dropped before. MediaRecorder.getStats() now gives per track how many frames were dropped by cause, and the peak of the writer's queue. The result values stay as they are.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes failure paths in track listeners, the recorder and the media reader, and makes recording losses measurable.
encoded_observer_addallocates its handle first and no longer throws through the C interface.MediaRecorder.getStats()reports dropped frames per track by cause, and the peak of the writer's queue.Behavior change:
new MediaRecorder(path)now throwsFileAlreadyExistsExceptionif the file exists.MediaRecorder(path, true)replaces it through a temporary file, once the recording is finished, so a recording without media no longer costs an earlier one.