mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-29 18:39:27 +01:00
Fix broken video compression due to NPE in library
Library issue: https://github.com/natario1/Transcoder/issues/154 Possibly fixes https://github.com/vector-im/element-android/issues/4337 Also add some logging for failures.
This commit is contained in:
parent
54daee2798
commit
076820bb10
1
changelog.d/4353.bugfix
Normal file
1
changelog.d/4353.bugfix
Normal file
@ -0,0 +1 @@
|
||||
Fix video compression before upload
|
@ -188,6 +188,9 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter
|
||||
}
|
||||
})
|
||||
.let { videoCompressionResult ->
|
||||
if (videoCompressionResult is VideoCompressionResult.CompressionFailed) {
|
||||
videoCompressionResult.failure.printStackTrace()
|
||||
}
|
||||
when (videoCompressionResult) {
|
||||
is VideoCompressionResult.Success -> {
|
||||
val compressedFile = videoCompressionResult.compressedFile
|
||||
|
@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.session.content
|
||||
|
||||
import com.otaliastudios.transcoder.Transcoder
|
||||
import com.otaliastudios.transcoder.TranscoderListener
|
||||
import com.otaliastudios.transcoder.source.FilePathDataSource
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.withContext
|
||||
@ -43,7 +44,16 @@ internal class VideoCompressor @Inject constructor(
|
||||
var result: Int = -1
|
||||
var failure: Throwable? = null
|
||||
Transcoder.into(destinationFile.path)
|
||||
.addDataSource(videoFile.path)
|
||||
.addDataSource(object : FilePathDataSource(videoFile.path) {
|
||||
// https://github.com/natario1/Transcoder/issues/154
|
||||
@Suppress("SENSELESS_COMPARISON") // Source is annotated as @NonNull, but can actually be null...
|
||||
override fun isInitialized(): Boolean {
|
||||
if (source == null) {
|
||||
return false
|
||||
}
|
||||
return super.isInitialized()
|
||||
}
|
||||
})
|
||||
.setListener(object : TranscoderListener {
|
||||
override fun onTranscodeProgress(progress: Double) {
|
||||
Timber.d("Compressing: $progress%")
|
||||
|
Loading…
x
Reference in New Issue
Block a user