diff --git a/.github/workflows/conan.yml b/.github/workflows/conan.yml new file mode 100644 index 00000000..b5acb73a --- /dev/null +++ b/.github/workflows/conan.yml @@ -0,0 +1,104 @@ +name: Cross-platform build using conan + +on: + push: + branches: [ "**" ] + pull_request: + branches: [ "master" ] + schedule: + - cron: '34 5 * * 5' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + CMake: + runs-on: ${{ matrix.platform }} + strategy: + fail-fast: false + matrix: + platform: [ ubuntu-latest, macos-latest, windows-latest ] + ffmpeg: [ 8.0.1, 7.1.3, 6.1.1 ] + + steps: + - name: Restart from scratch every Friday + run: gh cache delete --all + shell: bash + if: github.event_name == 'schedule' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - uses: conan-io/setup-conan@v1 + - uses: actions/checkout@v6 + with: + submodules: true + + - name: Get conan home + shell: bash + id: conan_home + run: echo path=`conan config home` >> $GITHUB_OUTPUT + - name: Cache conan artifacts + id: conan-artifacts + uses: actions/cache@v5 + with: + path: ${{ steps.conan_home.outputs.path }} + key: conan-${{ matrix.platform }}-${{ matrix.ffmpeg}}-cmake + + - run: conan profile detect --force + - run: conan install tests/conan -pr:a=tests/conan/conan.profile -b=missing -of build -o ffmpeg=${{ matrix.ffmpeg }} -o build=CMake + + - name: Generate CMake build (Windows) + shell: cmd + run: | + call conanbuild.bat + call conanrun.bat + cmake -DCMAKE_BUILD_TYPE=Release .. + working-directory: ${{ github.workspace }}/build + if: runner.os == 'Windows' + env: + PKG_CONFIG_EXECUTABLE: pkgconf.exe + PKG_CONFIG_PATH: ${{ github.workspace }}/build + + - name: Generate CMake build (Linux/macOS) + shell: bash + run: | + source conanbuild.sh + source conanrun.sh + cmake -DCMAKE_BUILD_TYPE=Release .. + working-directory: ${{ github.workspace }}/build + if: runner.os != 'Windows' + env: + PKG_CONFIG_PATH: ${{ github.workspace }}/build + + - name: Build (Windows) + shell: cmd + run: | + call conanbuild.bat + call conanrun.bat + cmake --build . + if: runner.os == 'Windows' + working-directory: ${{ github.workspace }}/build + + - name: Build (Linux/macOS) + run: | + source conanbuild.sh + source conanrun.sh + cmake --build . + if: runner.os != 'Windows' + working-directory: ${{ github.workspace }}/build + + - name: Run the unit tests (Windows) + shell: cmd + run: | + call conanrun.bat + ctest --output-on-failure + if: runner.os == 'Windows' + working-directory: ${{ github.workspace }}/build + + - name: Run the unit tests (Linux/macOS) + run: | + source conanrun.sh + ctest --output-on-failure + if: runner.os != 'Windows' + working-directory: ${{ github.workspace }}/build diff --git a/example/api2-samples/CMakeLists.txt b/example/api2-samples/CMakeLists.txt index a4ec3a05..c50220ec 100644 --- a/example/api2-samples/CMakeLists.txt +++ b/example/api2-samples/CMakeLists.txt @@ -23,11 +23,14 @@ set(TARGETS api2-dict-basic api2-timestamp api2-demux-seek - api2-remux api2-hw-encode api2-decode-raw-h264 ) +if(NOT WIN32) + list(APPEND TARGETS api2-remux) +endif() + if (AV_DISABLE_AVFORMAT) list(REMOVE_ITEM TARGETS api2-decode diff --git a/example/api2-samples/api2-decode-audio.cpp b/example/api2-samples/api2-decode-audio.cpp index bf7201b4..759eecd3 100644 --- a/example/api2-samples/api2-decode-audio.cpp +++ b/example/api2-samples/api2-decode-audio.cpp @@ -31,7 +31,7 @@ int main(int argc, char **argv) string uri {argv[1]}; - ssize_t audioStream = -1; + long audioStream = -1; AudioDecoderContext adec; Stream ast; error_code ec; diff --git a/example/api2-samples/api2-decode-encode-audio.cpp b/example/api2-samples/api2-decode-encode-audio.cpp index 0da58569..39040a26 100644 --- a/example/api2-samples/api2-decode-encode-audio.cpp +++ b/example/api2-samples/api2-decode-encode-audio.cpp @@ -32,7 +32,7 @@ int main(int argc, char **argv) string uri (argv[1]); string out (argv[2]); - ssize_t audioStream = -1; + long audioStream = -1; AudioDecoderContext adec; Stream ast; error_code ec; diff --git a/example/api2-samples/api2-decode-encode-video.cpp b/example/api2-samples/api2-decode-encode-video.cpp index cd2c220b..52529667 100644 --- a/example/api2-samples/api2-decode-encode-video.cpp +++ b/example/api2-samples/api2-decode-encode-video.cpp @@ -38,7 +38,7 @@ int main(int argc, char **argv) // INPUT // FormatContext ictx; - ssize_t videoStream = -1; + long videoStream = -1; VideoDecoderContext vdec; Stream vst; diff --git a/example/api2-samples/api2-decode-filter-encode.cpp b/example/api2-samples/api2-decode-filter-encode.cpp index 9f53ec75..85b9d9fd 100644 --- a/example/api2-samples/api2-decode-filter-encode.cpp +++ b/example/api2-samples/api2-decode-filter-encode.cpp @@ -39,7 +39,7 @@ int main(int argc, char **argv) string uri{argv[1]}; string out{argv[2]}; - ssize_t videoStream = -1; + long videoStream = -1; VideoDecoderContext vdec; Stream vst; error_code ec; diff --git a/example/api2-samples/api2-decode-overlay-encode.cpp b/example/api2-samples/api2-decode-overlay-encode.cpp index 170f9b1d..b6ddbf44 100644 --- a/example/api2-samples/api2-decode-overlay-encode.cpp +++ b/example/api2-samples/api2-decode-overlay-encode.cpp @@ -42,7 +42,7 @@ int main(int argc, char **argv) // INPUT // FormatContext ictx; - ssize_t videoStream = -1; + long videoStream = -1; VideoDecoderContext vdec; Stream vst; @@ -91,7 +91,7 @@ int main(int argc, char **argv) // STATIC IMAGE (more or less identical to INPUT) // FormatContext static_image_ctx; - ssize_t imageStream = -1; + long imageStream = -1; VideoDecoderContext static_image_dec; Stream image_st; diff --git a/example/api2-samples/api2-decode-rasample-audio.cpp b/example/api2-samples/api2-decode-rasample-audio.cpp index a83e2302..a87ec597 100644 --- a/example/api2-samples/api2-decode-rasample-audio.cpp +++ b/example/api2-samples/api2-decode-rasample-audio.cpp @@ -31,7 +31,7 @@ int main(int argc, char **argv) string uri {argv[1]}; - ssize_t audioStream = -1; + long audioStream = -1; AudioDecoderContext adec; Stream ast; error_code ec; diff --git a/example/api2-samples/api2-decode.cpp b/example/api2-samples/api2-decode.cpp index 1c126cd5..0ecb75a1 100644 --- a/example/api2-samples/api2-decode.cpp +++ b/example/api2-samples/api2-decode.cpp @@ -33,7 +33,7 @@ int main(int argc, char **argv) string uri {argv[1]}; - ssize_t videoStream = -1; + long videoStream = -1; VideoDecoderContext vdec; Stream vst; error_code ec; diff --git a/example/api2-samples/api2-dict-basic.cpp b/example/api2-samples/api2-dict-basic.cpp index 8a2074dd..874032b1 100644 --- a/example/api2-samples/api2-dict-basic.cpp +++ b/example/api2-samples/api2-dict-basic.cpp @@ -1,4 +1,5 @@ #include +#include #include "avcpp/av.h" #include "avcpp/dictionary.h" diff --git a/example/api2-samples/api2-hw-encode.cpp b/example/api2-samples/api2-hw-encode.cpp index 8b1cd3ae..1fe67d66 100644 --- a/example/api2-samples/api2-hw-encode.cpp +++ b/example/api2-samples/api2-hw-encode.cpp @@ -86,7 +86,7 @@ int main(int argc, char **argv) { // INPUT // FormatContext ictx; - ssize_t videoStream = -1; + long videoStream = -1; // VideoDecoderContext vdec; Stream vst; diff --git a/example/api2-samples/api2-scale-video.cpp b/example/api2-samples/api2-scale-video.cpp index c75a96e9..6c6248dd 100644 --- a/example/api2-samples/api2-scale-video.cpp +++ b/example/api2-samples/api2-scale-video.cpp @@ -41,7 +41,7 @@ int main(int argc, char **argv) // INPUT // FormatContext ictx; - ssize_t videoStream = -1; + long videoStream = -1; VideoDecoderContext vdec; Stream vst; diff --git a/tests/FormatCustomIO_test.cpp b/tests/FormatCustomIO_test.cpp index 0a6fec98..a0c45bd0 100644 --- a/tests/FormatCustomIO_test.cpp +++ b/tests/FormatCustomIO_test.cpp @@ -95,7 +95,7 @@ struct TestBufferIo : public av::CustomIO return _buffer.size(); } - ssize_t cur = -1; + long cur = -1; if (whence == SEEK_CUR) { cur = std::distance(_buffer.begin(), _pos); @@ -333,4 +333,4 @@ TEST_CASE("Format Custom IO checks", "[FormatCustomIo]") } } -#endif \ No newline at end of file +#endif diff --git a/tests/conan/conan.profile b/tests/conan/conan.profile new file mode 100644 index 00000000..3b7a9980 --- /dev/null +++ b/tests/conan/conan.profile @@ -0,0 +1,8 @@ +include(default) + +[conf] +tools.system.package_manager:mode=install +tools.system.package_manager:sudo=true + +[settings] +compiler.cppstd=20 diff --git a/tests/conan/conanfile.py b/tests/conan/conanfile.py new file mode 100644 index 00000000..168f5fbb --- /dev/null +++ b/tests/conan/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile + +required_conan_version = ">=2.0" + +class Avcpp(ConanFile): + settings = "os", "arch", "compiler", "build_type" + options = { + "ffmpeg": ["8.0.1", "7.1.3", "6.1.1"], + "build": [ "CMake", "meson" ] + } + default_options = { + "ffmpeg": "8.0.1", + "build": "CMake" + } + generators = 'PkgConfigDeps' + + def requirements(self): + self.requires(f"ffmpeg/{self.options.ffmpeg}", transitive_headers=True) + if self.settings.os == 'Windows': + self.tool_requires("pkgconf/2.5.1") + + def configure(self): + self.options["ffmpeg"].fPIC = True + self.options["ffmpeg"].shared = True + self.options["ffmpeg"].postproc = True + \ No newline at end of file