mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-02 16:27:33 +00:00
android, desktop: reduce timeout and do not use hardward acceleration for video preview generation (#6924)
Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
This commit is contained in:
+2
@@ -14,6 +14,8 @@ import java.util.*
|
||||
import kotlin.math.max
|
||||
|
||||
internal val vlcFactory: MediaPlayerFactory by lazy { MediaPlayerFactory() }
|
||||
// No hardware acceleration - more secure for previews
|
||||
internal val vlcPreviewFactory: MediaPlayerFactory by lazy { MediaPlayerFactory("--avcodec-hw=none") }
|
||||
|
||||
actual class RecorderNative: RecorderInterface {
|
||||
private var player: MediaPlayer? = null
|
||||
|
||||
+3
-3
@@ -225,9 +225,9 @@ actual class VideoPlayer actual constructor(
|
||||
player.media().startPaused(uri.toFile().absolutePath)
|
||||
val start = System.currentTimeMillis()
|
||||
var snap: BufferedImage? = null
|
||||
while (snap == null && start + 5000 > System.currentTimeMillis()) {
|
||||
while (snap == null && start + 1500 > System.currentTimeMillis()) {
|
||||
snap = player.snapshots()?.get()
|
||||
delay(10)
|
||||
delay(50)
|
||||
}
|
||||
val orientation = player.media().info().videoTracks().firstOrNull()?.orientation()
|
||||
if (orientation == null) {
|
||||
@@ -280,7 +280,7 @@ actual class VideoPlayer actual constructor(
|
||||
|
||||
private fun putPlayer(player: Component) = playersPool.add(player)
|
||||
|
||||
private fun getOrCreateHelperPlayer(): CallbackMediaPlayerComponent = helperPlayersPool.removeFirstOrNull() ?: CallbackMediaPlayerComponent(MediaPlayerSpecs.callbackMediaPlayerSpec().apply { withFactory(vlcFactory) })
|
||||
private fun getOrCreateHelperPlayer(): CallbackMediaPlayerComponent = helperPlayersPool.removeFirstOrNull() ?: CallbackMediaPlayerComponent(MediaPlayerSpecs.callbackMediaPlayerSpec().apply { withFactory(vlcPreviewFactory) })
|
||||
private fun putHelperPlayer(player: CallbackMediaPlayerComponent) = helperPlayersPool.add(player)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user