Browse Source

Merge branch 'master' of https://github.com/alfredh/baresip

master
Aaron Herting 7 years ago
parent
commit
13d19c4415
60 changed files with 1293 additions and 520 deletions
  1. +2
    -2
      debian/control
  2. +1
    -0
      docs/README
  3. +3
    -4
      include/baresip.h
  4. +23
    -7
      mk/modules.mk
  5. +9
    -11
      modules/alsa/alsa_play.c
  6. +8
    -10
      modules/alsa/alsa_src.c
  7. +1
    -8
      modules/amr/amr.c
  8. +2
    -3
      modules/aubridge/device.c
  9. +1
    -10
      modules/audiounit/player.c
  10. +1
    -1
      modules/audiounit/recorder.c
  11. +6
    -10
      modules/auloop/auloop.c
  12. +2
    -2
      modules/avcapture/avcapture.m
  13. +0
    -26
      modules/coreaudio/coreaudio.c
  14. +0
    -2
      modules/coreaudio/coreaudio.h
  15. +6
    -9
      modules/coreaudio/player.c
  16. +6
    -27
      modules/coreaudio/recorder.c
  17. +2
    -2
      modules/dshow/dshow.cpp
  18. +4
    -9
      modules/dtls_srtp/dtls.c
  19. +10
    -15
      modules/dtls_srtp/srtp.c
  20. +7
    -11
      modules/dtls_srtp/tls_udp.c
  21. +8
    -2
      modules/dtmfio/dtmfio.c
  22. +6
    -19
      modules/evdev/evdev.c
  23. +4
    -9
      modules/evdev/print.c
  24. +1
    -12
      modules/g722/g722.c
  25. +22
    -33
      modules/gst/gst.c
  26. +7
    -0
      modules/ice/ice.c
  27. +27
    -30
      modules/natbd/natbd.c
  28. +14
    -9
      modules/opensles/player.c
  29. +21
    -18
      modules/opensles/recorder.c
  30. +18
    -32
      modules/oss/oss.c
  31. +4
    -8
      modules/portaudio/portaudio.c
  32. +1
    -1
      modules/presence/subscriber.c
  33. +0
    -5
      modules/quicktime/quicktime.c
  34. +21
    -26
      modules/rst/audio.c
  35. +15
    -17
      modules/rst/rst.c
  36. +77
    -0
      modules/selftest/cmd.c
  37. +11
    -0
      modules/selftest/module.mk
  38. +75
    -0
      modules/selftest/selftest.c
  39. +58
    -0
      modules/selftest/selftest.h
  40. +97
    -0
      modules/selftest/sip_server.c
  41. +154
    -0
      modules/selftest/ua.c
  42. +11
    -0
      modules/sndio/module.mk
  43. +308
    -0
      modules/sndio/sndio.c
  44. +20
    -25
      modules/srtp/srtp.c
  45. +3
    -0
      modules/v4l2/module.mk
  46. +60
    -5
      modules/v4l2/v4l2.c
  47. +5
    -11
      modules/winwave/play.c
  48. +4
    -11
      modules/winwave/src.c
  49. +0
    -5
      modules/winwave/winwave.c
  50. +9
    -9
      src/account.c
  51. +19
    -17
      src/audio.c
  52. +66
    -11
      src/call.c
  53. +16
    -0
      src/config.c
  54. +1
    -1
      src/core.h
  55. +4
    -7
      src/message.c
  56. +1
    -1
      src/metric.c
  57. +9
    -10
      src/play.c
  58. +4
    -4
      src/sdp.c
  59. +10
    -5
      src/stream.c
  60. +8
    -8
      src/ua.c

+ 2
- 2
debian/control View File

@ -3,12 +3,12 @@ Section: comm
Priority: optional
Maintainer: Alfred E. Heggestad <aeh@db.org>
Standards-Version: 3.9.5
Build-Depends: debhelper (>= 9.20120311), librem-dev (>= 0.4.5), libre-dev (>= 0.4.5), libasound2-dev, libavformat-dev, libavdevice-dev
Build-Depends: debhelper (>= 9.20120311), librem-dev (>= 0.4.5), libre-dev (>= 0.4.8), libasound2-dev, libavformat-dev, libavdevice-dev
Homepage: http://www.creytiv.com/
Package: baresip
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, librem (>= 0.4.5), libre (>= 0.4.5)
Depends: ${shlibs:Depends}, ${misc:Depends}, librem (>= 0.4.5), libre (>= 0.4.8)
Description: Modular SIP User-Agent with audio and video support
Design goals:
.

+ 1
- 0
docs/README View File

@ -187,6 +187,7 @@ selfview Video selfview module
silk SILK audio codec
snapshot Save video-stream as PNG images
sndfile Audio dumper using libsndfile
sndio Audio driver for OpenBSD
speex Speex audio codec
speex_aec Acoustic Echo Cancellation (AEC) using libspeexdsp
speex_pp Audio pre-processor using libspeexdsp

+ 3
- 4
include/baresip.h View File

@ -74,6 +74,7 @@ void call_set_handlers(struct call *call, call_event_h *eh,
call_dtmf_h *dtmfh, void *arg);
uint16_t call_scode(const struct call *call);
uint32_t call_duration(const struct call *call);
uint32_t call_setup_duration(const struct call *call);
const char *call_peeruri(const struct call *call);
const char *call_peername(const struct call *call);
const char *call_localuri(const struct call *call);
@ -256,13 +257,12 @@ struct ausrc_st;
/** Audio Source parameters */
struct ausrc_prm {
int fmt; /**< Audio format (enum aufmt) */
uint32_t srate; /**< Sampling rate in [Hz] */
uint8_t ch; /**< Number of channels */
uint32_t ptime; /**< Wanted packet-time in [ms] */
};
typedef void (ausrc_read_h)(const uint8_t *buf, size_t sz, void *arg);
typedef void (ausrc_read_h)(const int16_t *sampv, size_t sampc, void *arg);
typedef void (ausrc_error_h)(int err, const char *str, void *arg);
typedef int (ausrc_alloc_h)(struct ausrc_st **stp, struct ausrc *ausrc,
@ -288,13 +288,12 @@ struct auplay_st;
/** Audio Player parameters */
struct auplay_prm {
int fmt; /**< Audio format (enum aufmt) */
uint32_t srate; /**< Sampling rate in [Hz] */
uint8_t ch; /**< Number of channels */
uint32_t ptime; /**< Wanted packet-time in [ms] */
};
typedef bool (auplay_write_h)(uint8_t *buf, size_t sz, void *arg);
typedef void (auplay_write_h)(int16_t *sampv, size_t sampc, void *arg);
typedef int (auplay_alloc_h)(struct auplay_st **stp, struct auplay *ap,
struct auplay_prm *prm, const char *device,

+ 23
- 7
mk/modules.mk View File

@ -7,6 +7,7 @@
#
# USE_ALSA ALSA audio driver
# USE_AMR Adaptive Multi-Rate (AMR) audio codec
# USE_AVCAPTURE AVFoundation video capture for OSX/iOS
# USE_BV32 BroadVoice32 Wideband Audio codec
# USE_CAIRO Cairo module
# USE_CONS Console input driver
@ -64,6 +65,7 @@ USE_AMR := $(shell [ -d $(SYSROOT)/include/opencore-amrnb ] || \
USE_BV32 := $(shell [ -f $(SYSROOT)/include/bv32/bv32.h ] || \
[ -f $(SYSROOT)/local/include/bv32/bv32.h ] && echo "yes")
USE_CAIRO := $(shell [ -f $(SYSROOT)/include/cairo/cairo.h ] || \
[ -f $(SYSROOT)/local/include/cairo/cairo.h ] || \
[ -f $(SYSROOT_ALT)/include/cairo/cairo.h ] && echo "yes")
USE_DTLS := $(shell [ -f $(SYSROOT)/include/openssl/dtls1.h ] || \
[ -f $(SYSROOT)/local/include/openssl/dtls1.h ] || \
@ -98,6 +100,7 @@ USE_ILBC := $(shell [ -f $(SYSROOT)/include/iLBC_define.h ] || \
USE_ISAC := $(shell [ -f $(SYSROOT)/include/isac.h ] || \
[ -f $(SYSROOT)/local/include/isac.h ] && echo "yes")
USE_MPG123 := $(shell [ -f $(SYSROOT)/include/mpg123.h ] || \
[ -f $(SYSROOT)/local/include/mpg123.h ] || \
[ -f $(SYSROOT_ALT)/include/mpg123.h ] && echo "yes")
USE_OPUS := $(shell [ -f $(SYSROOT)/include/opus/opus.h ] || \
[ -f $(SYSROOT_ALT)/include/opus/opus.h ] || \
@ -154,9 +157,13 @@ USE_UUID := $(shell [ -f $(SYSROOT)/include/uuid/uuid.h ] && echo "yes")
USE_V4L := $(shell [ -f $(SYSROOT)/include/libv4l1.h ] || \
[ -f $(SYSROOT)/local/include/libv4l1.h ] \
&& echo "yes")
USE_V4L2 := $(shell [ -f $(SYSROOT)/include/libv4l2.h ] || \
HAVE_LIBV4L2 := $(shell [ -f $(SYSROOT)/include/libv4l2.h ] || \
[ -f $(SYSROOT)/local/include/libv4l2.h ] \
&& echo "yes")
USE_V4L2 := $(shell [ -f $(SYSROOT)/include/linux/videodev2.h ] || \
[ -f $(SYSROOT)/local/include/linux/videodev2.h ] || \
[ -f $(SYSROOT)/include/sys/videoio.h ] \
&& echo "yes")
USE_X11 := $(shell [ -f $(SYSROOT)/include/X11/Xlib.h ] || \
[ -f $(SYSROOT)/local/include/X11/Xlib.h ] || \
[ -f $(SYSROOT_ALT)/include/X11/Xlib.h ] && echo "yes")
@ -182,11 +189,22 @@ endif
endif
USE_AVFOUNDATION := \
$(shell [ -d /System/Library/Frameworks/AVFoundation.framework ] \
&& echo "yes")
ifneq ($(USE_AVFOUNDATION),)
USE_AVCAPTURE := yes
else
USE_QTCAPTURE := yes
endif
endif
ifeq ($(OS),linux)
USE_EVDEV := $(shell [ -f $(SYSROOT)/include/linux/input.h ] && echo "yes")
MODULES += dtmfio
endif
ifeq ($(OS),win32)
USE_WINWAVE := yes
@ -200,6 +218,7 @@ endif
MODULES += $(EXTRA_MODULES)
MODULES += stun turn ice natbd auloop presence
MODULES += menu contact vumeter mwi account natpmp httpd
MODULES += selftest
ifneq ($(HAVE_PTHREAD),)
MODULES += aubridge
endif
@ -217,6 +236,9 @@ endif
ifneq ($(USE_AMR),)
MODULES += amr
endif
ifneq ($(USE_AVCAPTURE),)
MODULES += avcapture
endif
ifneq ($(USE_BV32),)
MODULES += bv32
endif
@ -347,9 +369,3 @@ endif
ifneq ($(USE_X11),)
MODULES += x11 x11grab
endif
ifeq ($(OS),linux)
MODULES += dtmfio
endif

+ 9
- 11
modules/alsa/alsa_play.c View File

@ -21,7 +21,8 @@ struct auplay_st {
pthread_t thread;
bool run;
snd_pcm_t *write;
struct mbuf *mbw;
int16_t *sampv;
size_t sampc;
auplay_write_h *wh;
void *arg;
struct auplay_prm prm;
@ -42,7 +43,7 @@ static void auplay_destructor(void *arg)
if (st->write)
snd_pcm_close(st->write);
mem_deref(st->mbw);
mem_deref(st->sampv);
mem_deref(st->ap);
mem_deref(st->device);
}
@ -59,13 +60,13 @@ static void *write_thread(void *arg)
while (st->run) {
const int samples = num_frames;
st->wh(st->mbw->buf, st->mbw->size, st->arg);
st->wh(st->sampv, st->sampc, st->arg);
n = snd_pcm_writei(st->write, st->mbw->buf, samples);
n = snd_pcm_writei(st->write, st->sampv, samples);
if (-EPIPE == n) {
snd_pcm_prepare(st->write);
n = snd_pcm_writei(st->write, st->mbw->buf, samples);
n = snd_pcm_writei(st->write, st->sampv, samples);
if (n != samples) {
warning("alsa: write error: %s\n",
snd_strerror(n));
@ -89,14 +90,11 @@ int alsa_play_alloc(struct auplay_st **stp, struct auplay *ap,
auplay_write_h *wh, void *arg)
{
struct auplay_st *st;
uint32_t sampc;
int num_frames;
int err;
if (!stp || !ap || !prm || !wh)
return EINVAL;
if (prm->fmt != AUFMT_S16LE)
return EINVAL;
if (!str_isset(device))
device = alsa_dev;
@ -114,11 +112,11 @@ int alsa_play_alloc(struct auplay_st **stp, struct auplay *ap,
st->wh = wh;
st->arg = arg;
sampc = prm->srate * prm->ch * prm->ptime / 1000;
st->sampc = prm->srate * prm->ch * prm->ptime / 1000;
num_frames = st->prm.srate * st->prm.ptime / 1000;
st->mbw = mbuf_alloc(2 * sampc);
if (!st->mbw) {
st->sampv = mem_alloc(2 * st->sampc, NULL);
if (!st->sampv) {
err = ENOMEM;
goto out;
}

+ 8
- 10
modules/alsa/alsa_src.c View File

@ -21,7 +21,8 @@ struct ausrc_st {
pthread_t thread;
bool run;
snd_pcm_t *read;
struct mbuf *mbr;
int16_t *sampv;
size_t sampc;
ausrc_read_h *rh;
void *arg;
struct ausrc_prm prm;
@ -42,7 +43,7 @@ static void ausrc_destructor(void *arg)
if (st->read)
snd_pcm_close(st->read);
mem_deref(st->mbr);
mem_deref(st->sampv);
mem_deref(st->as);
mem_deref(st->device);
}
@ -65,7 +66,7 @@ static void *read_thread(void *arg)
}
while (st->run) {
err = snd_pcm_readi(st->read, st->mbr->buf, num_frames);
err = snd_pcm_readi(st->read, st->sampv, num_frames);
if (err == -EPIPE) {
snd_pcm_prepare(st->read);
continue;
@ -74,7 +75,7 @@ static void *read_thread(void *arg)
continue;
}
st->rh(st->mbr->buf, err * 2 * st->prm.ch, st->arg);
st->rh(st->sampv, err * st->prm.ch, st->arg);
}
out:
@ -88,7 +89,6 @@ int alsa_src_alloc(struct ausrc_st **stp, struct ausrc *as,
ausrc_read_h *rh, ausrc_error_h *errh, void *arg)
{
struct ausrc_st *st;
uint32_t sampc;
int num_frames;
int err;
(void)ctx;
@ -96,8 +96,6 @@ int alsa_src_alloc(struct ausrc_st **stp, struct ausrc *as,
if (!stp || !as || !prm || !rh)
return EINVAL;
if (prm->fmt != AUFMT_S16LE)
return EINVAL;
if (!str_isset(device))
device = alsa_dev;
@ -115,11 +113,11 @@ int alsa_src_alloc(struct ausrc_st **stp, struct ausrc *as,
st->rh = rh;
st->arg = arg;
sampc = prm->srate * prm->ch * prm->ptime / 1000;
st->sampc = prm->srate * prm->ch * prm->ptime / 1000;
num_frames = st->prm.srate * st->prm.ptime / 1000;
st->mbr = mbuf_alloc(2 * sampc);
if (!st->mbr) {
st->sampv = mem_alloc(2 * st->sampc, NULL);
if (!st->sampv) {
err = ENOMEM;
goto out;
}

+ 1
- 8
modules/amr/amr.c View File

@ -19,11 +19,6 @@
#include <baresip.h>
#define DEBUG_MODULE "amr"
#define DEBUG_LEVEL 5
#include <re_dbg.h>
#ifdef VO_AMRWBENC_ENC_IF_H
#define IF2E_IF_encode E_IF_encode
#define IF2D_IF_decode D_IF_decode
@ -215,10 +210,8 @@ static int encode_wb(struct auenc_state *st, uint8_t *buf, size_t *len,
return ENOMEM;
n = IF2E_IF_encode(st->enc, 8, sampv, buf, 0);
if (n <= 0) {
DEBUG_WARNING("encode error: %d\n", n);
if (n <= 0)
return EPROTO;
}
*len = n;

+ 2
- 3
modules/aubridge/device.c View File

@ -88,8 +88,7 @@ static void *device_thread(void *arg)
continue;
if (dev->auplay && dev->auplay->wh) {
dev->auplay->wh((void *)sampv_in, 2 * sampc_in,
dev->auplay->arg);
dev->auplay->wh(sampv_in, sampc_in, dev->auplay->arg);
}
err = auresamp(&rs,
@ -100,7 +99,7 @@ static void *device_thread(void *arg)
}
if (dev->ausrc && dev->ausrc->rh) {
dev->ausrc->rh((void *)sampv_out, 2 * sampc_out,
dev->ausrc->rh(sampv_out, sampc_out,
dev->ausrc->arg);
}

+ 1
- 10
modules/audiounit/player.c View File

@ -11,9 +11,6 @@
#include "audiounit.h"
static uint8_t silbuf[4096]; /* silence */
struct auplay_st {
struct auplay *ap; /* inheritance */
struct audiosess_st *sess;
@ -72,13 +69,7 @@ static OSStatus output_callback(void *inRefCon,
AudioBuffer *ab = &ioData->mBuffers[i];
if (!wh(ab->mData, ab->mDataByteSize, arg)) {
if (ab->mDataByteSize < sizeof(silbuf))
ab->mData = silbuf;
else
memset(ab->mData, 0, ab->mDataByteSize);
}
wh(ab->mData, ab->mDataByteSize/2, arg);
}
return 0;

+ 1
- 1
modules/audiounit/recorder.c View File

@ -78,7 +78,7 @@ static OSStatus input_callback(void *inRefCon,
if (ret)
return ret;
rh(abl.mBuffers[0].mData, abl.mBuffers[0].mDataByteSize, arg);
rh(abl.mBuffers[0].mData, abl.mBuffers[0].mDataByteSize/2, arg);
return 0;
}

+ 6
- 10
modules/auloop/auloop.c View File

@ -112,21 +112,21 @@ static int codec_read(struct audio_loop *al, int16_t *sampv, size_t sampc)
}
static void read_handler(const uint8_t *buf, size_t sz, void *arg)
static void read_handler(const int16_t *sampv, size_t sampc, void *arg)
{
struct audio_loop *al = arg;
int err;
++al->n_read;
err = aubuf_write(al->ab, buf, sz);
err = aubuf_write_samp(al->ab, sampv, sampc);
if (err) {
warning("auloop: aubuf_write: %m\n", err);
}
}
static bool write_handler(uint8_t *buf, size_t sz, void *arg)
static void write_handler(int16_t *sampv, size_t sampc, void *arg)
{
struct audio_loop *al = arg;
int err;
@ -135,17 +135,15 @@ static bool write_handler(uint8_t *buf, size_t sz, void *arg)
/* read from beginning */
if (al->ac) {
err = codec_read(al, (void *)buf, sz/2);
err = codec_read(al, sampv, sampc);
if (err) {
warning("auloop: codec_read error "
"on %u bytes (%m)\n", sz, err);
"on %zu samples (%m)\n", sampc, err);
}
}
else {
aubuf_read(al->ab, buf, sz);
aubuf_read_samp(al->ab, sampv, sampc);
}
return true;
}
@ -223,7 +221,6 @@ static int auloop_reset(struct audio_loop *al)
if (err)
return err;
auplay_prm.fmt = AUFMT_S16LE;
auplay_prm.srate = al->srate;
auplay_prm.ch = al->ch;
auplay_prm.ptime = PTIME;
@ -236,7 +233,6 @@ static int auloop_reset(struct audio_loop *al)
return err;
}
ausrc_prm.fmt = AUFMT_S16LE;
ausrc_prm.srate = al->srate;
ausrc_prm.ch = al->ch;
ausrc_prm.ptime = PTIME;

+ 2
- 2
modules/avcapture/avcapture.m View File

@ -60,8 +60,8 @@ static void vidframe_set_pixbuf(struct vidframe *f, const CVImageBufferRef b)
break;
default:
re_printf("avcapture: pixfmt %c%c%c%c\n",
type>>24, type>>16, type>>8, type>>0);
warning("avcapture: unknown pixfmt %c%c%c%c\n",
type>>24, type>>16, type>>8, type>>0);
f->fmt = -1;
f->data[0] = NULL;
return;

+ 0
- 26
modules/coreaudio/coreaudio.c View File

@ -14,32 +14,6 @@ static struct auplay *auplay;
static struct ausrc *ausrc;
int audio_fmt(enum aufmt fmt)
{
switch (fmt) {
case AUFMT_S16LE: return kAudioFormatLinearPCM;
case AUFMT_PCMA: return kAudioFormatALaw;
case AUFMT_PCMU: return kAudioFormatULaw;
default:
warning("coreaudio: unknown format %d\n", fmt);
return -1;
}
}
int bytesps(enum aufmt fmt)
{
switch (fmt) {
case AUFMT_S16LE: return 2;
case AUFMT_PCMA: return 1;
case AUFMT_PCMU: return 1;
default: return 0;
}
}
#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_2_0
static void interruptionListener(void *data, UInt32 inInterruptionState)
{

+ 0
- 2
modules/coreaudio/coreaudio.h View File

@ -8,8 +8,6 @@
int audio_session_enable(void);
void audio_session_disable(void);
int audio_fmt(enum aufmt fmt);
int bytesps(enum aufmt fmt);
int coreaudio_player_alloc(struct auplay_st **stp, struct auplay *ap,
struct auplay_prm *prm, const char *device,

+ 6
- 9
modules/coreaudio/player.c View File

@ -72,10 +72,7 @@ static void play_handler(void *userData, AudioQueueRef outQ,
if (!wh)
return;
if (!wh(outQB->mAudioData, outQB->mAudioDataByteSize, arg)) {
/* Set the buffer to silence */
memset(outQB->mAudioData, 0, outQB->mAudioDataByteSize);
}
wh(outQB->mAudioData, outQB->mAudioDataByteSize/2, arg);
AudioQueueEnqueueBuffer(outQ, outQB, 0, NULL);
}
@ -110,17 +107,17 @@ int coreaudio_player_alloc(struct auplay_st **stp, struct auplay *ap,
goto out;
fmt.mSampleRate = (Float64)prm->srate;
fmt.mFormatID = audio_fmt(prm->fmt);
fmt.mFormatID = kAudioFormatLinearPCM;
fmt.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger |
kAudioFormatFlagIsPacked;
#ifdef __BIG_ENDIAN__
fmt.mFormatFlags |= kAudioFormatFlagIsBigEndian;
#endif
fmt.mFramesPerPacket = 1;
fmt.mBytesPerFrame = prm->ch * bytesps(prm->fmt);
fmt.mBytesPerPacket = prm->ch * bytesps(prm->fmt);
fmt.mBytesPerFrame = prm->ch * 2;
fmt.mBytesPerPacket = prm->ch * 2;
fmt.mChannelsPerFrame = prm->ch;
fmt.mBitsPerChannel = 8*bytesps(prm->fmt);
fmt.mBitsPerChannel = 16;
status = AudioQueueNewOutput(&fmt, play_handler, st, NULL,
kCFRunLoopCommonModes, 0, &st->queue);
@ -131,7 +128,7 @@ int coreaudio_player_alloc(struct auplay_st **stp, struct auplay *ap,
}
sampc = prm->srate * prm->ch * prm->ptime / 1000;
bytc = sampc * bytesps(prm->fmt);
bytc = sampc * 2;
for (i=0; i<ARRAY_SIZE(st->buf); i++) {

+ 6
- 27
modules/coreaudio/recorder.c View File

@ -20,7 +20,6 @@ struct ausrc_st {
AudioQueueRef queue;
AudioQueueBufferRef buf[BUFC];
pthread_mutex_t mutex;
struct mbuf *mb;
ausrc_read_h *rh;
void *arg;
unsigned int ptime;
@ -49,7 +48,6 @@ static void ausrc_destructor(void *arg)
AudioQueueDispose(st->queue, true);
}
mem_deref(st->mb);
mem_deref(st->as);
pthread_mutex_destroy(&st->mutex);
@ -63,10 +61,8 @@ static void record_handler(void *userData, AudioQueueRef inQ,
const AudioStreamPacketDescription *inPacketDesc)
{
struct ausrc_st *st = userData;
struct mbuf *mb = st->mb;
unsigned int ptime;
ausrc_read_h *rh;
size_t sz, sp;
void *arg;
(void)inStartTime;
(void)inNumPackets;
@ -81,18 +77,7 @@ static void record_handler(void *userData, AudioQueueRef inQ,
if (!rh)
return;
sz = inQB->mAudioDataByteSize;
sp = mbuf_get_space(mb);
if (sz >= sp) {
mbuf_write_mem(mb, inQB->mAudioData, sp);
rh(mb->buf, (uint32_t)mb->size, arg);
mb->pos = 0;
mbuf_write_mem(mb, (uint8_t *)inQB->mAudioData + sp, sz - sp);
}
else {
mbuf_write_mem(mb, inQB->mAudioData, sz);
}
rh(inQB->mAudioData, inQB->mAudioDataByteSize/2, arg);
AudioQueueEnqueueBuffer(inQ, inQB, 0, NULL);
@ -132,13 +117,7 @@ int coreaudio_recorder_alloc(struct ausrc_st **stp, struct ausrc *as,
st->arg = arg;
sampc = prm->srate * prm->ch * prm->ptime / 1000;
bytc = sampc * bytesps(prm->fmt);
st->mb = mbuf_alloc(bytc);
if (!st->mb) {
err = ENOMEM;
goto out;
}
bytc = sampc * 2;
err = pthread_mutex_init(&st->mutex, NULL);
if (err)
@ -149,7 +128,7 @@ int coreaudio_recorder_alloc(struct ausrc_st **stp, struct ausrc *as,
goto out;
fmt.mSampleRate = (Float64)prm->srate;
fmt.mFormatID = audio_fmt(prm->fmt);
fmt.mFormatID = kAudioFormatLinearPCM;
fmt.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger |
kAudioFormatFlagIsPacked;
#ifdef __BIG_ENDIAN__
@ -157,10 +136,10 @@ int coreaudio_recorder_alloc(struct ausrc_st **stp, struct ausrc *as,
#endif
fmt.mFramesPerPacket = 1;
fmt.mBytesPerFrame = prm->ch * bytesps(prm->fmt);
fmt.mBytesPerPacket = prm->ch * bytesps(prm->fmt);
fmt.mBytesPerFrame = prm->ch * 2;
fmt.mBytesPerPacket = prm->ch * 2;
fmt.mChannelsPerFrame = prm->ch;
fmt.mBitsPerChannel = 8*bytesps(prm->fmt);
fmt.mBitsPerChannel = 16;
status = AudioQueueNewInput(&fmt, record_handler, st, NULL,
kCFRunLoopCommonModes, 0, &st->queue);

+ 2
- 2
modules/dshow/dshow.cpp View File

@ -147,8 +147,8 @@ static int get_device(struct vidsrc_st *st, const char *name)
!str_casecmp(dev_name, name);
if (found) {
re_printf("dshow: got device '%s' id=%d\n",
name, id);
info("dshow: got device '%s' id=%d\n",
name, id);
st->dev_moniker = mon;
}
}

+ 4
- 9
modules/dtls_srtp/dtls.c View File

@ -12,11 +12,6 @@
#include "dtls_srtp.h"
#define DEBUG_MODULE "dtls_srtp"
#define DEBUG_LEVEL 5
#include <re_dbg.h>
/* note: shadow struct in libre's tls module */
struct tls {
SSL_CTX *ctx;
@ -157,8 +152,8 @@ int dtls_alloc_selfsigned(struct tls **tlsp, const char *aor,
/* Generate self-signed certificate */
err = tls_gen_selfsigned_cert(tls, aor);
if (err) {
DEBUG_WARNING("failed to generate certificate (%s): %m\n",
aor, err);
warning("dtls: failed to generate certificate (%s): %m\n",
aor, err);
goto out;
}
@ -175,8 +170,8 @@ int dtls_alloc_selfsigned(struct tls **tlsp, const char *aor,
}
if (0 != SSL_CTX_set_tlsext_use_srtp(tls->ctx, srtp_profiles)) {
DEBUG_WARNING("could not enable SRTP for profiles '%s'\n",
srtp_profiles);
warning("dtls: could not enable SRTP for profiles '%s'\n",
srtp_profiles);
err = ENOSYS;
goto out;
}

+ 10
- 15
modules/dtls_srtp/srtp.c View File

@ -13,11 +13,6 @@
#include "dtls_srtp.h"
#define DEBUG_MODULE "dtls_srtp"
#define DEBUG_LEVEL 5
#include <re_dbg.h>
struct srtp_stream {
srtp_policy_t policy;
srtp_t srtp;
@ -118,10 +113,10 @@ static bool send_handler(int *err, struct sa *dst, struct mbuf *mb, void *arg)
}
if (err_status_ok != e) {
DEBUG_WARNING("send: failed to protect %s-packet"
" with %d bytes (%H)\n",
is_rtcp_packet(mb) ? "RTCP" : "RTP",
len, errstatus_print, e);
warning("srtp: send: failed to protect %s-packet"
" with %d bytes (%H)\n",
is_rtcp_packet(mb) ? "RTCP" : "RTP",
len, errstatus_print, e);
*err = EPROTO;
return false;
}
@ -152,10 +147,10 @@ static bool recv_handler(struct sa *src, struct mbuf *mb, void *arg)
}
if (e != err_status_ok) {
DEBUG_WARNING("recv: failed to unprotect %s-packet"
" with %d bytes (%H)\n",
is_rtcp_packet(mb) ? "RTCP" : "RTP",
len, errstatus_print, e);
warning("srtp: recv: failed to unprotect %s-packet"
" with %d bytes (%H)\n",
is_rtcp_packet(mb) ? "RTCP" : "RTP",
len, errstatus_print, e);
return true; /* error - drop packet */
}
@ -195,7 +190,7 @@ int srtp_stream_add(struct srtp_stream **sp, const char *profile,
crypto_policy_set_aes_cm_128_hmac_sha1_32(&s->policy.rtcp);
}
else {
DEBUG_WARNING("unsupported profile: %s\n", profile);
warning("srtp: unsupported profile: %s\n", profile);
err = ENOSYS;
goto out;
}
@ -207,7 +202,7 @@ int srtp_stream_add(struct srtp_stream **sp, const char *profile,
e = srtp_create(&s->srtp, &s->policy);
if (err_status_ok != e) {
s->srtp = NULL;
DEBUG_WARNING("srtp_create() failed. e=%d\n", e);
warning("srtp: srtp_create() failed. e=%d\n", e);
err = ENOMEM;
goto out;
}

+ 7
- 11
modules/dtls_srtp/tls_udp.c View File

@ -8,14 +8,10 @@
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <re.h>
#include <baresip.h>
#include "dtls_srtp.h"
#define DEBUG_MODULE "tls_udp"
#define DEBUG_LEVEL 5
#include <re_dbg.h>
/* note: shadow struct in dtls.c */
struct tls {
SSL_CTX *ctx;
@ -81,7 +77,7 @@ static int bio_write(BIO *b, const char *buf, int len)
err = udp_send_helper(tc->us, &tc->peer, mb, tc->uh);
if (err) {
DEBUG_WARNING("udp_send_helper: %m\n", err);
warning("dtls: udp_send_helper: %m\n", err);
}
mem_deref(mb);
@ -179,8 +175,8 @@ static int get_srtp_key_info(const struct dtls_flow *tc, char *name, size_t sz,
keymatexportlen = (int)(kl + sl)*2;
if (keymatexportlen != 60) {
DEBUG_WARNING("expected 60 bits, but keying material is %d\n",
keymatexportlen);
warning("dtls: expected 60 bits, but keying material is %d\n",
keymatexportlen);
return EINVAL;
}
@ -257,7 +253,7 @@ static bool recv_handler(struct sa *src, struct mbuf *mb, void *arg)
err = get_srtp_key_info(flow, profile, sizeof(profile),
&client_key, &server_key);
if (err) {
DEBUG_WARNING("SRTP key info: %m\n", err);
warning("dtls: SRTP key info: %m\n", err);
return true;
}
@ -340,8 +336,8 @@ int dtls_flow_start(struct dtls_flow *flow, const struct sa *peer, bool active)
ERR_clear_error();
if (ssl_err != SSL_ERROR_WANT_READ) {
DEBUG_WARNING("SSL_connect() failed"
" (err=%d)\n", ssl_err);
warning("dtls: SSL_connect() failed"
" (err=%d)\n", ssl_err);
}
}

+ 8
- 2
modules/dtmfio/dtmfio.c View File

@ -52,6 +52,7 @@
* + Clean up build output so there aren't errors regarding unused vars
*/
#include <unistd.h>
#include <stdio.h>
#include <re.h>
#include <baresip.h>
@ -65,6 +66,9 @@ static const char *DTMF_OUT = "/tmp/dtmf.out";
static void dtmf_handler(struct call *call, char key, void *arg)
{
(void)call;
(void)arg;
if ( key != 0 ) {
fprintf(fd, "%c", key);
fflush(fd);
@ -78,6 +82,10 @@ static void ua_event_handler(struct ua *ua,
const char *prm,
void *arg )
{
(void)ua;
(void)prm;
(void)arg;
if ( ev == UA_EVENT_CALL_ESTABLISHED ) {
fprintf(fd, "E");
fflush(fd);
@ -88,8 +96,6 @@ static void ua_event_handler(struct ua *ua,
fprintf(fd, "F");
fflush(fd);
}
return;
}

+ 6
- 19
modules/evdev/evdev.c View File

@ -14,11 +14,6 @@
#include "print.h"
#define DEBUG_MODULE "evdev"
#define DEBUG_LEVEL 5
#include <re_dbg.h>
/* Note:
*
* KEY_NUMERIC_xyz added in linux kernel 2.6.28
@ -186,29 +181,21 @@ static void evdev_fd_handler(int flags, void *arg)
/* This might happen if you unplug a USB device */
if (flags & FD_EXCEPT) {
DEBUG_WARNING("fd handler: FD_EXCEPT - device unplugged?\n");
warning("evdev: fd handler: FD_EXCEPT - device unplugged?\n");
evdev_close(st);
return;
}
if (FD_READ != flags) {
DEBUG_WARNING("fd_handler: unexpected flags 0x%02x\n", flags);
return;
}
n = read(st->fd, evv, sizeof(evv));
if (n < (int) sizeof(struct input_event)) {
DEBUG_WARNING("event: short read (%m)\n", errno);
warning("evdev: event: short read (%m)\n", errno);
return;
}
for (i = 0; i < (int) (n / sizeof(struct input_event)); i++) {
const struct input_event *ev = &evv[i];
DEBUG_INFO("Event: type %u, code %u, value %d\n",
ev->type, ev->code, ev->value);
if (EV_KEY != ev->type)
continue;
@ -220,8 +207,8 @@ static void evdev_fd_handler(int flags, void *arg)
if (1 == ev->value) {
const int ascii = code2ascii(modifier, ev->code);
if (-1 == ascii) {
DEBUG_WARNING("unhandled key code %u\n",
ev->code);
warning("evdev: unhandled key code %u\n",
ev->code);
}
else
reportkey(st, ascii);
@ -259,7 +246,7 @@ static int evdev_alloc(struct ui_st **stp, struct ui_prm *prm,
/* grab the event device to prevent it from propagating
its events to the regular keyboard driver */
if (-1 == ioctl(st->fd, EVIOCGRAB, (void *)1)) {
DEBUG_WARNING("ioctl EVIOCGRAB on %s (%m)\n", dev, errno);
warning("evdev: ioctl EVIOCGRAB on %s (%m)\n", dev, errno);
}
#endif
@ -296,7 +283,7 @@ static int buzz(const struct ui_st *st, int value)
n = write(st->fd, &ev, sizeof(ev));
if (n < 0) {
DEBUG_WARNING("output: write fd=%d (%m)\n", st->fd, errno);
warning("evdev: output: write fd=%d (%m)\n", st->fd, errno);
}
return errno;

+ 4
- 9
modules/evdev/print.c View File

@ -10,16 +10,11 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/input.h>
#include <re_types.h>
#include <re_fmt.h>
#include <re.h>
#include <baresip.h>
#include "print.h"
#define DEBUG_MODULE "evdev"
#define DEBUG_LEVEL 5
#include <re_dbg.h>
#define test_bit(bit, array) (array[bit/8] & (1<<(bit%8)))
@ -36,7 +31,7 @@ void print_name(int fd)
perror("evdev ioctl");
}
DEBUG_NOTICE("evdev device name: %s\n", name);
info("evdev: device name: %s\n", name);
}
@ -52,7 +47,7 @@ void print_events(int fd)
memset(evtype_bitmask, 0, sizeof(evtype_bitmask));
if (ioctl(fd, EVIOCGBIT(0, EV_MAX), evtype_bitmask) < 0) {
DEBUG_WARNING("evdev ioctl EVIOCGBIT (%m)\n", errno);
warning("evdev: ioctl EVIOCGBIT (%m)\n", errno);
return;
}

+ 1
- 12
modules/g722/g722.c View File

@ -12,11 +12,6 @@
#include <spandsp.h>
#define DEBUG_MODULE "g722"
#define DEBUG_LEVEL 5
#include <re_dbg.h>
/*
http://www.soft-switch.org/spandsp-modules.html
*/
@ -76,7 +71,6 @@ static int encode_update(struct auenc_state **aesp,
return ENOMEM;
if (!g722_encode_init(&st->enc, G722_BITRATE_64k, 0)) {
DEBUG_WARNING("g722_encode_init failed\n");
err = EPROTO;
goto out;
}
@ -109,7 +103,6 @@ static int decode_update(struct audec_state **adsp,
return ENOMEM;
if (!g722_decode_init(&st->dec, G722_BITRATE_64k, 0)) {
DEBUG_WARNING("g722_decode_init failed\n");
err = EPROTO;
goto out;
}
@ -131,11 +124,9 @@ static int encode(struct auenc_state *st, uint8_t *buf, size_t *len,
n = g722_encode(&st->enc, buf, sampv, (int)sampc);
if (n <= 0) {
DEBUG_WARNING("g722_encode: len=%d\n", n);
return EPROTO;
}
else if (n > (int)*len) {
DEBUG_WARNING("encode: wrote %d > %d buf\n", n, *len);
return EOVERFLOW;
}
@ -154,10 +145,8 @@ static int decode(struct audec_state *st, int16_t *sampv, size_t *sampc,
return EINVAL;
n = g722_decode(&st->dec, sampv, buf, (int)len);
if (n < 0) {
DEBUG_WARNING("g722_decode: n=%d\n", n);
if (n < 0)
return EPROTO;
}
*sampc = n;

+ 22
- 33
modules/gst/gst.c View File

@ -15,11 +15,6 @@
#include "gst.h"
#define DEBUG_MODULE "gst"
#define DEBUG_LEVEL 5
#include <re_dbg.h>
/**
* Defines the Gstreamer state
*
@ -43,6 +38,7 @@ struct ausrc_st {
struct ausrc_prm prm; /**< Read parameters */
struct aubuf *aubuf; /**< Packet buffer */
uint32_t psize; /**< Packet size in bytes */
size_t sampc;
/* Gstreamer */
char *uri;
@ -61,7 +57,6 @@ static void *thread(void *arg)
struct ausrc_st *st = arg;
/* Now set to playing and iterate. */
DEBUG_NOTICE("Setting pipeline to PLAYING\n");
gst_element_set_state(st->pipeline, GST_STATE_PLAYING);
while (st->run) {
@ -86,8 +81,6 @@ static gboolean bus_watch_handler(GstBus *bus, GstMessage *msg, gpointer data)
switch (GST_MESSAGE_TYPE(msg)) {
case GST_MESSAGE_EOS:
DEBUG_NOTICE("End-of-stream\n");
/* XXX decrementing repeat count? */
/* Re-start stream */
@ -103,9 +96,9 @@ static gboolean bus_watch_handler(GstBus *bus, GstMessage *msg, gpointer data)
case GST_MESSAGE_ERROR:
gst_message_parse_error(msg, &err, &d);
DEBUG_WARNING("Error: %d(%m) message=%s\n", err->code,
err->code, err->message);
DEBUG_WARNING("Debug: %s\n", d);
warning("gst: Error: %d(%m) message=%s\n", err->code,
err->code, err->message);
warning("gst: Debug: %s\n", d);
g_free(d);
@ -123,7 +116,7 @@ static gboolean bus_watch_handler(GstBus *bus, GstMessage *msg, gpointer data)
gst_message_parse_tag(msg, &tag_list);
if (gst_tag_list_get_string(tag_list, GST_TAG_TITLE, &title)) {
DEBUG_NOTICE("Title: %s\n", title);
info("gst: title: %s\n", title);
g_free(title);
}
break;
@ -150,33 +143,33 @@ static void format_check(struct ausrc_st *st, GstStructure *s)
gst_structure_get_boolean(s, "signed", &sign);
if ((int)st->prm.srate != rate) {
DEBUG_WARNING("expected %u Hz (got %u Hz)\n", st->prm.srate,
rate);
warning("gst: expected %u Hz (got %u Hz)\n", st->prm.srate,
rate);
}
if (st->prm.ch != channels) {
DEBUG_WARNING("expected %d channels (got %d)\n",
st->prm.ch, channels);
warning("gst: expected %d channels (got %d)\n",
st->prm.ch, channels);
}
if (16 != width) {
DEBUG_WARNING("expected 16-bit width (got %d)\n", width);
warning("gst: expected 16-bit width (got %d)\n", width);
}
if (!sign) {
DEBUG_WARNING("expected signed 16-bit format\n");
warning("gst: expected signed 16-bit format\n");
}
}
static void play_packet(struct ausrc_st *st)
{
uint8_t buf[st->psize];
int16_t buf[st->sampc];
/* timed read from audio-buffer */
if (aubuf_get(st->aubuf, st->prm.ptime, buf, sizeof(buf)))
if (aubuf_get_samp(st->aubuf, st->prm.ptime, buf, st->sampc))
return;
/* call read handler */
if (st->rh)
st->rh(buf, sizeof(buf), st->arg);
st->rh(buf, st->sampc, st->arg);
}
@ -195,7 +188,7 @@ static void packet_handler(struct ausrc_st *st, GstBuffer *buffer)
err = aubuf_write(st->aubuf, GST_BUFFER_DATA(buffer),
GST_BUFFER_SIZE(buffer));
if (err) {
DEBUG_WARNING("aubuf_write: %m\n", err);
warning("gst: aubuf_write: %m\n", err);
}
/* Empty buffer now */
@ -274,7 +267,7 @@ static int gst_setup(struct ausrc_st *st)
st->pipeline = gst_pipeline_new("pipeline");
if (!st->pipeline) {
DEBUG_WARNING("failed to create pipeline element\n");
warning("gst: failed to create pipeline element\n");
return ENOMEM;
}
@ -282,7 +275,7 @@ static int gst_setup(struct ausrc_st *st)
st->source = gst_element_factory_make("playbin", "source");
if (!st->source) {
DEBUG_WARNING("failed to create playbin source element\n");
warning("gst: failed to create playbin source element\n");
return ENOMEM;
}
@ -292,7 +285,7 @@ static int gst_setup(struct ausrc_st *st)
st->capsfilt = gst_element_factory_make("capsfilter", NULL);
if (!st->capsfilt) {
DEBUG_WARNING("failed to create capsfilter element\n");
warning("gst: failed to create capsfilter element\n");
return ENOMEM;
}
@ -300,7 +293,7 @@ static int gst_setup(struct ausrc_st *st)
st->sink = gst_element_factory_make("fakesink", "sink");
if (!st->sink) {
DEBUG_WARNING("failed to create sink element\n");
warning("gst: failed to create sink element\n");
return ENOMEM;
}
@ -360,7 +353,6 @@ static int gst_alloc(struct ausrc_st **stp, struct ausrc *as,
ausrc_read_h *rh, ausrc_error_h *errh, void *arg)
{
struct ausrc_st *st;
unsigned sampc;
int err;
(void)ctx;
@ -371,8 +363,6 @@ static int gst_alloc(struct ausrc_st **stp, struct ausrc *as,
if (!prm)
return EINVAL;
prm->fmt = AUFMT_S16LE;
st = mem_zalloc(sizeof(*st), gst_destructor);
if (!st)
return ENOMEM;
@ -388,9 +378,8 @@ static int gst_alloc(struct ausrc_st **stp, struct ausrc *as,
st->prm = *prm;
sampc = prm->srate * prm->ch * prm->ptime / 1000;
st->psize = 2 * sampc;
st->sampc = prm->srate * prm->ch * prm->ptime / 1000;
st->psize = 2 * st->sampc;
err = aubuf_alloc(&st->aubuf, st->psize, 0);
if (err)
@ -425,7 +414,7 @@ static int mod_gst_init(void)
s = gst_version_string();
DEBUG_NOTICE("init: %s\n", s);
info("gst: init: %s\n", s);
g_free(s);

+ 7
- 0
modules/ice/ice.c View File

@ -227,6 +227,13 @@ static int media_start(struct mnat_sess *sess, struct mnat_media *m)
break;
case ICE_MODE_LITE:
err = icem_lite_set_default_candidates(m->icem);
if (err) {
warning("ice: could not set"
" default candidates (%m)\n", err);
return err;
}
gather_handler(0, 0, NULL, m);
break;
}

+ 27
- 30
modules/natbd/natbd.c View File

@ -7,12 +7,9 @@
#include <baresip.h>
#define DEBUG_MODULE "natbd"
#define DEBUG_LEVEL 5
#include <re_dbg.h>
/*
/**
* @defgroup natbd natbd
*
* NAT Behavior Discovery Using STUN (RFC 5780)
*
* This module is only for diagnostics purposes and does not affect
@ -129,7 +126,7 @@ static void nat_mapping_handler(int err, enum nat_type type, void *arg)
return;
if (err) {
DEBUG_WARNING("NAT mapping failed (%m)\n", err);
warning("natbd: NAT mapping failed (%m)\n", err);
goto out;
}
@ -155,7 +152,7 @@ static void nat_filtering_handler(int err, enum nat_type type, void *arg)
return;
if (err) {
DEBUG_WARNING("NAT filtering failed (%m)\n", err);
warning("natbd: NAT filtering failed (%m)\n", err);
goto out;
}
@ -182,7 +179,7 @@ static void nat_lifetime_handler(int err,
++natbd->n_nl;
if (err) {
DEBUG_WARNING("nat_lifetime_handler: (%m)\n", err);
warning("natbd: nat_lifetime_handler: (%m)\n", err);
return;
}
@ -206,12 +203,12 @@ static void nat_genalg_handler(int err, uint16_t scode, const char *reason,
return;
if (err) {
DEBUG_WARNING("Generic ALG detection failed: %m\n", err);
warning("natbd: Generic ALG detection failed: %m\n", err);
goto out;
}
else if (scode) {
DEBUG_WARNING("Generic ALG detection failed: %u %s\n",
scode, reason);
warning("natbd: Generic ALG detection failed: %u %s\n",
scode, reason);
goto out;
}
@ -255,8 +252,8 @@ static int natbd_start(struct natbd *natbd)
nat_hairpinning_handler, natbd);
err |= nat_hairpinning_start(natbd->nh);
if (err) {
DEBUG_WARNING("nat_hairpinning_start() failed (%m)\n",
err);
warning("natbd: nat_hairpinning_start() failed (%m)\n",
err);
}
}
@ -266,8 +263,8 @@ static int natbd_start(struct natbd *natbd)
nat_mapping_handler, natbd);
err |= nat_mapping_start(natbd->nm);
if (err) {
DEBUG_WARNING("nat_mapping_start() failed (%m)\n",
err);
warning("natbd: nat_mapping_start() failed (%m)\n",
err);
}
}
@ -280,8 +277,8 @@ static int natbd_start(struct natbd *natbd)
natbd);
err |= nat_filtering_start(natbd->nf);
if (err) {
DEBUG_WARNING("nat_filtering_start() (%m)\n",
err);
warning("natbd: nat_filtering_start() (%m)\n",
err);
}
}
}
@ -292,12 +289,12 @@ static int natbd_start(struct natbd *natbd)
nat_genalg_handler, natbd);
if (err) {
DEBUG_WARNING("natbd_init: %m\n", err);
warning("natbd: natbd_init: %m\n", err);
}
err |= nat_genalg_start(natbd-