From 0327ad390ee3e9d0e6b386f4ed52ddf4dc70e82f Mon Sep 17 00:00:00 2001 From: Dmitry Ilyin Date: Sat, 13 May 2023 16:43:57 +0300 Subject: [PATCH] Fix tests and make them act compatible (#11) * Fix tests and make them act compatible * Fix workflow syntax issue --- .github/workflows/c-cpp.yml | 36 +++++++++++++------------------- examples/CMakeLists.txt | 3 ++- examples/server.c | 2 +- include/smolrtsp/nal_transport.h | 3 +-- include/smolrtsp/rtp_transport.h | 3 +-- include/smolrtsp/transport.h | 2 +- src/nal_transport.c | 5 ++--- src/transport/tcp.c | 4 ++-- tests/transport.c | 2 +- 9 files changed, 25 insertions(+), 35 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index bc226245..e6badcd9 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -19,6 +19,13 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Install CMake and Clang + run: sudo apt update && sudo apt install -y cmake + + - name: Install Clang + if: matrix.compiler == 'clang' + run: sudo apt install -y clang + - name: Tests run: bash scripts/test.sh @@ -28,27 +35,8 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Install libevent, NASM - run: sudo apt install libevent-dev nasm - - - name: Install FFmpeg - run: | - wget https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 - tar -xf ffmpeg-snapshot.tar.bz2 - cd ffmpeg - ./configure --disable-everything --disable-doc \ - --disable-ffplay --disable-ffprobe \ - --enable-protocol=udp \ - --enable-protocol=tcp \ - --enable-protocol=rtp \ - --enable-protocol=file \ - --enable-demuxer=rtp \ - --enable-demuxer=rtsp \ - --enable-muxer=h264 \ - --enable-muxer=pcm_mulaw \ - --enable-decoder=h264 \ - --enable-parser=h264 - sudo make install -j $(nproc) + - name: Install libevent, CMake, FFMpeg + run: sudo apt update && sudo apt install -y libevent-dev cmake ffmpeg xxd - name: Test the example server run: sudo bash scripts/test-server.sh @@ -59,6 +47,9 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Install libevent + run: sudo apt update && sudo apt install -y clang-format + - name: Download run-clang-format run: git submodule update --init run-clang-format @@ -72,12 +63,13 @@ jobs: - uses: actions/checkout@v2 - name: Install Doxygen - run: sudo apt install doxygen graphviz + run: sudo apt update && sudo apt install -y doxygen graphviz - name: Build the docs run: bash scripts/docs.sh - name: Deploy the docs + if: ${{ !env.ACT && github.event_name != 'pull_request' }} uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 0546af47..6f675242 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -11,7 +11,8 @@ include(FetchContent) FetchContent_Declare( smolrtsp-libevent - URL https://github.com/OpenIPC/smolrtsp-libevent/archive/refs/tags/v0.1.0.tar.gz + GIT_REPOSITORY https://github.com/OpenIPC/smolrtsp-libevent + GIT_TAG 7451e74 ) FetchContent_MakeAvailable(smolrtsp-libevent) diff --git a/examples/server.c b/examples/server.c index 86e081d1..5a01c68a 100644 --- a/examples/server.c +++ b/examples/server.c @@ -496,7 +496,7 @@ static int setup_tcp( SmolRTSP_TransportConfig config) { ifLet(config.interleaved, SmolRTSP_ChannelPair_Some, interleaved) { *t = smolrtsp_transport_tcp( - SmolRTSP_Context_get_writer(ctx), interleaved->rtp_channel); + SmolRTSP_Context_get_writer(ctx), interleaved->rtp_channel, 0); smolrtsp_header( ctx, SMOLRTSP_HEADER_TRANSPORT, diff --git a/include/smolrtsp/nal_transport.h b/include/smolrtsp/nal_transport.h index 72166776..090cef75 100644 --- a/include/smolrtsp/nal_transport.h +++ b/include/smolrtsp/nal_transport.h @@ -111,5 +111,4 @@ int SmolRTSP_NalTransport_send_packet( */ declImplExtern99(SmolRTSP_Droppable, SmolRTSP_NalTransport); -bool -SmolRTSP_NalTransport_is_full(SmolRTSP_NalTransport *self); +bool SmolRTSP_NalTransport_is_full(SmolRTSP_NalTransport *self); diff --git a/include/smolrtsp/rtp_transport.h b/include/smolrtsp/rtp_transport.h index 4ccfbceb..d6ea481e 100644 --- a/include/smolrtsp/rtp_transport.h +++ b/include/smolrtsp/rtp_transport.h @@ -84,5 +84,4 @@ int SmolRTSP_RtpTransport_send_packet( */ declImplExtern99(SmolRTSP_Droppable, SmolRTSP_RtpTransport); -bool -SmolRTSP_RtpTransport_is_full(SmolRTSP_RtpTransport *self); +bool SmolRTSP_RtpTransport_is_full(SmolRTSP_RtpTransport *self); diff --git a/include/smolrtsp/transport.h b/include/smolrtsp/transport.h index aa534f9a..0c08dd9f 100644 --- a/include/smolrtsp/transport.h +++ b/include/smolrtsp/transport.h @@ -28,7 +28,7 @@ * on success. \ */ \ vfunc99(int, transmit, VSelf99, SmolRTSP_IoVecSlice bufs) \ - vfunc99(bool, is_full, VSelf99) + vfunc99(bool, is_full, VSelf99) /** * The superinterfaces of #SmolRTSP_Transport_IFACE. diff --git a/src/nal_transport.c b/src/nal_transport.c index 7370bdc5..82717732 100644 --- a/src/nal_transport.c +++ b/src/nal_transport.c @@ -58,9 +58,8 @@ static void SmolRTSP_NalTransport_drop(VSelf) { implExtern(SmolRTSP_Droppable, SmolRTSP_NalTransport); -bool -SmolRTSP_NalTransport_is_full(SmolRTSP_NalTransport *self) { - return SmolRTSP_RtpTransport_is_full(self->transport); +bool SmolRTSP_NalTransport_is_full(SmolRTSP_NalTransport *self) { + return SmolRTSP_RtpTransport_is_full(self->transport); } int SmolRTSP_NalTransport_send_packet( diff --git a/src/transport/tcp.c b/src/transport/tcp.c index 40913547..e4c43365 100644 --- a/src/transport/tcp.c +++ b/src/transport/tcp.c @@ -19,8 +19,8 @@ typedef struct { declImpl(SmolRTSP_Transport, SmolRTSP_TcpTransport); -SmolRTSP_Transport -smolrtsp_transport_tcp(SmolRTSP_Writer w, uint8_t channel_id, size_t max_buffer) { +SmolRTSP_Transport smolrtsp_transport_tcp( + SmolRTSP_Writer w, uint8_t channel_id, size_t max_buffer) { assert(w.self && w.vptr); SmolRTSP_TcpTransport *self = malloc(sizeof *self); diff --git a/tests/transport.c b/tests/transport.c index e8b0b52c..13c151af 100644 --- a/tests/transport.c +++ b/tests/transport.c @@ -44,7 +44,7 @@ TEST check_tcp(void) { const uint8_t chn_id = 123; SmolRTSP_Transport tcp = - smolrtsp_transport_tcp(smolrtsp_fd_writer(&fds[0]), chn_id); + smolrtsp_transport_tcp(smolrtsp_fd_writer(&fds[0]), chn_id, 0); const char total_len = strlen(DATA_0) + strlen(DATA_1); const char expected[] = {'$', chn_id, 0, total_len, 'a', 'b', 'c',