diff --git a/README.md b/README.md index 0419b90..ef906bc 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ allprojects { } } dependencies { - implementation 'com.github.pedroSG94:RTSP-Server:1.2.6' - implementation 'com.github.pedroSG94.RootEncoder:library:2.4.3' + implementation 'com.github.pedroSG94:RTSP-Server:1.2.7' + implementation 'com.github.pedroSG94.RootEncoder:library:2.4.4' } ``` diff --git a/build.gradle.kts b/build.gradle.kts index 317229c..9772c12 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,9 +1,9 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. val libraryGroup by rootProject.extra { "com.github.pedroSG94" } -val vCode by rootProject.extra { 126 } -val vName by rootProject.extra { "1.2.6" } +val vCode by rootProject.extra { 127 } +val vName by rootProject.extra { "1.2.7" } val coroutinesVersion by rootProject.extra { "1.7.3" } -val rootEncoderVersion by rootProject.extra { "2.4.3" } +val rootEncoderVersion by rootProject.extra { "2.4.4" } plugins { id("com.android.application") version "8.3.1" apply false diff --git a/rtspserver/src/main/java/com/pedro/rtspserver/server/RtspServer.kt b/rtspserver/src/main/java/com/pedro/rtspserver/server/RtspServer.kt index 5bf3cd8..3d74050 100644 --- a/rtspserver/src/main/java/com/pedro/rtspserver/server/RtspServer.kt +++ b/rtspserver/src/main/java/com/pedro/rtspserver/server/RtspServer.kt @@ -5,6 +5,7 @@ import android.util.Log import com.pedro.common.AudioCodec import com.pedro.common.ConnectChecker import com.pedro.common.VideoCodec +import com.pedro.common.onMainThreadHandler import com.pedro.rtsp.utils.RtpConstants import java.io.* import java.lang.RuntimeException @@ -90,13 +91,17 @@ class RtspServer( semaphore.tryAcquire(5000, TimeUnit.MILLISECONDS) } if (!serverCommandManager.videoInfoReady()) { - connectChecker.onConnectionFailed("video info is null") + onMainThreadHandler { + connectChecker.onConnectionFailed("video info is null") + } return@Thread } } server = ServerSocket(port) } catch (e: IOException) { - connectChecker.onConnectionFailed("Server creation failed") + onMainThreadHandler { + connectChecker.onConnectionFailed("Server creation failed") + } Log.e(TAG, "Error", e) return@Thread } @@ -117,7 +122,9 @@ class RtspServer( synchronized(clients) { clients.add(client) } - clientListener?.onClientConnected(client) + onMainThreadHandler { + clientListener?.onClientConnected(client) + } } catch (e: SocketException) { // server.close called break @@ -289,7 +296,9 @@ class RtspServer( synchronized(clients) { client.stopClient() clients.remove(client) - clientListener?.onClientDisconnected(client) + onMainThreadHandler { + clientListener?.onClientDisconnected(client) + } } } diff --git a/rtspserver/src/main/java/com/pedro/rtspserver/server/ServerClient.kt b/rtspserver/src/main/java/com/pedro/rtspserver/server/ServerClient.kt index c726245..245655c 100644 --- a/rtspserver/src/main/java/com/pedro/rtspserver/server/ServerClient.kt +++ b/rtspserver/src/main/java/com/pedro/rtspserver/server/ServerClient.kt @@ -3,6 +3,7 @@ package com.pedro.rtspserver.server import android.media.MediaCodec import android.util.Log import com.pedro.common.ConnectChecker +import com.pedro.common.onMainThreadHandler import com.pedro.rtsp.rtsp.Protocol import com.pedro.rtsp.rtsp.RtspSender import com.pedro.rtsp.rtsp.commands.Method @@ -86,12 +87,16 @@ class ServerClient( } } rtspSender.start() - connectChecker.onConnectionSuccess() + onMainThreadHandler { + connectChecker.onConnectionSuccess() + } canSend = true } else if (request.method == Method.TEARDOWN) { Log.i(TAG, "Client disconnected") listener.onClientDisconnected(this) - connectChecker.onDisconnect() + onMainThreadHandler { + connectChecker.onDisconnect() + } } } catch (e: SocketException) { // Client has left Log.e(TAG, "Client disconnected", e)