Dana
2025-12-01 ccf7a1f19b5c6276178c72609c88d057214c8239
app/src/main/java/com/anyun/h264/MainActivity.kt
@@ -1,7 +1,7 @@
package com.anyun.h264
import android.os.Bundle
import android.util.Log
import timber.log.Timber
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
@@ -52,7 +52,7 @@
    
    private fun startH264Encoder(): Boolean {
        if (h264Encoder != null) {
            Log.w("MainActivity", "H264Encoder is already running")
            Timber.w("H264Encoder is already running")
            return false
        }
        
@@ -80,16 +80,16 @@
            
            if (h264Encoder?.initialize(cameraIdRange, null, resolution, false) == true) {
                h264Encoder?.start()
                Log.d("MainActivity", "H264Encoder started successfully")
                Log.d("MainActivity", "Output file: ${outputFile.absolutePath}")
                Timber.d("H264Encoder started successfully")
                Timber.d("Output file: %s", outputFile.absolutePath)
                return true
            } else {
                Log.e("MainActivity", "Failed to initialize H264Encoder")
                Timber.e("Failed to initialize H264Encoder")
                h264Encoder = null
                return false
            }
        } catch (e: Exception) {
            Log.e("MainActivity", "Failed to start H264Encoder", e)
            Timber.e(e, "Failed to start H264Encoder")
            h264Encoder = null
            return false
        }
@@ -99,9 +99,9 @@
        h264Encoder?.let { encoder ->
            try {
                encoder.stop()
                Log.d("MainActivity", "H264Encoder stopped")
                Timber.d("H264Encoder stopped")
            } catch (e: Exception) {
                Log.e("MainActivity", "Failed to stop H264Encoder", e)
                Timber.e(e, "Failed to stop H264Encoder")
            }
            h264Encoder = null
        }