From 1b267abf36365cbd3343b6d7451f7ef10a66f2e1 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Mon, 9 Sep 2024 16:03:15 +0200 Subject: [PATCH] LibMedia: Link to avformat as well This allows us to process container formats in future commits. --- .github/actions/setup/action.yml | 4 ++-- Documentation/BuildInstructionsLadybird.md | 6 +++--- Meta/CMake/ffmpeg.cmake | 13 +++++++++++++ Userland/Libraries/LibMedia/CMakeLists.txt | 11 +++++------ 4 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 Meta/CMake/ffmpeg.cmake diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 9a813b139c6..ff3cf777ca9 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -26,8 +26,8 @@ runs: sudo apt-get update sudo apt-get install autoconf autoconf-archive automake build-essential ccache clang-18 clang++-18 cmake curl fonts-liberation2 \ - gcc-13 g++-13 libavcodec-dev libegl1-mesa-dev libgl1-mesa-dev libpulse-dev libssl-dev libstdc++-13-dev lld-18 nasm ninja-build \ - qt6-base-dev qt6-tools-dev-tools tar unzip zip + gcc-13 g++-13 libavcodec-dev libavformat-dev libegl1-mesa-dev libgl1-mesa-dev libpulse-dev libssl-dev libstdc++-13-dev lld-18 \ + nasm ninja-build qt6-base-dev qt6-tools-dev-tools tar unzip zip sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 100 sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 100 diff --git a/Documentation/BuildInstructionsLadybird.md b/Documentation/BuildInstructionsLadybird.md index b8f13d4be79..ca09d824b42 100644 --- a/Documentation/BuildInstructionsLadybird.md +++ b/Documentation/BuildInstructionsLadybird.md @@ -14,7 +14,7 @@ CMake 3.25 or newer must be available in $PATH. ### Debian/Ubuntu: ```bash -sudo apt install autoconf autoconf-archive automake build-essential ccache cmake curl fonts-liberation2 git libavcodec-dev libgl1-mesa-dev nasm ninja-build pkg-config qt6-base-dev qt6-tools-dev-tools qt6-wayland tar unzip zip +sudo apt install autoconf autoconf-archive automake build-essential ccache cmake curl fonts-liberation2 git libavcodec-dev libavformat-dev libgl1-mesa-dev nasm ninja-build pkg-config qt6-base-dev qt6-tools-dev-tools qt6-wayland tar unzip zip ``` #### CMake 3.25 or newer: @@ -83,12 +83,12 @@ sudo pacman -S --needed autoconf-archive automake base-devel ccache cmake curl f ### Fedora or derivatives: ``` -sudo dnf install autoconf-archive automake ccache cmake curl libavcodec-free-devel liberation-sans-fonts libglvnd-devel nasm ninja-build qt6-qtbase-devel qt6-qtmultimedia-devel qt6-qttools-devel qt6-qtwayland-devel tar unzip zip zlib-ng-compat-static +sudo dnf install autoconf-archive automake ccache cmake curl libavcodec-free-devel libavformat-free-devel liberation-sans-fonts libglvnd-devel nasm ninja-build qt6-qtbase-devel qt6-qtmultimedia-devel qt6-qttools-devel qt6-qtwayland-devel tar unzip zip zlib-ng-compat-static ``` ### openSUSE: ``` -sudo zypper install autoconf-archive automake ccache cmake curl ffmpeg-7-libavcodec-devel gcc13 gcc13-c++ liberation-fonts libglvnd-devel nasm ninja qt6-base-devel qt6-multimedia-devel qt6-tools-devel qt6-wayland-devel tar unzip zip +sudo zypper install autoconf-archive automake ccache cmake curl ffmpeg-7-libavcodec-devel ffmpeg-7-libavformat-devel gcc13 gcc13-c++ liberation-fonts libglvnd-devel nasm ninja qt6-base-devel qt6-multimedia-devel qt6-tools-devel qt6-wayland-devel tar unzip zip ``` The build process requires at least python3.7; openSUSE Leap only features Python 3.6 as default, so it is recommendable to install package python311 and create a virtual environment (venv) in this case. diff --git a/Meta/CMake/ffmpeg.cmake b/Meta/CMake/ffmpeg.cmake new file mode 100644 index 00000000000..a813d008d29 --- /dev/null +++ b/Meta/CMake/ffmpeg.cmake @@ -0,0 +1,13 @@ +include_guard() + +find_package(PkgConfig REQUIRED) +pkg_check_modules(AVCODEC IMPORTED_TARGET libavcodec) +pkg_check_modules(AVFORMAT IMPORTED_TARGET libavformat) + +if (AVCODEC_FOUND AND AVFORMAT_FOUND) + set(HAS_FFMPEG ON CACHE BOOL "" FORCE) + add_compile_definitions(USE_FFMPEG=1) + if (AVCODEC_VERSION VERSION_GREATER_EQUAL "59.24.100") + add_compile_definitions(USE_FFMPEG_CH_LAYOUT=1) + endif() +endif() diff --git a/Userland/Libraries/LibMedia/CMakeLists.txt b/Userland/Libraries/LibMedia/CMakeLists.txt index b548b6909a1..148f73abdec 100644 --- a/Userland/Libraries/LibMedia/CMakeLists.txt +++ b/Userland/Libraries/LibMedia/CMakeLists.txt @@ -1,3 +1,5 @@ +include(ffmpeg) + set(SOURCES Audio/GenericTypes.cpp Audio/SampleFormats.cpp @@ -26,7 +28,7 @@ if (HAVE_PULSEAUDIO) ) endif() -if (NOT ANDROID) +if (HAS_FFMPEG) list(APPEND SOURCES FFmpeg/FFmpegVideoDecoder.cpp) else() list(APPEND SOURCES FFmpeg/FFmpegVideoDecoderStub.cpp) @@ -35,11 +37,8 @@ endif() serenity_lib(LibMedia media) target_link_libraries(LibMedia PRIVATE LibCore LibCrypto LibRIFF LibIPC LibGfx LibThreading LibUnicode) -if (NOT ANDROID) - # Third-party - find_package(PkgConfig REQUIRED) - pkg_check_modules(AVCODEC REQUIRED IMPORTED_TARGET libavcodec) - target_link_libraries(LibMedia PRIVATE PkgConfig::AVCODEC) +if (HAS_FFMPEG) + target_link_libraries(LibMedia PRIVATE PkgConfig::AVCODEC PkgConfig::AVFORMAT) endif() if (HAVE_PULSEAUDIO)