vtenc: Restart encoding session when certain errors are detected
Sometimes under certain loads, VT can error out with -12912 or -12915, both of which aren't necessairly fatal and can be worked around by restarting the encoding session. These errors have been reported to happen more often than usual if CopyProperty/SetProperty() is used somewhere alongside the encode call.
These errors can be returned either immediately from VTCompressionSessionEncodeFrame()
, or later via the encoding
callback. This patch handles both scenarios the same way - a session restart will be attempted on next encode_frame()
call.
If the error is returned immediately by the encode call, it's possible that some correct frames will still be given to the output callback, but for simplicity (+ because I wasn't able to verify this scenario) let's just discard those.
Related bug reports in other projects:
http://www.openradar.me/45889262
https://github.com/aws/amazon-chime-sdk-ios/issues/170#issuecomment-741908622