diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 6499ab03..e5b2aa16 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -4,36 +4,36 @@ on: [push, pull_request] jobs: - test-1-16: + test-1-24-jdk25: - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v5 - - name: Set up JDK 1.8 - uses: actions/setup-java@v3 + - name: Set up JDK 25 + uses: actions/setup-java@v5 with: - java-version: '8' + java-version: '25' distribution: 'temurin' - name: Install GStreamer run: sudo apt-get update && sudo apt-get install gstreamer1.0-plugins-good gstreamer1.0-plugins-bad - name: Build with Maven - run: mvn -B verify --file pom.xml + run: ./mvnw --batch-mode verify - test-1-20: + test-1-20-jdk8: runs-on: ubuntu-22.04 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v5 - - name: Set up JDK 1.8 - uses: actions/setup-java@v3 + - name: Set up JDK 8 + uses: actions/setup-java@v5 with: java-version: '8' distribution: 'temurin' @@ -42,4 +42,4 @@ jobs: run: sudo apt-get update && sudo apt-get install gstreamer1.0-plugins-good gstreamer1.0-plugins-bad - name: Build with Maven - run: mvn -B verify --file pom.xml + run: ./mvnw --batch-mode verify diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 00000000..222cba3b --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,4 @@ +wrapperVersion=3.3.4 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip +distributionSha256Sum=0d7125e8c91097b36edb990ea5934e6c68b4440eef4ea96510a0f6815e7eeadb diff --git a/mvnw b/mvnw new file mode 100755 index 00000000..bd8896bf --- /dev/null +++ b/mvnw @@ -0,0 +1,295 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.3.4 +# +# Optional ENV vars +# ----------------- +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output +# ---------------------------------------------------------------------------- + +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x + +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac + +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" + + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 + fi + fi + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi + fi +} + +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" + done + printf %x\\n $h +} + +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } + +die() { + printf %s\\n "$1" >&2 + exit 1 +} + +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} + +scriptDir="$(dirname "$0")" +scriptName="$(basename "$0")" + +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} + +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" +fi + +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac + +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" +fi + +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" +fi + +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v + +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac + +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then + distributionSha256Result=true + fi + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 + fi +fi + +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" +else + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" +fi + +# Find the actual extracted directory name (handles snapshots where filename != directory name) +actualDistributionDir="" + +# First try the expected directory name (for regular distributions) +if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then + if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then + actualDistributionDir="$distributionUrlNameMain" + fi +fi + +# If not found, search for any directory with the Maven executable (for snapshots) +if [ -z "$actualDistributionDir" ]; then + # enable globbing to iterate over items + set +f + for dir in "$TMP_DOWNLOAD_DIR"/*; do + if [ -d "$dir" ]; then + if [ -f "$dir/bin/$MVN_CMD" ]; then + actualDistributionDir="$(basename "$dir")" + break + fi + fi + done + set -f +fi + +if [ -z "$actualDistributionDir" ]; then + verbose "Contents of $TMP_DOWNLOAD_DIR:" + verbose "$(ls -la "$TMP_DOWNLOAD_DIR")" + die "Could not find Maven distribution directory in extracted archive" +fi + +verbose "Found extracted Maven distribution directory: $actualDistributionDir" +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" + +clean || : +exec_maven "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 00000000..5761d948 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,189 @@ +<# : batch portion +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.3.4 +@REM +@REM Optional ENV vars +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output +@REM ---------------------------------------------------------------------------- + +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) +) +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' + +$MAVEN_M2_PATH = "$HOME/.m2" +if ($env:MAVEN_USER_HOME) { + $MAVEN_M2_PATH = "$env:MAVEN_USER_HOME" +} + +if (-not (Test-Path -Path $MAVEN_M2_PATH)) { + New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null +} + +$MAVEN_WRAPPER_DISTS = $null +if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) { + $MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists" +} else { + $MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists" +} + +$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain" +$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null + +# Find the actual extracted directory name (handles snapshots where filename != directory name) +$actualDistributionDir = "" + +# First try the expected directory name (for regular distributions) +$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain" +$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD" +if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) { + $actualDistributionDir = $distributionUrlNameMain +} + +# If not found, search for any directory with the Maven executable (for snapshots) +if (!$actualDistributionDir) { + Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object { + $testPath = Join-Path $_.FullName "bin/$MVN_CMD" + if (Test-Path -Path $testPath -PathType Leaf) { + $actualDistributionDir = $_.Name + } + } +} + +if (!$actualDistributionDir) { + Write-Error "Could not find Maven distribution directory in extracted archive" +} + +Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir" +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/pom.xml b/pom.xml index 6c73453d..e917e0a5 100644 --- a/pom.xml +++ b/pom.xml @@ -33,12 +33,12 @@ - ossrh - https://oss.sonatype.org/content/repositories/snapshots + sonatype-central + https://central.sonatype.com/repository/maven-snapshots - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ + sonatype-central + https://repo.maven.apache.org/maven2 @@ -64,10 +64,10 @@ - UTF-8 + 8 - 1.8 - 1.8 + 0.8.5 + UTF-8 @@ -80,7 +80,7 @@ net.java.dev.jna jna - [5.2.0,6.0) + 5.18.1 @@ -103,25 +103,40 @@ + + + eu.maveniverse.maven.njord + extension3 + ${njord.version} + + org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M7 + 3.5.4 - 1 + none false - -Djna.nosys=true ${maven.test.jvmargs} + -XX:+IgnoreUnrecognizedVMOptions --enable-native-access=ALL-UNNAMED -Djna.nosys=true ${maven.test.jvmargs} **/Test*.java + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.1 + + 8 + + org.apache.maven.plugins maven-jar-plugin - 3.1.2 + 3.4.2 @@ -130,14 +145,6 @@ - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.4 - - org.freedesktop.gstreamer.lowlevel - - @@ -173,7 +180,7 @@ org.apache.maven.plugins maven-source-plugin - 2.2.1 + 3.3.1 attach-sources @@ -186,9 +193,11 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.10.4 + 3.12.0 + none org.freedesktop.gstreamer.lowlevel + 8 @@ -202,7 +211,7 @@ org.apache.maven.plugins maven-gpg-plugin - 1.5 + 3.2.8 sign-artifacts diff --git a/src/org/freedesktop/gstreamer/Bin.java b/src/org/freedesktop/gstreamer/Bin.java index 74834123..f2e29cd0 100644 --- a/src/org/freedesktop/gstreamer/Bin.java +++ b/src/org/freedesktop/gstreamer/Bin.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Neil C Smith + * Copyright (c) 2025 Neil C Smith * Copyright (c) 2016 Christophe Lafolet * Copyright (c) 2009 Levente Farkas * Copyright (C) 2007 Wayne Meissner @@ -496,7 +496,7 @@ public void disconnect(DO_LATENCY listener) { /** * Available details for pipeline graphs produced by - * {@link #debugToDotFile(int, java.lang.String, boolean)} + * {@link #debugToDotFile(java.util.EnumSet, java.lang.String)} */ public static enum DebugGraphDetails implements NativeFlags { diff --git a/src/org/freedesktop/gstreamer/Bus.java b/src/org/freedesktop/gstreamer/Bus.java index ac48e6d3..2520e6e0 100644 --- a/src/org/freedesktop/gstreamer/Bus.java +++ b/src/org/freedesktop/gstreamer/Bus.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Neil C Smith + * Copyright (c) 2025 Neil C Smith * Copyright (C) 2014 Tom Greenwood * Copyright (C) 2007 Wayne Meissner * Copyright (C) 2004 Wim Taymans @@ -33,6 +33,7 @@ import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.LongByReference; import com.sun.jna.ptr.PointerByReference; +import org.freedesktop.gstreamer.glib.GObject; import org.freedesktop.gstreamer.glib.NativeEnum; import org.freedesktop.gstreamer.glib.Natives; @@ -766,9 +767,10 @@ public static interface BUFFERING { * {@code percent} is a value between 0 and 100. A value of 100 means * that the buffering completed. *

- * When {@code percent} is < 100 the application should PAUSE a PLAYING - * pipeline. When {@code percent} is 100, the application can set the - * pipeline (back) to PLAYING.

+ * When {@code percent} is less than 100 the application should PAUSE a + * PLAYING pipeline. When {@code percent} is 100, the application can + * set the pipeline (back) to PLAYING. + *

* The application must be prepared to receive BUFFERING messages in the * PREROLLING state and may only set the pipeline to PLAYING after * receiving a message with {@code percent} set to 100, which can happen diff --git a/src/org/freedesktop/gstreamer/BusSyncReply.java b/src/org/freedesktop/gstreamer/BusSyncReply.java index 797e92bb..24ba56f1 100644 --- a/src/org/freedesktop/gstreamer/BusSyncReply.java +++ b/src/org/freedesktop/gstreamer/BusSyncReply.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Neil C Smith + * Copyright (c) 2025 Neil C Smith * Copyright (c) 2007 Wayne Meissner * * This file is part of gstreamer-java. @@ -20,6 +20,7 @@ package org.freedesktop.gstreamer; import org.freedesktop.gstreamer.glib.NativeEnum; +import org.freedesktop.gstreamer.message.Message; /** * The result values for a GstBusSyncHandler. diff --git a/src/org/freedesktop/gstreamer/Caps.java b/src/org/freedesktop/gstreamer/Caps.java index f26a24a7..381cb49f 100644 --- a/src/org/freedesktop/gstreamer/Caps.java +++ b/src/org/freedesktop/gstreamer/Caps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Neil C Smith + * Copyright (c) 2025 Neil C Smith * Copyright (c) 2009 Levente Farkas * Copyright (C) 2007 Wayne Meissner * Copyright (C) <2003> David A. Schleef @@ -38,12 +38,12 @@ * given pad can handle. They are also stored in the {@link Registry} along with * a description of the {@link Element}. *

- * Caps are exposed on the element pads using the {@link Pad#getCaps} method. - * This method describes the possible types that the pad can handle or produce - * at runtime. + * Caps are exposed on the element pads using the {@link Pad#getAllowedCaps() } + * method. This method describes the possible types that the pad can handle or + * produce at runtime. *

* Caps are also attached to buffers to describe the content of the data pointed - * to by the buffer with {@link Buffer#setCaps}. Caps attached to a + * to by the buffer with {@link Sample#setCaps}. Caps attached to a * {@link Buffer} allow for format negotiation upstream and downstream. *

* A Caps can be constructed with the following code fragment: diff --git a/src/org/freedesktop/gstreamer/ClockID.java b/src/org/freedesktop/gstreamer/ClockID.java index 9bb243ad..ab25ebf8 100644 --- a/src/org/freedesktop/gstreamer/ClockID.java +++ b/src/org/freedesktop/gstreamer/ClockID.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Neil C Smith + * Copyright (c) 2025 Neil C Smith * Copyright (c) 2007 Wayne Meissner * * This file is part of gstreamer-java. @@ -57,7 +57,8 @@ public long getTime() { * Compares this ClockID to another. * * @param other The other ClockID to compare to - * @return negative value if a < b; zero if a = b; positive value if a > b + * @return negative value if + * {@code a < b; zero if a = b; positive value if a > b} */ @Override public int compareTo(ClockID other) { diff --git a/src/org/freedesktop/gstreamer/Context.java b/src/org/freedesktop/gstreamer/Context.java index ae83e62e..f77e713e 100644 --- a/src/org/freedesktop/gstreamer/Context.java +++ b/src/org/freedesktop/gstreamer/Context.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2025 Neil C Smith * Copyright (c) 2019 Christophe Lafolet * * This file is part of gstreamer-java. @@ -54,7 +55,7 @@ * application should provide one if it can. *

* Contexts can be persistent. A persistent context is kept in elements when - * they reach {@lin State#NULL}, non-persistent ones will be removed. Also, a + * they reach {@link State#NULL}, non-persistent ones will be removed. Also, a * non-persistent context won't override a previous persistent context set to an * element. */ diff --git a/src/org/freedesktop/gstreamer/Element.java b/src/org/freedesktop/gstreamer/Element.java index 57fa69ef..56d86194 100644 --- a/src/org/freedesktop/gstreamer/Element.java +++ b/src/org/freedesktop/gstreamer/Element.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Neil C Smith + * Copyright (c) 2025 Neil C Smith * Copyright (c) 2019 Christophe Lafolet * Copyright (c) 2009 Levente Farkas * Copyright (C) 2007 Wayne Meissner @@ -61,9 +61,6 @@ * (or source) pads. Core and plug-in writers can add and remove pads with * {@link #addPad} and {@link #removePad}. *

- * A pad of an element can be retrieved by name with {@link #getPad}. An list of - * all pads can be retrieved with {@link #getPads}. - *

* Elements can be linked through their pads. If the link is straightforward, * use the {@link #link} convenience function to link two elements, or * {@link #linkMany} for more elements in a row. @@ -109,16 +106,16 @@ protected static Initializer makeRawElement(String factoryName, String elementNa * destination; the other direction will not be tried. *

* The function looks for existing pads that aren't linked yet. It will - * request new pads if necessary. Such pads need to be released manualy when - * unlinking. If multiple links are possible, only one is established. + * request new pads if necessary. Such pads need to be released manually + * when unlinking. If multiple links are possible, only one is established. *

* Make sure you have added your elements to a bin or pipeline with * {@link Bin#add} or {@link Bin#addMany} before trying to link them. *

- * See {@link Element#linkPadsFiltered} if you need more control about - * which pads are selected for linking. + * See {@link #linkPadsFiltered} if you need more control about which pads + * are selected for linking. * - * @param dest The {@link Element} containing the destination pad. + * @param dest The element containing the destination pad. * @return true if the elements could be linked, false otherwise. */ public boolean link(Element dest) { @@ -127,20 +124,20 @@ public boolean link(Element dest) { /** * Links this element to another element using the given caps as filtercaps. - * The link must be from source to destination; the other direction will - * not be tried. + * The link must be from source to destination; the other direction will not + * be tried. *

* The function looks for existing pads that aren't linked yet. It will - * request new pads if necessary. Such pads need to be released manualy when - * unlinking. If multiple links are possible, only one is established. + * request new pads if necessary. Such pads need to be released manually + * when unlinking. If multiple links are possible, only one is established. *

* Make sure you have added your elements to a bin or pipeline with * {@link Bin#add} or {@link Bin#addMany} before trying to link them. *

- * See {@link Element#linkPadsFiltered} if you need more control about - * which pads are selected for linking. + * See {@link #linkPadsFiltered} if you need more control about which pads + * are selected for linking. * - * @param dest The {@link Element} containing the destination pad. + * @param dest The element containing the destination pad. * @param filter The {@link Caps} to filter the link, or Null for no filter. * @return true if the elements could be linked, false otherwise. */ @@ -148,23 +145,6 @@ public boolean linkFiltered(Element dest, Caps filter) { return GSTELEMENT_API.gst_element_link_filtered(this, dest, filter); } - -// /** -// * Chain together a series of elements, with this element as the first in the list. -// *

-// * Make sure you have added your elements to a bin or pipeline with -// * {@link Bin#add} or {@link Bin#addMany} before trying to link them. -// * -// * @param elems The list of elements to be linked. -// * @return true if the elements could be linked, false otherwise. -// */ -// public boolean link(Element... elems) { -// // Its much more efficient to copy the array and let the native code do the linking -// Element[] list = new Element[elems.length + 1]; -// list[0] = this; -// System.arraycopy(elems, 0, list, 1, elems.length); -// return linkMany(list); -// } /** * Unlinks all source pads of this source element with all sink pads of the * sink element to which they are linked. @@ -222,8 +202,8 @@ public StateChangeReturn pause() { } /** - * Tells the Element to pause playing the media stream. Equivalent to - * calling {@link #setState(org.freedesktop.gstreamer.State)} with + * Tells the Element to stop playing the media stream. Equivalent to calling + * {@link #setState(org.freedesktop.gstreamer.State)} with * {@link State#NULL}. * * @return the status of the element's state change. @@ -279,8 +259,8 @@ public State getState() { * Gets the state of the element. *

* For elements that performed an ASYNC state change, as reported by - * {@link #setState}, this function will block up to the specified timeout - * value for the state change to complete. + * {@link #setState(org.freedesktop.gstreamer.State)}, this function will + * block up to the specified timeout value for the state change to complete. * * @param timeout the amount of time to wait. * @param units the units of the timeout. @@ -297,8 +277,8 @@ public State getState(long timeout, TimeUnit units) { * Gets the state of the element. *

* For elements that performed an ASYNC state change, as reported by - * {@link #setState}, this function will block up to the specified timeout - * value for the state change to complete. + * {@link #setState(org.freedesktop.gstreamer.State)}, this function will + * block up to the specified timeout value for the state change to complete. * * @param timeout The amount of time in nanoseconds to wait. * @return The {@link State} the Element is currently in. @@ -314,13 +294,12 @@ public State getState(long timeout) { * Gets the state of the element. *

* For elements that performed an ASYNC state change, as reported by - * {@link #setState}, this function will block up to the specified timeout - * value for the state change to complete. + * {@link #setState(org.freedesktop.gstreamer.State)}, this function will + * block up to the specified timeout value for the state change to complete. * * @param timeout The amount of time in nanoseconds to wait. * @param states an array to store the states in. Must be of sufficient size * to hold two elements. - * */ public void getState(long timeout, State[] states) { State[] state = new State[1]; @@ -387,7 +366,7 @@ public List getSrcPads() { public List getSinkPads() { return padList(GSTELEMENT_API.gst_element_iterate_sink_pads(this)); } - + private List padList(GstIteratorPtr iter) { return GstIterator.asList(iter, Pad.class); } @@ -489,7 +468,7 @@ public boolean sendEvent(Event ev) { } /** - * Signal emitted when an {@link Pad} is added to this {@link Element} + * Signal emitted when an {@link Pad} is added to this element. * * @see #connect(PAD_ADDED) * @see #disconnect(PAD_ADDED) @@ -506,7 +485,7 @@ public static interface PAD_ADDED { } /** - * Signal emitted when an {@link Pad} is removed from this {@link Element} + * Signal emitted when an {@link Pad} is removed from this element. * * @see #connect(PAD_REMOVED) * @see #disconnect(PAD_REMOVED) @@ -523,8 +502,7 @@ public static interface PAD_REMOVED { } /** - * Signal emitted when this {@link Element} ceases to generated dynamic - * pads. + * Signal emitted when this element ceases to generated dynamic pads. * * @see #connect(NO_MORE_PADS) * @see #disconnect(NO_MORE_PADS) @@ -532,7 +510,7 @@ public static interface PAD_REMOVED { public static interface NO_MORE_PADS { /** - * Called when an {@link Element} ceases to generated dynamic pads. + * Called when an element ceases to generated dynamic pads. * * @param element the element which posted this message. */ @@ -543,7 +521,7 @@ public static interface NO_MORE_PADS { * Add a listener for the pad-added signal * * @param listener Listener to be called when a {@link Pad} is added to the - * {@link Element}. + * element. */ public void connect(final PAD_ADDED listener) { connect(PAD_ADDED.class, listener, new GstCallback() { @@ -567,7 +545,7 @@ public void disconnect(PAD_ADDED listener) { * Add a listener for the pad-added signal * * @param listener Listener to be called when a {@link Pad} is removed from - * the {@link Element}. + * the element. */ public void connect(final PAD_REMOVED listener) { connect(PAD_REMOVED.class, listener, new GstCallback() { @@ -590,8 +568,8 @@ public void disconnect(PAD_REMOVED listener) { /** * Add a listener for the no-more-pads signal * - * @param listener Listener to be called when the {@link Element} will has - * finished generating dynamic pads. + * @param listener Listener to be called when the element has finished + * generating dynamic pads. */ public void connect(final NO_MORE_PADS listener) { connect(NO_MORE_PADS.class, listener, new GstCallback() { @@ -641,10 +619,10 @@ public static void unlinkMany(Element... elements) { * child of the parent of the other element. If they have different parents, * the link fails. * - * @param src The {@link Element} containing the source {@link Pad}. + * @param src The element containing the source {@link Pad}. * @param srcPadName The name of the source {@link Pad}. Can be null for any * pad. - * @param dest The {@link Element} containing the destination {@link Pad}. + * @param dest The element containing the destination {@link Pad}. * @param destPadName The name of the destination {@link Pad}. Can be null * for any pad. * @@ -661,10 +639,10 @@ public static boolean linkPads(Element src, String srcPadName, Element dest, Str * fails. If caps is not null, makes sure that the caps of the link is a * subset of caps. * - * @param src The {@link Element} containing the source {@link Pad}. + * @param src The element containing the source {@link Pad}. * @param srcPadName The name of the source {@link Pad}. Can be null for any * pad. - * @param dest The {@link Element} containing the destination {@link Pad}. + * @param dest The element containing the destination {@link Pad}. * @param destPadName The name of the destination {@link Pad}. Can be null * for any pad. * @param caps The {@link Caps} to use to filter the link. @@ -679,9 +657,9 @@ public static boolean linkPadsFiltered(Element src, String srcPadName, /** * Unlink source and destination pads of two elements. * - * @param src The {@link Element} containing the source {@link Pad}. + * @param src The element containing the source {@link Pad}. * @param srcPadName The name of the source {@link Pad}. - * @param dest The {@link Element} containing the destination {@link Pad}. + * @param dest The element containing the destination {@link Pad}. * @param destPadName The name of the destination {@link Pad}. * */ @@ -752,7 +730,7 @@ public long getStartTime() { * * Toplevel elements like GstPipeline will manage the start_time and * base_time on its children. Setting the start_time to - * {@link long#NONE} on such a toplevel element will disable the + * {@link ClockTime#NONE} on such a toplevel element will disable the * distribution of the base_time to the children and can be useful if the * application manages the base_time itself, for example if you want to * synchronize capture from multiple pipelines, and you can also ensure that @@ -823,7 +801,7 @@ public long queryDuration(Format format) { long[] dur = {0}; return GSTELEMENT_API.gst_element_query_duration(this, format, dur) ? dur[0] : -1L; } - + /** * Queries an element (usually top-level pipeline or playbin element) for * the stream position in nanoseconds. This will be a value between 0 and @@ -839,7 +817,7 @@ public long queryPosition(Format format) { long[] pos = {0}; return GSTELEMENT_API.gst_element_query_position(this, format, pos) ? pos[0] : -1L; } - + /** * Sends a seek event to an element. See {@link SeekEvent} for the details * of the parameters. The seek event is sent to the element using the native @@ -891,7 +869,7 @@ public boolean seekSimple(Format format, Set seekFlags, long seekPosi return GSTELEMENT_API.gst_element_seek_simple(this, format, NativeFlags.toInt(seekFlags), seekPosition); } - + static class Handle extends GstObject.Handle { public Handle(GstObjectPtr ptr, boolean ownsHandle) { diff --git a/src/org/freedesktop/gstreamer/Gst.java b/src/org/freedesktop/gstreamer/Gst.java index 1621fbbd..8835c929 100644 --- a/src/org/freedesktop/gstreamer/Gst.java +++ b/src/org/freedesktop/gstreamer/Gst.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Neil C Smith + * Copyright (c) 2025 Neil C Smith * Copyright (c) 2018 Antonio Morales * Copyright (c) 2007 Wayne Meissner * @@ -358,7 +358,7 @@ private static GError extractError(Pointer errorPtr) { GErrorStruct struct = new GErrorStruct(errorPtr); struct.read(); GError err = new GError(struct.getCode(), struct.getMessage()); - GLIB_API.g_error_free(struct); + GLIB_API.g_error_free(errorPtr); return err; } diff --git a/src/org/freedesktop/gstreamer/device/DeviceProviderFactory.java b/src/org/freedesktop/gstreamer/device/DeviceProviderFactory.java index 64d26d15..a811163d 100644 --- a/src/org/freedesktop/gstreamer/device/DeviceProviderFactory.java +++ b/src/org/freedesktop/gstreamer/device/DeviceProviderFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Neil C Smith + * Copyright (c) 2025 Neil C Smith * Copyright (c) 2015 Andres Colubri * Copyright (C) 2013 Olivier Crete * @@ -39,9 +39,9 @@ * DeviceProviderFactory is used to create instances of device providers. A * DeviceProviderfactory can be added to a Plugin as it is also a PluginFeature. * - * Use the {@link #find(java.lang.String) and - * {@link #get() } functions to create device provider - * instances or use {@link #getByName(java.lang.String) } as a convenient + * Use the {@link #find(java.lang.String)} and + * {@link #get()} functions to create device provider + * instances or use {@link #getByName(java.lang.String)} as a convenient * shortcut. */ public class DeviceProviderFactory extends GstObject { diff --git a/src/org/freedesktop/gstreamer/elements/AppSrc.java b/src/org/freedesktop/gstreamer/elements/AppSrc.java index 40ab5c8d..54f09325 100644 --- a/src/org/freedesktop/gstreamer/elements/AppSrc.java +++ b/src/org/freedesktop/gstreamer/elements/AppSrc.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Neil C Smith + * Copyright (c) 2025 Neil C Smith * Copyright (c) 2009 Andres Colubri * Copyright (c) 2008 Wayne Meissner * Copyright (C) 2007 David Schleef @@ -23,6 +23,7 @@ import org.freedesktop.gstreamer.Buffer; import org.freedesktop.gstreamer.Caps; +import org.freedesktop.gstreamer.Element; import org.freedesktop.gstreamer.lowlevel.GstAPI.GstCallback; import static org.freedesktop.gstreamer.lowlevel.AppAPI.APP_API; diff --git a/src/org/freedesktop/gstreamer/elements/DecodeBin.java b/src/org/freedesktop/gstreamer/elements/DecodeBin.java index 5f72908d..d9b0e42e 100644 --- a/src/org/freedesktop/gstreamer/elements/DecodeBin.java +++ b/src/org/freedesktop/gstreamer/elements/DecodeBin.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Neil C Smith + * Copyright (c) 2025 Neil C Smith * Copyright (c) 2016 Christophe Lafolet * Copyright (c) 2010 DHoyt * @@ -31,7 +31,6 @@ import org.freedesktop.gstreamer.query.Query; import org.freedesktop.gstreamer.lowlevel.GValueAPI.GValueArray; import org.freedesktop.gstreamer.lowlevel.GstAPI.GstCallback; -import org.freedesktop.gstreamer.glib.NativeFlags; import org.freedesktop.gstreamer.lowlevel.GType; import org.freedesktop.gstreamer.lowlevel.GValueAPI; @@ -150,8 +149,8 @@ public void disconnect(AUTOPLUG_CONTINUE listener) { * pad is needed. {@link DecodeBin} will by default return an array with all * compatible factories, sorted by rank. *

- * If this function returns {@link Optional#EMPTY}, pad will be exposed as a - * final caps. + * If this function returns {@link Optional#empty()}, pad will be exposed as + * a final caps. *

* If this function returns an empty list, the pad will be considered as * having an unhandled type media type. @@ -213,7 +212,7 @@ public static interface AUTOPLUG_SORT { * @param pad the new Pad * @param caps the caps of the pad that cannot be resolved * @param factories A List of possible {@link ElementFactory} to use - * @return resorted list or {@link Optional#EMPTY} + * @return resorted list or {@link Optional#empty()} */ public Optional> autoplugSort( DecodeBin element, Pad pad, Caps caps, List factories); diff --git a/src/org/freedesktop/gstreamer/glib/GSocket.java b/src/org/freedesktop/gstreamer/glib/GSocket.java index 291e8027..27aab519 100644 --- a/src/org/freedesktop/gstreamer/glib/GSocket.java +++ b/src/org/freedesktop/gstreamer/glib/GSocket.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Neil C Smith + * Copyright (c) 2025 Neil C Smith * Copyright (c) 2016 Isaac RaƱo Jares * * This file is part of gstreamer-java. @@ -92,7 +92,7 @@ public boolean isBlocking() { private static String extractAndClearError(GErrorStruct struct) { struct.read(); String err = struct.getMessage(); - GLIB_API.g_error_free(struct); + GLIB_API.g_error_free(struct.getPointer()); return err; } diff --git a/src/org/freedesktop/gstreamer/lowlevel/GlibAPI.java b/src/org/freedesktop/gstreamer/lowlevel/GlibAPI.java index a9239329..7fb51bcb 100644 --- a/src/org/freedesktop/gstreamer/lowlevel/GlibAPI.java +++ b/src/org/freedesktop/gstreamer/lowlevel/GlibAPI.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2025 Neil C Smith * Copyright (c) 2009 Levente Farkas * Copyright (c) 2007 Wayne Meissner * @@ -108,7 +109,6 @@ int g_timeout_add_full(int priority, int interval, GSourceFunc function, int g_timeout_add_seconds(int interval, GSourceFunc function, Pointer data); GstAPI.GErrorStruct g_error_new(int quark, int code, String message); void g_error_free(Pointer error); - void g_error_free(GstAPI.GErrorStruct error); void g_source_remove(int id); void g_free(Pointer ptr); diff --git a/src/org/freedesktop/gstreamer/message/GErrorMessage.java b/src/org/freedesktop/gstreamer/message/GErrorMessage.java index 6076e6d2..387ddfa6 100644 --- a/src/org/freedesktop/gstreamer/message/GErrorMessage.java +++ b/src/org/freedesktop/gstreamer/message/GErrorMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Neil C Smith + * Copyright (C) 2025 Neil C Smith * Copyright (C) 2008 Wayne Meissner * * This file is part of gstreamer-java. @@ -50,7 +50,7 @@ public int getCode() { throw new NullPointerException("Could not parse message"); } int code = err.code; - GLIB_API.g_error_free(err); + GLIB_API.g_error_free(err.getPointer()); return code; } @@ -65,7 +65,7 @@ public String getMessage() { throw new NullPointerException("Could not parse message"); } String message = err.getMessage(); - GLIB_API.g_error_free(err); + GLIB_API.g_error_free(err.getPointer()); return message; } diff --git a/test/org/freedesktop/gstreamer/BusTest.java b/test/org/freedesktop/gstreamer/BusTest.java index 0f0e6831..951c8714 100644 --- a/test/org/freedesktop/gstreamer/BusTest.java +++ b/test/org/freedesktop/gstreamer/BusTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Neil C Smith + * Copyright (c) 2025 Neil C Smith * Copyright (c) 2007 Wayne Meissner * * This file is part of gstreamer-java. @@ -145,7 +145,7 @@ public void errorMessage() { pipe.dispose(); assertTrue("ERROR signal not received", signalFired.get()); assertEquals("Incorrect source object on signal", pipe.src, signalSource.get()); - GlibAPI.GLIB_API.g_error_free(msg); + GlibAPI.GLIB_API.g_error_free(msg.getPointer()); } @Test @@ -171,7 +171,7 @@ public void warningMessage() { pipe.dispose(); assertTrue("WARNING signal not received", signalFired.get()); assertEquals("Incorrect source object on signal", pipe.src, signalSource.get()); - GlibAPI.GLIB_API.g_error_free(msg); + GlibAPI.GLIB_API.g_error_free(msg.getPointer()); } @Test @@ -197,7 +197,7 @@ public void infoMessage() { pipe.dispose(); assertTrue("INFO signal not received", signalFired.get()); assertEquals("Incorrect source object on signal", pipe.src, signalSource.get()); - GlibAPI.GLIB_API.g_error_free(msg); + GlibAPI.GLIB_API.g_error_free(msg.getPointer()); } @Test diff --git a/test/org/freedesktop/gstreamer/InitTest.java b/test/org/freedesktop/gstreamer/InitTest.java index 6ad71c43..2efc9f98 100644 --- a/test/org/freedesktop/gstreamer/InitTest.java +++ b/test/org/freedesktop/gstreamer/InitTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Neil C Smith + * Copyright (c) 2025 Neil C Smith * Copyright (c) 2007 Wayne Meissner * * This file is part of gstreamer-java. @@ -47,7 +47,7 @@ public void testInit() { System.out.println("Expected init failure"); System.out.println(ex); } - String[] args = Gst.init(available, "InitTest", "--gst-plugin-spew"); + String[] args = Gst.init(available, "InitTest", "--gst-debug-no-color"); assertTrue(args.length == 0); assertTrue(Gst.testVersion(available.getMajor(), available.getMinor())); diff --git a/test/org/freedesktop/gstreamer/video/VideoTimeCodeMetaTest.java b/test/org/freedesktop/gstreamer/video/VideoTimeCodeMetaTest.java index 3ce6c9cc..17f9f75b 100644 --- a/test/org/freedesktop/gstreamer/video/VideoTimeCodeMetaTest.java +++ b/test/org/freedesktop/gstreamer/video/VideoTimeCodeMetaTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Neil C Smith + * Copyright (c) 2025 Neil C Smith * Copyright (c) 2020 Petr Lastovka * * This file is part of gstreamer-java. @@ -33,7 +33,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; - public class VideoTimeCodeMetaTest { @BeforeClass @@ -59,30 +58,30 @@ public void testVideoWithoutTimeCodeMeta() { @Test public void testVideoTimeCodeMetaPal() { // timecodestamper is available since 1.10 - TestAssumptions.requireGstVersion(1,10); + TestAssumptions.requireGstVersion(1, 10); TestAssumptions.requireElement("timecodestamper"); SampleTester.test(sample -> { Buffer buffer = sample.getBuffer(); if (Gst.testVersion(1, 14)) { assertTrue("Video should contains timecode meta", buffer.hasMeta(VideoTimeCodeMeta.API)); } - VideoTimeCodeMeta meta = buffer.getMeta(VideoTimeCodeMeta.API); - assertNotNull(meta); - VideoTimeCode timeCode = meta.getTimeCode(); - - //first frame 00:00:00:00 - assertEquals(0, timeCode.getHours()); - assertEquals(0, timeCode.getMinutes()); - assertEquals(0, timeCode.getSeconds()); - assertEquals(0, timeCode.getFrames()); - - VideoTimeCodeConfig timeCodeConfig = timeCode.getConfig(); - // PAL standard 25/1 - assertEquals(25, timeCodeConfig.getNumerator()); - assertEquals(1, timeCodeConfig.getDenominator()); - assertTrue(timeCodeConfig.getFlags().isEmpty()); - - }, "videotestsrc do-timestamp=true ! video/x-raw,framerate=25/1 ! timecodestamper ! videoconvert ! appsink name=myappsink"); + try (VideoTimeCodeMeta meta = buffer.getMeta(VideoTimeCodeMeta.API)) { + assertNotNull(meta); + VideoTimeCode timeCode = meta.getTimeCode(); + + //first frame 00:00:00:00 + assertEquals(0, timeCode.getHours()); + assertEquals(0, timeCode.getMinutes()); + assertEquals(0, timeCode.getSeconds()); + assertEquals(0, timeCode.getFrames()); + + VideoTimeCodeConfig timeCodeConfig = timeCode.getConfig(); + // PAL standard 25/1 + assertEquals(25, timeCodeConfig.getNumerator()); + assertEquals(1, timeCodeConfig.getDenominator()); + assertTrue(timeCodeConfig.getFlags().isEmpty()); + } + }, "videotestsrc ! video/x-raw,framerate=25/1 ! timecodestamper ! videoconvert ! appsink name=myappsink"); } @Test @@ -95,22 +94,22 @@ public void testVideoTimeCodeNTSCDrop() { if (Gst.testVersion(1, 14)) { assertTrue("Video should contains timecode meta", buffer.hasMeta(VideoTimeCodeMeta.API)); } - VideoTimeCodeMeta meta = buffer.getMeta(VideoTimeCodeMeta.API); - assertNotNull(meta); - VideoTimeCode timeCode = meta.getTimeCode(); - - //first frame 00:00:00;00 - assertEquals(0, timeCode.getHours()); - assertEquals(0, timeCode.getMinutes()); - assertEquals(0, timeCode.getSeconds()); - assertEquals(0, timeCode.getFrames()); - - VideoTimeCodeConfig timeCodeConfig = timeCode.getConfig(); - // NTSC drop standard 30000/1001 - assertEquals(30000, timeCodeConfig.getNumerator()); - assertEquals(1001, timeCodeConfig.getDenominator()); - assertTrue(timeCodeConfig.getFlags().contains(GST_VIDEO_TIME_CODE_FLAGS_DROP_FRAME)); - + try (VideoTimeCodeMeta meta = buffer.getMeta(VideoTimeCodeMeta.API)) { + assertNotNull(meta); + VideoTimeCode timeCode = meta.getTimeCode(); + + //first frame 00:00:00;00 + assertEquals(0, timeCode.getHours()); + assertEquals(0, timeCode.getMinutes()); + assertEquals(0, timeCode.getSeconds()); + assertEquals(0, timeCode.getFrames()); + + VideoTimeCodeConfig timeCodeConfig = timeCode.getConfig(); + // NTSC drop standard 30000/1001 + assertEquals(30000, timeCodeConfig.getNumerator()); + assertEquals(1001, timeCodeConfig.getDenominator()); + assertTrue(timeCodeConfig.getFlags().contains(GST_VIDEO_TIME_CODE_FLAGS_DROP_FRAME)); + } }, "videotestsrc ! video/x-raw,framerate=30000/1001 ! timecodestamper drop-frame=true ! videoconvert ! appsink name=myappsink"); } @@ -127,22 +126,22 @@ public void testVideoTimeCodeNTSCDropFrame() { if (Gst.testVersion(1, 14)) { assertTrue("Video should contains timecode meta", buffer.hasMeta(VideoTimeCodeMeta.API)); } - VideoTimeCodeMeta meta = buffer.getMeta(VideoTimeCodeMeta.API); - assertNotNull(meta); - VideoTimeCode timeCode = meta.getTimeCode(); - - //first frame 00:00:00;29 - assertEquals(0, timeCode.getHours()); - assertEquals(0, timeCode.getMinutes()); - assertEquals(0, timeCode.getSeconds()); - assertEquals(29, timeCode.getFrames()); - - VideoTimeCodeConfig timeCodeConfig = timeCode.getConfig(); - // NTSC drop standard 30000/1001 - assertEquals(30000, timeCodeConfig.getNumerator()); - assertEquals(1001, timeCodeConfig.getDenominator()); - assertTrue(timeCodeConfig.getFlags().contains(GST_VIDEO_TIME_CODE_FLAGS_DROP_FRAME)); - + try (VideoTimeCodeMeta meta = buffer.getMeta(VideoTimeCodeMeta.API)) { + assertNotNull(meta); + VideoTimeCode timeCode = meta.getTimeCode(); + + //first frame 00:00:00;29 + assertEquals(0, timeCode.getHours()); + assertEquals(0, timeCode.getMinutes()); + assertEquals(0, timeCode.getSeconds()); + assertEquals(29, timeCode.getFrames()); + + VideoTimeCodeConfig timeCodeConfig = timeCode.getConfig(); + // NTSC drop standard 30000/1001 + assertEquals(30000, timeCodeConfig.getNumerator()); + assertEquals(1001, timeCodeConfig.getDenominator()); + assertTrue(timeCodeConfig.getFlags().contains(GST_VIDEO_TIME_CODE_FLAGS_DROP_FRAME)); + } }, "videotestsrc ! video/x-raw,framerate=30000/1001 ! videoconvert ! timecodestamper drop-frame=true ! videoconvert ! appsink name=myappsink", 29); } @@ -156,22 +155,22 @@ public void testVideoTimeCodeNTSCNonDrop() { if (Gst.testVersion(1, 14)) { assertTrue("Video should contains timecode meta", buffer.hasMeta(VideoTimeCodeMeta.API)); } - VideoTimeCodeMeta meta = buffer.getMeta(VideoTimeCodeMeta.API); - assertNotNull(meta); - VideoTimeCode timeCode = meta.getTimeCode(); - - //first frame 00:00:00:00 - assertEquals(0, timeCode.getHours()); - assertEquals(0, timeCode.getMinutes()); - assertEquals(0, timeCode.getSeconds()); - assertEquals(0, timeCode.getFrames()); - - VideoTimeCodeConfig timeCodeConfig = timeCode.getConfig(); - // NTSC drop standard 30/1 - assertEquals(30, timeCodeConfig.getNumerator()); - assertEquals(1, timeCodeConfig.getDenominator()); - assertTrue(timeCodeConfig.getFlags().isEmpty()); - + try (VideoTimeCodeMeta meta = buffer.getMeta(VideoTimeCodeMeta.API)) { + assertNotNull(meta); + VideoTimeCode timeCode = meta.getTimeCode(); + + //first frame 00:00:00:00 + assertEquals(0, timeCode.getHours()); + assertEquals(0, timeCode.getMinutes()); + assertEquals(0, timeCode.getSeconds()); + assertEquals(0, timeCode.getFrames()); + + VideoTimeCodeConfig timeCodeConfig = timeCode.getConfig(); + // NTSC drop standard 30/1 + assertEquals(30, timeCodeConfig.getNumerator()); + assertEquals(1, timeCodeConfig.getDenominator()); + assertTrue(timeCodeConfig.getFlags().isEmpty()); + } }, "videotestsrc ! video/x-raw,framerate=30/1 ! timecodestamper ! videoconvert ! appsink name=myappsink"); } }