From 47a0366ae79446d68522620f4682a76249736776 Mon Sep 17 00:00:00 2001 From: ThibaultBee <37510686+ThibaultBee@users.noreply.github.com> Date: Tue, 9 Jul 2024 21:33:18 +0200 Subject: [PATCH] feat(*): move `build.gradle` to Kotlin DSL. Also move `srtdroid` package to `srtdroid-core` --- .github/workflows/docs.yml | 10 +- build.gradle | 47 ------- build.gradle.kts | 37 +++++ buildSrc/.gitignore | 1 + buildSrc/build.gradle.kts | 23 +++ buildSrc/src/main/kotlin/Configuration.kt | 49 +++++++ buildSrc/src/main/kotlin/Property.kt | 12 ++ buildSrc/src/main/kotlin/Publication.kt | 98 +++++++++++++ example/build.gradle | 60 -------- example/build.gradle.kts | 59 ++++++++ .../srtdroid/example/MainActivity.kt | 2 +- .../thibaultbee/srtdroid/example/Utils.kt | 4 +- .../srtdroid/example/tests/RecvFile.kt | 4 +- .../srtdroid/example/tests/SendFile.kt | 4 +- .../srtdroid/example/tests/TestClient.kt | 2 +- .../srtdroid/example/tests/TestServer.kt | 2 +- gradle/libs.versions.toml | 13 ++ settings.gradle | 3 - settings.gradle.kts | 25 ++++ {srtdroid => srtdroid-core}/.gitignore | 0 srtdroid-core/build.gradle.kts | 60 ++++++++ .../consumer-rules.pro | 0 .../proguard-rules.pro | 0 .../thibaultbee/srtdroid/core}/SrtTest.kt | 3 +- .../core}/enums/RejectReasonCodeTest.kt | 4 +- .../srtdroid/core}/enums/TranstypeTest.kt | 4 +- .../srtdroid/core}/models/EpollTest.kt | 17 ++- .../srtdroid/core}/models/ErrorTest.kt | 6 +- .../srtdroid/core}/models/SrtSocket6Test.kt | 17 ++- .../core}/models/SrtSocketCallbackTest.kt | 33 +++-- .../core}/models/SrtSocketRecvTest.kt | 10 +- .../core}/models/SrtSocketSendRecvFileTest.kt | 14 +- .../core}/models/SrtSocketSendTest.kt | 13 +- .../srtdroid/core}/models/SrtSocketTest.kt | 48 +++++-- .../srtdroid/core}/models/SrtUrlTest.kt | 6 +- .../srtdroid/core}/models/TimeTest.kt | 7 +- .../thibaultbee/srtdroid/core}/utils/Utils.kt | 6 +- .../src/main/AndroidManifest.xml | 0 .../src/main/cpp/CMakeLists.txt | 0 .../src/main/cpp/CallbackContext.cpp | 0 .../src/main/cpp/CallbackContext.h | 0 .../src/main/cpp/Enums/AddressFamily.h | 0 .../src/main/cpp/Enums/Bimap.h | 0 .../src/main/cpp/Enums/Boundary.h | 0 .../src/main/cpp/Enums/EnumConverter.h | 0 srtdroid-core/src/main/cpp/Enums/Enums.h | 27 ++++ .../src/main/cpp/Enums/EnumsSingleton.h | 0 .../src/main/cpp/Enums/EpollFlag.h | 0 .../src/main/cpp/Enums/EpollOpt.h | 0 .../src/main/cpp/Enums/ErrorType.h | 0 .../src/main/cpp/Enums/KMState.h | 0 .../src/main/cpp/Enums/RejectReasonCode.h | 0 .../src/main/cpp/Enums/SockOpt.h | 0 .../src/main/cpp/Enums/SockStatus.h | 0 .../src/main/cpp/Enums/TransType.h | 0 .../src/main/cpp/Models/Epoll.h | 0 .../src/main/cpp/Models/EpollEvent.h | 0 .../src/main/cpp/Models/EpollFlags.h | 0 .../src/main/cpp/Models/EpollOpts.h | 0 .../src/main/cpp/Models/InetSocketAddress.h | 0 .../src/main/cpp/Models/List.h | 0 .../src/main/cpp/Models/Models.h | 16 +-- .../src/main/cpp/Models/MsgCtrl.h | 0 .../src/main/cpp/Models/OptVal.h | 0 .../src/main/cpp/Models/Pair.h | 0 .../src/main/cpp/Models/Primitive.h | 0 .../src/main/cpp/Models/Socket.h | 0 .../src/main/cpp/Models/Stats.h | 0 .../src/main/cpp/glue.cpp | 0 .../src/main/cpp/log.h | 0 .../github/thibaultbee/srtdroid/core}/Srt.kt | 2 +- .../srtdroid/core}/enums/Boundary.kt | 4 +- .../srtdroid/core}/enums/EpollFlag.kt | 4 +- .../srtdroid/core}/enums/EpollOpt.kt | 4 +- .../srtdroid/core}/enums/ErrorType.kt | 4 +- .../srtdroid/core}/enums/KMState.kt | 2 +- .../srtdroid/core}/enums/RejectReasonCode.kt | 6 +- .../srtdroid/core}/enums/SockOpt.kt | 4 +- .../srtdroid/core}/enums/SockStatus.kt | 4 +- .../srtdroid/core}/enums/Transtype.kt | 2 +- .../srtdroid/core/extensions/IntExtensions.kt | 5 + .../core}/extensions/SocketExtensions.kt | 6 +- .../core}/interfaces/ConfigurableSrtSocket.kt | 4 +- .../srtdroid/core}/models/Epoll.kt | 30 ++-- .../srtdroid/core}/models/EpollEvent.kt | 6 +- .../srtdroid/core}/models/Error.kt | 6 +- .../srtdroid/core}/models/MsgCtrl.kt | 6 +- .../srtdroid/core}/models/SrtSocket.kt | 105 ++++++++++---- .../srtdroid/core}/models/SrtUrl.kt | 12 +- .../srtdroid/core}/models/Stats.kt | 2 +- .../thibaultbee/srtdroid/core}/models/Time.kt | 4 +- .../rejectreason/InternalRejectReason.kt | 4 +- .../rejectreason/PredefinedRejectReason.kt | 2 +- .../core}/models/rejectreason/RejectReason.kt | 4 +- .../rejectreason/UserDefinedRejectReason.kt | 5 +- .../src/main/res/values/strings.xml | 0 srtdroid-ktx/build.gradle | 41 ------ srtdroid-ktx/build.gradle.kts | 53 +++++++ .../srtdroid/ktx/CoroutineSrtSocket.kt | 53 +++---- .../extensions/CoroutineSocketExtensions.kt | 2 +- srtdroid/build.gradle | 133 ------------------ srtdroid/src/main/cpp/Enums/Enums.h | 27 ---- .../srtdroid/extensions/IntExtensions.kt | 5 - 103 files changed, 772 insertions(+), 525 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts create mode 100644 buildSrc/.gitignore create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/src/main/kotlin/Configuration.kt create mode 100644 buildSrc/src/main/kotlin/Property.kt create mode 100644 buildSrc/src/main/kotlin/Publication.kt delete mode 100644 example/build.gradle create mode 100644 example/build.gradle.kts create mode 100644 gradle/libs.versions.toml delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts rename {srtdroid => srtdroid-core}/.gitignore (100%) create mode 100644 srtdroid-core/build.gradle.kts rename {srtdroid => srtdroid-core}/consumer-rules.pro (100%) rename {srtdroid => srtdroid-core}/proguard-rules.pro (100%) rename {srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core}/SrtTest.kt (92%) rename {srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core}/enums/RejectReasonCodeTest.kt (90%) rename {srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core}/enums/TranstypeTest.kt (90%) rename {srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core}/models/EpollTest.kt (90%) rename {srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core}/models/ErrorTest.kt (92%) rename {srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core}/models/SrtSocket6Test.kt (81%) rename {srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core}/models/SrtSocketCallbackTest.kt (67%) rename {srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core}/models/SrtSocketRecvTest.kt (94%) rename {srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core}/models/SrtSocketSendRecvFileTest.kt (86%) rename {srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core}/models/SrtSocketSendTest.kt (95%) rename {srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core}/models/SrtSocketTest.kt (83%) rename {srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core}/models/SrtUrlTest.kt (90%) rename {srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core}/models/TimeTest.kt (82%) rename {srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core}/utils/Utils.kt (95%) rename {srtdroid => srtdroid-core}/src/main/AndroidManifest.xml (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/CMakeLists.txt (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/CallbackContext.cpp (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/CallbackContext.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Enums/AddressFamily.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Enums/Bimap.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Enums/Boundary.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Enums/EnumConverter.h (100%) create mode 100644 srtdroid-core/src/main/cpp/Enums/Enums.h rename {srtdroid => srtdroid-core}/src/main/cpp/Enums/EnumsSingleton.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Enums/EpollFlag.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Enums/EpollOpt.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Enums/ErrorType.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Enums/KMState.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Enums/RejectReasonCode.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Enums/SockOpt.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Enums/SockStatus.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Enums/TransType.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Models/Epoll.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Models/EpollEvent.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Models/EpollFlags.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Models/EpollOpts.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Models/InetSocketAddress.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Models/List.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Models/Models.h (59%) rename {srtdroid => srtdroid-core}/src/main/cpp/Models/MsgCtrl.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Models/OptVal.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Models/Pair.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Models/Primitive.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Models/Socket.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/Models/Stats.h (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/glue.cpp (100%) rename {srtdroid => srtdroid-core}/src/main/cpp/log.h (100%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/Srt.kt (98%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/enums/Boundary.kt (73%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/enums/EpollFlag.kt (91%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/enums/EpollOpt.kt (91%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/enums/ErrorType.kt (98%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/enums/KMState.kt (96%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/enums/RejectReasonCode.kt (93%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/enums/SockOpt.kt (98%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/enums/SockStatus.kt (93%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/enums/Transtype.kt (95%) create mode 100644 srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/extensions/IntExtensions.kt rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/extensions/SocketExtensions.kt (94%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/interfaces/ConfigurableSrtSocket.kt (62%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/models/Epoll.kt (93%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/models/EpollEvent.kt (80%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/models/Error.kt (91%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/models/MsgCtrl.kt (88%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/models/SrtSocket.kt (95%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/models/SrtUrl.kt (97%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/models/Stats.kt (99%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/models/Time.kt (91%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/models/rejectreason/InternalRejectReason.kt (86%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/models/rejectreason/PredefinedRejectReason.kt (92%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/models/rejectreason/RejectReason.kt (86%) rename {srtdroid/src/main/java/io/github/thibaultbee/srtdroid => srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core}/models/rejectreason/UserDefinedRejectReason.kt (84%) rename {srtdroid => srtdroid-core}/src/main/res/values/strings.xml (100%) delete mode 100644 srtdroid-ktx/build.gradle create mode 100644 srtdroid-ktx/build.gradle.kts delete mode 100644 srtdroid/build.gradle delete mode 100644 srtdroid/src/main/cpp/Enums/Enums.h delete mode 100644 srtdroid/src/main/java/io/github/thibaultbee/srtdroid/extensions/IntExtensions.kt diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 7292323f..212046b3 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,19 +13,17 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: - java-version: '17' + java-version: '21' distribution: 'adopt' - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Generate API documentation - if: ${{github.event_name == 'push'}} - run: ./gradlew dokkaHtml + run: ./gradlew dokkaHtmlMultiModule - name: Deploy API documentation to Github Pages - if: ${{github.event_name == 'push'}} uses: JamesIves/github-pages-deploy-action@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: gh-pages - folder: lib/build/dokka/html + folder: build/dokka/htmlMultiModule diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 46b3c1e9..00000000 --- a/build.gradle +++ /dev/null @@ -1,47 +0,0 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -buildscript { - ext { - versionCode = 001_007_000 - versionName = "1.7.0" - - kotlin_version = '1.9.22' - dokka_version = '1.9.20' - } - repositories { - google() - mavenCentral() - } - dependencies { - classpath 'com.android.tools.build:gradle:8.3.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - google() - mavenCentral() - } -} - -subprojects { - afterEvaluate{ - tasks.withType(KotlinCompile).tap { - configureEach { - if (project.plugins.hasPlugin("com.android.application") || project.plugins.hasPlugin("com.android.library")) { - kotlinOptions.jvmTarget = android.compileOptions.sourceCompatibility - } else { - kotlinOptions.jvmTarget = sourceCompatibility - } - } - } - } -} - -tasks.register('clean', Delete) { - delete rootProject.buildDir -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..ce6256d2 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,37 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +import org.jetbrains.dokka.DokkaConfiguration.Visibility +import org.jetbrains.dokka.gradle.DokkaTaskPartial +import java.net.URL + +plugins { + alias(libs.plugins.androidApplication).apply(false) + alias(libs.plugins.jetbrainsKotlinAndroid).apply(false) + alias(libs.plugins.androidLibrary).apply(false) + alias(libs.plugins.dokka) +} + +allprojects { + group = "io.github.thibaultbee.srtdroid" + version = "1.7.0" +} + +subprojects { + apply(plugin = "org.jetbrains.dokka") + + tasks.withType().configureEach { + dokkaSourceSets.configureEach { + documentedVisibilities.set( + setOf( + Visibility.PUBLIC, + Visibility.PROTECTED + ) + ) + + sourceLink { + localDirectory.set(projectDir.resolve("src")) + remoteUrl.set(URL("https://github.com/ThibaultBee/srtdroid/${project.name}/src")) + remoteLineSuffix.set("#L") + } + } + } +} diff --git a/buildSrc/.gitignore b/buildSrc/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/buildSrc/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 00000000..6f2cab93 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,23 @@ +import org.gradle.kotlin.dsl.`kotlin-dsl` +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + `kotlin-dsl` +} + +repositories { + mavenCentral() + google() + gradlePluginPortal() +} + +tasks.withType { + kotlinOptions { + jvmTarget = "11" + } +} + +java { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Configuration.kt b/buildSrc/src/main/kotlin/Configuration.kt new file mode 100644 index 00000000..9b094964 --- /dev/null +++ b/buildSrc/src/main/kotlin/Configuration.kt @@ -0,0 +1,49 @@ +object AndroidVersions { + const val MIN_SDK = 19 + const val TARGET_SDK = 34 + const val COMPILE_SDK = 34 +} + +object Publication { + object Repository { + val username: String? + get() = Property.get(Property.SonatypeUsername) + val password: String? + get() = Property.get(Property.SonatypePassword) + } + + object Pom { + const val PACKAGING = "aar" + const val URL = "https://github.com/ThibaultBee/srtdroid" + + object Scm { + const val CONNECTION = "scm:git:git://github.com/ThibaultBee/srtdroid.git" + const val DEVELOPER_CONNECTION = + "scm:git:ssh://github.com/ThibaultBee/srtdroid.git" + const val URL = "https://github.com/ThibaultBee/srtdroid" + } + + object License { + const val NAME = "Apache License, Version 2.0" + const val URL = "https://www.apache.org/licenses/LICENSE-2.0.txt" + const val DISTRIBUTION = "repo" + } + + object Developer { + const val URL = "https://github.com/ThibaultBee" + const val NAME = "Thibault B." + } + } + + object Signing { + val hasKey: Boolean + get() = key != null && keyId != null && password != null + + val key: String? + get() = Property.get(Property.GpgKey) + val password: String? + get() = Property.get(Property.GpgPassword) + val keyId: String? + get() = Property.get(Property.GpgKeyId) + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Property.kt b/buildSrc/src/main/kotlin/Property.kt new file mode 100644 index 00000000..ab2bfe47 --- /dev/null +++ b/buildSrc/src/main/kotlin/Property.kt @@ -0,0 +1,12 @@ +enum class Property(val key: String) { + SonatypeUsername("NEXUS_USERNAME"), + SonatypePassword("NEXUS_PASSWORD"), + GpgKey("GPG_KEY"), + GpgKeyId("GPG_KEY_ID"), + GpgPassword("GPG_PASSWORD"); + + companion object { + fun get(property: Property): String? = + System.getProperty(property.key) ?: System.getenv(property.key) + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Publication.kt b/buildSrc/src/main/kotlin/Publication.kt new file mode 100644 index 00000000..edc3c32f --- /dev/null +++ b/buildSrc/src/main/kotlin/Publication.kt @@ -0,0 +1,98 @@ +import org.gradle.api.Project +import org.gradle.api.publish.PublishingExtension +import org.gradle.api.publish.maven.MavenPom +import org.gradle.api.publish.maven.MavenPublication +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.create +import org.gradle.kotlin.dsl.the +import org.gradle.plugins.signing.SigningExtension + +fun Project.configurePublication() { + apply(plugin = "maven-publish") + apply(plugin = "com.android.library") + + the().apply { + publications.create("release") { + afterEvaluate { + if (isAndroid) { + from(components.getByName("release")) + } else { + from(components.getByName("java")) + } + } + + createPom { + name.set(project.name) + description.set(project.description) + } + } + + repositories { + maven { + if (isRelease) { + setUrl("https://oss.sonatype.org/service/local/staging/deploy/maven2/") + } else { + println("Using SNAPSHOT repository") + setUrl("https://oss.sonatype.org/content/repositories/snapshots/") + } + + credentials { + username = Publication.Repository.username + password = Publication.Repository.password + } + } + } + } + + if (Publication.Signing.hasKey) { + println("Signing publication") + apply(plugin = "signing") + + the().apply { + useInMemoryPgpKeys( + Publication.Signing.keyId, + Publication.Signing.key, + Publication.Signing.password + ) + sign(the().publications) + } + } else { + println("No signing key found. Publication will not be signed.") + } +} + +val Project.isRelease: Boolean + get() = version.toString().endsWith("-SNAPSHOT").not() + +val Project.isAndroid: Boolean + get() = project.hasProperty("android") + +fun MavenPublication.createPom( + configure: MavenPom.() -> Unit = {} +): Unit = + pom { + url.set(Publication.Pom.URL) + packaging = Publication.Pom.PACKAGING + + scm { + connection.set(Publication.Pom.Scm.CONNECTION) + developerConnection.set(Publication.Pom.Scm.DEVELOPER_CONNECTION) + url.set(Publication.Pom.Scm.URL) + } + + developers { + developer { + name.set(Publication.Pom.Developer.NAME) + url.set(Publication.Pom.Developer.URL) + } + } + + licenses { + license { + name.set(Publication.Pom.License.NAME) + url.set(Publication.Pom.License.URL) + distribution.set(Publication.Pom.License.DISTRIBUTION) + } + } + configure() + } diff --git a/example/build.gradle b/example/build.gradle deleted file mode 100644 index 9589bce5..00000000 --- a/example/build.gradle +++ /dev/null @@ -1,60 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' - -android { - defaultConfig { - applicationId "io.github.thibaultbee.srtdroid.example" - minSdk 19 - compileSdk 34 - targetSdk 34 - versionCode rootProject.versionCode - versionName rootProject.versionName - - multiDexEnabled true - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } -// To inline the bytecode built with JVM target 1.8 into -// bytecode that is being built with JVM target 1.6. (e.g. navArgs) - - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = "1.8" - } - - buildFeatures { - viewBinding true - } - namespace 'io.github.thibaultbee.srtdroid.example' - -} - -dependencies { - implementation project(':srtdroid-ktx') - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'androidx.core:core-ktx:1.12.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'androidx.multidex:multidex:2.0.1' - implementation 'androidx.preference:preference-ktx:1.2.1' - implementation 'androidx.navigation:navigation-fragment-ktx:2.7.7' - implementation 'androidx.navigation:navigation-ui-ktx:2.7.7' - implementation 'com.google.guava:guava:32.1.2-jre' - - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - -} diff --git a/example/build.gradle.kts b/example/build.gradle.kts new file mode 100644 index 00000000..2ef1a450 --- /dev/null +++ b/example/build.gradle.kts @@ -0,0 +1,59 @@ +plugins { + alias(libs.plugins.jetbrainsKotlinAndroid) + alias(libs.plugins.androidApplication) +} + +android { + namespace = "io.github.thibaultbee.srtdroid.example" + compileSdk = AndroidVersions.COMPILE_SDK + + defaultConfig { + minSdk = AndroidVersions.MIN_SDK + versionCode = 1 + versionName = "$version" + + multiDexEnabled = true + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + getByName("release") { + isMinifyEnabled = true + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + } + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = "1.8" + } + + buildFeatures { + viewBinding = true + } + + namespace = "io.github.thibaultbee.srtdroid.example" +} + +dependencies { + implementation(project(":srtdroid-ktx")) + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.22") + implementation("androidx.appcompat:appcompat:1.6.1") + implementation("androidx.core:core-ktx:1.12.0") + implementation("androidx.constraintlayout:constraintlayout:2.1.4") + implementation("androidx.multidex:multidex:2.0.1") + implementation("androidx.preference:preference-ktx:1.2.1") + implementation("androidx.navigation:navigation-fragment-ktx:2.7.7") + implementation("androidx.navigation:navigation-ui-ktx:2.7.7") + implementation("com.google.guava:guava:32.1.2-jre") + + testImplementation("junit:junit:4.13.2") + + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") +} + diff --git a/example/src/main/java/io/github/thibaultbee/srtdroid/example/MainActivity.kt b/example/src/main/java/io/github/thibaultbee/srtdroid/example/MainActivity.kt index 1cf36ce7..af3fde1f 100644 --- a/example/src/main/java/io/github/thibaultbee/srtdroid/example/MainActivity.kt +++ b/example/src/main/java/io/github/thibaultbee/srtdroid/example/MainActivity.kt @@ -18,7 +18,7 @@ package io.github.thibaultbee.srtdroid.example import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import androidx.lifecycle.ViewModelProvider -import io.github.thibaultbee.srtdroid.Srt +import io.github.thibaultbee.srtdroid.core.Srt import io.github.thibaultbee.srtdroid.example.databinding.ActivityMainBinding class MainActivity : AppCompatActivity() { diff --git a/example/src/main/java/io/github/thibaultbee/srtdroid/example/Utils.kt b/example/src/main/java/io/github/thibaultbee/srtdroid/example/Utils.kt index ade637e5..133709ba 100644 --- a/example/src/main/java/io/github/thibaultbee/srtdroid/example/Utils.kt +++ b/example/src/main/java/io/github/thibaultbee/srtdroid/example/Utils.kt @@ -18,9 +18,7 @@ package io.github.thibaultbee.srtdroid.example import android.content.Context import android.content.DialogInterface import androidx.appcompat.app.AlertDialog -import io.github.thibaultbee.srtdroid.models.Error -import java.io.File -import java.io.FileOutputStream +import io.github.thibaultbee.srtdroid.core.models.Error object Utils { diff --git a/example/src/main/java/io/github/thibaultbee/srtdroid/example/tests/RecvFile.kt b/example/src/main/java/io/github/thibaultbee/srtdroid/example/tests/RecvFile.kt index 4e42ecc0..ca800e37 100644 --- a/example/src/main/java/io/github/thibaultbee/srtdroid/example/tests/RecvFile.kt +++ b/example/src/main/java/io/github/thibaultbee/srtdroid/example/tests/RecvFile.kt @@ -3,8 +3,8 @@ package io.github.thibaultbee.srtdroid.example.tests import android.util.Log import com.google.common.primitives.Ints import com.google.common.primitives.Longs -import io.github.thibaultbee.srtdroid.enums.SockOpt -import io.github.thibaultbee.srtdroid.enums.Transtype +import io.github.thibaultbee.srtdroid.core.enums.SockOpt +import io.github.thibaultbee.srtdroid.core.enums.Transtype import io.github.thibaultbee.srtdroid.example.Utils import io.github.thibaultbee.srtdroid.ktx.CoroutineSrtSocket import io.github.thibaultbee.srtdroid.ktx.extensions.connect diff --git a/example/src/main/java/io/github/thibaultbee/srtdroid/example/tests/SendFile.kt b/example/src/main/java/io/github/thibaultbee/srtdroid/example/tests/SendFile.kt index fa85485a..2e3eb086 100644 --- a/example/src/main/java/io/github/thibaultbee/srtdroid/example/tests/SendFile.kt +++ b/example/src/main/java/io/github/thibaultbee/srtdroid/example/tests/SendFile.kt @@ -3,8 +3,8 @@ package io.github.thibaultbee.srtdroid.example.tests import android.util.Log import com.google.common.primitives.Ints import com.google.common.primitives.Longs -import io.github.thibaultbee.srtdroid.enums.SockOpt -import io.github.thibaultbee.srtdroid.enums.Transtype +import io.github.thibaultbee.srtdroid.core.enums.SockOpt +import io.github.thibaultbee.srtdroid.core.enums.Transtype import io.github.thibaultbee.srtdroid.ktx.CoroutineSrtSocket import io.github.thibaultbee.srtdroid.ktx.extensions.bind import io.github.thibaultbee.srtdroid.ktx.extensions.sendFile diff --git a/example/src/main/java/io/github/thibaultbee/srtdroid/example/tests/TestClient.kt b/example/src/main/java/io/github/thibaultbee/srtdroid/example/tests/TestClient.kt index 206211d9..abfd8cf6 100644 --- a/example/src/main/java/io/github/thibaultbee/srtdroid/example/tests/TestClient.kt +++ b/example/src/main/java/io/github/thibaultbee/srtdroid/example/tests/TestClient.kt @@ -1,7 +1,7 @@ package io.github.thibaultbee.srtdroid.example.tests import android.util.Log -import io.github.thibaultbee.srtdroid.enums.SockOpt +import io.github.thibaultbee.srtdroid.core.enums.SockOpt import io.github.thibaultbee.srtdroid.ktx.CoroutineSrtSocket import io.github.thibaultbee.srtdroid.ktx.extensions.connect import io.github.thibaultbee.srtdroid.ktx.extensions.send diff --git a/example/src/main/java/io/github/thibaultbee/srtdroid/example/tests/TestServer.kt b/example/src/main/java/io/github/thibaultbee/srtdroid/example/tests/TestServer.kt index 9c02a41b..f8eb6c9f 100644 --- a/example/src/main/java/io/github/thibaultbee/srtdroid/example/tests/TestServer.kt +++ b/example/src/main/java/io/github/thibaultbee/srtdroid/example/tests/TestServer.kt @@ -1,7 +1,7 @@ package io.github.thibaultbee.srtdroid.example.tests import android.util.Log -import io.github.thibaultbee.srtdroid.enums.SockOpt +import io.github.thibaultbee.srtdroid.core.enums.SockOpt import io.github.thibaultbee.srtdroid.ktx.CoroutineSrtSocket import io.github.thibaultbee.srtdroid.ktx.extensions.bind import kotlinx.coroutines.delay diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..1dbea8ef --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,13 @@ +[versions] +agp = "8.3.2" +dokkaBase = "1.9.20" +kotlin = "1.9.22" + +[libraries] + +[plugins] +androidApplication = { id = "com.android.application", version.ref = "agp" } +jetbrainsKotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +androidLibrary = { id = "com.android.library", version.ref = "agp" } +dokka = { id = "org.jetbrains.dokka", version.ref = "dokkaBase" } + diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 395363a0..00000000 --- a/settings.gradle +++ /dev/null @@ -1,3 +0,0 @@ -include ':srtdroid', ":example" -rootProject.name='srtdroid' -include ':srtdroid-ktx' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..f69dea74 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,25 @@ +pluginManagement { + repositories { + google { + content { + includeGroupByRegex("com\\.android.*") + includeGroupByRegex("com\\.google.*") + includeGroupByRegex("androidx.*") + } + } + mavenCentral() + gradlePluginPortal() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "srtdroid" +include(":srtdroid-core") +include(":srtdroid-ktx") +include(":example") diff --git a/srtdroid/.gitignore b/srtdroid-core/.gitignore similarity index 100% rename from srtdroid/.gitignore rename to srtdroid-core/.gitignore diff --git a/srtdroid-core/build.gradle.kts b/srtdroid-core/build.gradle.kts new file mode 100644 index 00000000..59f037d6 --- /dev/null +++ b/srtdroid-core/build.gradle.kts @@ -0,0 +1,60 @@ +plugins { + alias(libs.plugins.jetbrainsKotlinAndroid) + alias(libs.plugins.androidLibrary) +} + +description = "Secure Reliable Transport (SRT) Protocol for Android" +configurePublication() + +android { + namespace = "io.github.thibaultbee.srtdroid.core" + compileSdk = AndroidVersions.COMPILE_SDK + ndkVersion = "21.4.7075529" + + defaultConfig { + minSdk = AndroidVersions.MIN_SDK + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + buildTypes { + release { + isMinifyEnabled = true + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + externalNativeBuild { + cmake { + path = File("src/main/cpp/CMakeLists.txt") + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } + publishing { + singleVariant("release") { + withJavadocJar() + withSourcesJar() + } + } +} + +dependencies { + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.22") + implementation("androidx.core:core-ktx:1.12.0") + + testImplementation("junit:junit:4.13.2") + + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test:runner:1.5.2") + androidTestImplementation("androidx.test:rules:1.5.0") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") + androidTestImplementation("com.google.guava:guava:32.1.2-jre") +} \ No newline at end of file diff --git a/srtdroid/consumer-rules.pro b/srtdroid-core/consumer-rules.pro similarity index 100% rename from srtdroid/consumer-rules.pro rename to srtdroid-core/consumer-rules.pro diff --git a/srtdroid/proguard-rules.pro b/srtdroid-core/proguard-rules.pro similarity index 100% rename from srtdroid/proguard-rules.pro rename to srtdroid-core/proguard-rules.pro diff --git a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/SrtTest.kt b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/SrtTest.kt similarity index 92% rename from srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/SrtTest.kt rename to srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/SrtTest.kt index cef96879..3ea3d1a5 100644 --- a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/SrtTest.kt +++ b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/SrtTest.kt @@ -13,9 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid +package io.github.thibaultbee.srtdroid.core -import io.github.thibaultbee.srtdroid.Srt import org.junit.Assert.assertEquals import org.junit.Test diff --git a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/enums/RejectReasonCodeTest.kt b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/enums/RejectReasonCodeTest.kt similarity index 90% rename from srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/enums/RejectReasonCodeTest.kt rename to srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/enums/RejectReasonCodeTest.kt index 5083bee0..26e4dc14 100644 --- a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/enums/RejectReasonCodeTest.kt +++ b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/enums/RejectReasonCodeTest.kt @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.enums +package io.github.thibaultbee.srtdroid.core.enums -import io.github.thibaultbee.srtdroid.Srt +import io.github.thibaultbee.srtdroid.core.Srt import org.junit.After import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull diff --git a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/enums/TranstypeTest.kt b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/enums/TranstypeTest.kt similarity index 90% rename from srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/enums/TranstypeTest.kt rename to srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/enums/TranstypeTest.kt index e48cff51..0765c624 100644 --- a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/enums/TranstypeTest.kt +++ b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/enums/TranstypeTest.kt @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.enums +package io.github.thibaultbee.srtdroid.core.enums -import io.github.thibaultbee.srtdroid.models.SrtSocket +import io.github.thibaultbee.srtdroid.core.models.SrtSocket import org.junit.Test class TranstypeTest { diff --git a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/EpollTest.kt b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/EpollTest.kt similarity index 90% rename from srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/EpollTest.kt rename to srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/EpollTest.kt index d82ace79..f3791d23 100644 --- a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/EpollTest.kt +++ b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/EpollTest.kt @@ -13,14 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.models +package io.github.thibaultbee.srtdroid.core.models -import io.github.thibaultbee.srtdroid.Srt -import io.github.thibaultbee.srtdroid.enums.EpollFlag -import io.github.thibaultbee.srtdroid.enums.EpollOpt -import io.github.thibaultbee.srtdroid.enums.ErrorType +import io.github.thibaultbee.srtdroid.core.Srt +import io.github.thibaultbee.srtdroid.core.enums.EpollFlag +import io.github.thibaultbee.srtdroid.core.enums.EpollOpt +import io.github.thibaultbee.srtdroid.core.enums.ErrorType import org.junit.After -import org.junit.Assert.* +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Assert.fail import org.junit.Before import org.junit.Test @@ -121,7 +124,7 @@ class EpollTest { epoll.flags = listOf(EpollFlag.ENABLE_EMPTY) assertEquals(listOf(EpollFlag.ENABLE_EMPTY), epoll.flags) try { - epoll.uWait( 1000L) + epoll.uWait(1000L) } catch (e: Exception) { fail() } diff --git a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/ErrorTest.kt b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/ErrorTest.kt similarity index 92% rename from srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/ErrorTest.kt rename to srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/ErrorTest.kt index 50038ee7..5671a4df 100644 --- a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/ErrorTest.kt +++ b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/ErrorTest.kt @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.models +package io.github.thibaultbee.srtdroid.core.models import androidx.test.ext.junit.runners.AndroidJUnit4 -import io.github.thibaultbee.srtdroid.Srt -import io.github.thibaultbee.srtdroid.enums.ErrorType +import io.github.thibaultbee.srtdroid.core.Srt +import io.github.thibaultbee.srtdroid.core.enums.ErrorType import org.junit.After import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull diff --git a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtSocket6Test.kt b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtSocket6Test.kt similarity index 81% rename from srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtSocket6Test.kt rename to srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtSocket6Test.kt index be7a8ecc..19b0baa2 100644 --- a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtSocket6Test.kt +++ b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtSocket6Test.kt @@ -13,14 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.models +package io.github.thibaultbee.srtdroid.core.models import androidx.test.ext.junit.runners.AndroidJUnit4 -import io.github.thibaultbee.srtdroid.Srt -import io.github.thibaultbee.srtdroid.enums.* -import io.github.thibaultbee.srtdroid.models.rejectreason.InternalRejectReason +import io.github.thibaultbee.srtdroid.core.Srt +import io.github.thibaultbee.srtdroid.core.enums.ErrorType +import io.github.thibaultbee.srtdroid.core.enums.RejectReasonCode +import io.github.thibaultbee.srtdroid.core.enums.SockOpt +import io.github.thibaultbee.srtdroid.core.enums.SockStatus +import io.github.thibaultbee.srtdroid.core.enums.Transtype +import io.github.thibaultbee.srtdroid.core.models.rejectreason.InternalRejectReason import org.junit.After -import org.junit.Assert.* +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Assert.fail import org.junit.Before import org.junit.Test import org.junit.runner.RunWith diff --git a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtSocketCallbackTest.kt b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtSocketCallbackTest.kt similarity index 67% rename from srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtSocketCallbackTest.kt rename to srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtSocketCallbackTest.kt index c47eee19..6cf4e205 100644 --- a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtSocketCallbackTest.kt +++ b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtSocketCallbackTest.kt @@ -1,17 +1,22 @@ -package io.github.thibaultbee.srtdroid.models +package io.github.thibaultbee.srtdroid.core.models -import io.github.thibaultbee.srtdroid.Srt -import io.github.thibaultbee.srtdroid.enums.ErrorType -import io.github.thibaultbee.srtdroid.enums.SockOpt -import io.github.thibaultbee.srtdroid.enums.Transtype +import io.github.thibaultbee.srtdroid.core.Srt +import io.github.thibaultbee.srtdroid.core.enums.ErrorType +import io.github.thibaultbee.srtdroid.core.enums.SockOpt +import io.github.thibaultbee.srtdroid.core.enums.Transtype import org.junit.After -import org.junit.Assert.* +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test import java.lang.Thread.sleep import java.net.InetAddress import java.net.InetSocketAddress -import java.util.concurrent.* +import java.util.concurrent.Callable +import java.util.concurrent.CountDownLatch +import java.util.concurrent.Executors +import java.util.concurrent.Future +import java.util.concurrent.TimeUnit class SrtSocketCallbackTest { private lateinit var socket: SrtSocket @@ -35,11 +40,17 @@ class SrtSocketCallbackTest { val server = ServerConnectClose() val futureResult = server.enqueue() - socket.clientListener = object : SrtSocket.ClientListener { - override fun onConnectionLost(ns: SrtSocket, error: ErrorType, peerAddress: InetSocketAddress, token: Int) { - lock.countDown() + socket.clientListener = + object : SrtSocket.ClientListener { + override fun onConnectionLost( + ns: SrtSocket, + error: ErrorType, + peerAddress: InetSocketAddress, + token: Int + ) { + lock.countDown() + } } - } socket.connect(InetAddress.getLoopbackAddress(), server.port) diff --git a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtSocketRecvTest.kt b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtSocketRecvTest.kt similarity index 94% rename from srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtSocketRecvTest.kt rename to srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtSocketRecvTest.kt index 0b18bb17..f6d02d21 100644 --- a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtSocketRecvTest.kt +++ b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtSocketRecvTest.kt @@ -1,9 +1,9 @@ -package io.github.thibaultbee.srtdroid.models +package io.github.thibaultbee.srtdroid.core.models -import io.github.thibaultbee.srtdroid.Srt -import io.github.thibaultbee.srtdroid.enums.SockOpt -import io.github.thibaultbee.srtdroid.enums.Transtype -import io.github.thibaultbee.srtdroid.utils.Utils +import io.github.thibaultbee.srtdroid.core.Srt +import io.github.thibaultbee.srtdroid.core.enums.SockOpt +import io.github.thibaultbee.srtdroid.core.enums.Transtype +import io.github.thibaultbee.srtdroid.core.utils.Utils import org.junit.After import org.junit.Assert import org.junit.Before diff --git a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtSocketSendRecvFileTest.kt b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtSocketSendRecvFileTest.kt similarity index 86% rename from srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtSocketSendRecvFileTest.kt rename to srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtSocketSendRecvFileTest.kt index bee1774f..cd8450e3 100644 --- a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtSocketSendRecvFileTest.kt +++ b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtSocketSendRecvFileTest.kt @@ -1,10 +1,10 @@ -package io.github.thibaultbee.srtdroid.models +package io.github.thibaultbee.srtdroid.core.models import androidx.test.platform.app.InstrumentationRegistry -import io.github.thibaultbee.srtdroid.Srt -import io.github.thibaultbee.srtdroid.enums.SockOpt -import io.github.thibaultbee.srtdroid.enums.Transtype -import io.github.thibaultbee.srtdroid.utils.Utils +import io.github.thibaultbee.srtdroid.core.Srt +import io.github.thibaultbee.srtdroid.core.enums.SockOpt +import io.github.thibaultbee.srtdroid.core.enums.Transtype +import io.github.thibaultbee.srtdroid.core.utils.Utils import org.junit.After import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue @@ -12,7 +12,7 @@ import org.junit.Before import org.junit.Test import java.io.File import java.net.InetAddress -import java.util.* +import java.util.UUID import java.util.concurrent.Callable import java.util.concurrent.Executors import java.util.concurrent.Future @@ -69,7 +69,7 @@ class SrtSocketSendRecvFileTest { serverSocket.listen(1) val pair = serverSocket.accept() val comSocket = pair.first - val numOfSentBytes =comSocket.sendFile(file) + val numOfSentBytes = comSocket.sendFile(file) comSocket.close() numOfSentBytes }) diff --git a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtSocketSendTest.kt b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtSocketSendTest.kt similarity index 95% rename from srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtSocketSendTest.kt rename to srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtSocketSendTest.kt index 4c20fcd5..1ffd41d7 100644 --- a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtSocketSendTest.kt +++ b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtSocketSendTest.kt @@ -1,11 +1,12 @@ -package io.github.thibaultbee.srtdroid.models +package io.github.thibaultbee.srtdroid.core.models -import io.github.thibaultbee.srtdroid.Srt -import io.github.thibaultbee.srtdroid.enums.SockOpt -import io.github.thibaultbee.srtdroid.enums.Transtype -import io.github.thibaultbee.srtdroid.utils.Utils +import io.github.thibaultbee.srtdroid.core.Srt +import io.github.thibaultbee.srtdroid.core.enums.SockOpt +import io.github.thibaultbee.srtdroid.core.enums.Transtype +import io.github.thibaultbee.srtdroid.core.utils.Utils import org.junit.After -import org.junit.Assert.* +import org.junit.Assert.assertArrayEquals +import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test import java.net.InetAddress diff --git a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtSocketTest.kt b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtSocketTest.kt similarity index 83% rename from srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtSocketTest.kt rename to srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtSocketTest.kt index ff104f67..ec72859e 100644 --- a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtSocketTest.kt +++ b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtSocketTest.kt @@ -13,18 +13,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.models +package io.github.thibaultbee.srtdroid.core.models import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry -import io.github.thibaultbee.srtdroid.Srt -import io.github.thibaultbee.srtdroid.models.rejectreason.InternalRejectReason -import io.github.thibaultbee.srtdroid.models.rejectreason.PredefinedRejectReason -import io.github.thibaultbee.srtdroid.models.rejectreason.UserDefinedRejectReason -import io.github.thibaultbee.srtdroid.utils.Utils.createTestFile -import io.github.thibaultbee.srtdroid.enums.* +import io.github.thibaultbee.srtdroid.core.Srt +import io.github.thibaultbee.srtdroid.core.enums.Boundary +import io.github.thibaultbee.srtdroid.core.enums.ErrorType +import io.github.thibaultbee.srtdroid.core.enums.KMState +import io.github.thibaultbee.srtdroid.core.enums.RejectReasonCode +import io.github.thibaultbee.srtdroid.core.enums.SockOpt +import io.github.thibaultbee.srtdroid.core.enums.SockStatus +import io.github.thibaultbee.srtdroid.core.enums.Transtype +import io.github.thibaultbee.srtdroid.core.models.rejectreason.InternalRejectReason +import io.github.thibaultbee.srtdroid.core.models.rejectreason.PredefinedRejectReason +import io.github.thibaultbee.srtdroid.core.utils.Utils.createTestFile import org.junit.After -import org.junit.Assert.* +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNotEquals +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Assert.fail import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -205,7 +215,11 @@ class SrtSocketTest { @Test fun sendByteBuffer3Test() { - val msgCtrl = MsgCtrl(boundary = Boundary.SUBSEQUENT, pktSeq = 1, no = 1) + val msgCtrl = MsgCtrl( + boundary = Boundary.SUBSEQUENT, + pktSeq = 1, + no = 1 + ) try { socket.send(ByteBuffer.allocateDirect(10), msgCtrl) fail() @@ -216,7 +230,11 @@ class SrtSocketTest { @Test fun sendByteArray3Test() { - val msgCtrl = MsgCtrl(boundary = Boundary.SUBSEQUENT, pktSeq = 1, no = 1) + val msgCtrl = MsgCtrl( + boundary = Boundary.SUBSEQUENT, + pktSeq = 1, + no = 1 + ) try { socket.send("Hello World !", msgCtrl) fail() @@ -242,7 +260,12 @@ class SrtSocketTest { try { socket.recv( 4 /*Int nb bytes*/, - MsgCtrl(flags = 0, boundary = Boundary.FIRST, pktSeq = 0, no = 10) + MsgCtrl( + flags = 0, + boundary = Boundary.FIRST, + pktSeq = 0, + no = 10 + ) ) fail() } catch (e: SocketException) { @@ -281,7 +304,8 @@ class SrtSocketTest { @Test fun setRejectReasonTest() { - socket.rejectReason = UserDefinedRejectReason(2) + socket.rejectReason = + io.github.thibaultbee.srtdroid.core.models.rejectreason.UserDefinedRejectReason(2) socket.rejectReason = PredefinedRejectReason(1) } diff --git a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtUrlTest.kt b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtUrlTest.kt similarity index 90% rename from srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtUrlTest.kt rename to srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtUrlTest.kt index ba0eab89..0302a0b2 100644 --- a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/SrtUrlTest.kt +++ b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/SrtUrlTest.kt @@ -1,7 +1,7 @@ -package io.github.thibaultbee.srtdroid.models +package io.github.thibaultbee.srtdroid.core.models -import io.github.thibaultbee.srtdroid.enums.SockOpt -import io.github.thibaultbee.srtdroid.enums.Transtype +import io.github.thibaultbee.srtdroid.core.enums.SockOpt +import io.github.thibaultbee.srtdroid.core.enums.Transtype import org.junit.Assert.assertEquals import org.junit.Test diff --git a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/TimeTest.kt b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/TimeTest.kt similarity index 82% rename from srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/TimeTest.kt rename to srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/TimeTest.kt index 39ed6247..e0039448 100644 --- a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/models/TimeTest.kt +++ b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/models/TimeTest.kt @@ -13,10 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.models +package io.github.thibaultbee.srtdroid.core.models -import io.github.thibaultbee.srtdroid.Srt -import io.github.thibaultbee.srtdroid.models.Time +import io.github.thibaultbee.srtdroid.core.Srt import org.junit.After import org.junit.Assert.assertEquals import org.junit.Assert.assertNotEquals @@ -31,7 +30,7 @@ class TimeTest { @Test fun nowTest() { - assertNotEquals (0, Time.now()) + assertNotEquals(0, Time.now()) } } \ No newline at end of file diff --git a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/utils/Utils.kt b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/utils/Utils.kt similarity index 95% rename from srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/utils/Utils.kt rename to srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/utils/Utils.kt index 726b7265..8ccb7540 100644 --- a/srtdroid/src/androidTest/java/io/github/thibaultbee/srtdroid/utils/Utils.kt +++ b/srtdroid-core/src/androidTest/java/io/github/thibaultbee/srtdroid/core/utils/Utils.kt @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.utils +package io.github.thibaultbee.srtdroid.core.utils import androidx.test.platform.app.InstrumentationRegistry import org.junit.Assert import java.io.File import java.io.FileWriter import java.nio.ByteBuffer -import java.util.* +import java.util.UUID import kotlin.random.Random object Utils { @@ -68,7 +68,7 @@ object Utils { */ fun assertByteBufferEquals(expected: ByteBuffer, actual: ByteBuffer) { Assert.assertEquals(expected.remaining(), actual.remaining()) - while(expected.hasRemaining()) { + while (expected.hasRemaining()) { Assert.assertEquals( "Not equals at position ${expected.position()}", expected.get(), diff --git a/srtdroid/src/main/AndroidManifest.xml b/srtdroid-core/src/main/AndroidManifest.xml similarity index 100% rename from srtdroid/src/main/AndroidManifest.xml rename to srtdroid-core/src/main/AndroidManifest.xml diff --git a/srtdroid/src/main/cpp/CMakeLists.txt b/srtdroid-core/src/main/cpp/CMakeLists.txt similarity index 100% rename from srtdroid/src/main/cpp/CMakeLists.txt rename to srtdroid-core/src/main/cpp/CMakeLists.txt diff --git a/srtdroid/src/main/cpp/CallbackContext.cpp b/srtdroid-core/src/main/cpp/CallbackContext.cpp similarity index 100% rename from srtdroid/src/main/cpp/CallbackContext.cpp rename to srtdroid-core/src/main/cpp/CallbackContext.cpp diff --git a/srtdroid/src/main/cpp/CallbackContext.h b/srtdroid-core/src/main/cpp/CallbackContext.h similarity index 100% rename from srtdroid/src/main/cpp/CallbackContext.h rename to srtdroid-core/src/main/cpp/CallbackContext.h diff --git a/srtdroid/src/main/cpp/Enums/AddressFamily.h b/srtdroid-core/src/main/cpp/Enums/AddressFamily.h similarity index 100% rename from srtdroid/src/main/cpp/Enums/AddressFamily.h rename to srtdroid-core/src/main/cpp/Enums/AddressFamily.h diff --git a/srtdroid/src/main/cpp/Enums/Bimap.h b/srtdroid-core/src/main/cpp/Enums/Bimap.h similarity index 100% rename from srtdroid/src/main/cpp/Enums/Bimap.h rename to srtdroid-core/src/main/cpp/Enums/Bimap.h diff --git a/srtdroid/src/main/cpp/Enums/Boundary.h b/srtdroid-core/src/main/cpp/Enums/Boundary.h similarity index 100% rename from srtdroid/src/main/cpp/Enums/Boundary.h rename to srtdroid-core/src/main/cpp/Enums/Boundary.h diff --git a/srtdroid/src/main/cpp/Enums/EnumConverter.h b/srtdroid-core/src/main/cpp/Enums/EnumConverter.h similarity index 100% rename from srtdroid/src/main/cpp/Enums/EnumConverter.h rename to srtdroid-core/src/main/cpp/Enums/EnumConverter.h diff --git a/srtdroid-core/src/main/cpp/Enums/Enums.h b/srtdroid-core/src/main/cpp/Enums/Enums.h new file mode 100644 index 00000000..3aab3959 --- /dev/null +++ b/srtdroid-core/src/main/cpp/Enums/Enums.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2021 Thibault B. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#define ENUM_PACKAGE "io.github.thibaultbee.srtdroid.core.enums" +#define BOUNDARY_CLASS "io/github/thibaultbee/srtdroid/core/enums/Boundary" +#define EPOLLFLAG_CLASS "io/github/thibaultbee/srtdroid/core/enums/EpollFlag" +#define EPOLLOPT_CLASS "io/github/thibaultbee/srtdroid/core/enums/EpollOpt" +#define ERRORTYPE_CLASS "io/github/thibaultbee/srtdroid/core/enums/ErrorType" +#define KMSTATE_CLASS "io/github/thibaultbee/srtdroid/core/enums/KMState" +#define REJECT_REASON_CLASS "io/github/thibaultbee/srtdroid/core/enums/RejectReasonCode" +#define SOCKOPT_CLASS "io/github/thibaultbee/srtdroid/core/enums/SockOpt" +#define SOCKSTATUS_CLASS "io/github/thibaultbee/srtdroid/core/enums/SockStatus" +#define TRANSTYPE_CLASS "io/github/thibaultbee/srtdroid/core/enums/Transtype" diff --git a/srtdroid/src/main/cpp/Enums/EnumsSingleton.h b/srtdroid-core/src/main/cpp/Enums/EnumsSingleton.h similarity index 100% rename from srtdroid/src/main/cpp/Enums/EnumsSingleton.h rename to srtdroid-core/src/main/cpp/Enums/EnumsSingleton.h diff --git a/srtdroid/src/main/cpp/Enums/EpollFlag.h b/srtdroid-core/src/main/cpp/Enums/EpollFlag.h similarity index 100% rename from srtdroid/src/main/cpp/Enums/EpollFlag.h rename to srtdroid-core/src/main/cpp/Enums/EpollFlag.h diff --git a/srtdroid/src/main/cpp/Enums/EpollOpt.h b/srtdroid-core/src/main/cpp/Enums/EpollOpt.h similarity index 100% rename from srtdroid/src/main/cpp/Enums/EpollOpt.h rename to srtdroid-core/src/main/cpp/Enums/EpollOpt.h diff --git a/srtdroid/src/main/cpp/Enums/ErrorType.h b/srtdroid-core/src/main/cpp/Enums/ErrorType.h similarity index 100% rename from srtdroid/src/main/cpp/Enums/ErrorType.h rename to srtdroid-core/src/main/cpp/Enums/ErrorType.h diff --git a/srtdroid/src/main/cpp/Enums/KMState.h b/srtdroid-core/src/main/cpp/Enums/KMState.h similarity index 100% rename from srtdroid/src/main/cpp/Enums/KMState.h rename to srtdroid-core/src/main/cpp/Enums/KMState.h diff --git a/srtdroid/src/main/cpp/Enums/RejectReasonCode.h b/srtdroid-core/src/main/cpp/Enums/RejectReasonCode.h similarity index 100% rename from srtdroid/src/main/cpp/Enums/RejectReasonCode.h rename to srtdroid-core/src/main/cpp/Enums/RejectReasonCode.h diff --git a/srtdroid/src/main/cpp/Enums/SockOpt.h b/srtdroid-core/src/main/cpp/Enums/SockOpt.h similarity index 100% rename from srtdroid/src/main/cpp/Enums/SockOpt.h rename to srtdroid-core/src/main/cpp/Enums/SockOpt.h diff --git a/srtdroid/src/main/cpp/Enums/SockStatus.h b/srtdroid-core/src/main/cpp/Enums/SockStatus.h similarity index 100% rename from srtdroid/src/main/cpp/Enums/SockStatus.h rename to srtdroid-core/src/main/cpp/Enums/SockStatus.h diff --git a/srtdroid/src/main/cpp/Enums/TransType.h b/srtdroid-core/src/main/cpp/Enums/TransType.h similarity index 100% rename from srtdroid/src/main/cpp/Enums/TransType.h rename to srtdroid-core/src/main/cpp/Enums/TransType.h diff --git a/srtdroid/src/main/cpp/Models/Epoll.h b/srtdroid-core/src/main/cpp/Models/Epoll.h similarity index 100% rename from srtdroid/src/main/cpp/Models/Epoll.h rename to srtdroid-core/src/main/cpp/Models/Epoll.h diff --git a/srtdroid/src/main/cpp/Models/EpollEvent.h b/srtdroid-core/src/main/cpp/Models/EpollEvent.h similarity index 100% rename from srtdroid/src/main/cpp/Models/EpollEvent.h rename to srtdroid-core/src/main/cpp/Models/EpollEvent.h diff --git a/srtdroid/src/main/cpp/Models/EpollFlags.h b/srtdroid-core/src/main/cpp/Models/EpollFlags.h similarity index 100% rename from srtdroid/src/main/cpp/Models/EpollFlags.h rename to srtdroid-core/src/main/cpp/Models/EpollFlags.h diff --git a/srtdroid/src/main/cpp/Models/EpollOpts.h b/srtdroid-core/src/main/cpp/Models/EpollOpts.h similarity index 100% rename from srtdroid/src/main/cpp/Models/EpollOpts.h rename to srtdroid-core/src/main/cpp/Models/EpollOpts.h diff --git a/srtdroid/src/main/cpp/Models/InetSocketAddress.h b/srtdroid-core/src/main/cpp/Models/InetSocketAddress.h similarity index 100% rename from srtdroid/src/main/cpp/Models/InetSocketAddress.h rename to srtdroid-core/src/main/cpp/Models/InetSocketAddress.h diff --git a/srtdroid/src/main/cpp/Models/List.h b/srtdroid-core/src/main/cpp/Models/List.h similarity index 100% rename from srtdroid/src/main/cpp/Models/List.h rename to srtdroid-core/src/main/cpp/Models/List.h diff --git a/srtdroid/src/main/cpp/Models/Models.h b/srtdroid-core/src/main/cpp/Models/Models.h similarity index 59% rename from srtdroid/src/main/cpp/Models/Models.h rename to srtdroid-core/src/main/cpp/Models/Models.h index fea3b757..025f37e6 100644 --- a/srtdroid/src/main/cpp/Models/Models.h +++ b/srtdroid-core/src/main/cpp/Models/Models.h @@ -23,11 +23,11 @@ #define LIST_CLASS "java/util/List" -#define ERROR_CLASS "io/github/thibaultbee/srtdroid/models/Error" -#define SRT_CLASS "io/github/thibaultbee/srtdroid/Srt" -#define TIME_CLASS "io/github/thibaultbee/srtdroid/models/Time" -#define EPOLL_CLASS "io/github/thibaultbee/srtdroid/models/Epoll" -#define EPOLLEVENT_CLASS "io/github/thibaultbee/srtdroid/models/EpollEvent" -#define MSGCTRL_CLASS "io/github/thibaultbee/srtdroid/models/MsgCtrl" -#define SRTSOCKET_CLASS "io/github/thibaultbee/srtdroid/models/SrtSocket" -#define STATS_CLASS "io/github/thibaultbee/srtdroid/models/Stats" +#define ERROR_CLASS "io/github/thibaultbee/srtdroid/core/models/Error" +#define SRT_CLASS "io/github/thibaultbee/srtdroid/core/Srt" +#define TIME_CLASS "io/github/thibaultbee/srtdroid/core/models/Time" +#define EPOLL_CLASS "io/github/thibaultbee/srtdroid/core/models/Epoll" +#define EPOLLEVENT_CLASS "io/github/thibaultbee/srtdroid/core/models/EpollEvent" +#define MSGCTRL_CLASS "io/github/thibaultbee/srtdroid/core/models/MsgCtrl" +#define SRTSOCKET_CLASS "io/github/thibaultbee/srtdroid/core/models/SrtSocket" +#define STATS_CLASS "io/github/thibaultbee/srtdroid/core/models/Stats" diff --git a/srtdroid/src/main/cpp/Models/MsgCtrl.h b/srtdroid-core/src/main/cpp/Models/MsgCtrl.h similarity index 100% rename from srtdroid/src/main/cpp/Models/MsgCtrl.h rename to srtdroid-core/src/main/cpp/Models/MsgCtrl.h diff --git a/srtdroid/src/main/cpp/Models/OptVal.h b/srtdroid-core/src/main/cpp/Models/OptVal.h similarity index 100% rename from srtdroid/src/main/cpp/Models/OptVal.h rename to srtdroid-core/src/main/cpp/Models/OptVal.h diff --git a/srtdroid/src/main/cpp/Models/Pair.h b/srtdroid-core/src/main/cpp/Models/Pair.h similarity index 100% rename from srtdroid/src/main/cpp/Models/Pair.h rename to srtdroid-core/src/main/cpp/Models/Pair.h diff --git a/srtdroid/src/main/cpp/Models/Primitive.h b/srtdroid-core/src/main/cpp/Models/Primitive.h similarity index 100% rename from srtdroid/src/main/cpp/Models/Primitive.h rename to srtdroid-core/src/main/cpp/Models/Primitive.h diff --git a/srtdroid/src/main/cpp/Models/Socket.h b/srtdroid-core/src/main/cpp/Models/Socket.h similarity index 100% rename from srtdroid/src/main/cpp/Models/Socket.h rename to srtdroid-core/src/main/cpp/Models/Socket.h diff --git a/srtdroid/src/main/cpp/Models/Stats.h b/srtdroid-core/src/main/cpp/Models/Stats.h similarity index 100% rename from srtdroid/src/main/cpp/Models/Stats.h rename to srtdroid-core/src/main/cpp/Models/Stats.h diff --git a/srtdroid/src/main/cpp/glue.cpp b/srtdroid-core/src/main/cpp/glue.cpp similarity index 100% rename from srtdroid/src/main/cpp/glue.cpp rename to srtdroid-core/src/main/cpp/glue.cpp diff --git a/srtdroid/src/main/cpp/log.h b/srtdroid-core/src/main/cpp/log.h similarity index 100% rename from srtdroid/src/main/cpp/log.h rename to srtdroid-core/src/main/cpp/log.h diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/Srt.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/Srt.kt similarity index 98% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/Srt.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/Srt.kt index bfda755a..6dc3ed02 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/Srt.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/Srt.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid +package io.github.thibaultbee.srtdroid.core /** * This class provides main SRT control. Before calling any other SRT API, you shall call [startUp]. diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/Boundary.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/Boundary.kt similarity index 73% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/Boundary.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/Boundary.kt index abc7931a..16c73afb 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/Boundary.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/Boundary.kt @@ -1,6 +1,6 @@ -package io.github.thibaultbee.srtdroid.enums +package io.github.thibaultbee.srtdroid.core.enums -import io.github.thibaultbee.srtdroid.models.MsgCtrl +import io.github.thibaultbee.srtdroid.core.models.MsgCtrl /** * To be use as [MsgCtrl.boundary] diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/EpollFlag.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/EpollFlag.kt similarity index 91% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/EpollFlag.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/EpollFlag.kt index 7e22a27d..2a26a982 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/EpollFlag.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/EpollFlag.kt @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.enums +package io.github.thibaultbee.srtdroid.core.enums -import io.github.thibaultbee.srtdroid.models.Epoll +import io.github.thibaultbee.srtdroid.core.models.Epoll /** * Use this enumeration in [Epoll.flags] and [Epoll.setFlags]. diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/EpollOpt.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/EpollOpt.kt similarity index 91% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/EpollOpt.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/EpollOpt.kt index 96dea755..b01798cc 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/EpollOpt.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/EpollOpt.kt @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.enums +package io.github.thibaultbee.srtdroid.core.enums -import io.github.thibaultbee.srtdroid.models.Epoll +import io.github.thibaultbee.srtdroid.core.models.Epoll /** * Description of [Epoll] event options. diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/ErrorType.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/ErrorType.kt similarity index 98% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/ErrorType.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/ErrorType.kt index 088d8c35..9e16bd22 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/ErrorType.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/ErrorType.kt @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.enums +package io.github.thibaultbee.srtdroid.core.enums -import io.github.thibaultbee.srtdroid.Srt +import io.github.thibaultbee.srtdroid.core.Srt /** * SRT error codes. diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/KMState.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/KMState.kt similarity index 96% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/KMState.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/KMState.kt index 10426bc7..aaffc453 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/KMState.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/KMState.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.enums +package io.github.thibaultbee.srtdroid.core.enums /** * The defined encryption state as performed by the Key Material Exchange, used by diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/RejectReasonCode.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/RejectReasonCode.kt similarity index 93% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/RejectReasonCode.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/RejectReasonCode.kt index fa07bc14..23a41e3a 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/RejectReasonCode.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/RejectReasonCode.kt @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.enums +package io.github.thibaultbee.srtdroid.core.enums -import io.github.thibaultbee.srtdroid.Srt -import io.github.thibaultbee.srtdroid.models.rejectreason.InternalRejectReason +import io.github.thibaultbee.srtdroid.core.Srt +import io.github.thibaultbee.srtdroid.core.models.rejectreason.InternalRejectReason /** * Internal reject reason for [InternalRejectReason]. diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/SockOpt.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/SockOpt.kt similarity index 98% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/SockOpt.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/SockOpt.kt index 9b13affe..c96a8db7 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/SockOpt.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/SockOpt.kt @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.enums +package io.github.thibaultbee.srtdroid.core.enums -import io.github.thibaultbee.srtdroid.models.SrtSocket +import io.github.thibaultbee.srtdroid.core.models.SrtSocket /** * Parameter or returned value of [SrtSocket.setSockFlag] and [SrtSocket.getSockFlag]. diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/SockStatus.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/SockStatus.kt similarity index 93% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/SockStatus.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/SockStatus.kt index 0715c97f..6bca1eb4 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/SockStatus.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/SockStatus.kt @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.enums +package io.github.thibaultbee.srtdroid.core.enums -import io.github.thibaultbee.srtdroid.models.SrtSocket +import io.github.thibaultbee.srtdroid.core.models.SrtSocket /** * SRT socket status (from [SrtSocket.sockState]). diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/Transtype.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/Transtype.kt similarity index 95% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/Transtype.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/Transtype.kt index 4df71b5f..565e7460 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/enums/Transtype.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/enums/Transtype.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.enums +package io.github.thibaultbee.srtdroid.core.enums /** * Used by [SockOpt.TRANSTYPE] option. diff --git a/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/extensions/IntExtensions.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/extensions/IntExtensions.kt new file mode 100644 index 00000000..14669b07 --- /dev/null +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/extensions/IntExtensions.kt @@ -0,0 +1,5 @@ +package io.github.thibaultbee.srtdroid.core.extensions + +internal fun Int.toBoolean(): Boolean { + return this != 0 +} \ No newline at end of file diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/extensions/SocketExtensions.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/extensions/SocketExtensions.kt similarity index 94% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/extensions/SocketExtensions.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/extensions/SocketExtensions.kt index 2b2e59af..0d5286d5 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/extensions/SocketExtensions.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/extensions/SocketExtensions.kt @@ -1,7 +1,7 @@ -package io.github.thibaultbee.srtdroid.extensions +package io.github.thibaultbee.srtdroid.core.extensions -import io.github.thibaultbee.srtdroid.models.SrtSocket -import io.github.thibaultbee.srtdroid.models.SrtUrl +import io.github.thibaultbee.srtdroid.core.models.SrtSocket +import io.github.thibaultbee.srtdroid.core.models.SrtUrl import java.net.BindException import java.net.ConnectException import java.net.SocketException diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/interfaces/ConfigurableSrtSocket.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/interfaces/ConfigurableSrtSocket.kt similarity index 62% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/interfaces/ConfigurableSrtSocket.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/interfaces/ConfigurableSrtSocket.kt index e8b6bccb..4f7f6704 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/interfaces/ConfigurableSrtSocket.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/interfaces/ConfigurableSrtSocket.kt @@ -1,6 +1,6 @@ -package io.github.thibaultbee.srtdroid.interfaces +package io.github.thibaultbee.srtdroid.core.interfaces -import io.github.thibaultbee.srtdroid.enums.SockOpt +import io.github.thibaultbee.srtdroid.core.enums.SockOpt /** * A convenient interface to get and set socket options diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/Epoll.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/Epoll.kt similarity index 93% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/Epoll.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/Epoll.kt index 0570c4c4..d62d5d9a 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/Epoll.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/Epoll.kt @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.models +package io.github.thibaultbee.srtdroid.core.models import android.util.Pair -import io.github.thibaultbee.srtdroid.Srt -import io.github.thibaultbee.srtdroid.enums.EpollFlag -import io.github.thibaultbee.srtdroid.enums.EpollOpt +import io.github.thibaultbee.srtdroid.core.Srt +import io.github.thibaultbee.srtdroid.core.enums.EpollFlag +import io.github.thibaultbee.srtdroid.core.enums.EpollOpt import java.security.InvalidParameterException /** @@ -54,7 +54,10 @@ private constructor(private val eid: Int) { val isValid: Boolean get() = nativeIsValid() - private external fun nativeAddUSock(socket: SrtSocket, events: List?): Int + private external fun nativeAddUSock( + socket: SrtSocket, + events: List? + ): Int /** * Adds a socket to a epoll container. @@ -65,13 +68,19 @@ private constructor(private val eid: Int) { * @param events list of selected [EpollOpt]. Set null if you want to subscribe a socket for all events. * @throws InvalidParameterException if [Epoll] is not valid */ - fun addUSock(socket: SrtSocket, events: List?) { + fun addUSock( + socket: SrtSocket, + events: List? + ) { if (nativeAddUSock(socket, events) != 0) { throw InvalidParameterException(Error.lastErrorMessage) } } - private external fun nativeUpdateUSock(socket: SrtSocket, events: List?): Int + private external fun nativeUpdateUSock( + socket: SrtSocket, + events: List? + ): Int /** * Updates a socket to a epoll container. @@ -82,7 +91,10 @@ private constructor(private val eid: Int) { * @param events list of selected [EpollOpt]. Set null if you want to subscribe a socket for all events. * @throws InvalidParameterException if [Epoll] is not valid */ - fun updateUSock(socket: SrtSocket, events: List?) { + fun updateUSock( + socket: SrtSocket, + events: List? + ) { if (nativeUpdateUSock(socket, events) != 0) { throw InvalidParameterException(Error.lastErrorMessage) } @@ -236,7 +248,7 @@ private constructor(private val eid: Int) { if (other !is Epoll) return false return eid == other.eid } - + override fun hashCode(): Int { return eid.hashCode() } diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/EpollEvent.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/EpollEvent.kt similarity index 80% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/EpollEvent.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/EpollEvent.kt index a314cfe3..34578684 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/EpollEvent.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/EpollEvent.kt @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.models +package io.github.thibaultbee.srtdroid.core.models -import io.github.thibaultbee.srtdroid.enums.EpollOpt +import io.github.thibaultbee.srtdroid.core.enums.EpollOpt /** * This class represents SRT socket and their events. @@ -25,4 +25,4 @@ import io.github.thibaultbee.srtdroid.enums.EpollOpt * @param socket the SRT socket * @param events list of [EpollOpt] that report readiness of this socket */ -class EpollEvent(val socket: SrtSocket, val events: List) \ No newline at end of file +class EpollEvent(val socket: io.github.thibaultbee.srtdroid.core.models.SrtSocket, val events: List) \ No newline at end of file diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/Error.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/Error.kt similarity index 91% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/Error.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/Error.kt index 3a227a01..804949ec 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/Error.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/Error.kt @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.models +package io.github.thibaultbee.srtdroid.core.models -import io.github.thibaultbee.srtdroid.Srt -import io.github.thibaultbee.srtdroid.enums.ErrorType +import io.github.thibaultbee.srtdroid.core.Srt +import io.github.thibaultbee.srtdroid.core.enums.ErrorType /** * This class contains API to manage errors. diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/MsgCtrl.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/MsgCtrl.kt similarity index 88% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/MsgCtrl.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/MsgCtrl.kt index 4f0a3a0d..dd0caff1 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/MsgCtrl.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/MsgCtrl.kt @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.models +package io.github.thibaultbee.srtdroid.core.models -import io.github.thibaultbee.srtdroid.enums.Boundary +import io.github.thibaultbee.srtdroid.core.enums.Boundary /** * This class represents extra parameters for [SrtSocket.send] and [SrtSocket.recv] @@ -38,7 +38,7 @@ data class MsgCtrl( /** * Reserved for future use. Should be [Boundary.SUBSEQUENT]. */ - val boundary: Boundary = Boundary.SUBSEQUENT, + val boundary: io.github.thibaultbee.srtdroid.core.enums.Boundary = io.github.thibaultbee.srtdroid.core.enums.Boundary.SUBSEQUENT, /** * Receiver: specifies the time when the packet was intended to be delivered to the receiving application (in microseconds since SRT clock epoch). * Sender: specifies the application-provided timestamp to be associated with the packet. diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/SrtSocket.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/SrtSocket.kt similarity index 95% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/SrtSocket.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/SrtSocket.kt index e6e79f71..dfd15f82 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/SrtSocket.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/SrtSocket.kt @@ -13,19 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.models +package io.github.thibaultbee.srtdroid.core.models import android.util.Pair -import io.github.thibaultbee.srtdroid.Srt -import io.github.thibaultbee.srtdroid.enums.ErrorType -import io.github.thibaultbee.srtdroid.enums.RejectReasonCode -import io.github.thibaultbee.srtdroid.enums.SockOpt -import io.github.thibaultbee.srtdroid.enums.SockStatus -import io.github.thibaultbee.srtdroid.interfaces.ConfigurableSrtSocket -import io.github.thibaultbee.srtdroid.models.rejectreason.InternalRejectReason -import io.github.thibaultbee.srtdroid.models.rejectreason.PredefinedRejectReason -import io.github.thibaultbee.srtdroid.models.rejectreason.RejectReason -import io.github.thibaultbee.srtdroid.models.rejectreason.UserDefinedRejectReason +import io.github.thibaultbee.srtdroid.core.Srt +import io.github.thibaultbee.srtdroid.core.enums.ErrorType +import io.github.thibaultbee.srtdroid.core.enums.RejectReasonCode +import io.github.thibaultbee.srtdroid.core.enums.SockOpt +import io.github.thibaultbee.srtdroid.core.enums.SockStatus +import io.github.thibaultbee.srtdroid.core.interfaces.ConfigurableSrtSocket +import io.github.thibaultbee.srtdroid.core.models.rejectreason.InternalRejectReason +import io.github.thibaultbee.srtdroid.core.models.rejectreason.PredefinedRejectReason +import io.github.thibaultbee.srtdroid.core.models.rejectreason.RejectReason +import io.github.thibaultbee.srtdroid.core.models.rejectreason.UserDefinedRejectReason import java.io.Closeable import java.io.File import java.io.IOException @@ -82,7 +82,13 @@ private constructor(private val srtsocket: Int) : ConfigurableSrtSocket, Closeab * **See Also:** [srt_socket](https://github.com/Haivision/srt/blob/master/docs/API/API-functions.md#srt_socket) */ @Deprecated(message = "Use Socket() instead", replaceWith = ReplaceWith("Socket()")) - constructor(af: StandardProtocolFamily) : this(nativeCreateSocket(af, 0, 0)) + constructor(af: StandardProtocolFamily) : this( + nativeCreateSocket( + af, + 0, + 0 + ) + ) /** * Creates an SRT socket. @@ -337,7 +343,8 @@ private constructor(private val srtsocket: Int) : ConfigurableSrtSocket, Closeab * @throws [SocketException] if SRT socket is invalid or not connected */ val peerName: InetSocketAddress - get() = nativeGetPeerName() ?: throw SocketException(Error.lastErrorMessage) + get() = nativeGetPeerName() + ?: throw SocketException(Error.lastErrorMessage) /** * Retrieves the remote [InetAddress] to which the socket is connected. @@ -375,7 +382,8 @@ private constructor(private val srtsocket: Int) : ConfigurableSrtSocket, Closeab * @see [localAddress] and [localPort] */ val sockName: InetSocketAddress - get() = nativeGetSockName() ?: throw SocketException(Error.lastErrorMessage) + get() = nativeGetSockName() + ?: throw SocketException(Error.lastErrorMessage) /** * Extracts the [InetAddress] to which the socket was bound. @@ -414,7 +422,8 @@ private constructor(private val srtsocket: Int) : ConfigurableSrtSocket, Closeab * @see [setSockFlag] */ override fun getSockFlag(opt: SockOpt): Any { - return nativeGetSockFlag(opt) ?: throw IOException(Error.lastErrorMessage) + return nativeGetSockFlag(opt) + ?: throw IOException(Error.lastErrorMessage) } private external fun nativeSetSockFlag(opt: SockOpt, value: Any): Int @@ -640,8 +649,19 @@ private constructor(private val srtsocket: Int) : ConfigurableSrtSocket, Closeab fun send(msg: String, ttl: Int = -1, inOrder: Boolean = false) = send(msg.toByteArray(), ttl, inOrder) - private external fun nativeSend(msg: ByteBuffer, offset: Int, size: Int, msgCtrl: MsgCtrl): Int - private external fun nativeSend(msg: ByteArray, offset: Int, size: Int, msgCtrl: MsgCtrl): Int + private external fun nativeSend( + msg: ByteBuffer, + offset: Int, + size: Int, + msgCtrl: MsgCtrl + ): Int + + private external fun nativeSend( + msg: ByteArray, + offset: Int, + size: Int, + msgCtrl: MsgCtrl + ): Int /** * Sends a message to a remote party. @@ -686,7 +706,12 @@ private constructor(private val srtsocket: Int) : ConfigurableSrtSocket, Closeab * @throws SocketTimeoutException if a timeout has been triggered * @see [recv] */ - fun send(msg: ByteArray, offset: Int, size: Int, msgCtrl: MsgCtrl): Int { + fun send( + msg: ByteArray, + offset: Int, + size: Int, + msgCtrl: MsgCtrl + ): Int { val byteSent = nativeSend(msg, offset, size, msgCtrl) when { byteSent < 0 -> { @@ -713,7 +738,8 @@ private constructor(private val srtsocket: Int) : ConfigurableSrtSocket, Closeab * @throws SocketTimeoutException if a timeout has been triggered * @see [recv] */ - fun send(msg: ByteArray, msgCtrl: MsgCtrl) = send(msg, 0, msg.size, msgCtrl) + fun send(msg: ByteArray, msgCtrl: MsgCtrl) = + send(msg, 0, msg.size, msgCtrl) /** * Sends a message to a remote party. @@ -727,7 +753,8 @@ private constructor(private val srtsocket: Int) : ConfigurableSrtSocket, Closeab * @throws SocketTimeoutException if a timeout has been triggered * @see [recv] */ - fun send(msg: String, msgCtrl: MsgCtrl) = send(msg.toByteArray(), msgCtrl) + fun send(msg: String, msgCtrl: MsgCtrl) = + send(msg.toByteArray(), msgCtrl) /** * Returns an output stream for this socket. @@ -739,9 +766,15 @@ private constructor(private val srtsocket: Int) : ConfigurableSrtSocket, Closeab * @see [getInputStream] */ fun getOutputStream(msgCtrl: MsgCtrl? = null) = - SrtSocketOutputStream(this, msgCtrl) as OutputStream - - private class SrtSocketOutputStream(private val socket: SrtSocket, private val msgCtrl: MsgCtrl?) : + SrtSocketOutputStream( + this, + msgCtrl + ) as OutputStream + + private class SrtSocketOutputStream( + private val socket: SrtSocket, + private val msgCtrl: MsgCtrl? + ) : OutputStream() { override fun close() { @@ -852,7 +885,10 @@ private constructor(private val srtsocket: Int) : ConfigurableSrtSocket, Closeab } } - private external fun nativeRecv(size: Int, msgCtrl: MsgCtrl): Pair + private external fun nativeRecv( + size: Int, + msgCtrl: MsgCtrl + ): Pair /** * Received a message from a remote device @@ -932,9 +968,15 @@ private constructor(private val srtsocket: Int) : ConfigurableSrtSocket, Closeab * @see [getOutputStream] */ fun getInputStream(msgCtrl: MsgCtrl? = null) = - SrtSocketInputStream(this, msgCtrl) as InputStream - - private class SrtSocketInputStream(private val socket: SrtSocket, private val msgCtrl: MsgCtrl?) : + SrtSocketInputStream( + this, + msgCtrl + ) as InputStream + + private class SrtSocketInputStream( + private val socket: SrtSocket, + private val msgCtrl: MsgCtrl? + ) : InputStream() { override fun available(): Int { @@ -1122,7 +1164,9 @@ private constructor(private val srtsocket: Int) : ConfigurableSrtSocket, Closeab return when { code < RejectReasonCode.PREDEFINED_OFFSET -> InternalRejectReason(RejectReasonCode.values()[code]) code < RejectReasonCode.USERDEFINED_OFFSET -> PredefinedRejectReason(code - RejectReasonCode.PREDEFINED_OFFSET) - else -> UserDefinedRejectReason(code - RejectReasonCode.USERDEFINED_OFFSET) + else -> UserDefinedRejectReason( + code - RejectReasonCode.USERDEFINED_OFFSET + ) } } /** @@ -1174,7 +1218,10 @@ private constructor(private val srtsocket: Int) : ConfigurableSrtSocket, Closeab * @param instantaneous true if the statistics should use instant data, not moving averages * @return the current [Stats] */ - external fun bistats(clear: Boolean, instantaneous: Boolean): Stats + external fun bistats( + clear: Boolean, + instantaneous: Boolean + ): Stats // Time access private external fun nativeGetConnectionTime(): Long diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/SrtUrl.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/SrtUrl.kt similarity index 97% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/SrtUrl.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/SrtUrl.kt index 108a3ce6..63532bf1 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/SrtUrl.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/SrtUrl.kt @@ -13,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.models +package io.github.thibaultbee.srtdroid.core.models import android.net.Uri import android.util.Log -import io.github.thibaultbee.srtdroid.Srt -import io.github.thibaultbee.srtdroid.enums.SockOpt -import io.github.thibaultbee.srtdroid.enums.Transtype -import io.github.thibaultbee.srtdroid.extensions.toBoolean -import io.github.thibaultbee.srtdroid.interfaces.ConfigurableSrtSocket +import io.github.thibaultbee.srtdroid.core.Srt +import io.github.thibaultbee.srtdroid.core.enums.SockOpt +import io.github.thibaultbee.srtdroid.core.enums.Transtype +import io.github.thibaultbee.srtdroid.core.extensions.toBoolean +import io.github.thibaultbee.srtdroid.core.interfaces.ConfigurableSrtSocket import java.security.InvalidParameterException /** diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/Stats.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/Stats.kt similarity index 99% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/Stats.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/Stats.kt index 2559f86a..9ba8566c 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/Stats.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/Stats.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.models +package io.github.thibaultbee.srtdroid.core.models /** * This class represents SRT statistics diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/Time.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/Time.kt similarity index 91% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/Time.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/Time.kt index b60ebe9a..24950a79 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/Time.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/Time.kt @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.models +package io.github.thibaultbee.srtdroid.core.models -import io.github.thibaultbee.srtdroid.Srt +import io.github.thibaultbee.srtdroid.core.Srt /** * This class contains time utils. diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/rejectreason/InternalRejectReason.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/rejectreason/InternalRejectReason.kt similarity index 86% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/rejectreason/InternalRejectReason.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/rejectreason/InternalRejectReason.kt index 0c5746b3..af194b1d 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/rejectreason/InternalRejectReason.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/rejectreason/InternalRejectReason.kt @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.models.rejectreason +package io.github.thibaultbee.srtdroid.core.models.rejectreason -import io.github.thibaultbee.srtdroid.enums.RejectReasonCode +import io.github.thibaultbee.srtdroid.core.enums.RejectReasonCode /** * This class represents a reject reason that was triggered by internal mechanism. diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/rejectreason/PredefinedRejectReason.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/rejectreason/PredefinedRejectReason.kt similarity index 92% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/rejectreason/PredefinedRejectReason.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/rejectreason/PredefinedRejectReason.kt index 5688b58b..e2ee78ca 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/rejectreason/PredefinedRejectReason.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/rejectreason/PredefinedRejectReason.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.models.rejectreason +package io.github.thibaultbee.srtdroid.core.models.rejectreason /** * This class represents a reject reason that was triggered by server/application. diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/rejectreason/RejectReason.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/rejectreason/RejectReason.kt similarity index 86% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/rejectreason/RejectReason.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/rejectreason/RejectReason.kt index 4410336e..3a399435 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/rejectreason/RejectReason.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/rejectreason/RejectReason.kt @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.models.rejectreason +package io.github.thibaultbee.srtdroid.core.models.rejectreason -import io.github.thibaultbee.srtdroid.models.SrtSocket +import io.github.thibaultbee.srtdroid.core.models.SrtSocket /** * Base class of [InternalRejectReason], [PredefinedRejectReason] and [UserDefinedRejectReason]. diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/rejectreason/UserDefinedRejectReason.kt b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/rejectreason/UserDefinedRejectReason.kt similarity index 84% rename from srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/rejectreason/UserDefinedRejectReason.kt rename to srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/rejectreason/UserDefinedRejectReason.kt index 3d0950ef..244666e9 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/rejectreason/UserDefinedRejectReason.kt +++ b/srtdroid-core/src/main/java/io/github/thibaultbee/srtdroid/core/models/rejectreason/UserDefinedRejectReason.kt @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.github.thibaultbee.srtdroid.models.rejectreason +package io.github.thibaultbee.srtdroid.core.models.rejectreason /** * This class represents a reject reason that was triggered by user. * * @param code an User-defined rejection reason */ -data class UserDefinedRejectReason(val code: Int): RejectReason() \ No newline at end of file +data class UserDefinedRejectReason(val code: Int) : + RejectReason() \ No newline at end of file diff --git a/srtdroid/src/main/res/values/strings.xml b/srtdroid-core/src/main/res/values/strings.xml similarity index 100% rename from srtdroid/src/main/res/values/strings.xml rename to srtdroid-core/src/main/res/values/strings.xml diff --git a/srtdroid-ktx/build.gradle b/srtdroid-ktx/build.gradle deleted file mode 100644 index 6d57d7dd..00000000 --- a/srtdroid-ktx/build.gradle +++ /dev/null @@ -1,41 +0,0 @@ -plugins { - id 'com.android.library' - id 'org.jetbrains.kotlin.android' -} - -android { - namespace 'io.github.thibaultbee.srtdroid' - compileSdk 34 - - defaultConfig { - minSdk 19 - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - consumerProguardFiles "consumer-rules.pro" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - } -} - -dependencies { - api project(':srtdroid') - - implementation 'androidx.core:core-ktx:1.12.0' - implementation 'androidx.appcompat:appcompat:1.6.1' - - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' -} \ No newline at end of file diff --git a/srtdroid-ktx/build.gradle.kts b/srtdroid-ktx/build.gradle.kts new file mode 100644 index 00000000..61235da6 --- /dev/null +++ b/srtdroid-ktx/build.gradle.kts @@ -0,0 +1,53 @@ +plugins { + alias(libs.plugins.jetbrainsKotlinAndroid) + alias(libs.plugins.androidLibrary) +} + +description = "Secure Reliable Transport (SRT) Protocol with Kotlin coroutines for Android" +configurePublication() + +android { + namespace = "io.github.thibaultbee.srtdroid.ktx" + compileSdk = AndroidVersions.COMPILE_SDK + + defaultConfig { + minSdk = AndroidVersions.MIN_SDK + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } + publishing { + singleVariant("release") { + withJavadocJar() + withSourcesJar() + } + } +} + +dependencies { + api(project(":srtdroid-core")) + + implementation("androidx.core:core-ktx:1.12.0") + implementation("androidx.appcompat:appcompat:1.6.1") + + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") +} + diff --git a/srtdroid-ktx/src/main/java/io/github/thibaultbee/srtdroid/ktx/CoroutineSrtSocket.kt b/srtdroid-ktx/src/main/java/io/github/thibaultbee/srtdroid/ktx/CoroutineSrtSocket.kt index 8ee0bce8..db04350c 100644 --- a/srtdroid-ktx/src/main/java/io/github/thibaultbee/srtdroid/ktx/CoroutineSrtSocket.kt +++ b/srtdroid-ktx/src/main/java/io/github/thibaultbee/srtdroid/ktx/CoroutineSrtSocket.kt @@ -2,21 +2,21 @@ package io.github.thibaultbee.srtdroid.ktx import android.util.Log import android.util.Pair -import io.github.thibaultbee.srtdroid.enums.EpollOpt -import io.github.thibaultbee.srtdroid.enums.ErrorType -import io.github.thibaultbee.srtdroid.enums.SockOpt -import io.github.thibaultbee.srtdroid.enums.SockStatus -import io.github.thibaultbee.srtdroid.interfaces.ConfigurableSrtSocket -import io.github.thibaultbee.srtdroid.models.Epoll -import io.github.thibaultbee.srtdroid.models.Error -import io.github.thibaultbee.srtdroid.models.MsgCtrl -import io.github.thibaultbee.srtdroid.models.SrtSocket -import io.github.thibaultbee.srtdroid.models.SrtSocket.ServerListener -import io.github.thibaultbee.srtdroid.models.Stats -import io.github.thibaultbee.srtdroid.models.rejectreason.InternalRejectReason -import io.github.thibaultbee.srtdroid.models.rejectreason.PredefinedRejectReason -import io.github.thibaultbee.srtdroid.models.rejectreason.RejectReason -import io.github.thibaultbee.srtdroid.models.rejectreason.UserDefinedRejectReason +import io.github.thibaultbee.srtdroid.core.enums.EpollOpt +import io.github.thibaultbee.srtdroid.core.enums.ErrorType +import io.github.thibaultbee.srtdroid.core.enums.SockOpt +import io.github.thibaultbee.srtdroid.core.enums.SockStatus +import io.github.thibaultbee.srtdroid.core.interfaces.ConfigurableSrtSocket +import io.github.thibaultbee.srtdroid.core.models.Epoll +import io.github.thibaultbee.srtdroid.core.models.Error +import io.github.thibaultbee.srtdroid.core.models.MsgCtrl +import io.github.thibaultbee.srtdroid.core.models.SrtSocket +import io.github.thibaultbee.srtdroid.core.models.SrtSocket.ServerListener +import io.github.thibaultbee.srtdroid.core.models.Stats +import io.github.thibaultbee.srtdroid.core.models.rejectreason.InternalRejectReason +import io.github.thibaultbee.srtdroid.core.models.rejectreason.PredefinedRejectReason +import io.github.thibaultbee.srtdroid.core.models.rejectreason.RejectReason +import io.github.thibaultbee.srtdroid.core.models.rejectreason.UserDefinedRejectReason import kotlinx.coroutines.CompletableJob import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -56,19 +56,20 @@ private constructor( socket.setSockFlag(SockOpt.RCVSYN, false) socket.setSockFlag(SockOpt.SNDSYN, false) - socket.clientListener = object : SrtSocket.ClientListener { - override fun onConnectionLost( - ns: SrtSocket, - error: ErrorType, - peerAddress: InetSocketAddress, - token: Int - ) { - if (hasBeenConnected) { - socketContext.completeExceptionally(ConnectException(error.toString())) - coroutineContext.cancelChildren() + socket.clientListener = + object : SrtSocket.ClientListener { + override fun onConnectionLost( + ns: SrtSocket, + error: ErrorType, + peerAddress: InetSocketAddress, + token: Int + ) { + if (hasBeenConnected) { + socketContext.completeExceptionally(ConnectException(error.toString())) + coroutineContext.cancelChildren() + } } } - } } private var hasBeenConnected = false diff --git a/srtdroid-ktx/src/main/java/io/github/thibaultbee/srtdroid/ktx/extensions/CoroutineSocketExtensions.kt b/srtdroid-ktx/src/main/java/io/github/thibaultbee/srtdroid/ktx/extensions/CoroutineSocketExtensions.kt index c791cf8f..a3c7e96f 100644 --- a/srtdroid-ktx/src/main/java/io/github/thibaultbee/srtdroid/ktx/extensions/CoroutineSocketExtensions.kt +++ b/srtdroid-ktx/src/main/java/io/github/thibaultbee/srtdroid/ktx/extensions/CoroutineSocketExtensions.kt @@ -1,7 +1,7 @@ package io.github.thibaultbee.srtdroid.ktx.extensions +import io.github.thibaultbee.srtdroid.core.models.SrtUrl import io.github.thibaultbee.srtdroid.ktx.CoroutineSrtSocket -import io.github.thibaultbee.srtdroid.models.SrtUrl import java.io.File import java.net.BindException import java.net.ConnectException diff --git a/srtdroid/build.gradle b/srtdroid/build.gradle deleted file mode 100644 index 34e584c2..00000000 --- a/srtdroid/build.gradle +++ /dev/null @@ -1,133 +0,0 @@ -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' -apply plugin: 'maven-publish' -apply plugin: 'org.jetbrains.dokka' -apply plugin: 'signing' - -android { - ndkVersion '21.4.7075529' - - defaultConfig { - minSdk 19 - compileSdk 34 - targetSdk 34 - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - consumerProguardFiles 'consumer-rules.pro' - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - - externalNativeBuild { - cmake { - path "src/main/cpp/CMakeLists.txt" - } - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - namespace 'io.github.thibaultbee.srtdroid' - - publishing { - singleVariant('release') { - withSourcesJar() - withJavadocJar() - } - } -} - -dokkaHtml { - moduleName.set("${rootProject.name}") - - dokkaSourceSets { - named("main") { - noAndroidSdkLink.set(false) - skipDeprecated.set(true) - includeNonPublic.set(false) - skipEmptyPackages.set(true) - } - } -} - -ext { - isReleasedVersion = !project.version.endsWith("-SNAPSHOT") -} - -publishing { - publications { - release(MavenPublication) { - groupId = "io.github.thibaultbee" - artifactId = "srtdroid" - version = "${rootProject.versionName}" - - pom { - name = "srtdroid" - packaging = "aar" - description = "Secure Reliable Transport (SRT) Protocol for Android" - url = "https://github.com/ThibaultBee/srtdroid" - - scm { - url = "https://github.com/ThibaultBee/srtdroid" - connection = "scm:git:git://github.com/ThibaultBee/srtdroid.git" - developerConnection = "scm:git:ssh://github.com/ThibaultBee/srtdroid.git" - } - - licenses { - license { - name = "Apache License, Version 2.0" - url = "https://www.apache.org/licenses/LICENSE-2.0.txt" - distribution = "repo" - } - } - - developers { - developer { - name = "Thibault B. & SRT team" - organizationUrl = "https://github.com/ThibaultBee" - } - } - } - afterEvaluate { - from components.release - } - } - } - repositories { - maven { - name = "OSSRH" - if (!isReleasedVersion) { - url "https://s01.oss.sonatype.org/content/repositories/snapshots" - } else { - url "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2" - } - credentials { - username = System.getenv("MAVEN_USERNAME") - password = System.getenv("MAVEN_PASSWORD") - } - } - } - signing { - required { isReleasedVersion && gradle.taskGraph.hasTask("uploadArchives") } - sign publishing.publications.release - } -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.core:core-ktx:1.12.0' - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test:runner:1.5.2' - androidTestImplementation 'androidx.test:rules:1.5.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - androidTestImplementation 'com.google.guava:guava:32.1.2-jre' - -} diff --git a/srtdroid/src/main/cpp/Enums/Enums.h b/srtdroid/src/main/cpp/Enums/Enums.h deleted file mode 100644 index e5435035..00000000 --- a/srtdroid/src/main/cpp/Enums/Enums.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2021 Thibault B. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#pragma once - -#define ENUM_PACKAGE "io.github.thibaultbee.srtdroid.enums" -#define BOUNDARY_CLASS "io/github/thibaultbee/srtdroid/enums/Boundary" -#define EPOLLFLAG_CLASS "io/github/thibaultbee/srtdroid/enums/EpollFlag" -#define EPOLLOPT_CLASS "io/github/thibaultbee/srtdroid/enums/EpollOpt" -#define ERRORTYPE_CLASS "io/github/thibaultbee/srtdroid/enums/ErrorType" -#define KMSTATE_CLASS "io/github/thibaultbee/srtdroid/enums/KMState" -#define REJECT_REASON_CLASS "io/github/thibaultbee/srtdroid/enums/RejectReasonCode" -#define SOCKOPT_CLASS "io/github/thibaultbee/srtdroid/enums/SockOpt" -#define SOCKSTATUS_CLASS "io/github/thibaultbee/srtdroid/enums/SockStatus" -#define TRANSTYPE_CLASS "io/github/thibaultbee/srtdroid/enums/Transtype" diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/extensions/IntExtensions.kt b/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/extensions/IntExtensions.kt deleted file mode 100644 index a9c8bd57..00000000 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/extensions/IntExtensions.kt +++ /dev/null @@ -1,5 +0,0 @@ -package io.github.thibaultbee.srtdroid.extensions - -fun Int.toBoolean(): Boolean { - return this != 0 -} \ No newline at end of file