From aaa21a4b328d53fea1c9e121004ae6c622595862 Mon Sep 17 00:00:00 2001 From: Dario Pellegrino Date: Wed, 20 Aug 2025 15:47:24 +0200 Subject: [PATCH 1/8] Add first ci with some static analysis tools Signed-off-by: Dario Pellegrino --- .github/workflows/static-analysis.yml | 56 ++++++++++++++++++ Dockerfile.ci | 81 +++++++++++++++++++++++++++ README.md | 2 + 3 files changed, 139 insertions(+) create mode 100644 .github/workflows/static-analysis.yml create mode 100644 Dockerfile.ci diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 0000000..5e7d31e --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -0,0 +1,56 @@ +name: Static Analysis + +on: + push: + branches: [ main, develop ] + pull_request: + branches: [ main, develop ] + workflow_dispatch: + +jobs: + analyze: + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Set up Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build SDK image (cached) + uses: docker/build-push-action@v6 + with: + context: . + file: Dockerfile.ci + tags: freeswitch-sdk:ci + load: true + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Run analysis inside container + uses: addnab/docker-run-action@v3 + with: + image: freeswitch-sdk:ci + options: -v ${{ github.workspace }}:/work + run: | + set -eux + cd /work + cmake -S . -B build \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DCMAKE_C_COMPILER=clang \ + -DCMAKE_CXX_COMPILER=clang++ \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + + scan-build --status-bugs cmake --build build -j"$(nproc)" + + clang-tidy -p build $(git ls-files '*.c' '*.cc' '*.cpp' '*.cxx') \ + --warnings-as-errors='' || true + + cppcheck --enable=all --inconclusive --std=c++17 --force \ + --project=build/compile_commands.json \ + --suppress=missingIncludeSystem \ + -i build . 2> cppcheck.log || true diff --git a/Dockerfile.ci b/Dockerfile.ci new file mode 100644 index 0000000..58c18f4 --- /dev/null +++ b/Dockerfile.ci @@ -0,0 +1,81 @@ +# syntax=docker/dockerfile:1.7 + +############################ +# Stage 1: Build dependencies + FreeSWITCH +############################ +FROM debian:12 AS builder + +ENV DEBIAN_FRONTEND=noninteractive + + +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates git curl wget \ + build-essential cmake automake autoconf libtool libtool-bin libltdl-dev pkg-config \ + libssl-dev zlib1g-dev libdb-dev unixodbc-dev libncurses5-dev libexpat1-dev \ + libgdbm-dev bison erlang-dev libtpl-dev libtiff5-dev uuid-dev \ + libpcre3-dev libpcre2-dev libedit-dev libsqlite3-dev libcurl4-openssl-dev nasm \ + libogg-dev libspeex-dev libspeexdsp-dev libldns-dev python3-dev \ + libavformat-dev libswscale-dev libswresample-dev \ + liblua5.2-dev libopus-dev libpq-dev \ + libsndfile1-dev libflac-dev libvorbis-dev \ + && rm -rf /var/lib/apt/lists/* + + +WORKDIR /src + +RUN git clone https://github.com/signalwire/libks && \ + git clone https://github.com/freeswitch/sofia-sip && \ + git clone https://github.com/freeswitch/spandsp && \ + git clone https://github.com/signalwire/signalwire-c && \ + git clone https://github.com/signalwire/freeswitch + +# libks +WORKDIR /src/libks +RUN cmake . -DCMAKE_INSTALL_PREFIX=/usr -DWITH_LIBBACKTRACE=1 && \ + make -j"$(nproc)" && make install + +# sofia-sip +WORKDIR /src/sofia-sip +RUN ./bootstrap.sh && \ + ./configure --with-pic --with-glib=no --without-doxygen --disable-stun --prefix=/usr && \ + make -j"$(nproc)" && make install + +# spandsp +WORKDIR /src/spandsp +RUN ./bootstrap.sh && \ + ./configure --with-pic --prefix=/usr && \ + make -j"$(nproc)" && make install + +# signalwire-c +WORKDIR /src/signalwire-c +RUN PKG_CONFIG_PATH=/usr/lib/pkgconfig cmake . -DCMAKE_INSTALL_PREFIX=/usr && \ + make -j"$(nproc)" && make install + +# FreeSWITCH SDK +WORKDIR /src/freeswitch +RUN ./bootstrap.sh -j && \ + ./configure --prefix=/usr && \ + make -j"$(nproc)" && make install + +############################ +# Stage 2: Slim SDK image (no FreeSWITCH runtime) +############################ +FROM debian:12 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + clang clang-tidy clang-tools \ + cppcheck cmake pkg-config ccache \ + libssl-dev zlib1g-dev \ + libspeexdsp-dev libspandsp-dev \ + git curl wget \ + && rm -rf /var/lib/apt/lists/* + +# Copy only SDK bits +COPY --from=builder /usr/include/freeswitch/ /usr/include/freeswitch/ +COPY --from=builder /usr/lib/pkgconfig/freeswitch.pc /usr/lib/pkgconfig/ +COPY --from=builder /usr/lib/libfreeswitch.so* /usr/lib/ + +WORKDIR /work diff --git a/README.md b/README.md index 9d033f4..a27726c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # mod_openai_audio_stream +![Static Analysis](https://github.com/dariopellegrino00/mod_openai_audio_stream/actions/workflows/static-analysis.yml/badge.svg) + A fork of [mod_audio_stream](https://github.com/amigniter/mod_audio_stream) specifically designed for streaming audio to OpenAI's realtime API and playing the responses back to the user via FreeSWITCH and WebSocket. **mod_openai_audio_stream** is a FreeSWITCH module that streams L16 audio from a channel to an OpenAI realtime websocket endpoint. The stream is adherent to OpenAI's Realtime API specification and allows for real-time audio playback directly in the channel. From 5d3fa25868aeb7c3344d74ca09aa010509908798 Mon Sep 17 00:00:00 2001 From: Dario Pellegrino Date: Wed, 20 Aug 2025 17:09:39 +0200 Subject: [PATCH 2/8] Fix build and static checks Signed-off-by: Dario Pellegrino --- .github/workflows/{static-analysis.yml => checks.yml} | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{static-analysis.yml => checks.yml} (98%) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/checks.yml similarity index 98% rename from .github/workflows/static-analysis.yml rename to .github/workflows/checks.yml index 5e7d31e..f87617e 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/checks.yml @@ -1,4 +1,4 @@ -name: Static Analysis +name: Build & Static Checks on: push: diff --git a/README.md b/README.md index a27726c..35f1792 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # mod_openai_audio_stream -![Static Analysis](https://github.com/dariopellegrino00/mod_openai_audio_stream/actions/workflows/static-analysis.yml/badge.svg) +![Build & Static Code Checks](https://github.com/dariopellegrino00/mod_openai_audio_stream/actions/workflows/checks.yml/badge.svg) A fork of [mod_audio_stream](https://github.com/amigniter/mod_audio_stream) specifically designed for streaming audio to OpenAI's realtime API and playing the responses back to the user via FreeSWITCH and WebSocket. **mod_openai_audio_stream** is a FreeSWITCH module that streams L16 audio from a channel to an OpenAI realtime websocket endpoint. The stream is adherent to OpenAI's Realtime API specification and allows for real-time audio playback directly in the channel. From f489ad6ea85492dc07e871587cfda21c807b3ae3 Mon Sep 17 00:00:00 2001 From: Dario Pellegrino Date: Wed, 20 Aug 2025 17:35:07 +0200 Subject: [PATCH 3/8] Update README Signed-off-by: Dario Pellegrino --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 35f1792..294ad99 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,12 @@ # mod_openai_audio_stream -![Build & Static Code Checks](https://github.com/dariopellegrino00/mod_openai_audio_stream/actions/workflows/checks.yml/badge.svg) +![Build & Static Code Checks](https://github.com/VoiSmart/mod_openai_audio_stream/actions/workflows/checks.yml/badge.svg) -A fork of [mod_audio_stream](https://github.com/amigniter/mod_audio_stream) specifically designed for streaming audio to OpenAI's realtime API and playing the responses back to the user via FreeSWITCH and WebSocket. -**mod_openai_audio_stream** is a FreeSWITCH module that streams L16 audio from a channel to an OpenAI realtime websocket endpoint. The stream is adherent to OpenAI's Realtime API specification and allows for real-time audio playback directly in the channel. +**mod_openai_audio_stream** is a FreeSWITCH module that streams L16 audio from a channel to an OpenAI Realtime WebSocket endpoint. The stream follows OpenAI's Realtime API specification and enables real-time audio playback directly in the channel. + +It is a fork of [mod_audio_stream](https://github.com/amigniter/mod_audio_stream), specifically adapted for streaming audio to OpenAI's Realtime API and playing the responses back to the user via FreeSWITCH and WebSocket. + +The goal of **mod_openai_audio_stream** is to provide a simple, lightweight, yet effective module for streaming audio and receiving responses directly from OpenAI’s Realtime WebSocket into the call through FreeSWITCH. It uses [ixwebsocket](https://machinezone.github.io/IXWebSocket/), a C++ WebSocket library compiled as a static library. The purpose of **mod_openai_audio_stream** was to make a simple, less dependent but yet effective module to stream audio and receive responses directly from OpenAI realtime websocket into the call via switch. It uses [ixwebsocket](https://machinezone.github.io/IXWebSocket/), c++ library for websocket protocol which is compiled as a static library. From 614959f2266e2e26bc929dbc3b0a4ac02b793c30 Mon Sep 17 00:00:00 2001 From: Dario Pellegrino <72254164+dariopellegrino00@users.noreply.github.com> Date: Wed, 20 Aug 2025 17:45:53 +0200 Subject: [PATCH 4/8] Update README.md reduntant Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 294ad99..9ee293c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ It is a fork of [mod_audio_stream](https://github.com/amigniter/mod_audio_stream The goal of **mod_openai_audio_stream** is to provide a simple, lightweight, yet effective module for streaming audio and receiving responses directly from OpenAI’s Realtime WebSocket into the call through FreeSWITCH. It uses [ixwebsocket](https://machinezone.github.io/IXWebSocket/), a C++ WebSocket library compiled as a static library. -The purpose of **mod_openai_audio_stream** was to make a simple, less dependent but yet effective module to stream audio and receive responses directly from OpenAI realtime websocket into the call via switch. It uses [ixwebsocket](https://machinezone.github.io/IXWebSocket/), c++ library for websocket protocol which is compiled as a static library. ## Notes From 8a1f38d253e4d8cabe73e94fa5bb6371edd0791d Mon Sep 17 00:00:00 2001 From: Dario Pellegrino <72254164+dariopellegrino00@users.noreply.github.com> Date: Wed, 20 Aug 2025 17:47:47 +0200 Subject: [PATCH 5/8] Update .github/workflows/checks.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/checks.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index f87617e..b84b511 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -54,3 +54,4 @@ jobs: --project=build/compile_commands.json \ --suppress=missingIncludeSystem \ -i build . 2> cppcheck.log || true + cat cppcheck.log From df6fe9147ce043c73935d215e1adc696184968c3 Mon Sep 17 00:00:00 2001 From: Dario Pellegrino Date: Wed, 20 Aug 2025 17:58:52 +0200 Subject: [PATCH 6/8] Add clang-tidy critic warning as errors Signed-off-by: Dario Pellegrino --- .github/workflows/checks.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index b84b511..a194d5f 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -48,7 +48,8 @@ jobs: scan-build --status-bugs cmake --build build -j"$(nproc)" clang-tidy -p build $(git ls-files '*.c' '*.cc' '*.cpp' '*.cxx') \ - --warnings-as-errors='' || true + --warnings-as-errors='clang-analyzer-*,bugprone-*,performance-*' + cppcheck --enable=all --inconclusive --std=c++17 --force \ --project=build/compile_commands.json \ From 8005d738fe07eff69e80d4db50e616d2e87bed39 Mon Sep 17 00:00:00 2001 From: Dario Pellegrino <72254164+dariopellegrino00@users.noreply.github.com> Date: Wed, 20 Aug 2025 18:06:32 +0200 Subject: [PATCH 7/8] Update .github/workflows/checks.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/checks.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a194d5f..8bfd444 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -48,7 +48,13 @@ jobs: scan-build --status-bugs cmake --build build -j"$(nproc)" clang-tidy -p build $(git ls-files '*.c' '*.cc' '*.cpp' '*.cxx') \ - --warnings-as-errors='clang-analyzer-*,bugprone-*,performance-*' + FILES="$(git ls-files '*.c' '*.cc' '*.cpp' '*.cxx')" + if [ -n "$FILES" ]; then + clang-tidy -p build $FILES \ + --warnings-as-errors='clang-analyzer-*,bugprone-*,performance-*' + else + echo "No source files found for clang-tidy analysis." + fi cppcheck --enable=all --inconclusive --std=c++17 --force \ From 0a9e493c5643c943e3812494ca1c6670b2d96c49 Mon Sep 17 00:00:00 2001 From: Dario Pellegrino <72254164+dariopellegrino00@users.noreply.github.com> Date: Wed, 20 Aug 2025 18:06:39 +0200 Subject: [PATCH 8/8] Update .github/workflows/checks.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 8bfd444..b98e106 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -57,7 +57,7 @@ jobs: fi - cppcheck --enable=all --inconclusive --std=c++17 --force \ + cppcheck --enable=warning,style,performance,portability --std=c++17 --force \ --project=build/compile_commands.json \ --suppress=missingIncludeSystem \ -i build . 2> cppcheck.log || true