Skip to content

Commit

Permalink
Merge pull request #118 from pedroSG94/feature/update-dependecy
Browse files Browse the repository at this point in the history
update to 2.4.4 and callbacks to main thread
  • Loading branch information
pedroSG94 authored Apr 3, 2024
2 parents 3044682 + 6cc8b39 commit 1379ce9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
```
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 13 additions & 4 deletions rtspserver/src/main/java/com/pedro/rtspserver/server/RtspServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand Down Expand Up @@ -289,7 +296,9 @@ class RtspServer(
synchronized(clients) {
client.stopClient()
clients.remove(client)
clientListener?.onClientDisconnected(client)
onMainThreadHandler {
clientListener?.onClientDisconnected(client)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1379ce9

Please sign in to comment.