Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sippy/libg722
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v_1_2_0
Choose a base ref
...
head repository: sippy/libg722
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 8 commits
  • 4 files changed
  • 2 contributors

Commits on Jul 31, 2024

  1. Copy the full SHA
    25b4590 View commit details
  2. Copy the full SHA
    7597a9d View commit details

Commits on Aug 1, 2024

  1. Copy the full SHA
    167ab15 View commit details

Commits on Aug 9, 2024

  1. Generate output on test failure.

    Use clang.
    
    Filter out mips64le in debian-sid for now. It fails to test,
    something broken with binary generation.
    sobomax committed Aug 9, 2024
    Copy the full SHA
    24d6c94 View commit details

Commits on Aug 16, 2024

  1. Set platforms correctly.

    sobomax committed Aug 16, 2024
    Copy the full SHA
    d06f115 View commit details

Commits on Oct 23, 2024

  1. Copy the full SHA
    531537d View commit details

Commits on Nov 12, 2024

  1. Fix if: ${{ env.DOCKER_RW }}.

    sobomax committed Nov 12, 2024
    Copy the full SHA
    6583a1b View commit details
  2. Change C_STANDARD to C11

    C17 is not available until cmake 3.21, and it does not seem necessary
    Marcello Caramma authored and sobomax committed Nov 12, 2024
    Copy the full SHA
    ba275e0 View commit details
Showing with 43 additions and 20 deletions.
  1. +15 −7 .github/workflows/build_and_test.yml
  2. +1 −1 CMakeLists.txt
  3. +3 −2 docker/Dockerfile.build
  4. +24 −10 tests/test_encode.py
22 changes: 15 additions & 7 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ permissions:
jobs:
build_and_test:
# The type of runner that the job will run on
runs-on: [self-hosted, linux, x64]
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
@@ -147,22 +147,21 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
base_image: ['debian:sid-slim', 'debian:12-slim']
base_image: ['debian:sid-slim', 'debian:12-slim', 'ubuntu:latest']
env:
DOCKER_REPO: sippylabs/libg722
BASE_IMAGE: ${{ matrix.base_image }}
DOCKER_RW: ${{ ( github.repository == 'sippy/libg722' && github.event_name != 'pull_request' ) && 'true' || 'false' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
with:
platforms: arm64,arm,riscv64,mips64le,ppc64le,s390x

- name: Log in to Docker Hub
if: github.event_name != 'pull_request' && github.repository == 'sippy/libg722'
if: ${{ env.DOCKER_RW == 'true' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
@@ -173,7 +172,16 @@ jobs:

- name: Set environments
run: |
PLATFORMS="`docker manifest inspect ${{ env.BASE_IMAGE }} | jq -r '.manifests[] | "\(.platform.os)/\(.platform.architecture)"' | sort -u | paste -sd ','`"
# mips64 seems to be broken at the moment...
if [ "${{ env.BASE_IMAGE }}" = "debian:sid-slim" ]
then
FILT="grep -v mips64le"
else
FILT="cat"
fi
PLATFORMS="`docker manifest inspect ${{ env.BASE_IMAGE }} | \
jq -r '.manifests[] | "\(.platform.os)/\(.platform.architecture)\(if .platform.variant != null then "/\(.platform.variant)" else "" end)"' | \
sort -u | grep -v unknown | ${FILT} | paste -sd ','`"
echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_ENV
GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
GIT_BRANCH="${GIT_BRANCH#refs/tags/}"
@@ -206,6 +214,6 @@ jobs:
platforms: ${{ env.PLATFORMS }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ github.repository == 'sippy/libg722' && 'true' || 'false' }}
push: ${{ env.DOCKER_RW }}
cache-from: ${{ env.CACHE_SPEC }}
cache-to: ${{ env.CACHE_SPEC }},mode=max
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ option(ENABLE_STATIC_LIB "Build static library" ON)

# lots of warnings and all warnings as errors
## add_compile_options(-Wall -Wextra )
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD 11)

file(GLOB_RECURSE SRC_LIST_C CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/g722*.c" )

5 changes: 3 additions & 2 deletions docker/Dockerfile.build
Original file line number Diff line number Diff line change
@@ -4,11 +4,12 @@ ARG BASE_IMAGE="debian:sid-slim"
FROM ${BASE_IMAGE} AS build
LABEL maintainer="Maksym Sobolyev <sobomax@sippysoft.com>"

ARG BUILD_PKGS="cmake make gcc libc6-dev openssl"
ARG BUILD_PKGS="cmake make clang libc6-dev openssl"
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends ${BUILD_PKGS}
WORKDIR /src
RUN --mount=type=bind,target=.,rw cmake -B build && make -C build all test install
RUN --mount=type=bind,target=.,rw cmake -B build && \
make -C build CTEST_OUTPUT_ON_FAILURE=1 all test install
FROM ${BASE_IMAGE} AS clean
COPY --from=build /usr/local/lib/libg722.* /usr/local/lib/
COPY --from=build --exclude=g722_common.h --exclude=g722_private.h \
34 changes: 24 additions & 10 deletions tests/test_encode.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
import unittest

import numpy as np

from G722 import G722

class TestEncoder(unittest.TestCase):
def test_encode_len(self):
bitrates = [48000, 56000, 64000]
sample_rates = [8000, 16000]

bitrates = (48000, 56000, 64000)
sample_rates = (8000, 16000)
sample_inputs = (b"\x00\x01\x02\x03", np.array((0, 1, 2, 3), dtype=np.int16), (0, 1, 2, 3), ('aa', 'bb', 'cc'), 42)
def do_test(br, sr, id):
with self.subTest(bitrate=br, sample_rate=sr, input_data=id):
g722 = G722(sr, br)
try:
encoded_data = g722.encode(id)
except TypeError:
got = isinstance(id, int) or isinstance(id[0], str)
want = True
self.assertEqual(want, got)
return
else:
got = isinstance(id, int)
want = False
self.assertEqual(want, got)
got = len(encoded_data)
want = 4 if sample_rate == 8000 else 2
self.assertEqual(want, got)
for bitrate in bitrates:
for sample_rate in sample_rates:
with self.subTest(bitrate=bitrate, sample_rate=sample_rate):
g722 = G722(sample_rate, bitrate)
audio_data = b"\x00\x01\x02\x03" # Example raw audio data
encoded_data = g722.encode(audio_data)
got = len(encoded_data)
want = 4 if sample_rate == 8000 else 2
self.assertEqual(want, got)
for sample_input in sample_inputs:
do_test(bitrate, sample_rate, sample_input)

if __name__ == '__main__':
unittest.main()