dash-mpd-cli 0.2.32

Download media content from a DASH-MPEG or DASH-WebM MPD manifest.
on: [push]

name: build

jobs:
  check:
    name: dash-mpd-cli check/nightly
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
           fetch-depth: 0

      - uses: dtolnay/rust-toolchain@nightly

      - name: Install protobuf compiler
        run: sudo apt-get update && sudo apt-get install protobuf-compiler

      - run: cargo check
      - run: cargo build
      - run: cargo build --no-default-features

      - name: Install ffmpeg and GPAC
        run: sudo apt-get install ffmpeg gpac wget

      - name: Install Bento4 mp4decrypt
        run: |
          wget -q -O /tmp/bento4.zip https://www.bok.net/Bento4/binaries/Bento4-SDK-1-6-0-641.x86_64-unknown-linux.zip
          unzip /tmp/bento4.zip "Bento4-SDK-*/bin/mp4decrypt" -d /tmp
          sudo mv /tmp/Bento4-SDK*/bin/mp4decrypt /usr/local/bin
          mp4decrypt || true

      - name: Install shaka-packager
        run: |
          wget -q -O /tmp/shaka-packager https://github.com/shaka-project/shaka-packager/releases/latest/download/packager-linux-x64
          mv /tmp/shaka-packager /usr/local/bin
          chmod +x /usr/local/bin/shaka-packager

      - name: Install xsltproc
        run: sudo apt install xsltproc

      - run: cargo test --jobs 1 --features sandbox -- --show-output
      - run: cargo doc --no-deps --all-features

  build-macos:
    runs-on: macos-14
    steps:
    - uses: actions/checkout@v6
      with:
         fetch-depth: 0

    - uses: dtolnay/rust-toolchain@stable

    - name: install protobuf compiler
      run: brew install protobuf cmake

    - run: cargo build --jobs 1 --verbose

    # The "|| true" on upgrade is to work around homebrew conflicts between GitHub-installed Python versions
    # and those required by our packages.
    - name: install GPAC/MP4Box
      run: |
        brew update
        brew upgrade || true
        HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install gpac

    - name: install ffmpeg
      run: brew install ffmpeg

    - name: Install Bento4 mp4decrypt
      run: |
        wget -q -O /tmp/bento4.zip https://www.bok.net/Bento4/binaries/Bento4-SDK-1-6-0-641.universal-apple-macosx.zip
        unzip /tmp/bento4.zip "Bento4-SDK-*/bin/mp4decrypt" -d /tmp
        sudo mv /tmp/Bento4-SDK*/bin/mp4decrypt /usr/local/bin
        mp4decrypt || true

    # Shaka packager is not available via homebrew. Alternatively, could use docker
    # google/shaka-packager. Here we are depending on the macos runner being an AMD64 machine.
    - name: Install shaka-packager
      run: |
        wget -q -O /tmp/shaka-packager https://github.com/shaka-project/shaka-packager/releases/latest/download/packager-osx-x64
        mv /tmp/shaka-packager /usr/local/bin
        chmod +x /usr/local/bin/shaka-packager

    - name: install xsltproc
      run: brew install libxslt

    # podman does not start on the macos-14 runners, perhaps because they are running on M1
    # processors that do not support nested virtualization.
    
    # - name: install podman
    #   run: |
    #     brew install podman
    #     podman machine init
    #     podman machine start

    - run: cargo test --jobs 1 -- --show-output
      env:
        DOCKER: "docker"


  build-windows:
    runs-on: windows-latest
    steps:
    - uses: actions/checkout@v6
      with:
         fetch-depth: 0

    - uses: dtolnay/rust-toolchain@stable

    # We need path-type of inherit to include important utility applications such as podman,
    # mp4decrypt, shaka-packager, ffmpeg, xsltproc on the $PATH for our tests. To be more precise,
    # we need in addition to the standard UCRT paths, /c/ProgramData/chocolatey/bin and
    # /c/windows/system32.
    # See https://github.com/msys2/setup-msys2
    - uses: msys2/setup-msys2@v2
      with:
        msystem: UCRT64
        update: true
        install: base-devel autotools mingw-w64-ucrt-x86_64-toolchain mingw-w64-ucrt-x86_64-rust mingw-w64-ucrt-x86_64-gcc
        path-type: inherit

    - name: install protobuf compiler
      run: choco install --yes --limit-output -–no-progress protoc

    - name: install NASM for rustls-tls build
      run: |
         choco install --yes --limit-output -–no-progress nasm
         echo "C:\Program Files\NASM" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

    # The ffmpeg executable is installed at C:\ProgramData\chocolatey\lib\ffmpeg\tools\ffmpeg\bin\ffmpeg.exe
    # A shim is created at C:\ProgramData\chocolatey\bin\ffmpeg.exe.
    - name: install ffmpeg
      run: |
         choco install --yes --limit-output -–no-progress ffmpeg
         echo "C:\ProgramData\chocolatey\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

    # Isn't this fun
    - name: install Bento4/mp4decrypt
      run: |
          Invoke-WebRequest -Uri "https://www.bok.net/Bento4/binaries/Bento4-SDK-1-6-0-641.x86_64-microsoft-win32.zip" -OutFile bento4.zip
          Expand-Archive -Path bento4.zip -DestinationPath .
          Get-ChildItem
          del bento4.zip
          New-Item -ItemType Directory -Force -Path "C:\tools"
          cp Bento4-SDK-1-6-0-641.x86_64-microsoft-win32/bin/mp4decrypt.exe "C:\tools\mp4decrypt.exe"
          Remove-Item -LiteralPath "Bento4-SDK-1-6-0-641.x86_64-microsoft-win32" -Force -Recurse
          echo "C:\tools" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
          Get-ChildItem c:\tools

    - name: Install shaka-packager
      run: |
        Invoke-WebRequest -Uri "https://github.com/shaka-project/shaka-packager/releases/latest/download/packager-win-x64.exe" -OutFile c:\tools\shaka-packager.exe

    - name: install xsltproc
      run: choco install --yes --limit-output -–no-progress xsltproc

    # the ~/ here depends on Windows CI runners using Powershell. We create ~/.ssh to work around a
    # podman bug (https://github.com/containers/podman/issues/24650)
    - name: install podman
      run: |
         mkdir ~/.ssh
         choco install --yes --limit-output -–no-progress podman-cli
         podman machine init
         podman machine start

    - run: cargo build --jobs 1 --verbose
      shell: msys2 {0}

    - run: cargo test --jobs 1 -- --show-output --test-threads=1
      shell: msys2 {0}