fix: Fix NoSuchElementException in getRecommendedBitRate (#2266)

* Remove unused hasConstants method.  Do no thrown error on minBy call when filterd videoProfiles contains zero items.

* Remove not related to the fix changes.
This commit is contained in:
Romick2005 2023-12-12 12:15:10 +02:00 committed by GitHub
parent 4ee52d6211
commit a612eb9d38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,7 +31,7 @@ fun RecordingSession.getRecommendedBitRate(fps: Int, codec: VideoCodec, hdr: Boo
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
val profiles = CamcorderProfile.getAll(cameraId, quality) val profiles = CamcorderProfile.getAll(cameraId, quality)
if (profiles != null) { if (profiles != null) {
val best = profiles.videoProfiles.filterNotNull().minBy { val best = profiles.videoProfiles.filterNotNull().minByOrNull {
abs(it.width * it.height - targetResolution.width * targetResolution.height) abs(it.width * it.height - targetResolution.width * targetResolution.height)
} }