1B Music 0.1.4 (com.onebytesystems.music, versionCode 5) — corresponding source for the LGPL components
=======================================================================================================

Published by 1Byte Systems at https://1bytesystems.com/source/ to comply with the
GNU Lesser General Public License, version 2.1 or later (LGPL-2.1-or-later). Full text: docs/licenses/LGPL-2.1.txt.

Compared with 0.1.3, FFmpeg, the build script, the JNI code and the Kotlin ports are unchanged; only the version
number (androidApp/build.gradle.kts) and the notice docs/licenses/ffmpeg.txt changed.

1. FFmpeg 9.0.2 (libavformat, libavcodec, libavutil, libswresample)
--------------------------------------------------------------------
1B Music uses FFmpeg only to decode audio formats that Android does not decode by itself (APE, WavPack, TTA,
Musepack, WMA, DSD, AIFF/AIFC, CAF, Speex, and Ogg Opus/Vorbis for exact gapless playback).

* Source: the ORIGINAL, UNMODIFIED release tarball ffmpeg-9.0.2.tar.xz, published next to this archive
  (also at https://ffmpeg.org/releases/ffmpeg-9.0.2.tar.xz).
  SHA-256 8c3850283eb25fa026482078a04051e0be17347b09ef81a0849bec15a96e002e
  OpenPGP signature: ffmpeg-9.0.2.tar.xz.asc (FFmpeg release signing key FCF9 86EA 15E6 E293 A564 4F10 B432 2F04 D676 58D8).
* Patches: none. 1B Music uses the release exactly as published.
* Build script and configuration: tools/build-ffmpeg-android.sh (the exact script used for 0.1.4). It downloads the
  tarball, checks its SHA-256 and runs ./configure for arm64-v8a, armeabi-v7a and x86_64 (Android API 30, NDK
  30.0.16248370) with --disable-everything plus the listed demuxers/decoders/parsers, --enable-shared, LGPL only
  (no --enable-gpl, no --enable-nonfree; the script fails if config.h says otherwise).
* The libraries ship as SEPARATE SHARED LIBRARIES inside the app: lib/<abi>/libavformat.so, libavcodec.so,
  libavutil.so and libswresample.so.
* Our own code that uses FFmpeg: androidApp/src/main/cpp/onebaudio.c (JNI decoder) and CMakeLists.txt, which build
  lib/<abi>/libonebaudio.so and link it DYNAMICALLY against the four FFmpeg libraries. The Kotlin side of the JNI
  bridge is androidApp/src/main/kotlin/.../playback/ffmpeg/NativeAudio.kt. androidApp/build.gradle.kts shows how
  Gradle runs the script (task ffmpegPrebuilt) and passes FFMPEG_ROOT to CMake.

How to rebuild FFmpeg and use your own build
  1. Install the Android NDK 30.0.16248370 (sdkmanager --install "ndk;30.0.16248370").
  2. Put the script in an empty folder as tools/build-ffmpeg-android.sh and run it:
        ANDROID_HOME=~/Android/Sdk tools/build-ffmpeg-android.sh
     (it downloads FFmpeg to build/ffmpeg-src/; to use a modified FFmpeg, unpack your sources into
     build/ffmpeg-src/ffmpeg-9.0.2/ before running it, or change the configure line).
     The .so files end up in ~/.cache/1bmusic-ffmpeg/9.0.2-<hash>/<abi>/lib/.
  3. Replace the four lib*.so files of the matching ABI in the APK (lib/<abi>/; an installation from Google Play
     is split, and they are in split_config.<abi>.apk), then zipalign and sign all the APKs of the app with your
     own key (apksigner) and install them together (adb install-multiple). Android will not install it over the Play version (different signature):
     uninstall 1B Music first. Your build must keep the same public API/ABI (FFmpeg 9.0.x, same library names
     without version suffix — the script uses --target-os=android for that).
  4. libonebaudio.so can be rebuilt from onebaudio.c with CMakeLists.txt (-DFFMPEG_ROOT=<your build>) if you
     change FFmpeg's ABI.

2. Chromaprint and libswresample (algorithms ported to Kotlin)
--------------------------------------------------------------
To compute AcoustID-compatible acoustic fingerprints, 1B Music contains a Kotlin port of the Chromaprint 1.6.0
algorithm (https://github.com/acoustid/chromaprint) and a Kotlin re-implementation of the libswresample resampler
in the mode used by fpcalc. These files are derived from LGPL-2.1-or-later code and are provided under the same
license:
  audio/src/commonMain/kotlin/com/onebytesystems/music/audio/fingerprint/ChromaprintEngine.kt
  audio/src/commonMain/kotlin/com/onebytesystems/music/audio/fingerprint/ChromaprintCodec.kt
  audio/src/commonMain/kotlin/com/onebytesystems/music/audio/fingerprint/ChromaprintFingerprinter.kt
  audio/src/commonMain/kotlin/com/onebytesystems/music/audio/fingerprint/SwrResampler.kt
They are compiled into the app's Java bytecode (classes.dex); the app keeps working without network access to
any fingerprint service.

Notices shipped inside the app: docs/licenses/ffmpeg.txt (= assets/licenses/ffmpeg.txt) and LGPL-2.1.txt, shown
in Settings → About → Licenses.

Questions: 1bytesystems@gmail.com
FFmpeg is a trademark of Fabrice Bellard, originator of the FFmpeg project.
