-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: the server stopped when requesting the maximum integer value(2147483647) for 'videoBitRate' #4930
Conversation
@@ -48,11 +49,34 @@ public SurfaceEncoder(SurfaceCapture capture, Streamer streamer, int videoBitRat | |||
this.downsizeOnError = downsizeOnError; | |||
} | |||
|
|||
/** | |||
* Fixing the issue that the server crashes when requesting the maximum integer value(2147483647) for 'videoBitRate' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it "crash" (like a segfault) or just throw an exception printed in the console?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The program did not terminate abnormally due to a segmentation fault; instead, it exited with an 'aborted' log message.
String mimeType = format.getString(MediaFormat.KEY_MIME); | ||
if (mimeType != null) { | ||
MediaCodecInfo mediaCodecInfo = mediaCodec.getCodecInfo(); | ||
Range<Integer> bitrateRange = mediaCodecInfo.getCapabilitiesForType(mimeType).getVideoCapabilities().getBitrateRange(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory, it would be better to check all video capabilities like you are doing there.
But in the past, I noticed that in practice (on some devices), the reported values were not always accurate (especially for sizes), where "valid" values don't work or "invalid" values works. That's why I don't use them to filter parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you mentioned, if there are cases where the attribute values provided by the equipment are invalid, a comprehensive test of the entire equipment (within a specific range) will be required.
If the value of --video-bit-rate exceeds the supported range, the server is stopped.
I have added exception handling code for this issue.