Revert dramatic changes

hh
Laurent 5 years ago
parent c2ad1c9ece
commit 44db39c743
  1. 30
      app/src/main/java/net/pokeranalytics/android/util/video/MMediaMuxer.kt

@ -50,8 +50,6 @@ class MMediaMuxer {
ShowProgressBar() ShowProgressBar()
} }
// private val aHandler = Handler()
fun AddFrame(byteFrame: ByteArray) { fun AddFrame(byteFrame: ByteArray) {
CheckDataListState() CheckDataListState()
Thread(Runnable { Thread(Runnable {
@ -162,14 +160,20 @@ class MMediaMuxer {
@Throws(IOException::class) @Throws(IOException::class)
private fun PrepareEncoder() { private fun PrepareEncoder() {
val codecInfo = selectCodec(MIME_TYPE) val codecInfo =
selectCodec(
MIME_TYPE
)
if (codecInfo == null) { if (codecInfo == null) {
Loge("Unable to find an appropriate codec for $MIME_TYPE") Loge("Unable to find an appropriate codec for $MIME_TYPE")
} }
Logd("found codec: " + codecInfo!!.name) Logd("found codec: " + codecInfo!!.name)
val colorFormat: Int val colorFormat: Int
colorFormat = try { colorFormat = try {
selectColorFormat(codecInfo, MIME_TYPE) selectColorFormat(
codecInfo,
MIME_TYPE
)
} catch (e: Exception) { } catch (e: Exception) {
CodecCapabilities.COLOR_FormatYUV420SemiPlanar CodecCapabilities.COLOR_FormatYUV420SemiPlanar
} }
@ -215,7 +219,9 @@ class MMediaMuxer {
val TIMEOUT_USEC: Long = 5000 val TIMEOUT_USEC: Long = 5000
val inputBufIndex = mediaCodec!!.dequeueInputBuffer(TIMEOUT_USEC) val inputBufIndex = mediaCodec!!.dequeueInputBuffer(TIMEOUT_USEC)
val ptsUsec = val ptsUsec =
computePresentationTime(generateIndex.toLong(), FRAME_RATE) computePresentationTime(generateIndex.toLong(),
FRAME_RATE
)
if (inputBufIndex >= 0) { if (inputBufIndex >= 0) {
val input = bitFirst!![currentIndexFrame] val input = bitFirst!![currentIndexFrame]
val inputBuffer = mediaCodec!!.getInputBuffer(inputBufIndex) val inputBuffer = mediaCodec!!.getInputBuffer(inputBufIndex)
@ -382,12 +388,18 @@ class MMediaMuxer {
* code. If no match is found, this throws a test failure -- the set of * 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. * formats known to the test should be expanded for new platforms.
*/ */
private fun selectColorFormat(codecInfo: MediaCodecInfo, mimeType: String): Int { private fun selectColorFormat(
codecInfo: MediaCodecInfo,
val capabilities = codecInfo.getCapabilitiesForType(mimeType) mimeType: String
): Int {
val capabilities = codecInfo
.getCapabilitiesForType(mimeType)
for (i in capabilities.colorFormats.indices) { for (i in capabilities.colorFormats.indices) {
val colorFormat = capabilities.colorFormats[i] val colorFormat = capabilities.colorFormats[i]
if (isRecognizedFormat(colorFormat)) { if (isRecognizedFormat(
colorFormat
)
) {
return colorFormat return colorFormat
} }
} }

Loading…
Cancel
Save