mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-28 22:41:02 +00:00
4259d284bd
This commit adds an Android `webrtcsrc` based example with the following features: * A first view allows retrieving the producer list from the signaller (peer ids are uuids which are too long to tap, especially using an onscreen keyboard). * Selecting a producer opens a second view. The first available video stream is rendered on a native Surface. All the audio streams are rendered using `autoaudiosink`. Available Settings: * Signaller URI. * A toggle to prefer hardware decoding for OPUS, otherwise the app defaults to raising `opusdec`'s rank. Hardware decoding was moved aside since it was found to crash the app on all tested devices (2 smartphones, 1 tv). **Warning**: in order to ease testing, this demonstration application enables unencrypted network communication. See `AndroidManifest.xml`. The application uses the technologies currenlty proposed by Android Studio when creating a new project: * Kotlin as the default language, which is fully interoperable with Java and uses the same SDK. * gradle 8.6. * kotlin dialect for gradle. The structure is mostly the same as the previously preferred dialect, for which examples can be found online readily. * However, JNI code generation still uses Makefiles (instead of CMake) due to the need to call [`gstreamer-1.0.mk`] for `gstreamer_android` generation. Note: on-going work on that front: - https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1466 - https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6794 Current limitations: * x86 support is currently discarded as `gstreamer_android` libs generation fails (observed with `gstreamer-1.0-android-universal-1.24.3`). * A selector could be added to let the user chose the video streams and possibly decide whether to render all audio streams or just select one. Nice to have: * Support for the synchronization features of the `webrtc-precise-sync-recv` example (NTP clock, RFC 7273). * It could be nice to use Rust for the specific native code. [`gstreamer-1.0.mk`]: https://gitlab.freedesktop.org/gstreamer/cerbero/-/blob/main/data/ndk-build/gstreamer-1.0.mk Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1578>
93 lines
3.2 KiB
Text
93 lines
3.2 KiB
Text
import java.text.SimpleDateFormat
|
|
import java.util.Date
|
|
|
|
plugins {
|
|
alias(libs.plugins.android.application)
|
|
alias(libs.plugins.jetbrains.kotlin.android)
|
|
alias(libs.plugins.androidx.navigation.safeargs)
|
|
kotlin("plugin.serialization") version "1.9.22"
|
|
}
|
|
|
|
android {
|
|
namespace = "org.freedesktop.gstreamer.examples.webrtcsrc"
|
|
compileSdk = 34
|
|
ndkVersion = "25.2.9519653"
|
|
|
|
defaultConfig {
|
|
applicationId = "org.freedesktop.gstreamer.examples.WebRTCSrc"
|
|
minSdk = 28
|
|
targetSdk = 34
|
|
versionCode = 1
|
|
versionName = "0.1.0"
|
|
|
|
externalNativeBuild {
|
|
ndkBuild {
|
|
var gstRoot: String?
|
|
if (project.hasProperty("gstAndroidRoot"))
|
|
gstRoot = project.property("gstAndroidRoot").toString()
|
|
else
|
|
gstRoot = System.getenv("GSTREAMER_ROOT_ANDROID")
|
|
if (gstRoot == null)
|
|
throw GradleException("GSTREAMER_ROOT_ANDROID must be set, or 'gstAndroidRoot' must be defined in your gradle.properties in the top level directory of the unpacked universal GStreamer Android binaries")
|
|
|
|
arguments("NDK_APPLICATION_MK=src/main/cpp/Application.mk", "GSTREAMER_JAVA_SRC_DIR=src/main/java", "GSTREAMER_ROOT_ANDROID=$gstRoot", "V=1")
|
|
|
|
targets("gstreamer_webrtcsrc")
|
|
|
|
// All archs except MIPS and MIPS64 are supported
|
|
//abiFilters("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
|
|
// FIXME for some reasons x86 generation fails (observed with gstreamer-1.0-android-universal-1.24.3)
|
|
abiFilters("armeabi-v7a", "arm64-v8a", "x86_64")
|
|
}
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
isMinifyEnabled = false
|
|
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
|
}
|
|
}
|
|
|
|
applicationVariants.all {
|
|
val variant = this
|
|
variant.outputs
|
|
.map { it as com.android.build.gradle.internal.api.BaseVariantOutputImpl }
|
|
.forEach { output ->
|
|
val date = SimpleDateFormat("YYYYMMdd").format(Date())
|
|
val outputFileName = "GstExamples.WebRTCSrc-${variant.baseName}-${variant.versionName}-${date}.apk"
|
|
output.outputFileName = outputFileName
|
|
}
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
|
targetCompatibility = JavaVersion.VERSION_1_8
|
|
}
|
|
kotlinOptions {
|
|
jvmTarget = "1.8"
|
|
}
|
|
buildFeatures {
|
|
viewBinding = true
|
|
}
|
|
externalNativeBuild {
|
|
ndkBuild {
|
|
path = file("src/main/cpp/Android.mk")
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation(libs.androidx.appcompat)
|
|
implementation(libs.androidx.constraintlayout)
|
|
implementation(libs.androidx.core.ktx)
|
|
implementation(libs.androidx.lifecycle.runtime.ktx)
|
|
implementation(libs.androidx.navigation.fragment.ktx)
|
|
implementation(libs.androidx.navigation.ui.ktx)
|
|
implementation(libs.androidx.preference)
|
|
implementation(libs.androidx.recyclerview)
|
|
implementation(libs.androidx.work.runtime.ktx)
|
|
implementation(libs.kotlinx.serialization.json)
|
|
implementation(libs.ktor.client.okhttp)
|
|
implementation(libs.material)
|
|
}
|