From 44db39c743eb6c63e01e2ae9e3d284dba117fd17 Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 1 Jul 2020 09:10:16 +0200 Subject: [PATCH] Revert dramatic changes --- .../android/util/video/MMediaMuxer.kt | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/net/pokeranalytics/android/util/video/MMediaMuxer.kt b/app/src/main/java/net/pokeranalytics/android/util/video/MMediaMuxer.kt index f4ea3849..10b4eafa 100644 --- a/app/src/main/java/net/pokeranalytics/android/util/video/MMediaMuxer.kt +++ b/app/src/main/java/net/pokeranalytics/android/util/video/MMediaMuxer.kt @@ -50,8 +50,6 @@ class MMediaMuxer { ShowProgressBar() } -// private val aHandler = Handler() - fun AddFrame(byteFrame: ByteArray) { CheckDataListState() Thread(Runnable { @@ -162,14 +160,20 @@ class MMediaMuxer { @Throws(IOException::class) private fun PrepareEncoder() { - val codecInfo = selectCodec(MIME_TYPE) + val codecInfo = + selectCodec( + MIME_TYPE + ) if (codecInfo == null) { Loge("Unable to find an appropriate codec for $MIME_TYPE") } Logd("found codec: " + codecInfo!!.name) val colorFormat: Int colorFormat = try { - selectColorFormat(codecInfo, MIME_TYPE) + selectColorFormat( + codecInfo, + MIME_TYPE + ) } catch (e: Exception) { CodecCapabilities.COLOR_FormatYUV420SemiPlanar } @@ -215,7 +219,9 @@ class MMediaMuxer { val TIMEOUT_USEC: Long = 5000 val inputBufIndex = mediaCodec!!.dequeueInputBuffer(TIMEOUT_USEC) val ptsUsec = - computePresentationTime(generateIndex.toLong(), FRAME_RATE) + computePresentationTime(generateIndex.toLong(), + FRAME_RATE + ) if (inputBufIndex >= 0) { val input = bitFirst!![currentIndexFrame] val inputBuffer = mediaCodec!!.getInputBuffer(inputBufIndex) @@ -354,7 +360,7 @@ class MMediaMuxer { private const val BIT_RATE = 800000 private const val INFLAME_INTERVAL = 1 private const val FRAME_RATE = 50 -// private const val DEBUG = false + // private const val DEBUG = false private const val TAG = "CODEC" /** * Returns the first codec capable of encoding the specified MIME type, or @@ -382,12 +388,18 @@ class MMediaMuxer { * code. If no match is found, this throws a test failure -- the set of * formats known to the test should be expanded for new platforms. */ - private fun selectColorFormat(codecInfo: MediaCodecInfo, mimeType: String): Int { - - val capabilities = codecInfo.getCapabilitiesForType(mimeType) + private fun selectColorFormat( + codecInfo: MediaCodecInfo, + mimeType: String + ): Int { + val capabilities = codecInfo + .getCapabilitiesForType(mimeType) for (i in capabilities.colorFormats.indices) { val colorFormat = capabilities.colorFormats[i] - if (isRecognizedFormat(colorFormat)) { + if (isRecognizedFormat( + colorFormat + ) + ) { return colorFormat } } @@ -421,4 +433,4 @@ class MMediaMuxer { // Log.e(TAG, Mess) } } -} \ No newline at end of file +}