Skip to content

Commit

Permalink
LibMedia: Link to avformat as well
Browse files Browse the repository at this point in the history
This allows us to process container formats in future commits.
  • Loading branch information
gmta committed Sep 11, 2024
1 parent 7c7d0c8 commit 7981ba4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Documentation/BuildInstructionsLadybird.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.

Expand Down
13 changes: 13 additions & 0 deletions Meta/CMake/ffmpeg.cmake
Original file line number Diff line number Diff line change
@@ -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()
11 changes: 5 additions & 6 deletions Userland/Libraries/LibMedia/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include(ffmpeg)

set(SOURCES
Audio/GenericTypes.cpp
Audio/SampleFormats.cpp
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 7981ba4

Please sign in to comment.