diff --git a/app/src/main/java/com/yutou/doormanager/MainActivity.kt b/app/src/main/java/com/yutou/doormanager/MainActivity.kt index 9340f7d..47c3898 100644 --- a/app/src/main/java/com/yutou/doormanager/MainActivity.kt +++ b/app/src/main/java/com/yutou/doormanager/MainActivity.kt @@ -27,6 +27,7 @@ import me.lake.librestreaming.ws.filter.hardfilter.WatermarkFilter import me.lake.librestreaming.ws.filter.hardfilter.extra.GPUImageCompatibleFilter import org.json.JSONObject import java.io.File +import java.math.BigDecimal import java.util.* @@ -37,7 +38,7 @@ class MainActivity : AppCompatActivity() { private lateinit var button_open: Button private lateinit var button_af: Button private lateinit var mLiveCameraView: StreamLiveCameraView - private var zoom = 0.0f + private var zoom =BigDecimal(0) private var isUpdate = true public lateinit var myDataListener: MyDataListener override fun onCreate(savedInstanceState: Bundle?) { @@ -74,19 +75,20 @@ class MainActivity : AppCompatActivity() { button_open = findViewById(R.id.openPC) button_af = findViewById(R.id.af) button_up.setOnClickListener { - zoom += 0.1f - if (zoom > 1.0f) { - zoom = 1.0f + zoom.add(BigDecimal(0.1)) + if (zoom.toFloat() > 1.0f) { + zoom = BigDecimal(1.0) } - mLiveCameraView.setZoomByPercent(zoom) + + mLiveCameraView.setZoomByPercent(zoom.toFloat()) uploadZoom(zoom) } button_down.setOnClickListener { - zoom -= 0.1f - if (zoom < 0f) { - zoom = 0.0f + zoom.subtract(BigDecimal(0.1)) + if (zoom.toFloat() < 0f) { + zoom = BigDecimal(0) } - mLiveCameraView.setZoomByPercent(zoom) + mLiveCameraView.setZoomByPercent(zoom.toFloat()) uploadZoom(zoom) } button_screen.setOnClickListener { @@ -119,14 +121,14 @@ class MainActivity : AppCompatActivity() { } } - private fun uploadZoom(zoom: Float) { + private fun uploadZoom(zoom: BigDecimal) { val json = JSONObject() - json.put("zoom", zoom) + json.put("zoom", "${zoom.toFloat()}") HttpUtils.post("http://192.168.31.88:8000/door/zoom.do", json, null, object : HttpListener { override fun data(code: Int, data: String) { if (data == "1") { Handler(Looper.getMainLooper()).post { - Toast.makeText(this@MainActivity, "设置成功:${zoom}", Toast.LENGTH_LONG).show() + Toast.makeText(this@MainActivity, "设置成功:${zoom.toFloat()}", Toast.LENGTH_LONG).show() } } } @@ -170,7 +172,7 @@ class MainActivity : AppCompatActivity() { Timer().schedule(object : TimerTask() { override fun run() { watermark.updateText(32f, Utils.getTime()+" 推流:${mLiveCameraView.avSpeed}") - if (!mLiveCameraView.isStreaming||mLiveCameraView.avSpeed==0) { + if (mLiveCameraView.avSpeed==0) { mLiveCameraView.stopStreaming() mLiveCameraView.startStreaming("rtmp://192.168.31.88/live") } @@ -194,8 +196,8 @@ class MainActivity : AppCompatActivity() { inner class MyDataListener : DataListener { override fun out(json: JSONObject) { Handler(Looper.getMainLooper()).post { - zoom = json.getDouble("zoom").toFloat() - mLiveCameraView.setZoomByPercent(zoom) + zoom = BigDecimal(json.getDouble("zoom")) + mLiveCameraView.setZoomByPercent(zoom.toFloat()) if (json.getString("restart").equals("1")) { val intent = packageManager.getLaunchIntentForPackage(packageName); intent!!.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); diff --git a/libWSLive/build.gradle b/libWSLive/build.gradle index e413bf0..5a82d32 100644 --- a/libWSLive/build.gradle +++ b/libWSLive/build.gradle @@ -5,6 +5,7 @@ android { compileSdkVersion 31 defaultConfig { targetSdkVersion 31 + minSdk 21 ndk{ abiFilters "armeabi-v7a" } @@ -22,6 +23,13 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + buildFeatures { + viewBinding true + } /* externalNativeBuild{ ndkBuild{ path file("src/main/jni/rtmp/Android.mk") @@ -39,4 +47,13 @@ android { dependencies { implementation 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1' + + def camerax_version = "1.1.0-beta01" + implementation "androidx.camera:camera-core:${camerax_version}" + implementation "androidx.camera:camera-camera2:${camerax_version}" + implementation "androidx.camera:camera-lifecycle:${camerax_version}" + implementation "androidx.camera:camera-video:${camerax_version}" + + implementation "androidx.camera:camera-view:${camerax_version}" + implementation "androidx.camera:camera-extensions:${camerax_version}" } diff --git a/libWSLive/src/main/java/me/lake/librestreaming/client/RESVideoClient.java b/libWSLive/src/main/java/me/lake/librestreaming/client/RESVideoClient.java index e2f0c2d..2e32790 100644 --- a/libWSLive/src/main/java/me/lake/librestreaming/client/RESVideoClient.java +++ b/libWSLive/src/main/java/me/lake/librestreaming/client/RESVideoClient.java @@ -511,7 +511,7 @@ public class RESVideoClient { public void setCameraArea(){ System.out.println("设置对焦"); List focusAreas = new ArrayList<>(); - focusAreas.add(new Camera.Area(calculateTapArea(0,0,5,5,1.0f), 800)); + focusAreas.add(new Camera.Area(new Rect(-100, -100, 100, 100), 1000)); Camera.Parameters parameters=camera.getParameters(); parameters.setFocusAreas(focusAreas); camera.setParameters(parameters);