Skip to content

Commit 2281da6

Browse files
committed
.
1 parent d65f56f commit 2281da6

6 files changed

Lines changed: 125 additions & 14 deletions

File tree

.github/workflows/android.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Android CI
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: set up JDK 17
17+
uses: actions/setup-java@v4
18+
with:
19+
java-version: '17'
20+
distribution: 'temurin'
21+
cache: gradle
22+
23+
- name: Grant execute permission for gradlew
24+
run: chmod +x gradlew
25+
- name: Build with Gradle
26+
run: ./gradlew assembleRelease
27+
- name: Set up Keystore
28+
run: |
29+
sudo apt update -y || true
30+
sudo apt install -y --no-install-recommends coreutils
31+
mkdir -p $RUNNER_TEMP/keystores
32+
echo "${{ secrets.KEYSTORE_FILE }}" | base64 --decode > $RUNNER_TEMP/keystores/keystore.jks
33+
- name: Sign APK
34+
run: |
35+
ANDROID_SDK_PATH=$ANDROID_HOME/build-tools/35.0.0/apksigner
36+
$ANDROID_SDK_PATH sign \
37+
--ks $RUNNER_TEMP/keystores/keystore.jks \
38+
--ks-key-alias ${{ secrets.RELEASE_SIGN_KEY_ALIAS }} \
39+
--ks-pass pass:${{ secrets.KEYSTORE_PASSWORD }} \
40+
--key-pass pass:${{ secrets.KEYSTORE_PASSWORD }} \
41+
--out app-release.apk \
42+
app/build/outputs/apk/release/*.apk
43+
- name: Upload APK Artifact
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: apk-artifact
47+
path: app-release.apk
48+
compression-level: 5

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mobile/src/main/assets/ffmpeg

48.1 MB
Binary file not shown.

mobile/src/main/assets/readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
я хз как правельно, сори за говно-код

mobile/src/main/java/com/iokreal/myapplication/MainActivity.kt

Lines changed: 65 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ import androidx.media3.ui.PlayerView
1313
import androidx.core.content.edit
1414
import org.json.JSONObject
1515
import java.io.File
16+
import java.io.FileOutputStream
1617
import java.net.HttpURLConnection
1718
import java.net.URL
19+
import java.nio.file.Files
20+
1821
object AppPreferences {
1922
private const val PREFS_NAME = "AppPreferences"
2023
private lateinit var sharedPref: SharedPreferences
@@ -23,7 +26,7 @@ object AppPreferences {
2326
context.applicationContext.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
2427
}
2528
var urlCam: String
26-
get() = sharedPref.getString("urlCam", "rtsp://192.168.50.60") ?: "rtsp://192.168.50.60"
29+
get() = sharedPref.getString("urlCam", "") ?: ""
2730
set(value) {
2831
sharedPref.edit { putString("urlCam", value) }
2932
}
@@ -49,6 +52,7 @@ object AppPreferences {
4952
}
5053
}
5154
class MainActivity : AppCompatActivity() {
55+
private var ffmpegPath = ""
5256
companion object{
5357
val cams = mutableListOf<Array<String>>()
5458
}
@@ -67,25 +71,15 @@ class MainActivity : AppCompatActivity() {
6771
}
6872

6973
//nukewebviewData()
70-
71-
Thread{
72-
if (demon){
73-
return@Thread
74-
}
75-
while (true){
76-
demon = true
77-
Thread.sleep(4320000)
78-
setStreamsRTC()
79-
}
80-
}.start()
74+
startFFmpeg()
8175
}
8276

8377
override fun onResume() {
8478
super.onResume()
8579
setStreamsUser()
8680
Thread{
8781
setStreamsRTC()
88-
}.start()
82+
}//.start()
8983
}
9084

9185
private fun openLogin(){
@@ -105,7 +99,7 @@ class MainActivity : AppCompatActivity() {
10599
private fun setStreamsUser(){
106100
var playerView = findViewById<PlayerView>(R.id.videoView6)
107101
if (AppPreferences.urlCam != "" || AppPreferences.urlCam != " ") {
108-
initPlayer(playerView, AppPreferences.urlCam)
102+
initPlayer(playerView, "127.0.0.1:1234")
109103
}else{
110104
playerView.visibility = View.GONE
111105
}
@@ -182,4 +176,61 @@ class MainActivity : AppCompatActivity() {
182176
setStreamsRTC()
183177
}.start()
184178
}
179+
180+
fun startFFmpeg() {
181+
val destinationFile = File(application.filesDir, "ffmpeg")
182+
if (destinationFile.exists()) {
183+
Log.d("FFmpeg", "FFmpeg execf futable already exists in internal storage.")
184+
}else {
185+
try {
186+
val inputStream = application.assets.open("ffmpeg")
187+
val outputStream = FileOutputStream(destinationFile)
188+
inputStream.copyTo(outputStream)
189+
outputStream.close()
190+
inputStream.close()
191+
destinationFile.setExecutable(true)
192+
193+
Log.d(
194+
"FFmpeg",
195+
"FFmpeg executable successfully copied to: ${destinationFile.absolutePath}"
196+
)
197+
198+
} catch (e: Exception) {
199+
Log.e("FFmpeg", "Failed to copy FFmpeg asset.", e)
200+
}
201+
}
202+
val command = listOf(
203+
destinationFile.absolutePath,
204+
"-i",
205+
"rtsp://192.168.50.60:554",
206+
"-c",
207+
"copy",
208+
"-f",
209+
"mpegts",
210+
"udp://127.0.0.1:1234"
211+
)
212+
213+
// Using Thread is fine, but Coroutines are generally better practice in modern Android
214+
Thread {
215+
try {
216+
//Thread.sleep(5000)
217+
val process = ProcessBuilder(command)
218+
//.redirectErrorStream(true) // Combines stdout and stderr
219+
.start()
220+
221+
process.inputStream.bufferedReader().use { reader ->
222+
reader.forEachLine { line ->
223+
Log.i("FFmpeg_Output", line) // Log FFmpeg's output
224+
}
225+
}
226+
227+
val exitCode = process.waitFor()
228+
Log.d("FFmpeg", "FFmpeg process finished with exit code: $exitCode")
229+
230+
} catch (e: Exception) {
231+
// Log the exception details
232+
Log.e("FFmpeg_Exec", "Error running FFmpeg command.", e)
233+
}
234+
}.start()
235+
}
185236
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">
2+
3+
<path android:fillColor="@android:color/white" android:pathData="M480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480L160,480Q160,595 232.5,683Q305,771 418,794L360,736L416,680L598,862Q569,872 539.5,876Q510,880 480,880ZM500,600L500,360L620,360Q637,360 648.5,371.5Q660,383 660,400L660,560Q660,577 648.5,588.5Q637,600 620,600L500,600ZM300,600L300,540L400,540L400,500L340,500L340,460L400,460L400,420L300,420L300,360L420,360Q437,360 448.5,371.5Q460,383 460,400L460,560Q460,577 448.5,588.5Q437,600 420,600L300,600ZM560,540L600,540Q600,540 600,540Q600,540 600,540L600,420Q600,420 600,420Q600,420 600,420L560,420L560,540ZM800,480Q800,365 727.5,277Q655,189 542,166L600,224L544,280L362,98Q391,88 420.5,84Q450,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480L800,480Z"/>
4+
5+
</vector>

0 commit comments

Comments
 (0)