Skip to content

Commit

Permalink
opus
Browse files Browse the repository at this point in the history
  • Loading branch information
louist103 committed Dec 7, 2024
1 parent 73a1297 commit cfa2a5d
Show file tree
Hide file tree
Showing 8 changed files with 532 additions and 52 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@ jobs:
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y libsdl2-dev libzip-dev libogg-dev libvorbis-dev libtinyxml2-dev zipcmp zipmerge ziptool
sudo apt install -y libsdl2-dev libzip-dev libogg-dev libvorbis-dev libopus-dev libopusfile-dev libopusenc-dev opus-tools libtinyxml2-dev zipcmp zipmerge ziptool
- name: Build libopusenc
run: |
git clone https://gitlab.xiph.org/xiph/libopusenc.git
cd libopusenc
./autogen.sh
./configure
make -j 10
sudo make install
sudo ldconfig
- name: Build
run: |
cmake -S. -Bbuild-rel -DCMAKE_BUILD_TYPE:STRING=Release
Expand All @@ -38,7 +47,16 @@ jobs:
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y libsdl2-dev libzip-dev libogg-dev libvorbis-dev libtinyxml2-dev zipcmp zipmerge ziptool
sudo apt install -y libsdl2-dev libzip-dev libogg-dev libvorbis-dev libopus-dev libopusfile-dev opus-tools libtinyxml2-dev zipcmp zipmerge ziptool
- name: Build libopusenc
run: |
git clone https://gitlab.xiph.org/xiph/libopusenc.git
cd libopusenc
./autogen.sh
./configure
make -j 10
sudo make install
sudo ldconfig
- name: Build
run: |
cmake -S. -Bbuild-rel -DCMAKE_BUILD_TYPE:STRING=Release
Expand Down
61 changes: 61 additions & 0 deletions CMake/FindOgg.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# - Find ogg
# Find the native ogg includes and libraries
#
# OGG_INCLUDE_DIRS - where to find ogg.h, etc.
# OGG_LIBRARIES - List of libraries when using ogg.
# OGG_FOUND - True if ogg found.

if (OGG_INCLUDE_DIR)
# Already in cache, be silent
set(OGG_FIND_QUIETLY TRUE)
endif ()

find_package (PkgConfig QUIET)
pkg_check_modules (PC_OGG QUIET ogg>=1.3.0)

set (OGG_VERSION ${PC_OGG_VERSION})

find_path (OGG_INCLUDE_DIR ogg/ogg.h
HINTS
${PC_OGG_INCLUDEDIR}
${PC_OGG_INCLUDE_DIRS}
${OGG_ROOT}
)
# MSVC built ogg may be named ogg_static.
# The provided project files name the library with the lib prefix.
find_library (OGG_LIBRARY
NAMES
ogg
ogg_static
libogg
libogg_static
HINTS
${PC_OGG_LIBDIR}
${PC_OGG_LIBRARY_DIRS}
${OGG_ROOT}
)
# Handle the QUIETLY and REQUIRED arguments and set OGG_FOUND
# to TRUE if all listed variables are TRUE.
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (Ogg
REQUIRED_VARS
OGG_LIBRARY
OGG_INCLUDE_DIR
VERSION_VAR
OGG_VERSION
)

if (OGG_FOUND)
set (OGG_LIBRARIES ${OGG_LIBRARY})
set (OGG_INCLUDE_DIRS ${OGG_INCLUDE_DIR})

if(NOT TARGET Ogg::ogg)
add_library(Ogg::ogg UNKNOWN IMPORTED)
set_target_properties(Ogg::ogg PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OGG_INCLUDE_DIRS}"
IMPORTED_LOCATION "${OGG_LIBRARIES}"
)
endif ()
endif ()

mark_as_advanced (OGG_INCLUDE_DIR OGG_LIBRARY)
44 changes: 44 additions & 0 deletions CMake/FindOpus.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# - FindOpus.cmake
# Find the native opus includes and libraries
#
# OPUS_INCLUDE_DIRS - where to find opus/opus.h, etc.
# OPUS_LIBRARIES - List of libraries when using libopus(file).
# OPUS_FOUND - True if libopus found.

if(OPUS_INCLUDE_DIR AND OPUS_LIBRARY AND OPUSFILE_LIBRARY)
# Already in cache, be silent
set(OPUS_FIND_QUIETLY TRUE)
endif(OPUS_INCLUDE_DIR AND OPUS_LIBRARY AND OPUSFILE_LIBRARY)

find_path(OPUS_INCLUDE_DIR
NAMES opusfile.h
PATH_SUFFIXES opus
)

# MSVC built opus may be named opus_static
# The provided project files name the library with the lib prefix.
find_library(OPUS_LIBRARY
NAMES opus opus_static libopus libopus_static
)
find_library(OPUSFILE_LIBRARY
NAMES opusfile opusfile_static libopusfile libopusfile_static
)

# Handle the QUIETLY and REQUIRED arguments and set OPUS_FOUND
# to TRUE if all listed variables are TRUE.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Opus DEFAULT_MSG
OPUSFILE_LIBRARY OPUS_LIBRARY OPUS_INCLUDE_DIR
)

if(OPUS_FOUND)
set(OPUS_LIBRARIES ${OPUSFILE_LIBRARY} ${OPUS_LIBRARY})
set(OPUS_INCLUDE_DIRS ${OPUS_INCLUDE_DIR})
if(NOT TARGET Opus::opus)
add_library(Opus::opus UNKNOWN IMPORTED)
set_target_properties(Opus::opus PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OPUS_INCLUDE_DIRS}"
IMPORTED_LOCATION "${OPUS_LIBRARIES}"
)
endif()
endif(OPUS_FOUND)
51 changes: 51 additions & 0 deletions CMake/FindOpusenc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# FindOpusenc.cmake
# This module locates the opusenc library and its headers.
# It defines the following variables:
# - Opusenc_FOUND: Boolean indicating if opusenc was found
# - Opusenc_INCLUDE_DIRS: Include directories for opusenc
# - Opusenc_LIBRARIES: Libraries to link against opusenc
# - Opusenc_VERSION: Version of the found opusenc library (optional)

# Locate the opusenc header
find_path(Opusenc_INCLUDE_DIR
NAMES opusenc.h
HINTS
${CMAKE_PREFIX_PATH}
PATH_SUFFIXES
include
opus
)

# Locate the opusenc library
find_library(Opusenc_LIBRARY
NAMES opusenc
HINTS
${CMAKE_PREFIX_PATH}
PATH_SUFFIXES
lib
)

# Check if both the library and headers were found
if (Opusenc_INCLUDE_DIR AND Opusenc_LIBRARY)
set(Opusenc_FOUND TRUE)
else ()
set(Opusenc_FOUND FALSE)
endif ()

# Provide include directories and libraries if found
if (Opusenc_FOUND)
set(Opusenc_INCLUDE_DIRS ${Opusenc_INCLUDE_DIR})
set(Opusenc_LIBRARIES ${Opusenc_LIBRARY})
if(NOT TARGET Opus::opusenc)
add_library(Opus::opusenc UNKNOWN IMPORTED)
set_target_properties(Opus::opusenc PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Opusenc_INCLUDE_DIRS}"
IMPORTED_LOCATION "${Opusenc_LIBRARIES}"
)
endif()
# Optional: Retrieve library version
set(Opusenc_VERSION "Unknown") # Adjust if version detection is needed
endif ()

# Mark variables as advanced to reduce clutter
mark_as_advanced(Opusenc_INCLUDE_DIR Opusenc_LIBRARY)
Loading

0 comments on commit cfa2a5d

Please sign in to comment.