Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge rem into re #683

Merged
merged 11 commits into from
Feb 16, 2023
8 changes: 0 additions & 8 deletions .github/workflows/build.yml
Expand Up @@ -58,13 +58,6 @@ jobs:
run: |
cmake -B build && cmake --build build

- uses: sreimers/pr-dependency-action@v0.5
with:
name: rem
repo: https://github.com/baresip/rem
secret: ${{ secrets.GITHUB_TOKEN }}
working-directory: '../.'

- uses: sreimers/pr-dependency-action@v0.5
with:
name: retest
Expand All @@ -75,5 +68,4 @@ jobs:
- name: retest
run: |
cd ..
cmake -S rem -B rem/build && cmake --build rem/build
cd retest && make && ./retest -r
10 changes: 1 addition & 9 deletions .github/workflows/coverage.yml
Expand Up @@ -31,13 +31,6 @@ jobs:
run: |
cmake -B build -DCMAKE_C_FLAGS="--coverage" && cmake --build build -j

- uses: sreimers/pr-dependency-action@v0.5
with:
name: rem
repo: https://github.com/baresip/rem
secret: ${{ secrets.GITHUB_TOKEN }}
working-directory: '../.'

- uses: sreimers/pr-dependency-action@v0.5
with:
name: retest
Expand All @@ -48,7 +41,6 @@ jobs:
- name: retest
run: |
cd ..
cmake -S rem -B rem/build && cmake --build rem/build
cd retest; cmake -B build -DCMAKE_EXE_LINKER_FLAGS="--coverage" && \
cmake --build build -j && \
./build/retest -a -v && \
Expand All @@ -65,7 +57,7 @@ jobs:

- name: coverage check
run: |
min_cov="59.4"
min_cov="57.0"
cov=$(~/.local/bin/gcovr -r . -s | grep lines | awk '{ print $2 }' | sed 's/%//')
echo "Coverage: ${cov}% (min $min_cov%)"
exit $(echo "$cov < $min_cov" | bc -l)
16 changes: 7 additions & 9 deletions .github/workflows/mingw.yml
Expand Up @@ -24,22 +24,20 @@ jobs:

- uses: sreimers/pr-dependency-action@v0.5
with:
name: rem
repo: https://github.com/baresip/rem
name: retest
repo: https://github.com/baresip/retest
secret: ${{ secrets.GITHUB_TOKEN }}

- uses: sreimers/pr-dependency-action@v0.5
with:
name: retest
repo: https://github.com/baresip/retest
name: baresip-win32
repo: https://github.com/baresip/baresip-win32
secret: ${{ secrets.GITHUB_TOKEN }}

- name: "clone baresip-win32 repo"
- name: "baresip-win32 repo"
run: |
git clone https://github.com/baresip/baresip-win32.git
mv rem baresip-win32/
mv retest baresip-win32/

- uses: actions/checkout@v3
with:
path: baresip-win32/re
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/sanitizers.yml
Expand Up @@ -43,13 +43,6 @@ jobs:
run: |
cmake -B build -DHAVE_THREADS= && cmake --build build -j

- uses: sreimers/pr-dependency-action@v0.5
with:
name: rem
repo: https://github.com/baresip/rem
secret: ${{ secrets.GITHUB_TOKEN }}
working-directory: '../.'

- uses: sreimers/pr-dependency-action@v0.5
with:
name: retest
Expand All @@ -60,5 +53,4 @@ jobs:
- name: retest
run: |
cd ..
cmake -S rem -B rem/build && cmake --build rem/build -j
cd retest && make && ./retest -riv
8 changes: 0 additions & 8 deletions .github/workflows/valgrind.yml
Expand Up @@ -25,13 +25,6 @@ jobs:
run: |
cmake -B build && cmake --build build -j

- uses: sreimers/pr-dependency-action@v0.5
with:
name: rem
repo: https://github.com/baresip/rem
secret: ${{ secrets.GITHUB_TOKEN }}
working-directory: '../.'

- uses: sreimers/pr-dependency-action@v0.5
with:
name: retest
Expand All @@ -42,7 +35,6 @@ jobs:
- name: retest
run: |
cd ..
cmake -S rem -B rem/build && cmake --build rem/build
cd retest
cmake -B build && cmake --build build -j
valgrind --leak-check=full --show-reachable=yes --error-exitcode=42 ./build/retest -r -v
59 changes: 59 additions & 0 deletions CMakeLists.txt
Expand Up @@ -45,6 +45,7 @@ include(CheckCCompilerFlag)
# Options
#

option(USE_REM "Enable Librem" ON)
option(USE_BFCP "Enable BFCP" ON)
option(USE_JBUF "Enable JBUF" ON)
option(USE_PCP "Enable PCP" ON)
Expand Down Expand Up @@ -174,6 +175,32 @@ set(HEADERS
include/re_websock.h
)

set(REM_HEADERS
include/rem_aac.h
include/rem_aubuf.h
include/rem_auconv.h
include/rem_audio.h
include/rem_aufile.h
include/rem_auframe.h
include/rem_au.h
include/rem_aulevel.h
include/rem_aumix.h
include/rem_auresamp.h
include/rem_autone.h
include/rem_avc.h
include/rem_dsp.h
include/rem_dtmf.h
include/rem_fir.h
include/rem_flv.h
include/rem_g711.h
include/rem_goertzel.h
include/rem.h
include/rem_vidconv.h
include/rem_video.h
include/rem_vid.h
include/rem_vidmix.h
)

if(USE_UNIXSOCK)
list(APPEND HEADERS
include/re_unixsock.h
Expand Down Expand Up @@ -371,6 +398,32 @@ set(SRCS
src/websock/websock.c
)

set(REM_SRCS
rem/aac/aac.c
rem/au/fmt.c
rem/au/util.c
rem/aubuf/aubuf.c
rem/aubuf/ajb.c
rem/auconv/auconv.c
rem/aufile/aufile.c
rem/aufile/wave.c
rem/auframe/auframe.c
rem/aulevel/aulevel.c
rem/aumix/aumix.c
rem/auresamp/resamp.c
rem/autone/tone.c
rem/avc/config.c
rem/dtmf/dec.c
rem/fir/fir.c
rem/g711/g711.c
rem/goertzel/goertzel.c
rem/vid/draw.c
rem/vid/fmt.c
rem/vid/frame.c
rem/vidconv/vconv.c
rem/vidmix/vidmix.c
)

if(USE_UNIXSOCK)
list(APPEND SRCS
src/unixsock/unixsock.c
Expand Down Expand Up @@ -534,6 +587,10 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
)
endif()

if(USE_REM)
list(APPEND SRCS ${REM_SRCS})
endif()


##############################################################################
#
Expand Down Expand Up @@ -567,6 +624,8 @@ if(WIN32)
wsock32
ws2_32
)
else()
list(APPEND LINKLIBS -lm)
endif()

if(UNIX)
Expand Down
25 changes: 25 additions & 0 deletions include/rem.h
@@ -0,0 +1,25 @@
/**
* @file rem.h Wrapper for librem headers
*
* Copyright (C) 2010 Creytiv.com
*/

#ifndef REM_H__
#define REM_H__

#ifdef __cplusplus
extern "C" {
#endif


#include "rem_audio.h"
#include "rem_video.h"
#include "rem_dsp.h"
#include "rem_flv.h"


#ifdef __cplusplus
}
#endif

#endif
15 changes: 15 additions & 0 deletions include/rem_aac.h
@@ -0,0 +1,15 @@
/**
* @file rem_aac.h Advanced Audio Coding
*
* Copyright (C) 2010 Creytiv.com
*/


/** Defines the AAC header */
struct aac_header {
unsigned sample_rate; /**< Audio sample rate in [Hz] */
unsigned channels; /**< Number of audio channels */
unsigned frame_size; /**< Frame size, 960 or 1024 bits */
};

int aac_header_decode(struct aac_header *hdr, const uint8_t *p, size_t len);
22 changes: 22 additions & 0 deletions include/rem_au.h
@@ -0,0 +1,22 @@
/**
* @file rem_au.h Basic audio types
*
* Copyright (C) 2010 Creytiv.com
*/


/** Audio formats */
enum aufmt {
AUFMT_S16LE, /**< Signed 16-bit PCM */
AUFMT_S32LE, /**< Signed 32-bit PCM */
AUFMT_PCMA, /**< G.711 A-law */
AUFMT_PCMU, /**< G.711 U-law */
AUFMT_FLOAT, /**< Float 32 bit (CPU endian) */
AUFMT_S24_3LE,/**< Signed 24bit Little Endian in 3bytes format */
AUFMT_RAW, /**< RAW PCM */
};

size_t aufmt_sample_size(enum aufmt fmt);
const char *aufmt_name(enum aufmt fmt);

uint32_t calc_nsamp(uint32_t srate, uint8_t channels, uint16_t ptime);
104 changes: 104 additions & 0 deletions include/rem_aubuf.h
@@ -0,0 +1,104 @@
/**
* @file rem_aubuf.h Audio Buffer
*
* Copyright (C) 2010 Creytiv.com
*/
struct aubuf;

enum aubuf_mode {
AUBUF_FIXED,
AUBUF_ADAPTIVE
};

int aubuf_alloc(struct aubuf **abp, size_t min_sz, size_t max_sz);
void aubuf_set_live(struct aubuf *ab, bool live);
void aubuf_set_mode(struct aubuf *ab, enum aubuf_mode mode);
void aubuf_set_silence(struct aubuf *ab, double silence);
int aubuf_resize(struct aubuf *ab, size_t min_sz, size_t max_sz);
int aubuf_write_auframe(struct aubuf *ab, const struct auframe *af);
int aubuf_append_auframe(struct aubuf *ab, struct mbuf *mb,
const struct auframe *af);
void aubuf_read_auframe(struct aubuf *ab, struct auframe *af);
void aubuf_sort_auframe(struct aubuf *ab);
int aubuf_get(struct aubuf *ab, uint32_t ptime, uint8_t *p, size_t sz);
void aubuf_flush(struct aubuf *ab);
int aubuf_debug(struct re_printf *pf, const struct aubuf *ab);
size_t aubuf_cur_size(const struct aubuf *ab);
void aubuf_drop_auframe(struct aubuf *ab, const struct auframe *af);


static inline int aubuf_append(struct aubuf *ab, struct mbuf *mb)
{
return aubuf_append_auframe(ab, mb, NULL);
}


static inline int aubuf_get_samp(struct aubuf *ab, uint32_t ptime,
int16_t *sampv, size_t sampc)
{
return aubuf_get(ab, ptime, (uint8_t *)sampv, sampc * 2);
}


#ifndef __cplusplus
static inline int aubuf_write(struct aubuf *ab, const uint8_t *p, size_t sz)
{
struct auframe af = {
.fmt = AUFMT_RAW,
.srate = 0,
.sampv = (uint8_t *)p,
.sampc = sz,
.timestamp = 0,
.level = AULEVEL_UNDEF
};

return aubuf_write_auframe(ab, &af);
}


static inline int aubuf_write_samp(struct aubuf *ab, const int16_t *sampv,
size_t sampc)
{
struct auframe af = {
.fmt = AUFMT_S16LE,
.srate = 0,
.sampv = (uint8_t *)sampv,
.sampc = sampc,
.timestamp = 0,
.level = AULEVEL_UNDEF
};

return aubuf_write_auframe(ab, &af);
}


static inline void aubuf_read(struct aubuf *ab, uint8_t *p, size_t sz)
{
struct auframe af = {
.fmt = AUFMT_RAW,
.srate = 0,
.sampv = p,
.sampc = sz,
.timestamp = 0,
.level = AULEVEL_UNDEF
};

aubuf_read_auframe(ab, &af);
}


static inline void aubuf_read_samp(struct aubuf *ab, int16_t *sampv,
size_t sampc)
{
struct auframe af = {
.fmt = AUFMT_S16LE,
.srate = 0,
.sampv = (uint8_t *)sampv,
.sampc = sampc,
.timestamp = 0,
.level = AULEVEL_UNDEF
};

aubuf_read_auframe(ab, &af);
}
#endif