libffmpeg-sf (FFmpeg 7.1.5) - complete corresponding source
=================================================================

This is the complete corresponding source of libffmpeg-sf.so, the FFmpeg library in the StreamFusion
Android TV app (lib/<abi>/libffmpeg-sf.so in the APK, for arm64-v8a, armeabi-v7a, x86 and x86_64). The app
uses it to decode a background copy of the audio for speech analysis (subtitle sync) and, on devices that can
neither decode an audio track themselves nor pass it through to a receiver, to play that track.

libffmpeg-sf.so is FFmpeg 7.1.5 (libavcodec, libswresample and libavutil), unmodified, under the GNU
Lesser General Public License, version 2.1 or (at your option) any later version: see COPYING.LGPLv2.1
and FFMPEG-LICENSE.md. It was configured without --enable-gpl, --enable-version3 and --enable-nonfree;
FFmpeg's configure reported "License: LGPL version 2.1 or later". Only FFmpeg's configure options and the
link step were chosen by us: no FFmpeg source file was changed.

Contents
--------
  ffmpeg-7.1.5.tar.xz
      The FFmpeg release exactly as published at https://ffmpeg.org/releases/ffmpeg-7.1.5.tar.xz
  ffmpeg-7.1.5.tar.xz.asc
      Its signature by the FFmpeg release signing key.
  tools/nativeaudio/build_ffmpeg.sh
      The script that configures, builds, links and checks the library.
  tools/nativeaudio/ffmpeg-sf.map
      The export list: the FFmpeg functions the app calls.
  tools/nativeaudio/ffmpeg-release-key.asc
      The FFmpeg release signing key, fingerprint FCF9 86EA 15E6 E293 A564 4F10 B432 2F04 D676 58D8.
  nativeaudio/prebuilt/BUILDINFO.txt
      The record of the shipped build: tool versions, the exact configure and link command lines, and
      the size and sha256 of the library for every ABI.
  COPYING.LGPLv2.1, FFMPEG-LICENSE.md
      The licence texts.
  SHA256SUMS
      Checksums of all of the above.

1. Check it
-----------
    sha256sum -c SHA256SUMS
    gpg --import tools/nativeaudio/ffmpeg-release-key.asc
    gpg --verify ffmpeg-7.1.5.tar.xz.asc ffmpeg-7.1.5.tar.xz

  The tarball's sha256 is de668509caf9e35e3cd162473441fdb29538c6d96ed080292b3cf9e6fc5d558f.

2. Build the library
--------------------
  Needs the Android NDK r27c (27.2.12479018; Android SDK manager package "ndk;27.2.12479018"),
  bash, make, tar, xz, nasm, gpg, sha256sum and a host C compiler (FFmpeg's configure wants one). Linux
  and macOS work as they are; on Windows use MSYS2 with the packages make diffutils pkgconf nasm gnupg tar
  xz gcc. From this directory:

    ANDROID_NDK_HOME=/path/to/ndk/27.2.12479018 bash tools/nativeaudio/build_ffmpeg.sh

  The script takes the tarball from this directory (nothing is downloaded), checks its sha256 and its
  signature, refuses any licence other than "LGPL version 2.1 or later", and writes
  nativeaudio/prebuilt/<abi>/libffmpeg-sf.so plus a new BUILDINFO.txt. ABIS=arm64-v8a builds one ABI,
  JOBS=8 sets the parallel jobs.

  On the same kind of host as the shipped build (BUILDINFO.txt, "Host:", here: MSYS x86_64) the libraries
  come out bit-identical to the shipped ones: compare their sha256. FFmpeg compiles its configure line
  into the library, and that line names the compiler as the host calls it (clang.exe on Windows), so a
  build on another kind of host is functionally the same with a different checksum.

3. Build a modified library
---------------------------
  Unpack the tarball, change FFmpeg, and pack the tree again as ffmpeg-7.1.5/ into
  ffmpeg-7.1.5.tar.xz in this directory (or point SF_FFMPEG_TARBALL at it). Then:

    SF_MODIFIED_SOURCE=1 ANDROID_NDK_HOME=/path/to/ndk/27.2.12479018 bash tools/nativeaudio/build_ffmpeg.sh

  That skips the checks against the original release and records the modified source in BUILDINFO.txt.
  For the app to use it, the library must keep the name libffmpeg-sf.so and export the functions listed in
  tools/nativeaudio/ffmpeg-sf.map with the interface of FFmpeg 7.1.5 (libavcodec 61, libavutil
  59, libswresample 5); the script checks the export list.

4. Use it with the app
----------------------
  The app loads libffmpeg-sf.so at run time as a separate shared library, so you can replace it in your
  copy of the app: put your libffmpeg-sf.so into the APK at lib/<abi>/ in place of the original (stored
  uncompressed, like the original entry), align the APK with zipalign from the Android SDK build tools
  (-P 16 keeps native libraries on 16 KB pages), sign it with your own key (apksigner), uninstall the
  original app (Android does not update an app across different signatures) and install yours. The app's
  licence permits this and reverse engineering to debug such a modification.

Questions about this source, or a copy on a physical medium: see the written offer in the NOTICE that
comes with the app (assets/licenses/NOTICE.txt in the APK).
