From 99e9bf9ca7d65994312ad615132650176d430d6f Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Mon, 25 Dec 2017 16:56:44 +0100 Subject: audio: update doxygen comments --- src/audio.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/audio.c b/src/audio.c index 17eb5f6..f0d6720 100644 --- a/src/audio.c +++ b/src/audio.c @@ -81,7 +81,7 @@ struct autx { struct auenc_state *enc; /**< Audio encoder state (optional) */ struct aubuf *aubuf; /**< Packetize outgoing stream */ size_t aubuf_maxsz; /**< Maximum aubuf size in [bytes] */ - volatile bool aubuf_started; + volatile bool aubuf_started; /**< Aubuf was started flag */ struct auresamp resamp; /**< Optional resampler for DSP */ struct list filtl; /**< Audio filters in encoding order */ struct mbuf *mb; /**< Buffer for outgoing RTP packets */ @@ -90,14 +90,14 @@ struct autx { int16_t *sampv_rs; /**< Sample buffer for resampler */ uint32_t ptime; /**< Packet time for sending */ uint64_t ts_ext; /**< Ext. Timestamp for outgoing RTP */ - uint32_t ts_base; + uint32_t ts_base; /**< First timestamp sent */ uint32_t ts_tel; /**< Timestamp for Telephony Events */ size_t psize; /**< Packet size for sending */ bool marker; /**< Marker bit for outgoing RTP */ bool muted; /**< Audio source is muted */ int cur_key; /**< Currently transmitted event */ - enum aufmt src_fmt; - bool need_conv; + enum aufmt src_fmt; /**< Sample format for audio source */ + bool need_conv; /**< Sample format conversion needed */ struct { uint64_t aubuf_overrun; @@ -137,7 +137,7 @@ struct aurx { struct audec_state *dec; /**< Audio decoder state (optional) */ struct aubuf *aubuf; /**< Incoming audio buffer */ size_t aubuf_maxsz; /**< Maximum aubuf size in [bytes] */ - volatile bool aubuf_started; + volatile bool aubuf_started; /**< Aubuf was started flag */ struct auresamp resamp; /**< Optional resampler for DSP */ struct list filtl; /**< Audio filters in decoding order */ char device[64]; /**< Audio player device name */ @@ -147,9 +147,9 @@ struct aurx { int pt; /**< Payload type for incoming RTP */ double level_last; bool level_set; - enum aufmt play_fmt; - bool need_conv; - struct timestamp_recv ts_recv; + enum aufmt play_fmt; /**< Sample format for audio playback*/ + bool need_conv; /**< Sample format conversion needed */ + struct timestamp_recv ts_recv;/**< Receive timestamp state */ uint64_t n_discard; struct { @@ -309,7 +309,7 @@ static inline double calc_ptime(size_t nsamp, uint32_t srate, uint8_t channels) /** - * Get the DSP samplerate for an audio-codec (exception for G.722 and MPA) + * Get the DSP samplerate for an audio-codec */ static inline uint32_t get_srate(const struct aucodec *ac) { -- cgit v1.2.3 From d6572244e3ff5193a2e215547c12794070fff2d5 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Mon, 25 Dec 2017 22:29:56 +0100 Subject: update README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8edddee..78baad3 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,7 @@ Distributed under BSD license - Command-line console over UDP/TCP - Command line interface (CLI) - Simple configuration files + - MQTT (Message Queue Telemetry Transport) module ## Building -- cgit v1.2.3 From bab01601a80e138264cac3c7755b6a3b01aa917b Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 30 Dec 2017 16:19:12 +0100 Subject: mk: avahi does not depend on avcodec --- mk/modules.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/modules.mk b/mk/modules.mk index 9211dfd..24c4b14 100644 --- a/mk/modules.mk +++ b/mk/modules.mk @@ -308,10 +308,10 @@ MODULES += avcodec ifneq ($(USE_AVFORMAT),) MODULES += avformat endif +endif ifneq ($(USE_AVAHI),) MODULES += avahi endif -endif ifneq ($(USE_BV32),) MODULES += bv32 endif -- cgit v1.2.3 From db657ef309e201587c182d1a9d45fde2417150f5 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 30 Dec 2017 17:44:46 +0100 Subject: avformat: use av_dump_format() --- modules/avformat/avformat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/avformat/avformat.c b/modules/avformat/avformat.c index 68ef088..0a2b473 100644 --- a/modules/avformat/avformat.c +++ b/modules/avformat/avformat.c @@ -314,7 +314,7 @@ static int alloc(struct vidsrc_st **stp, const struct vidsrc *vs, } #if 0 - dump_format(st->ic, 0, dev, 0); + av_dump_format(st->ic, 0, dev, 0); #endif for (i=0; iic->nb_streams; i++) { -- cgit v1.2.3 From a1e912235a55232327dd1b708aca25195a73a1f7 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 30 Dec 2017 23:12:38 +0100 Subject: vidutil: new file for video utility functions --- src/core.h | 3 ++- src/srcs.mk | 1 + src/video.c | 38 +------------------------------------- src/vidutil.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 38 deletions(-) create mode 100644 src/vidutil.c diff --git a/src/core.h b/src/core.h index a390e0c..3c1ba2b 100644 --- a/src/core.h +++ b/src/core.h @@ -35,7 +35,8 @@ enum { /** Media constants */ enum { - AUDIO_BANDWIDTH = 128000 /**< Bandwidth for audio in bits/s */ + AUDIO_BANDWIDTH = 128000, /**< Bandwidth for audio in bits/s */ + VIDEO_SRATE = 90000, /**< Sampling rate for video */ }; diff --git a/src/srcs.mk b/src/srcs.mk index a35e0d8..4e9a2a7 100644 --- a/src/srcs.mk +++ b/src/srcs.mk @@ -46,6 +46,7 @@ SRCS += vidcodec.c SRCS += vidfilt.c SRCS += vidisp.c SRCS += vidsrc.c +SRCS += vidutil.c endif ifneq ($(STATIC),) diff --git a/src/video.c b/src/video.c index f191215..5c1b8bb 100644 --- a/src/video.c +++ b/src/video.c @@ -25,7 +25,6 @@ enum { - SRATE = 90000, MAX_MUTED_FRAMES = 3, }; @@ -980,7 +979,7 @@ int video_start(struct video *v, const char *peer) return err; } - stream_set_srate(v->strm, SRATE, SRATE); + stream_set_srate(v->strm, VIDEO_SRATE, VIDEO_SRATE); if (vidisp_find(baresip_vidispl(), NULL)) { err = set_vidisp(&v->vrx); @@ -1384,38 +1383,3 @@ void video_set_devicename(struct video *v, const char *src, const char *disp) str_ncpy(v->vtx.device, src, sizeof(v->vtx.device)); str_ncpy(v->vrx.device, disp, sizeof(v->vrx.device)); } - - -/** - * Calculate the RTP timestamp from Presentation Time Stamp (PTS) - * or Decoding Time Stamp (DTS) and framerate. - * - * @note The calculated RTP Timestamp may wrap around. - * - * @param pts Presentation Time Stamp (PTS) - * @param fps Framerate in [frames per second] - * - * @return RTP Timestamp - */ -uint32_t video_calc_rtp_timestamp(int64_t pts, unsigned fps) -{ - uint64_t rtp_ts; - - if (!fps) - return 0; - - rtp_ts = ((uint64_t)SRATE * pts) / fps; - - return (uint32_t)rtp_ts; -} - - -double video_calc_seconds(uint32_t rtp_ts) -{ - double timestamp; - - /* convert from RTP clockrate to seconds */ - timestamp = (double)rtp_ts / (double)SRATE; - - return timestamp; -} diff --git a/src/vidutil.c b/src/vidutil.c new file mode 100644 index 0000000..b55f216 --- /dev/null +++ b/src/vidutil.c @@ -0,0 +1,52 @@ +/** + * @file vidutil.c Video utility functions + * + * Copyright (C) 2017 Creytiv.com + */ + +#include +#include +#include +#include "core.h" + + +/** + * Calculate the RTP timestamp from Presentation Time Stamp (PTS) + * or Decoding Time Stamp (DTS) and framerate. + * + * @note The calculated RTP Timestamp may wrap around. + * + * @param pts Presentation Time Stamp (PTS) + * @param fps Framerate in [frames per second] + * + * @return RTP Timestamp + */ +uint32_t video_calc_rtp_timestamp(int64_t pts, unsigned fps) +{ + uint64_t rtp_ts; + + if (!fps) + return 0; + + rtp_ts = ((uint64_t)VIDEO_SRATE * pts) / fps; + + return (uint32_t)rtp_ts; +} + + +/** + * Calculate the timestamp in seconds from the RTP timestamp. + * + * @param rtp_ts RTP Timestamp + * + * @return Timestamp in seconds + */ +double video_calc_seconds(uint32_t rtp_ts) +{ + double timestamp; + + /* convert from RTP clockrate to seconds */ + timestamp = (double)rtp_ts / (double)VIDEO_SRATE; + + return timestamp; +} -- cgit v1.2.3 From 63bb32c8eaf92ca816ed91e638acb714fb155d6a Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 30 Dec 2017 23:28:38 +0100 Subject: account: password in SIP uri is now deprecated ^^^^^^^^ deprecated please use the "auth_pass" parameter instead: ;auth_pass=xxx --- src/account.c | 3 +++ test/account.c | 6 ++++-- test/sip/sipsrv.c | 2 +- test/ua.c | 18 +++++++++++------- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/account.c b/src/account.c index 2a99e58..d7ab9c0 100644 --- a/src/account.c +++ b/src/account.c @@ -388,6 +388,9 @@ int account_alloc(struct account **accp, const char *sipaddr) /* optional password prompt */ if (pl_isset(&acc->laddr.uri.password)) { + warning("account: username:password is now deprecated" + " please use ;auth_pass=xxx instead\n"); + err = re_sdprintf(&acc->auth_pass, "%H", uri_password_unescape, &acc->laddr.uri.password); diff --git a/test/account.c b/test/account.c index bf03b03..cb62acd 100644 --- a/test/account.c +++ b/test/account.c @@ -15,9 +15,10 @@ static const char str[] = - "\"Mr User\" " + "\"Mr User\" " ";answermode=auto" ";auth_user=xuser" + ";auth_pass=pass" ";outbound=\"sip:edge.domain.com\"" ";ptime=10" ";regint=600" @@ -45,7 +46,7 @@ int test_account(void) TEST_STRCMP("Mr User", 7, addr->dname.p, addr->dname.l); TEST_STRCMP("sip", 3, addr->uri.scheme.p, addr->uri.scheme.l); TEST_STRCMP("user", 4, addr->uri.user.p, addr->uri.user.l); - TEST_STRCMP("pass", 4, addr->uri.password.p, addr->uri.password.l); + TEST_STRCMP("", 0, addr->uri.password.p, addr->uri.password.l); TEST_STRCMP("domain.com", 10, addr->uri.host.p, addr->uri.host.l); ASSERT_EQ(0, addr->uri.params.l); ASSERT_TRUE(addr->params.l > 0); @@ -53,6 +54,7 @@ int test_account(void) /* verify all decoded parameters */ ASSERT_TRUE(ANSWERMODE_AUTO == account_answermode(acc)); ASSERT_STREQ("xuser", account_auth_user(acc)); + ASSERT_STREQ("pass", account_auth_pass(acc)); ASSERT_STREQ("sip:edge.domain.com", account_outbound(acc, 0)); ASSERT_TRUE(NULL == account_outbound(acc, 1)); ASSERT_TRUE(NULL == account_outbound(acc, 333)); diff --git a/test/sip/sipsrv.c b/test/sip/sipsrv.c index 374ea3b..1174893 100644 --- a/test/sip/sipsrv.c +++ b/test/sip/sipsrv.c @@ -322,7 +322,7 @@ int sip_server_uri(struct sip_server *srv, char *uri, size_t sz, return err; /* NOTE: angel brackets needed to parse ;transport parameter */ - if (re_snprintf(uri, sz, "", + if (re_snprintf(uri, sz, "", &laddr, sip_transp_param(tp)) < 0) return ENOMEM; diff --git a/test/ua.c b/test/ua.c index 4f04e4f..0621e92 100644 --- a/test/ua.c +++ b/test/ua.c @@ -293,7 +293,7 @@ static int reg_dns(enum sip_transp tp) t.srvc = server_count; /* NOTE: angel brackets needed to parse ;transport parameter */ - if (re_snprintf(aor, sizeof(aor), "", + if (re_snprintf(aor, sizeof(aor), "", domain, sip_transp_name(tp)) < 0) return ENOMEM; @@ -362,7 +362,7 @@ int test_ua_register_dns(void) #define USER "alfredh" -#define PASS "pass%40word" /* NOTE: url-encoded */ +#define PASS "pass@word" #define DOMAIN "localhost" static int reg_auth(enum sip_transp tp) @@ -384,7 +384,7 @@ static int reg_auth(enum sip_transp tp) TEST_ERR(err); err = user_add(domain_lookup(t.srvv[0], DOMAIN)->ht_usr, - "alfredh", "pass@word", DOMAIN); + USER, PASS, DOMAIN); TEST_ERR(err); t.srvv[0]->auth_enabled = true; @@ -395,10 +395,12 @@ static int reg_auth(enum sip_transp tp) /* NOTE: angel brackets needed to parse ;transport parameter */ if (re_snprintf(aor, sizeof(aor), - ";outbound=\"sip:%J;transport=%s\"", + "" + ";auth_pass=%s" + ";outbound=\"sip:%J;transport=%s\"", USER, - PASS, DOMAIN, + PASS, &laddr, sip_transp_name(tp)) < 0) return ENOMEM; @@ -540,8 +542,10 @@ static int reg_auth_dns(enum sip_transp tp) t.srvc = server_count; /* NOTE: angel brackets needed to parse ;transport parameter */ - if (re_snprintf(aor, sizeof(aor), "", - username, password, domain, sip_transp_name(tp)) < 0) + if (re_snprintf(aor, sizeof(aor), + ";auth_pass=%s", + username, domain, sip_transp_name(tp), + password) < 0) return ENOMEM; /* -- cgit v1.2.3 From 82133bf1731ab6bcb65ce05e4fcdc2e36cfe0d95 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Mon, 1 Jan 2018 22:44:47 +0100 Subject: video: add some more details to video_debug --- src/video.c | 55 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/src/video.c b/src/video.c index 5c1b8bb..527f8a6 100644 --- a/src/video.c +++ b/src/video.c @@ -1303,6 +1303,43 @@ void video_sdp_attr_decode(struct video *v) } +static int vtx_debug(struct re_printf *pf, const struct vtx *vtx) +{ + int err = 0; + + err |= re_hprintf(pf, " tx: encode: %s %s\n", + vtx->vc ? vtx->vc->name : "none", + vtx->frame ? vidfmt_name(vtx->frame->fmt) : "?"); + err |= re_hprintf(pf, " source: %s %u x %u, fps=%d\n", + vtx->vsrc ? vidsrc_get(vtx->vsrc)->name : "none", + vtx->vsrc_size.w, + vtx->vsrc_size.h, vtx->vsrc_prm.fps); + err |= re_hprintf(pf, " skipc=%u\n", vtx->skipc); + err |= re_hprintf(pf, " time = %.3f sec\n", + video_calc_seconds(vtx->ts_max - vtx->ts_min)); + + return err; +} + + +static int vrx_debug(struct re_printf *pf, const struct vrx *vrx) +{ + int err = 0; + + err |= re_hprintf(pf, " rx: decode: %s\n", + vrx->vc ? vrx->vc->name : "none"); + err |= re_hprintf(pf, " vidisp: %s %u x %u\n", + vrx->vidisp ? vidisp_get(vrx->vidisp)->name : "none", + vrx->size.w, vrx->size.h); + err |= re_hprintf(pf, " n_intra=%u, n_picup=%u\n", + vrx->n_intra, vrx->n_picup); + err |= re_hprintf(pf, " time = %.3f sec\n", + video_calc_seconds(vrx->ts_max - vrx->ts_min)); + + return err; +} + + int video_debug(struct re_printf *pf, const struct video *v) { const struct vtx *vtx; @@ -1318,20 +1355,10 @@ int video_debug(struct re_printf *pf, const struct video *v) err = re_hprintf(pf, "\n--- Video stream ---\n"); err |= re_hprintf(pf, " started: %s\n", v->started ? "yes" : "no"); - err |= re_hprintf(pf, " tx: %u x %u, fps=%d\n", - vtx->vsrc_size.w, - vtx->vsrc_size.h, vtx->vsrc_prm.fps); - err |= re_hprintf(pf, " skipc=%u\n", vtx->skipc); - err |= re_hprintf(pf, " time = %.3f sec\n", - video_calc_seconds(vtx->ts_max - vtx->ts_min)); - - err |= re_hprintf(pf, " rx: %u x %u\n", vrx->size.w, vrx->size.h); - err |= re_hprintf(pf, " pt=%d\n", vrx->pt_rx); - - err |= re_hprintf(pf, " n_intra=%u, n_picup=%u\n", - vrx->n_intra, vrx->n_picup); - err |= re_hprintf(pf, " time = %.3f sec\n", - video_calc_seconds(vrx->ts_max - vrx->ts_min)); + err |= vtx_debug(pf, vtx); + err |= vrx_debug(pf, vrx); + if (err) + return err; if (!list_isempty(baresip_vidfiltl())) { err |= vtx_print_pipeline(pf, vtx); -- cgit v1.2.3 From 4b4920f542554755b3fc7af5fddbfef801bd8d2e Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Fri, 5 Jan 2018 14:43:03 +0100 Subject: timer: add tmr_jiffies_usec --- src/core.h | 7 +++++++ src/srcs.mk | 1 + src/timer.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 src/timer.c diff --git a/src/core.h b/src/core.h index 3c1ba2b..6e48e5d 100644 --- a/src/core.h +++ b/src/core.h @@ -540,3 +540,10 @@ static inline int timestamp_wrap(uint32_t ts_new, uint32_t ts_old) return 0; } + + +/* + * Timer + */ + +uint64_t tmr_jiffies_usec(void); diff --git a/src/srcs.mk b/src/srcs.mk index 4e9a2a7..86cbe8c 100644 --- a/src/srcs.mk +++ b/src/srcs.mk @@ -34,6 +34,7 @@ SRCS += rtpkeep.c SRCS += sdp.c SRCS += sipreq.c SRCS += stream.c +SRCS += timer.c SRCS += ua.c SRCS += ui.c diff --git a/src/timer.c b/src/timer.c new file mode 100644 index 0000000..bb49671 --- /dev/null +++ b/src/timer.c @@ -0,0 +1,52 @@ +/** + * @file timer.c Timer functions + * + * Copyright (C) 2010 Creytiv.com + */ + +#define _BSD_SOURCE 1 +#define _DEFAULT_SOURCE 1 +#include +#include +#include +#include "core.h" + + +/** + * Get the timer jiffies in microseconds [us] + * + * @return Jiffies in [us] + */ +uint64_t tmr_jiffies_usec(void) +{ + uint64_t jfs; + +#if defined(WIN32) + FILETIME ft; + ULARGE_INTEGER li; + GetSystemTimeAsFileTime(&ft); + li.LowPart = ft.dwLowDateTime; + li.HighPart = ft.dwHighDateTime; + jfs = li.QuadPart/10; +#else + struct timespec now; + clockid_t clock_id; + +#if defined (CLOCK_BOOTTIME) + clock_id = CLOCK_BOOTTIME; +#else + clock_id = CLOCK_MONOTONIC; +#endif + + if (0 != clock_gettime(clock_id, &now)) { + warning("timer: clock_gettime() failed (%m)\n", errno); + return 0; + } + + jfs = (long)now.tv_sec * (uint64_t)1000000; + jfs += now.tv_nsec / (uint64_t)1000; + +#endif + + return jfs; +} -- cgit v1.2.3 From 51111f4747355c0f15e62c5626a47d94fc92ccba Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Fri, 5 Jan 2018 15:57:37 +0100 Subject: audio: add function to set encoder bitrate - auenc API updated with bitrate in bits/s - new command to set encoder bitrate: /aubitrate 128000 --- include/baresip.h | 2 ++ modules/menu/menu.c | 22 ++++++++++++++++++++++ modules/opus/encode.c | 4 ++++ src/audio.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+) diff --git a/include/baresip.h b/include/baresip.h index 746a95e..6887c5c 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -826,6 +826,7 @@ const struct vidisp *vidisp_find(const struct list *vidispl, const char *name); /** Audio Codec parameters */ struct auenc_param { uint32_t ptime; /**< Packet time in [ms] */ + uint32_t bitrate;/**< Wanted bitrate in [bit/s] */ }; struct auenc_state; @@ -986,6 +987,7 @@ void audio_encoder_cycle(struct audio *audio); int audio_level_get(const struct audio *au, double *level); int audio_debug(struct re_printf *pf, const struct audio *a); struct stream *audio_strm(const struct audio *a); +int audio_set_bitrate(struct audio *au, uint32_t bitrate); /* diff --git a/modules/menu/menu.c b/modules/menu/menu.c index c7f1646..0ea87b7 100644 --- a/modules/menu/menu.c +++ b/modules/menu/menu.c @@ -774,6 +774,27 @@ static int set_current_call(struct re_printf *pf, void *arg) } +static int set_audio_bitrate(struct re_printf *pf, void *arg) +{ + struct cmd_arg *carg = arg; + struct call *call; + uint32_t bitrate = atoi(carg->prm); + int err; + + call = ua_call(uag_cur()); + if (call) { + err = re_hprintf(pf, "setting audio bitrate: %u bps\n", + bitrate); + audio_set_bitrate(call_audio(call), bitrate); + } + else { + err = re_hprintf(pf, "call not found\n"); + } + + return err; +} + + static const struct cmd callcmdv[] = { {"reinvite", 'I', 0, "Send re-INVITE", call_reinvite }, {"resume", 'X', 0, "Call resume", cmd_call_resume }, @@ -784,6 +805,7 @@ static const struct cmd callcmdv[] = { {"hold", 'x', 0, "Call hold", cmd_call_hold }, {"", 'H', 0, "Hold previous call", hold_prev_call }, {"", 'L', 0, "Resume previous call",hold_prev_call }, +{"aubitrate", 0, CMD_PRM, "Set audio bitrate", set_audio_bitrate }, #ifdef USE_VIDEO {"video_cycle", 'E', 0, "Cycle video encoder", call_videoenc_cycle }, diff --git a/modules/opus/encode.c b/modules/opus/encode.c index 7ee1ca2..6723ac8 100644 --- a/modules/opus/encode.c +++ b/modules/opus/encode.c @@ -134,6 +134,10 @@ int opus_encode_update(struct auenc_state **aesp, const struct aucodec *ac, fch = prm.stereo ? OPUS_AUTO : 1; vbr = prm.cbr ? 0 : 1; + /* override local bitrate */ + if (param && param->bitrate) + prm.bitrate = param->bitrate; + (void)opus_encoder_ctl(aes->enc, OPUS_SET_MAX_BANDWIDTH(srate2bw(prm.srate))); (void)opus_encoder_ctl(aes->enc, OPUS_SET_BITRATE(prm.bitrate)); diff --git a/src/audio.c b/src/audio.c index f0d6720..cc6e41f 100644 --- a/src/audio.c +++ b/src/audio.c @@ -1602,6 +1602,7 @@ int audio_encoder_set(struct audio *a, const struct aucodec *ac, struct auenc_param prm; prm.ptime = tx->ptime; + prm.bitrate = 0; /* auto */ err = ac->encupdh(&tx->enc, ac, &prm, params); if (err) { @@ -2079,3 +2080,44 @@ int audio_print_rtpstat(struct re_printf *pf, const struct audio *a) return err; } + + +int audio_set_bitrate(struct audio *au, uint32_t bitrate) +{ + struct autx *tx; + const struct aucodec *ac; + int err; + + if (!au) + return EINVAL; + + tx = &au->tx; + + ac = tx->ac; + + info("audio: set bitrate for encoder '%s' to %u bits/s\n", + ac ? ac->name : "?", + bitrate); + + if (ac) { + + if (ac->encupdh) { + struct auenc_param prm; + + prm.ptime = tx->ptime; + prm.bitrate = bitrate; + + err = ac->encupdh(&tx->enc, ac, &prm, NULL); + if (err) { + warning("audio: encupdh error: %m\n", err); + return err; + } + } + + } + else { + info("audio: set_bitrate: no audio encoder\n"); + } + + return 0; +} -- cgit v1.2.3 From 27f75c0831439d9727865aafcef0254311f4692d Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Fri, 5 Jan 2018 19:21:51 +0100 Subject: auloop: initialize bitrate field in struct auenc_param --- modules/auloop/auloop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/auloop/auloop.c b/modules/auloop/auloop.c index 8324a88..347f130 100644 --- a/modules/auloop/auloop.c +++ b/modules/auloop/auloop.c @@ -186,7 +186,7 @@ static void error_handler(int err, const char *str, void *arg) static void start_codec(struct audio_loop *al, const char *name) { - struct auenc_param prm = {PTIME}; + struct auenc_param prm = {PTIME, 0}; int err; al->ac = aucodec_find(baresip_aucodecl(), name, -- cgit v1.2.3 From 4d6e0dfbad11b6d8f65d15ac5a1743cc8d2afc4d Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 6 Jan 2018 10:36:15 +0100 Subject: account: update template with auth_pass parameter --- modules/account/account.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/account/account.c b/modules/account/account.c index c972908..25e4c40 100644 --- a/modules/account/account.c +++ b/modules/account/account.c @@ -39,12 +39,13 @@ static int account_write_template(const char *file) if (!f) return errno; - login = pass = sys_username(); + login = sys_username(); if (!login) { login = "user"; - pass = "pass"; } + pass = "PASSWORD"; + domain = net_domain(baresip_network()); if (!domain) domain = "domain"; @@ -53,7 +54,7 @@ static int account_write_template(const char *file) "#\n" "# SIP accounts - one account per line\n" "#\n" - "# Displayname ;addr-params\n" "#\n" "# uri-params:\n" @@ -63,6 +64,7 @@ static int account_write_template(const char *file) "# ;answermode={manual,early,auto}\n" "# ;audio_codecs=speex/16000,pcma,...\n" "# ;auth_user=username\n" + "# ;auth_pass=password\n" "# ;mediaenc={srtp,srtp-mand,srtp-mandf" ",dtls_srtp,zrtp}\n" "# ;medianat={stun,turn,ice}\n" @@ -88,7 +90,7 @@ static int account_write_template(const char *file) "[2001:df8:0:16:216:6fff:fe91:614c]:5070" ";transport=tcp>\n" "#\n" - "#\n", login, pass, domain); + "#;auth_pass=%s\n", login, domain, pass); if (r < 0) err = ENOMEM; -- cgit v1.2.3 From 96b9b6c0d94606b346bc67b5ce78bb20f2e28769 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 6 Jan 2018 16:20:25 +0100 Subject: audio: sample format for audio encoder/decoder config: auenc_format s16 # s16, float audec_format s16 # s16, float modules: only opus module supports this for now. default is s16 --- include/baresip.h | 10 +++++ modules/opus/decode.c | 25 +++++++++++ modules/opus/encode.c | 25 +++++++++++ modules/opus/opus.c | 2 + modules/opus/opus.h | 5 +++ src/audio.c | 117 +++++++++++++++++++++++++++++++++++++++----------- src/config.c | 6 +++ 7 files changed, 165 insertions(+), 25 deletions(-) diff --git a/include/baresip.h b/include/baresip.h index 6887c5c..526354d 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -205,6 +205,8 @@ struct config_audio { bool level; /**< Enable audio level indication */ int src_fmt; /**< Audio source sample format */ int play_fmt; /**< Audio playback sample format */ + int enc_fmt; /**< Audio encoder sample format */ + int dec_fmt; /**< Audio decoder sample format */ }; #ifdef USE_VIDEO @@ -838,11 +840,17 @@ typedef int (auenc_update_h)(struct auenc_state **aesp, struct auenc_param *prm, const char *fmtp); typedef int (auenc_encode_h)(struct auenc_state *aes, uint8_t *buf, size_t *len, const int16_t *sampv, size_t sampc); +typedef int (auenc_encode_fmt_h)(struct auenc_state *aes, + uint8_t *buf, size_t *len, + int fmt, const void *sampv, size_t sampc); typedef int (audec_update_h)(struct audec_state **adsp, const struct aucodec *ac, const char *fmtp); typedef int (audec_decode_h)(struct audec_state *ads, int16_t *sampv, size_t *sampc, const uint8_t *buf, size_t len); +typedef int (audec_decode_fmt_h)(struct audec_state *ads, + int fmt, void *sampv, size_t *sampc, + const uint8_t *buf, size_t len); typedef int (audec_plc_h)(struct audec_state *ads, int16_t *sampv, size_t *sampc); @@ -861,6 +869,8 @@ struct aucodec { audec_plc_h *plch; sdp_fmtp_enc_h *fmtp_ench; sdp_fmtp_cmp_h *fmtp_cmph; + auenc_encode_fmt_h *encfmth; + audec_decode_fmt_h *decfmth; }; void aucodec_register(struct list *aucodecl, struct aucodec *ac); diff --git a/modules/opus/decode.c b/modules/opus/decode.c index f2d67b1..a09f2ff 100644 --- a/modules/opus/decode.c +++ b/modules/opus/decode.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include "opus.h" @@ -84,6 +85,30 @@ int opus_decode_frm(struct audec_state *ads, int16_t *sampv, size_t *sampc, } +int opus_decode_format_frm(struct audec_state *ads, + int fmt, void *sampv, size_t *sampc, + const uint8_t *buf, size_t len) +{ + int n; + + if (!ads || !sampv || !sampc || !buf) + return EINVAL; + if (fmt != AUFMT_FLOAT) + return ENOTSUP; + + n = opus_decode_float(ads->dec, buf, (opus_int32)len, + sampv, (int)(*sampc/ads->ch), 0); + if (n < 0) { + warning("opus: decode error: %s\n", opus_strerror(n)); + return EPROTO; + } + + *sampc = n * ads->ch; + + return 0; +} + + int opus_decode_pkloss(struct audec_state *ads, int16_t *sampv, size_t *sampc) { int n; diff --git a/modules/opus/encode.c b/modules/opus/encode.c index 6723ac8..7450d92 100644 --- a/modules/opus/encode.c +++ b/modules/opus/encode.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include "opus.h" @@ -189,3 +190,27 @@ int opus_encode_frm(struct auenc_state *aes, uint8_t *buf, size_t *len, return 0; } + + +int opus_encode_format_frm(struct auenc_state *aes, uint8_t *buf, size_t *len, + int fmt, const void *sampv, size_t sampc) +{ + opus_int32 n; + + if (!aes || !buf || !len || !sampv) + return EINVAL; + + if (fmt != AUFMT_FLOAT) + return ENOTSUP; + + n = opus_encode_float(aes->enc, sampv, (int)(sampc/aes->ch), + buf, (opus_int32)(*len)); + if (n < 0) { + warning("opus: encode error: %s\n", opus_strerror((int)n)); + return EPROTO; + } + + *len = n; + + return 0; +} diff --git a/modules/opus/opus.c b/modules/opus/opus.c index 7acccec..8346680 100644 --- a/modules/opus/opus.c +++ b/modules/opus/opus.c @@ -69,6 +69,8 @@ static struct aucodec opus = { .decupdh = opus_decode_update, .dech = opus_decode_frm, .plch = opus_decode_pkloss, + .encfmth = opus_encode_format_frm, + .decfmth = opus_decode_format_frm, }; diff --git a/modules/opus/opus.h b/modules/opus/opus.h index d521652..9e79bd5 100644 --- a/modules/opus/opus.h +++ b/modules/opus/opus.h @@ -20,6 +20,8 @@ int opus_encode_update(struct auenc_state **aesp, const struct aucodec *ac, struct auenc_param *prm, const char *fmtp); int opus_encode_frm(struct auenc_state *aes, uint8_t *buf, size_t *len, const int16_t *sampv, size_t sampc); +int opus_encode_format_frm(struct auenc_state *aes, uint8_t *buf, size_t *len, + int fmt, const void *sampv, size_t sampc); /* Decode */ @@ -27,6 +29,9 @@ int opus_decode_update(struct audec_state **adsp, const struct aucodec *ac, const char *fmtp); int opus_decode_frm(struct audec_state *ads, int16_t *sampv, size_t *sampc, const uint8_t *buf, size_t len); +int opus_decode_format_frm(struct audec_state *ads, + int fmt, void *sampv, size_t *sampc, + const uint8_t *buf, size_t len); int opus_decode_pkloss(struct audec_state *st, int16_t *sampv, size_t *sampc); diff --git a/src/audio.c b/src/audio.c index cc6e41f..0a18454 100644 --- a/src/audio.c +++ b/src/audio.c @@ -86,7 +86,7 @@ struct autx { struct list filtl; /**< Audio filters in encoding order */ struct mbuf *mb; /**< Buffer for outgoing RTP packets */ char device[64]; /**< Audio source device name */ - int16_t *sampv; /**< Sample buffer */ + void *sampv; /**< Sample buffer */ int16_t *sampv_rs; /**< Sample buffer for resampler */ uint32_t ptime; /**< Packet time for sending */ uint64_t ts_ext; /**< Ext. Timestamp for outgoing RTP */ @@ -97,6 +97,7 @@ struct autx { bool muted; /**< Audio source is muted */ int cur_key; /**< Currently transmitted event */ enum aufmt src_fmt; /**< Sample format for audio source */ + enum aufmt enc_fmt; bool need_conv; /**< Sample format conversion needed */ struct { @@ -141,13 +142,14 @@ struct aurx { struct auresamp resamp; /**< Optional resampler for DSP */ struct list filtl; /**< Audio filters in decoding order */ char device[64]; /**< Audio player device name */ - int16_t *sampv; /**< Sample buffer */ + void *sampv; /**< Sample buffer */ int16_t *sampv_rs; /**< Sample buffer for resampler */ uint32_t ptime; /**< Packet time for receiving */ int pt; /**< Payload type for incoming RTP */ double level_last; bool level_set; enum aufmt play_fmt; /**< Sample format for audio playback*/ + enum aufmt dec_fmt; bool need_conv; /**< Sample format conversion needed */ struct timestamp_recv ts_recv;/**< Receive timestamp state */ uint64_t n_discard; @@ -448,7 +450,20 @@ static void encode_rtp_send(struct audio *a, struct autx *tx, len = mbuf_get_space(tx->mb); - err = tx->ac->ench(tx->enc, mbuf_buf(tx->mb), &len, sampv, sampc); + if (tx->enc_fmt == AUFMT_S16LE) { + err = tx->ac->ench(tx->enc, mbuf_buf(tx->mb), &len, + sampv, sampc); + } + else if (tx->ac->encfmth) { + err = tx->ac->encfmth(tx->enc, mbuf_buf(tx->mb), &len, + tx->enc_fmt, sampv, sampc); + } + else { + warning("audio: sample format not supported by encoder (%s)\n", + aufmt_name(tx->enc_fmt)); + return; + } + if ((err & 0xffff0000) == 0x00010000) { /* MPA needs some special treatment here */ tx->ts_ext = err & 0xffff; @@ -514,7 +529,7 @@ static void poll_aubuf_tx(struct audio *a) /* timed read from audio-buffer */ - if (tx->src_fmt == AUFMT_S16LE) { + if (tx->src_fmt == tx->enc_fmt) { aubuf_read(tx->aubuf, (uint8_t *)tx->sampv, num_bytes); } @@ -545,6 +560,13 @@ static void poll_aubuf_tx(struct audio *a) if (tx->resamp.resample) { size_t sampc_rs = AUDIO_SAMPSZ; + if (tx->enc_fmt != AUFMT_S16LE) { + warning("audio: skipping resampler due to" + " incompatible format (%s)\n", + aufmt_name(tx->enc_fmt)); + return; + } + err = auresamp(&tx->resamp, tx->sampv_rs, &sampc_rs, tx->sampv, sampc); @@ -555,15 +577,23 @@ static void poll_aubuf_tx(struct audio *a) sampc = sampc_rs; } - /* Process exactly one audio-frame in list order */ - for (le = tx->filtl.head; le; le = le->next) { - struct aufilt_enc_st *st = le->data; + if (tx->enc_fmt == AUFMT_S16LE) { - if (st->af && st->af->ench) - err |= st->af->ench(st, sampv, &sampc); + /* Process exactly one audio-frame in list order */ + for (le = tx->filtl.head; le; le = le->next) { + struct aufilt_enc_st *st = le->data; + + if (st->af && st->af->ench) + err |= st->af->ench(st, sampv, &sampc); + } + if (err) { + warning("audio: aufilter encode: %m\n", err); + } } - if (err) { - warning("audio: aufilter encode: %m\n", err); + else if (!list_isempty(&tx->filtl)) { + warning("audio: skipping audio-filters due to" + " incompatible format (%s)\n", + aufmt_name(tx->enc_fmt)); } /* Encode and send */ @@ -726,7 +756,7 @@ static void handle_telev(struct audio *a, struct mbuf *mb) static int aurx_stream_decode(struct aurx *rx, struct mbuf *mb) { size_t sampc = AUDIO_SAMPSZ; - int16_t *sampv; + void *sampv; struct le *le; int err = 0; @@ -735,10 +765,25 @@ static int aurx_stream_decode(struct aurx *rx, struct mbuf *mb) return 0; if (mbuf_get_left(mb)) { - err = rx->ac->dech(rx->dec, rx->sampv, &sampc, - mbuf_buf(mb), mbuf_get_left(mb)); + + if (rx->dec_fmt == AUFMT_S16LE) { + err = rx->ac->dech(rx->dec, rx->sampv, &sampc, + mbuf_buf(mb), mbuf_get_left(mb)); + + } + else if (rx->ac->decfmth) { + err = rx->ac->decfmth(rx->dec, + rx->dec_fmt, rx->sampv, &sampc, + mbuf_buf(mb), mbuf_get_left(mb)); + } + else { + warning("audio: sample format not supported" + " by decoder (%s)\n", + aufmt_name(rx->dec_fmt)); + return ENOTSUP; + } } - else if (rx->ac->plch) { + else if (rx->ac->plch && rx->dec_fmt == AUFMT_S16LE) { sampc = rx->ac->srate * rx->ac->ch * rx->ptime / 1000; err = rx->ac->plch(rx->dec, rx->sampv, &sampc); @@ -754,12 +799,19 @@ static int aurx_stream_decode(struct aurx *rx, struct mbuf *mb) goto out; } - /* Process exactly one audio-frame in reverse list order */ - for (le = rx->filtl.tail; le; le = le->prev) { - struct aufilt_dec_st *st = le->data; + if (rx->dec_fmt == AUFMT_S16LE) { + /* Process exactly one audio-frame in reverse list order */ + for (le = rx->filtl.tail; le; le = le->prev) { + struct aufilt_dec_st *st = le->data; - if (st->af && st->af->dech) - err |= st->af->dech(st, rx->sampv, &sampc); + if (st->af && st->af->dech) + err |= st->af->dech(st, rx->sampv, &sampc); + } + } + else if (!list_isempty(&rx->filtl)) { + warning("audio: skipping audio-filters due to" + " incompatible format (%s)\n", + aufmt_name(rx->dec_fmt)); } if (!rx->aubuf) @@ -771,6 +823,13 @@ static int aurx_stream_decode(struct aurx *rx, struct mbuf *mb) if (rx->resamp.resample) { size_t sampc_rs = AUDIO_SAMPSZ; + if (rx->dec_fmt != AUFMT_S16LE) { + warning("audio: skipping resampler due to" + " incompatible format (%s)\n", + aufmt_name(rx->dec_fmt)); + return ENOTSUP; + } + err = auresamp(&rx->resamp, rx->sampv_rs, &sampc_rs, rx->sampv, sampc); @@ -789,15 +848,17 @@ static int aurx_stream_decode(struct aurx *rx, struct mbuf *mb) rx->stats.aubuf_overrun); } - if (rx->play_fmt == AUFMT_S16LE) { - err = aubuf_write_samp(rx->aubuf, sampv, sampc); + if (rx->play_fmt == rx->dec_fmt) { + + size_t num_bytes = sampc * aufmt_sample_size(rx->play_fmt); + + err = aubuf_write(rx->aubuf, sampv, num_bytes); if (err) goto out; } else { /* Convert from 16-bit to auplay format */ - void *tmp_sampv; size_t num_bytes = sampc * aufmt_sample_size(rx->play_fmt); @@ -1057,6 +1118,9 @@ int audio_alloc(struct audio **ap, const struct stream_param *stream_prm, tx->src_fmt = cfg->audio.src_fmt; rx->play_fmt = cfg->audio.play_fmt; + tx->enc_fmt = cfg->audio.enc_fmt; + rx->dec_fmt = cfg->audio.dec_fmt; + err = stream_alloc(&a->strm, stream_prm, &cfg->avt, call, sdp_sess, "audio", label, mnat, mnat_sess, menc, menc_sess, @@ -1101,8 +1165,11 @@ int audio_alloc(struct audio **ap, const struct stream_param *stream_prm, } tx->mb = mbuf_alloc(STREAM_PRESZ + 4096); - tx->sampv = mem_zalloc(AUDIO_SAMPSZ * sizeof(int16_t), NULL); - rx->sampv = mem_zalloc(AUDIO_SAMPSZ * sizeof(int16_t), NULL); + tx->sampv = mem_zalloc(AUDIO_SAMPSZ * aufmt_sample_size(tx->enc_fmt), + NULL); + + rx->sampv = mem_zalloc(AUDIO_SAMPSZ * aufmt_sample_size(rx->dec_fmt), + NULL); if (!tx->mb || !tx->sampv || !rx->sampv) { err = ENOMEM; goto out; diff --git a/src/config.c b/src/config.c index ce748d3..1d010e0 100644 --- a/src/config.c +++ b/src/config.c @@ -58,6 +58,8 @@ static struct config core_config = { false, AUFMT_S16LE, AUFMT_S16LE, + AUFMT_S16LE, + AUFMT_S16LE, }, #ifdef USE_VIDEO @@ -270,6 +272,8 @@ int config_parse_conf(struct config *cfg, const struct conf *conf) conf_get_aufmt(conf, "ausrc_format", &cfg->audio.src_fmt); conf_get_aufmt(conf, "auplay_format", &cfg->audio.play_fmt); + conf_get_aufmt(conf, "auenc_format", &cfg->audio.enc_fmt); + conf_get_aufmt(conf, "audec_format", &cfg->audio.dec_fmt); #ifdef USE_VIDEO /* Video */ @@ -541,6 +545,8 @@ static int core_config_template(struct re_printf *pf, const struct config *cfg) "audio_level\t\tno\n" "ausrc_format\t\ts16\t\t# s16, float, ..\n" "auplay_format\t\ts16\t\t# s16, float, ..\n" + "auenc_format\t\ts16\t\t# s16, float, ..\n" + "audec_format\t\ts16\t\t# s16, float, ..\n" , poll_method_name(poll_method_best()), cfg->call.local_timeout, -- cgit v1.2.3 From 88adec838a1684277412430eccce4b420766c881 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 6 Jan 2018 16:27:13 +0100 Subject: audio: add sample formats to debug --- src/audio.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/audio.c b/src/audio.c index 0a18454..b5ce913 100644 --- a/src/audio.c +++ b/src/audio.c @@ -1959,9 +1959,10 @@ int audio_debug(struct re_printf *pf, const struct audio *a) err = re_hprintf(pf, "\n--- Audio stream ---\n"); - err |= re_hprintf(pf, " tx: %H ptime=%ums\n", + err |= re_hprintf(pf, " tx: encode: %H ptime=%ums %s\n", aucodec_print, tx->ac, - tx->ptime); + tx->ptime, + aufmt_name(tx->enc_fmt)); err |= re_hprintf(pf, " aubuf: %H" " (cur %.2fms, max %.2fms, or %llu, ur %llu)\n", aubuf_debug, tx->aubuf, @@ -1973,14 +1974,15 @@ int audio_debug(struct re_printf *pf, const struct audio *a) tx->ausrc_prm.ch), tx->stats.aubuf_overrun, tx->stats.aubuf_underrun); - + err |= re_hprintf(pf, " source: %s\n", + aufmt_name(tx->src_fmt)); err |= re_hprintf(pf, " time = %.3f sec\n", autx_calc_seconds(tx)); err |= re_hprintf(pf, - " rx: %H\n" + " rx: decode: %H %s\n" " ptime=%ums pt=%d\n", - aucodec_print, rx->ac, + aucodec_print, rx->ac, aufmt_name(rx->dec_fmt), rx->ptime, rx->pt); err |= re_hprintf(pf, " aubuf: %H" " (cur %.2fms, max %.2fms, or %llu, ur %llu)\n", @@ -1994,7 +1996,7 @@ int audio_debug(struct re_printf *pf, const struct audio *a) rx->stats.aubuf_overrun, rx->stats.aubuf_underrun ); - + err |= re_hprintf(pf, " player: %s\n", aufmt_name(rx->play_fmt)); err |= re_hprintf(pf, " n_discard:%llu\n", rx->n_discard); if (rx->level_set) { -- cgit v1.2.3 From 0a6d3066caa52060975537f81a352efe463a807a Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 6 Jan 2018 19:40:46 +0100 Subject: update some modules with new aucodec api --- modules/g711/g711.c | 4 ++-- modules/l16/l16.c | 16 ++++++++-------- modules/speex/speex.c | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/g711/g711.c b/modules/g711/g711.c index 7c01b61..d264153 100644 --- a/modules/g711/g711.c +++ b/modules/g711/g711.c @@ -98,12 +98,12 @@ static int pcma_decode(struct audec_state *ads, int16_t *sampv, static struct aucodec pcmu = { LE_INIT, "0", "PCMU", 8000, 8000, 1, NULL, - NULL, pcmu_encode, NULL, pcmu_decode, NULL, NULL, NULL + NULL, pcmu_encode, NULL, pcmu_decode, NULL, NULL, NULL, NULL, NULL }; static struct aucodec pcma = { LE_INIT, "8", "PCMA", 8000, 8000, 1, NULL, - NULL, pcma_encode, NULL, pcma_decode, NULL, NULL, NULL + NULL, pcma_encode, NULL, pcma_decode, NULL, NULL, NULL, NULL, NULL }; diff --git a/modules/l16/l16.c b/modules/l16/l16.c index 204a8f5..ce131a0 100644 --- a/modules/l16/l16.c +++ b/modules/l16/l16.c @@ -62,14 +62,14 @@ static int decode(struct audec_state *st, int16_t *sampv, size_t *sampc, /* See RFC 3551 */ static struct aucodec l16v[NR_CODECS] = { -{LE_INIT, "10", "L16", 44100, 44100, 2, 0, 0, encode, 0, decode, 0, 0, 0}, -{LE_INIT, 0, "L16", 32000, 32000, 2, 0, 0, encode, 0, decode, 0, 0, 0}, -{LE_INIT, 0, "L16", 16000, 16000, 2, 0, 0, encode, 0, decode, 0, 0, 0}, -{LE_INIT, 0, "L16", 8000, 8000, 2, 0, 0, encode, 0, decode, 0, 0, 0}, -{LE_INIT, "11", "L16", 44100, 44100, 1, 0, 0, encode, 0, decode, 0, 0, 0}, -{LE_INIT, 0, "L16", 32000, 32000, 1, 0, 0, encode, 0, decode, 0, 0, 0}, -{LE_INIT, 0, "L16", 16000, 16000, 1, 0, 0, encode, 0, decode, 0, 0, 0}, -{LE_INIT, 0, "L16", 8000, 8000, 1, 0, 0, encode, 0, decode, 0, 0, 0}, +{LE_INIT, "10", "L16", 44100, 44100, 2, 0, 0, encode, 0, decode, 0, 0, 0,0,0}, +{LE_INIT, 0, "L16", 32000, 32000, 2, 0, 0, encode, 0, decode, 0, 0, 0,0,0}, +{LE_INIT, 0, "L16", 16000, 16000, 2, 0, 0, encode, 0, decode, 0, 0, 0,0,0}, +{LE_INIT, 0, "L16", 8000, 8000, 2, 0, 0, encode, 0, decode, 0, 0, 0,0,0}, +{LE_INIT, "11", "L16", 44100, 44100, 1, 0, 0, encode, 0, decode, 0, 0, 0,0,0}, +{LE_INIT, 0, "L16", 32000, 32000, 1, 0, 0, encode, 0, decode, 0, 0, 0,0,0}, +{LE_INIT, 0, "L16", 16000, 16000, 1, 0, 0, encode, 0, decode, 0, 0, 0,0,0}, +{LE_INIT, 0, "L16", 8000, 8000, 1, 0, 0, encode, 0, decode, 0, 0, 0,0,0}, }; diff --git a/modules/speex/speex.c b/modules/speex/speex.c index 33b52e2..66a7ff4 100644 --- a/modules/speex/speex.c +++ b/modules/speex/speex.c @@ -465,19 +465,19 @@ static struct aucodec speexv[] = { /* Stereo Speex */ {LE_INIT, 0, "speex", 32000, 32000, 2, speex_fmtp_wb, - encode_update, encode, decode_update, decode, pkloss, 0, 0}, + encode_update, encode, decode_update, decode, pkloss, 0, 0, 0, 0}, {LE_INIT, 0, "speex", 16000, 16000, 2, speex_fmtp_wb, - encode_update, encode, decode_update, decode, pkloss, 0, 0}, + encode_update, encode, decode_update, decode, pkloss, 0, 0, 0, 0}, {LE_INIT, 0, "speex", 8000, 8000, 2, speex_fmtp_nb, - encode_update, encode, decode_update, decode, pkloss, 0, 0}, + encode_update, encode, decode_update, decode, pkloss, 0, 0, 0, 0}, /* Standard Speex */ {LE_INIT, 0, "speex", 32000, 32000, 1, speex_fmtp_wb, - encode_update, encode, decode_update, decode, pkloss, 0, 0}, + encode_update, encode, decode_update, decode, pkloss, 0, 0, 0, 0}, {LE_INIT, 0, "speex", 16000, 16000, 1, speex_fmtp_wb, - encode_update, encode, decode_update, decode, pkloss, 0, 0}, + encode_update, encode, decode_update, decode, pkloss, 0, 0, 0, 0}, {LE_INIT, 0, "speex", 8000, 8000, 1, speex_fmtp_nb, - encode_update, encode, decode_update, decode, pkloss, 0, 0}, + encode_update, encode, decode_update, decode, pkloss, 0, 0, 0, 0}, }; -- cgit v1.2.3 From 9e7cc48e964ee6a094fe762c31e66bdfc1388ae7 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 7 Jan 2018 11:34:21 +0100 Subject: omx: minor fixes --- modules/omx/omx.c | 20 +++++++++++++------- modules/omx/omx.h | 4 ++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/modules/omx/omx.c b/modules/omx/omx.c index 6b08d19..13f3207 100644 --- a/modules/omx/omx.c +++ b/modules/omx/omx.c @@ -153,8 +153,11 @@ static void block_until_state_changed(OMX_HANDLETYPE hComponent, } -void omx_deinit(struct omx_state* st) +void omx_deinit(struct omx_state *st) { + if (!st) + return; + info("omx_deinit"); OMX_SendCommand(st->video_render, OMX_CommandStateSet, OMX_StateIdle, NULL); @@ -167,13 +170,15 @@ void omx_deinit(struct omx_state* st) } -void omx_display_disable(struct omx_state* st) +void omx_display_disable(struct omx_state *st) { - (void)st; - - #ifdef RASPBERRY_PI +#ifdef RASPBERRY_PI OMX_ERRORTYPE err; OMX_CONFIG_DISPLAYREGIONTYPE config; + + if (!st) + return; + memset(&config, 0, sizeof(OMX_CONFIG_DISPLAYREGIONTYPE)); config.nSize = sizeof(OMX_CONFIG_DISPLAYREGIONTYPE); config.nVersion.nVersion = OMX_VERSION; @@ -187,8 +192,9 @@ void omx_display_disable(struct omx_state* st) if (err != 0) { warning("omx_display_disable command failed"); } - - #endif +#else + (void)st; +#endif } diff --git a/modules/omx/omx.h b/modules/omx/omx.h index 13d8928..6691d95 100644 --- a/modules/omx/omx.h +++ b/modules/omx/omx.h @@ -41,6 +41,6 @@ int omx_display_input_buffer(struct omx_state* st, void** pbuf, uint32_t* plen); int omx_display_flush_buffer(struct omx_state* st); -int omx_display_enable(struct omx_state* st, +int omx_display_enable(struct omx_state *st, int width, int height, int stride); -void omx_display_disable(struct omx_state* st); +void omx_display_disable(struct omx_state *st); -- cgit v1.2.3 From 42b0d07efad8fe684159daa40b56b841e79f0343 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 7 Jan 2018 10:38:35 +0000 Subject: omx: use -isystem to avoid warning in system header files --- modules/omx/module.mk | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/omx/module.mk b/modules/omx/module.mk index 958a1a5..c7a796d 100644 --- a/modules/omx/module.mk +++ b/modules/omx/module.mk @@ -9,10 +9,11 @@ $(MOD)_SRCS += omx.c module.c ifneq ($(USE_OMX_RPI),) $(MOD)_CFLAGS := -DRASPBERRY_PI -DOMX_SKIP64BIT \ - -I/usr/local/include/interface/vmcs_host/linux/ \ - -I /usr/local/include/interface/vcos/pthreads/ \ - -I /opt/vc/include -I /opt/vc/include/interface/vmcs_host/linux \ - -I /opt/vc/include/interface/vcos/pthreads + -isystem /usr/local/include/interface/vmcs_host/linux/ \ + -isystem /usr/local/include/interface/vcos/pthreads/ \ + -isystem /opt/vc/include \ + -isystem /opt/vc/include/interface/vmcs_host/linux \ + -isystem /opt/vc/include/interface/vcos/pthreads $(MOD)_LFLAGS += -lvcos -lbcm_host -lopenmaxil -L /opt/vc/lib endif -- cgit v1.2.3 From adbae9ce7955e6c70ab90d173054b875831d456e Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 7 Jan 2018 10:58:32 +0000 Subject: omx: include bcm_host.h (ref #344) --- modules/omx/omx.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/omx/omx.c b/modules/omx/omx.c index 13f3207..16f38bf 100644 --- a/modules/omx/omx.c +++ b/modules/omx/omx.c @@ -5,6 +5,8 @@ * Copyright (C) 2016 - 2017 Jonathan Sieber */ +#define _POSIX_C_SOURCE 199309L + #include "omx.h" #include @@ -19,6 +21,11 @@ #include #include +#ifdef RASPBERRY_PI +#include +#endif + + /** * @defgroup omx omx * -- cgit v1.2.3 From abc990ae7290aad4c4c4e26dd1ac291ad9ac722a Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 7 Jan 2018 16:18:46 +0100 Subject: update copyright year to 2018 --- README.md | 2 +- docs/COPYING | 6 +++--- src/main.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 78baad3..286ba4d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ baresip README Baresip is a portable and modular SIP User-Agent with audio and video support. -Copyright (c) 2010 - 2017 Creytiv.com +Copyright (c) 2010 - 2018 Creytiv.com Distributed under BSD license diff --git a/docs/COPYING b/docs/COPYING index 938d6cc..7bcab4f 100644 --- a/docs/COPYING +++ b/docs/COPYING @@ -1,6 +1,6 @@ -Copyright (c) 2010 - 2017, Alfred E. Heggestad -Copyright (c) 2010 - 2017, Richard Aas -Copyright (c) 2010 - 2017, Creytiv.com +Copyright (c) 2010 - 2018, Alfred E. Heggestad +Copyright (c) 2010 - 2018, Richard Aas +Copyright (c) 2010 - 2018, Creytiv.com All rights reserved. diff --git a/src/main.c b/src/main.c index b789648..27683d4 100644 --- a/src/main.c +++ b/src/main.c @@ -78,7 +78,7 @@ int main(int argc, char *argv[]) int err; (void)re_fprintf(stdout, "baresip v%s" - " Copyright (C) 2010 - 2017" + " Copyright (C) 2010 - 2018" " Alfred E. Heggestad et al.\n", BARESIP_VERSION); -- cgit v1.2.3 From 369b0c0f0e96c529823a11cfc9ab55ce7ade4451 Mon Sep 17 00:00:00 2001 From: Jonathan Sieber Date: Sun, 7 Jan 2018 16:51:40 +0100 Subject: avcodec: Return EPROTO when encountering missing fragments in H264 stream, to trigger intra-frame request (#339) --- modules/avcodec/decode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/avcodec/decode.c b/modules/avcodec/decode.c index 77e6e77..badb192 100644 --- a/modules/avcodec/decode.c +++ b/modules/avcodec/decode.c @@ -333,6 +333,7 @@ int decode_h264(struct viddec_state *st, struct vidframe *frame, " ignoring NAL\n"); fragment_rewind(st); ++st->stats.n_lost; + return EPROTO; } st->frag_start = st->mb->pos; @@ -351,7 +352,7 @@ int decode_h264(struct viddec_state *st, struct vidframe *frame, if (!st->frag) { debug("avcodec: ignoring fragment\n"); ++st->stats.n_lost; - return 0; + return EPROTO; } if (seq_diff(st->frag_seq, seq) != 1) { @@ -359,7 +360,7 @@ int decode_h264(struct viddec_state *st, struct vidframe *frame, fragment_rewind(st); st->frag = false; ++st->stats.n_lost; - return 0; + return EPROTO; } } -- cgit v1.2.3 From e82f91f0301c4615b86ad85229b8a7eb6a564844 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Mon, 8 Jan 2018 09:54:09 +0100 Subject: reg: add display-name to SIP register --- src/reg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/reg.c b/src/reg.c index 23bb337..7756636 100644 --- a/src/reg.c +++ b/src/reg.c @@ -183,6 +183,7 @@ int reg_add(struct list *lst, struct ua *ua, int regid) int reg_register(struct reg *reg, const char *reg_uri, const char *params, uint32_t regint, const char *outbound) { + struct account *acc; const char *routev[1]; int err; @@ -191,10 +192,12 @@ int reg_register(struct reg *reg, const char *reg_uri, const char *params, reg->scode = 0; routev[0] = outbound; + acc = ua_account(reg->ua); reg->sipreg = mem_deref(reg->sipreg); err = sipreg_register(®->sipreg, uag_sip(), reg_uri, - ua_aor(reg->ua), ua_aor(reg->ua), + ua_aor(reg->ua), + acc ? acc->dispname : NULL, ua_aor(reg->ua), regint, ua_local_cuser(reg->ua), routev[0] ? routev : NULL, routev[0] ? 1 : 0, -- cgit v1.2.3 From 782ff0f986caab726afcd8424c63e9372409c5f8 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 17 Jan 2018 15:06:43 +0100 Subject: timer: add compile-time check for clock_gettime (#347) --- src/timer.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/timer.c b/src/timer.c index bb49671..472787e 100644 --- a/src/timer.c +++ b/src/timer.c @@ -6,7 +6,15 @@ #define _BSD_SOURCE 1 #define _DEFAULT_SOURCE 1 + +#ifdef HAVE_SYS_TIME_H +#include +#endif +#ifdef WIN32 +#include +#else #include +#endif #include #include #include "core.h" @@ -28,7 +36,7 @@ uint64_t tmr_jiffies_usec(void) li.LowPart = ft.dwLowDateTime; li.HighPart = ft.dwHighDateTime; jfs = li.QuadPart/10; -#else +#elif defined(HAVE_CLOCK_GETTIME) struct timespec now; clockid_t clock_id; @@ -46,6 +54,16 @@ uint64_t tmr_jiffies_usec(void) jfs = (long)now.tv_sec * (uint64_t)1000000; jfs += now.tv_nsec / (uint64_t)1000; +#else + struct timeval now; + + if (0 != gettimeofday(&now, NULL)) { + warning("timer: gettimeofday() failed (%m)\n", errno); + return 0; + } + + jfs = (long)now.tv_sec * (uint64_t)1000000; + jfs += now.tv_usec; #endif return jfs; -- cgit v1.2.3 From dd9ccaf01650d77e6ea7e90f6ca588711e554d3f Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 17 Jan 2018 18:46:43 +0100 Subject: selftest: add testcase for events --- src/event.c | 7 ++++++- test/event.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/main.c | 1 + test/srcs.mk | 1 + test/test.h | 1 + 5 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 test/event.c diff --git a/src/event.c b/src/event.c index b29ab8b..a489fa1 100644 --- a/src/event.c +++ b/src/event.c @@ -96,7 +96,12 @@ int event_encode_dict(struct odict *od, struct ua *ua, enum ua_event ev, err |= odict_entry_add(od, "type", ODICT_STRING, event_str); err |= odict_entry_add(od, "class", ODICT_STRING, event_class_name(ev)); - err |= odict_entry_add(od, "accountaor", ODICT_STRING, ua_aor(ua)); + + if (ua) { + err |= odict_entry_add(od, "accountaor", + ODICT_STRING, ua_aor(ua)); + } + if (err) goto out; diff --git a/test/event.c b/test/event.c new file mode 100644 index 0000000..563d5d3 --- /dev/null +++ b/test/event.c @@ -0,0 +1,55 @@ +/** + * @file test/event.c Baresip selftest -- event handling + * + * Copyright (C) 2010 Creytiv.com + */ +#include +#include +#include +#include "test.h" + + +int test_event(void) +{ + struct odict *od = NULL; + size_t i; + int err = 0; + + static const enum ua_event eventv[] = { + UA_EVENT_REGISTERING, + UA_EVENT_REGISTER_OK, + UA_EVENT_REGISTER_FAIL, + UA_EVENT_UNREGISTERING, + UA_EVENT_SHUTDOWN, + UA_EVENT_EXIT + /* .. more events .. */ + }; + + for (i=0; i= 2); + + /* verify the mandatory entries */ + entry = odict_lookup(od, "type"); + ASSERT_TRUE(entry != NULL); + ASSERT_EQ(ODICT_STRING, entry->type); + ASSERT_STREQ(uag_event_str(ev), entry->u.str); + + od = mem_deref(od); + } + + out: + mem_deref(od); + + return err; +} diff --git a/test/main.c b/test/main.c index e917f2d..09ff19e 100644 --- a/test/main.c +++ b/test/main.c @@ -44,6 +44,7 @@ static const struct test tests[] = { TEST(test_cmd_long), TEST(test_contact), TEST(test_cplusplus), + TEST(test_event), TEST(test_message), TEST(test_mos), TEST(test_network), diff --git a/test/srcs.mk b/test/srcs.mk index 0bcb6de..bdb0d0b 100644 --- a/test/srcs.mk +++ b/test/srcs.mk @@ -14,6 +14,7 @@ TEST_SRCS += call.c TEST_SRCS += cmd.c TEST_SRCS += contact.c TEST_SRCS += cplusplus.c +TEST_SRCS += event.c TEST_SRCS += message.c TEST_SRCS += mos.c TEST_SRCS += net.c diff --git a/test/test.h b/test/test.h index f276a8d..7977272 100644 --- a/test/test.h +++ b/test/test.h @@ -181,6 +181,7 @@ int test_account(void); int test_aulevel(void); int test_cmd(void); int test_cmd_long(void); +int test_event(void); int test_contact(void); int test_ua_alloc(void); int test_uag_find_param(void); -- cgit v1.2.3 From 67829d86c4c2d173807b532e97c09402415341c5 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 17 Jan 2018 18:47:47 +0100 Subject: event: fix memory leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit thanks to José Luis Millán who fixed it in his PR: https://github.com/alfredh/baresip/pull/346 --- src/event.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/event.c b/src/event.c index a489fa1..4d1304b 100644 --- a/src/event.c +++ b/src/event.c @@ -79,6 +79,8 @@ static int add_rtcp_stats(struct odict *od_parent, const struct rtcp_stats *rs) out: mem_deref(od); + mem_deref(tx); + mem_deref(rx); return err; } -- cgit v1.2.3 From 535fc124686c212be2ce6f1a646505a58879b190 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 17 Jan 2018 19:30:01 +0100 Subject: call: add call_id accessor --- include/baresip.h | 1 + src/call.c | 6 ++++++ test/call.c | 2 ++ 3 files changed, 9 insertions(+) diff --git a/include/baresip.h b/include/baresip.h index 526354d..ee2cdbf 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -113,6 +113,7 @@ void call_set_handlers(struct call *call, call_event_h *eh, 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_id(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); diff --git a/src/call.c b/src/call.c index 99bec4b..67b3c22 100644 --- a/src/call.c +++ b/src/call.c @@ -901,6 +901,12 @@ int call_sdp_get(const struct call *call, struct mbuf **descp, bool offer) } +const char *call_id(const struct call *call) +{ + return call ? sip_dialog_callid(sipsess_dialog(call->sess)) : NULL; +} + + const char *call_peeruri(const struct call *call) { return call ? call->peer_uri : NULL; diff --git a/test/call.c b/test/call.c index 34c5fd5..73f3ebd 100644 --- a/test/call.c +++ b/test/call.c @@ -176,6 +176,8 @@ static void event_handler(struct ua *ua, enum ua_event ev, case UA_EVENT_CALL_ESTABLISHED: ++ag->n_established; + ASSERT_TRUE(str_isset(call_id(call))); + /* are both agents established? */ if (ag->n_established >= f->exp_estab && ag->peer->n_established >= f->exp_estab) { -- cgit v1.2.3 From 308fd8dd1d373ab22c19697f16ca2f3cbf0307ad Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Fri, 19 Jan 2018 17:29:11 +0100 Subject: timer: include winsock2.h to avoid warning --- src/timer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/timer.c b/src/timer.c index 472787e..d12f650 100644 --- a/src/timer.c +++ b/src/timer.c @@ -11,6 +11,7 @@ #include #endif #ifdef WIN32 +#include #include #else #include -- cgit v1.2.3 From 1b622f6442a44e0ab1f9eea60e08a14d830697f3 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 24 Jan 2018 18:39:46 +0100 Subject: event: add call-id to JSON dict --- src/event.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/event.c b/src/event.c index 4d1304b..94db0d2 100644 --- a/src/event.c +++ b/src/event.c @@ -116,6 +116,7 @@ int event_encode_dict(struct odict *od, struct ua *ua, enum ua_event ev, err |= odict_entry_add(od, "direction", ODICT_STRING, dir); err |= odict_entry_add(od, "peeruri", ODICT_STRING, call_peeruri(call)); + err |= odict_entry_add(od, "id", ODICT_STRING, call_id(call)); if (err) goto out; } -- cgit v1.2.3 From 8fe9103440b47f43eade53bbbc1b4c3438fc0f98 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 24 Jan 2018 18:41:34 +0100 Subject: call: print error-string to reason --- src/call.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/call.c b/src/call.c index 67b3c22..404071b 100644 --- a/src/call.c +++ b/src/call.c @@ -1299,6 +1299,8 @@ static void sipsess_close_handler(int err, const struct sip_msg *msg, if (err) { info("%s: session closed: %m\n", call->peer_uri, err); + (void)re_snprintf(reason, sizeof(reason), "%m", err); + if (call->not) { (void)call_notify_sipfrag(call, 500, "%m", err); } -- cgit v1.2.3 From 9d0b0fec87691312ade86b4d330265b5ca59c997 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 27 Jan 2018 17:41:30 +0100 Subject: call: save session callid on the struct --- src/call.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/call.c b/src/call.c index 404071b..b6c9357 100644 --- a/src/call.c +++ b/src/call.c @@ -59,6 +59,7 @@ struct call { char *local_name; /**< Local display name */ char *peer_uri; /**< Peer SIP Address */ char *peer_name; /**< Peer display name */ + char *id; /**< Cached session call-id */ struct tmr tmr_inv; /**< Timer for incoming calls */ struct tmr tmr_dtmf; /**< Timer for incoming DTMF events */ time_t time_start; /**< Time when call started */ @@ -378,6 +379,7 @@ static void call_destructor(void *arg) tmr_cancel(&call->tmr_dtmf); mem_deref(call->sess); + mem_deref(call->id); mem_deref(call->local_uri); mem_deref(call->local_name); mem_deref(call->peer_uri); @@ -903,7 +905,7 @@ int call_sdp_get(const struct call *call, struct mbuf **descp, bool offer) const char *call_id(const struct call *call) { - return call ? sip_dialog_callid(sipsess_dialog(call->sess)) : NULL; + return call ? call->id : NULL; } @@ -946,10 +948,10 @@ int call_debug(struct re_printf *pf, const struct call *call) err |= re_hprintf(pf, " local_uri: %s <%s>\n" " peer_uri: %s <%s>\n" - " af=%s\n", + " af=%s id=%s\n", call->local_name, call->local_uri, call->peer_name, call->peer_uri, - net_af2name(call->af)); + net_af2name(call->af), call->id); err |= re_hprintf(pf, " direction: %s\n", call->outgoing ? "Outgoing" : "Incoming"); @@ -1429,6 +1431,11 @@ int call_accept(struct call *call, struct sipsess_sock *sess_sock, return err; } + err = str_dup(&call->id, + sip_dialog_callid(sipsess_dialog(call->sess))); + if (err) + return err; + set_state(call, STATE_INCOMING); /* New call */ @@ -1533,8 +1540,12 @@ static int send_invite(struct call *call) ua_print_supported, call->ua); if (err) { warning("call: sipsess_connect: %m\n", err); + return err; } + err = str_dup(&call->id, + sip_dialog_callid(sipsess_dialog(call->sess))); + /* save call setup timer */ call->time_conn = time(NULL); -- cgit v1.2.3 From dce37b83eaa6fd543664128bd75f680b418f0d41 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 28 Jan 2018 17:38:04 +0100 Subject: update account templates with new password syntax --- docs/examples/accounts | 6 +++--- modules/account/account.c | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/examples/accounts b/docs/examples/accounts index 2b4a39c..ca4f2a8 100644 --- a/docs/examples/accounts +++ b/docs/examples/accounts @@ -40,19 +40,19 @@ # # Use SIP Outbound over TCP, with ICE for Media NAT Traversal, and DTLS-SRTP for encryption # -;sipnat=outbound;outbound="sip:example.com;transport=tcp";medianat=ice;mediaenc=dtls_srtp +;sipnat=outbound;outbound="sip:example.com;transport=tcp";medianat=ice;mediaenc=dtls_srtp;auth_pass=pass # # Use ICE for Media NAT Traversal, using a specific STUN-server # -;medianat=ice;stunserver="stun:username:password@stunserver.org" +;medianat=ice;stunserver="stun:username:password@stunserver.org";auth_pass=pass # # Force audio-codec 'opus' and video-codec 'vp8' # -;audio_codecs=opus/48000/2;video_codecs=vp8 +;audio_codecs=opus/48000/2;video_codecs=vp8;auth_pass=pass # ... more examples can be added here ... diff --git a/modules/account/account.c b/modules/account/account.c index 25e4c40..74c047f 100644 --- a/modules/account/account.c +++ b/modules/account/account.c @@ -20,7 +20,7 @@ * Examples: \verbatim "User 1 with password prompt" - "User 2 with stored password" + "User 2 with stored password" ;auth_pass=pass "User 2 with ICE" ;medianat=ice "User 3 with IPv6" \endverbatim @@ -84,11 +84,13 @@ static int account_write_template(const char *file) "#\n" "# Examples:\n" "#\n" - "# \n" - "# \n" - "# " + ";auth_pass=secret\n" + "# " + ";auth_pass=secret\n" + "# \n" + ";transport=tcp>;auth_pass=secret\n" "#\n" "#;auth_pass=%s\n", login, domain, pass); if (r < 0) -- cgit v1.2.3 From 376796ffe68fb078c77ee7da435acb23fa6a3b3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Mon, 29 Jan 2018 15:21:39 +0100 Subject: ctrl_tcp module (#346) * ctrl_tcp module * ua: set a default reason for UA_EVENT_CALL_CLOSED on user hangup * ctrl_tcp: netstring * ctrl_tcp: fix typo * ctrl_tcp: avoid compiler warnings * ctrl_tcp: fix memory leak * ctrl_tcp: make linter happy * ctrl_tcp: make linter happy * ctrl_tcp: enhance message definition * ctrl_tcp: work on command error and empty response * ctrl_tcp: add response message attribute 'ok' * ctrl_tcp: cleanup * ctrl_tcp: linter. Fix too wide line * ctrl_tcp: Fix. remove unused variable * ctrl_tcp: rename 'netstring-c' folder by 'netstring' * ctrl_tcp: rename 'netstring.[ch]' by 'tcp_netstring.[ch]' * ctrl_tcp: reformat 'netstring' code * ctrl_tcp: move 'netstring_error_str' function to 'netstring' code * ctrl_tcp: remove cstring README file * ctrl_tcp: cleanup cstring makefile * ctrl_tcp: remove makefile and testsuite files from 'netstring' * ctrl_tcp: move variable decalaration to the beginning of the function * ctrl_tcp: add copyright headers --- mk/modules.mk | 1 + modules/ctrl_tcp/ctrl_tcp.c | 377 +++++++++++++++++++++++++++++++++ modules/ctrl_tcp/module.mk | 10 + modules/ctrl_tcp/netstring/netstring.c | 163 ++++++++++++++ modules/ctrl_tcp/netstring/netstring.h | 28 +++ modules/ctrl_tcp/tcp_netstring.c | 221 +++++++++++++++++++ modules/ctrl_tcp/tcp_netstring.h | 16 ++ src/ua.c | 3 +- 8 files changed, 818 insertions(+), 1 deletion(-) create mode 100644 modules/ctrl_tcp/ctrl_tcp.c create mode 100644 modules/ctrl_tcp/module.mk create mode 100644 modules/ctrl_tcp/netstring/netstring.c create mode 100644 modules/ctrl_tcp/netstring/netstring.h create mode 100644 modules/ctrl_tcp/tcp_netstring.c create mode 100644 modules/ctrl_tcp/tcp_netstring.h diff --git a/mk/modules.mk b/mk/modules.mk index 24c4b14..6d6ba6e 100644 --- a/mk/modules.mk +++ b/mk/modules.mk @@ -275,6 +275,7 @@ MODULES += menu contact vumeter mwi account natpmp httpd MODULES += srtp MODULES += uuid MODULES += debug_cmd +MODULES += ctrl_tcp ifneq ($(HAVE_LIBMQTT),) MODULES += mqtt diff --git a/modules/ctrl_tcp/ctrl_tcp.c b/modules/ctrl_tcp/ctrl_tcp.c new file mode 100644 index 0000000..2d0bfcd --- /dev/null +++ b/modules/ctrl_tcp/ctrl_tcp.c @@ -0,0 +1,377 @@ +/** + * @file ctrl_tcp.c TCP control interface using JSON payload + * + * Copyright (C) 2018 46 Labs LLC + */ + +#include +#include + +#include "tcp_netstring.h" + + +/** + * @defgroup ctrl_tcp ctrl_tcp + * + * Communication channel to control and monitor Baresip via JSON messages. + * + * It receives commands to be executed, sends back command responses and + * notifies about events. + * + * Command message parameters: + * + * - command : Command to be executed. + * - params : Command parameters. + * - token : Optional. Included in the response if present. + * + * Command message example: + * + \verbatim + { + "command" : "dial", + "params" : "sip:alice@atlanta.com", + "token" : "qwerasdf" + } + \endverbatim + * + * + * Response message parameters: + * + * - response : true. Identifies the message type. + * - ok: : true/false. Indicates whether the command execution succeeded. + * - data : Baresip response to the related command execution. + * - token : Present if it was included in the related command request. + * + * Response message example: + * + \verbatim + { + "response" : true, + "ok" : true, + "data" : "", + "token" : "qwerasdf" + } + \endverbatim + * + * + * Event message parameters: + * + * - event : true. Identifies the message type. + * - class : Event class. + * - type : Event ID. + * - param : Specific event information. + * + * Apart from the above, events may contain aditional parameters. + * + * Event message example: + * + \verbatim + { + "event" : "true", + "class" : "call", + "type" : "CALL_CLOSED", + "param" : "Connection reset by peer", + "account" : "sip:alice@atlanta.com", + "direction" : "incoming", + "peer" : "sip:bob@biloxy.com", + "id" : "73a12546589651f8" + } + \endverbatim + * + * + * Sample config: + * + \verbatim + ctrl_tcp_listen 0.0.0.0:4444 # IP-address and port to listen on + \endverbatim + */ + + +enum {CTRL_PORT = 4444}; + +struct ctrl_st { + struct tcp_sock *ts; + struct tcp_conn *tc; + struct netstring *ns; +}; + +static struct ctrl_st *ctrl = NULL; /* allow only one instance */ + +static int print_handler(const char *p, size_t size, void *arg) +{ + struct mbuf *mb = arg; + + return mbuf_write_mem(mb, (uint8_t *)p, size); +} + + +static int encode_response(int cmd_error, struct mbuf *resp, const char *token) +{ + struct re_printf pf = {print_handler, resp}; + struct odict *od = NULL; + char *buf = NULL; + char m[256]; + int err; + + /* Empty response. */ + if (resp->pos == NETSTRING_HEADER_SIZE) + { + buf = mem_alloc(1, NULL); + buf[0] = '\0'; + } + else + { + resp->pos = NETSTRING_HEADER_SIZE; + err = mbuf_strdup(resp, &buf, + resp->end - NETSTRING_HEADER_SIZE); + if (err) + return err; + } + + err = odict_alloc(&od, 8); + if (err) + return err; + + err |= odict_entry_add(od, "response", ODICT_BOOL, true); + err |= odict_entry_add(od, "ok", ODICT_BOOL, (bool)!cmd_error); + + if (cmd_error && str_len(buf) == 0) + err |= odict_entry_add(od, "data", ODICT_STRING, + str_error(cmd_error, m, sizeof(m))); + else + err |= odict_entry_add(od, "data", ODICT_STRING, buf); + + if (token) + err |= odict_entry_add(od, "token", ODICT_STRING, token); + + if (err) + goto out; + + mbuf_reset(resp); + mbuf_init(resp); + resp->pos = NETSTRING_HEADER_SIZE; + + err = json_encode_odict(&pf, od); + if (err) + warning("ctrl_tcp: failed to encode response JSON (%m)\n", + err); + + out: + mem_deref(buf); + mem_deref(od); + + return err; +} + + +static bool command_handler(struct mbuf *mb, void *arg) +{ + struct ctrl_st *st = arg; + struct mbuf *resp = mbuf_alloc(2048); + struct re_printf pf = {print_handler, resp}; + struct odict *od = NULL; + const struct odict_entry *oe_cmd, *oe_prm, *oe_tok; + char buf[256]; + int err; + + err = json_decode_odict(&od, 32, (const char*)mb->buf, mb->end, 16); + if (err) { + warning("ctrl_tcp: failed to decode JSON (%m)\n", err); + goto out; + } + + oe_cmd = odict_lookup(od, "command"); + oe_prm = odict_lookup(od, "params"); + oe_tok = odict_lookup(od, "token"); + if (!oe_cmd) { + warning("ctrl_tcp: missing json entries\n"); + goto out; + } + + debug("ctrl_tcp: handle_command: cmd='%s', params:'%s', token='%s'\n", + oe_cmd ? oe_cmd->u.str : "", + oe_prm ? oe_prm->u.str : "", + oe_tok ? oe_tok->u.str : ""); + + re_snprintf(buf, sizeof(buf), "%s%s%s", + oe_cmd->u.str, + oe_prm ? " " : "", + oe_prm ? oe_prm->u.str : ""); + + resp->pos = NETSTRING_HEADER_SIZE; + + /* Relay message to long commands */ + err = cmd_process_long(baresip_commands(), + buf, + str_len(buf), + &pf, NULL); + if (err) { + warning("ctrl_tcp: error processing command (%m)\n", err); + } + + err = encode_response(err, resp, oe_tok ? oe_tok->u.str : NULL); + if (err) { + warning("ctrl_tcp: failed to encode response (%m)\n", err); + goto out; + } + + resp->pos = NETSTRING_HEADER_SIZE; + err = tcp_send(st->tc, resp); + if (err) { + warning("ctrl_tcp: failed to send the message (%m)\n", err); + } + + out: + mem_deref(resp); + mem_deref(od); + + return true; /* always handled */ +} + + +static void tcp_close_handler(int err, void *arg) +{ + struct ctrl_st *st = arg; + + (void)err; + + st->tc = mem_deref(st->tc); +} + + +static void tcp_conn_handler(const struct sa *peer, void *arg) +{ + struct ctrl_st *st = arg; + + (void)peer; + + /* only one connection allowed */ + st->tc = mem_deref(st->tc); + st->tc = mem_deref(st->ns); + + (void)tcp_accept(&st->tc, st->ts, NULL, NULL, tcp_close_handler, st); + (void)netstring_insert(&st->ns, st->tc, 0, command_handler, st); +} + + +/* + * Relay UA events + */ +static void ua_event_handler(struct ua *ua, enum ua_event ev, + struct call *call, const char *prm, void *arg) +{ + struct ctrl_st *st = arg; + struct mbuf *buf = mbuf_alloc(1024); + struct re_printf pf = {print_handler, buf}; + struct odict *od = NULL; + int err; + + buf->pos = NETSTRING_HEADER_SIZE; + + err = odict_alloc(&od, 8); + if (err) + return; + + err = odict_entry_add(od, "event", ODICT_BOOL, true); + err |= event_encode_dict(od, ua, ev, call, prm); + if (err) + goto out; + + err = json_encode_odict(&pf, od); + if (err) { + warning("ctrl_tcp: failed to encode json (%m)\n", err); + goto out; + } + + if (st->tc) { + buf->pos = NETSTRING_HEADER_SIZE; + err = tcp_send(st->tc, buf); + if (err) { + warning("ctrl_tcp: failed to send the message (%m)\n", + err); + } + } + + out: + mem_deref(buf); + mem_deref(od); +} + + +static void ctrl_destructor(void *arg) +{ + struct ctrl_st *st = arg; + + mem_deref(st->tc); + mem_deref(st->ts); + mem_deref(st->ns); +} + + +static int ctrl_alloc(struct ctrl_st **stp, const struct sa *laddr) +{ + struct ctrl_st *st; + int err; + + if (!stp) + return EINVAL; + + st = mem_zalloc(sizeof(*st), ctrl_destructor); + if (!st) + return ENOMEM; + + err = tcp_listen(&st->ts, laddr, tcp_conn_handler, st); + if (err) { + warning("ctrl_tcp: failed to listen on TCP %J (%m)\n", + laddr, err); + goto out; + } + + debug("ctrl_tcp: TCP socket listening on %J\n", laddr); + + out: + if (err) + mem_deref(st); + else + *stp = st; + + return err; +} + + +static int ctrl_init(void) +{ + struct sa laddr; + int err; + + if (conf_get_sa(conf_cur(), "ctrl_tcp_listen", &laddr)) { + sa_set_str(&laddr, "0.0.0.0", CTRL_PORT); + } + + err = ctrl_alloc(&ctrl, &laddr); + if (err) + return err; + + err = uag_event_register(ua_event_handler, ctrl); + if (err) + return err; + + return 0; +} + + +static int ctrl_close(void) +{ + uag_event_unregister(ua_event_handler); + ctrl = mem_deref(ctrl); + + return 0; +} + + +const struct mod_export DECL_EXPORTS(ctrl) = { + "ctrl_tcp", + "application", + ctrl_init, + ctrl_close +}; diff --git a/modules/ctrl_tcp/module.mk b/modules/ctrl_tcp/module.mk new file mode 100644 index 0000000..cf6f0f3 --- /dev/null +++ b/modules/ctrl_tcp/module.mk @@ -0,0 +1,10 @@ +# +# module.mk +# +# Copyright (C) 2018 46 Labs LLC +# + +MOD := ctrl_tcp +$(MOD)_SRCS += ctrl_tcp.c tcp_netstring.c ./netstring/netstring.c + +include mk/mod.mk diff --git a/modules/ctrl_tcp/netstring/netstring.c b/modules/ctrl_tcp/netstring/netstring.c new file mode 100644 index 0000000..d429791 --- /dev/null +++ b/modules/ctrl_tcp/netstring/netstring.c @@ -0,0 +1,163 @@ +/* Streaming API for netstrings. */ + +#include +#include +#include +#include +#include +#include "netstring.h" + + +const char* netstring_error_str(netstring_error err) +{ + switch (err) { + case NETSTRING_ERROR_TOO_LONG: + return "NETSTRING_ERROR_TOO_LONG"; + case NETSTRING_ERROR_NO_COLON: + return "NETSTRING_ERROR_NO_COLON"; + case NETSTRING_ERROR_TOO_SHORT: + return "NETSTRING_ERROR_TOO_SHORT"; + case NETSTRING_ERROR_NO_COMMA: + return "NETSTRING_ERROR_NO_COMMA"; + case NETSTRING_ERROR_LEADING_ZERO: + return "NETSTRING_ERROR_LEADING_ZERO"; + case NETSTRING_ERROR_NO_LENGTH: + return "NETSTRING_ERROR_NO_LENGTH"; + default: + return "NETSTRING_ERROR_UNKNOWN"; + } +} + + +/** + * Reads a netstring from a `buffer` of length `buffer_length`. Writes + * to `netstring_start` a pointer to the beginning of the string in + * the buffer, and to `netstring_length` the length of the + * string. Does not allocate any memory. If it reads successfully, + * then it returns 0. If there is an error, then the return value will + * be negative. The error values are: + + * NETSTRING_ERROR_TOO_LONG More than 999999999 bytes in a field + * NETSTRING_ERROR_NO_COLON No colon was found after the number + * NETSTRING_ERROR_TOO_SHORT Number of bytes greater than buffer length + * NETSTRING_ERROR_NO_COMMA No comma was found at the end + * NETSTRING_ERROR_LEADING_ZERO Leading zeros are not allowed + * NETSTRING_ERROR_NO_LENGTH Length not given at start of netstring + + * If you're sending messages with more than 999999999 bytes -- about + * 2 GB -- then you probably should not be doing so in the form of a + * single netstring. This restriction is in place partially to protect + * from malicious or erroneous input, and partly to be compatible with + * D. J. Bernstein's reference implementation. + + * Example: + * if (netstring_read("3:foo,", 6, &str, &len) < 0) explode_and_die(); + */ +int netstring_read(char *buffer, size_t buffer_length, + char **netstring_start, size_t *netstring_length) +{ + size_t i; + size_t len = 0; + + /* Write default values for outputs */ + *netstring_start = NULL; *netstring_length = 0; + + /* Make sure buffer is big enough. Minimum size is 3. */ + if (buffer_length < 3) + return NETSTRING_ERROR_TOO_SHORT; + + /* No leading zeros allowed! */ + if (buffer[0] == '0' && isdigit(buffer[1])) + return NETSTRING_ERROR_LEADING_ZERO; + + /* The netstring must start with a number */ + if (!isdigit(buffer[0])) + return NETSTRING_ERROR_NO_LENGTH; + + /* Read the number of bytes */ + for (i = 0; i < buffer_length && isdigit(buffer[i]); i++) { + + /* Error if more than 9 digits */ + if (i >= 9) + return NETSTRING_ERROR_TOO_LONG; + + /* Accumulate each digit, assuming ASCII. */ + len = len*10 + (buffer[i] - '0'); + } + + /** + * Check buffer length. The buffer must be longer than the sum of: + * - the number we've read. + * - the length of the string itself. + * - the colon. + * - the comma. + */ + if (i + len + 1 >= buffer_length) + return NETSTRING_ERROR_TOO_SHORT; + + /* Read the colon */ + if (buffer[i++] != ':') + return NETSTRING_ERROR_NO_COLON; + + /* Test for the trailing comma, and set the return values */ + if (buffer[i + len] != ',') + return NETSTRING_ERROR_NO_COMMA; + + *netstring_start = &buffer[i]; *netstring_length = len; + + return 0; +} + +/** + * Return the number of digits represented in the given number. + * We are assuming that the input is not bigger than NETSTRING_MAX_SIZE. + */ +size_t netstring_num_len(size_t num) +{ + char num_str[10]; + + sprintf(num_str, "%zu", num); + + return strlen(num_str); +} + +/** + * Return the length, in ASCII characters, of a netstring containing + * `data_length` bytes. + */ +size_t netstring_buffer_size(size_t data_length) +{ + if (data_length == 0) + return 3; + + return netstring_num_len(data_length) + data_length + 2; +} + +/* + * Allocate and create a netstring containing the first `len` bytes of `data`. + * This must be manually freed by the client. + * If `len` is 0 then no data will be read from `data`, and it may be NULL. + */ +size_t netstring_encode_new(char **netstring, char *data, size_t len) +{ + char *ns; + size_t num_len = 1; + + if (len == 0) { + ns = malloc(3); + ns[0] = '0'; + ns[1] = ':'; + ns[2] = ','; + } + else { + num_len = netstring_num_len(len); + ns = malloc(num_len + len + 2); + sprintf(ns, "%lu:", (unsigned long)len); + memcpy(ns + num_len + 1, data, len); + ns[num_len + len + 1] = ','; + } + + *netstring = ns; + + return num_len + len + 2; +} diff --git a/modules/ctrl_tcp/netstring/netstring.h b/modules/ctrl_tcp/netstring/netstring.h new file mode 100644 index 0000000..a084428 --- /dev/null +++ b/modules/ctrl_tcp/netstring/netstring.h @@ -0,0 +1,28 @@ +#ifndef __NETSTRING_STREAM_H +#define __NETSTRING_STREAM_H + +#include + +const char* netstring_error_str(int err); + +int netstring_read(char *buffer, size_t buffer_length, + char **netstring_start, size_t *netstring_length); + +size_t netstring_num_len(size_t num); +size_t netstring_buffer_size(size_t data_length); + +size_t netstring_encode_new(char **netstring, char *data, size_t len); + +#define NETSTRING_MAX_SIZE 999999999 + +/* Errors that can occur during netstring parsing */ +typedef enum { + NETSTRING_ERROR_TOO_LONG = -100, + NETSTRING_ERROR_NO_COLON, + NETSTRING_ERROR_TOO_SHORT, + NETSTRING_ERROR_NO_COMMA, + NETSTRING_ERROR_LEADING_ZERO, + NETSTRING_ERROR_NO_LENGTH +} netstring_error; + +#endif diff --git a/modules/ctrl_tcp/tcp_netstring.c b/modules/ctrl_tcp/tcp_netstring.c new file mode 100644 index 0000000..7b025fd --- /dev/null +++ b/modules/ctrl_tcp/tcp_netstring.c @@ -0,0 +1,221 @@ +/** + * @file tcp_netstring.c TCP netstring framing + * + * Copyright (C) 2018 46 Labs LLC + */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "tcp_netstring.h" +#include "netstring/netstring.h" + + +#define DEBUG_MODULE "tcp_netstring" +#define DEBUG_LEVEL 5 +#include + + +struct netstring { + struct tcp_conn *tc; + struct tcp_helper *th; + struct mbuf *mb; + netstring_frame_h *frameh; + void *arg; + + uint64_t n_tx; + uint64_t n_rx; +}; + + +/* responsible for adding the netstring header + - assumes that the sent MBUF contains a complete packet + */ +static bool netstring_send_handler(int *err, struct mbuf *mb, void *arg) +{ + struct netstring *netstring = arg; + size_t num_len; + char num_str[10]; + + if (mb->pos < NETSTRING_HEADER_SIZE) { + DEBUG_WARNING("send: not enough space for netstring header\n"); + *err = ENOMEM; + return true; + } + + if (mbuf_get_left(mb) > NETSTRING_MAX_SIZE) { + DEBUG_WARNING("send: buffer exceeds max size\n"); + *err = EMSGSIZE; + return true; + } + + /* Build the netstring. */ + if (mbuf_get_left(mb) == 0) { + mb->buf[0] = '0'; + mb->buf[1] = ':'; + mb->buf[2] = ','; + + mb->end += 3; + + return false; + } + + sprintf(num_str, "%zu", mbuf_get_left(mb)); + num_len = strlen(num_str); + + mb->pos = NETSTRING_HEADER_SIZE - (num_len + 1); + mbuf_write_mem(mb, (uint8_t*) num_str, num_len); + mb->pos = NETSTRING_HEADER_SIZE - (num_len + 1); + mb->buf[mb->pos + num_len] = ':'; + mb->buf[mb->end] = ','; + + mb->end += 1; + + ++netstring->n_tx; + + return false; +} + + +static bool netstring_recv_handler(int *errp, struct mbuf *mbx, bool *estab, + void *arg) +{ + struct netstring *netstring = arg; + int err = 0; + size_t pos = 0; + (void)estab; + + /* handle re-assembly */ + if (!netstring->mb) { + netstring->mb = mbuf_alloc(1024); + if (!netstring->mb) { + *errp = ENOMEM; + return true; + } + } + + pos = netstring->mb->pos; + + netstring->mb->pos = netstring->mb->end; + + err = mbuf_write_mem(netstring->mb, mbuf_buf(mbx), + mbuf_get_left(mbx)); + if (err) + goto out; + + netstring->mb->pos = pos; + + /* extract all NETSTRING-frames in the TCP-stream */ + for (;;) { + + size_t len, end; + struct mbuf mb; + + if (mbuf_get_left(netstring->mb) < (3)) + break; + + err = netstring_read((char*)netstring->mb->buf, + netstring->mb->end, + (char**)&mb.buf, &len); + if (err) { + + if (err == NETSTRING_ERROR_TOO_SHORT) { + DEBUG_INFO("receive: %s\n", + netstring_error_str(err)); + } + + else { + DEBUG_WARNING("receive: %s\n", + netstring_error_str(err)); + netstring->mb = mem_deref(netstring->mb); + } + + return false; + } + + pos = netstring->mb->pos; + end = netstring->mb->end; + + netstring->mb->end = pos + len; + + ++netstring->n_rx; + + netstring->frameh(&mb, netstring->arg); + + netstring->mb->pos = pos + netstring_buffer_size(len); + netstring->mb->end = end; + + if (netstring->mb->pos >= netstring->mb->end) { + netstring->mb = mem_deref(netstring->mb); + break; + } + + continue; + } + + out: + if (err) + *errp = err; + + return true; /* always handled */ +} + + +static void destructor(void *arg) +{ + struct netstring *netstring = arg; + + mem_deref(netstring->th); + mem_deref(netstring->tc); + mem_deref(netstring->mb); +} + + +int netstring_insert(struct netstring **netstringp, struct tcp_conn *tc, + int layer, netstring_frame_h *frameh, void *arg) +{ + struct netstring *netstring; + int err; + + if (!netstringp || !tc || !frameh) + return EINVAL; + + netstring = mem_zalloc(sizeof(*netstring), destructor); + if (!netstring) + return ENOMEM; + + netstring->tc = mem_ref(tc); + err = tcp_register_helper(&netstring->th, tc, layer, NULL, + netstring_send_handler, + netstring_recv_handler, netstring); + if (err) + goto out; + + netstring->frameh = frameh; + netstring->arg = arg; + + out: + if (err) + mem_deref(netstring); + else + *netstringp = netstring; + + return err; +} + + +int netstring_debug(struct re_printf *pf, const struct netstring *netstring) +{ + if (!netstring) + return 0; + + return re_hprintf(pf, "tx=%llu, rx=%llu", + netstring->n_tx, netstring->n_rx); +} diff --git a/modules/ctrl_tcp/tcp_netstring.h b/modules/ctrl_tcp/tcp_netstring.h new file mode 100644 index 0000000..8195217 --- /dev/null +++ b/modules/ctrl_tcp/tcp_netstring.h @@ -0,0 +1,16 @@ +/** + * @file tcp_netstring.h TCP netstring framing + * + * Copyright (C) 2018 46 Labs LLC + */ + +enum {NETSTRING_HEADER_SIZE = 10}; + +struct netstring; + +typedef bool (netstring_frame_h)(struct mbuf *mb, void *arg); + + +int netstring_insert(struct netstring **netstringp, struct tcp_conn *tc, + int layer, netstring_frame_h *frameh, void *arg); +int netstring_debug(struct re_printf *pf, const struct netstring *netstring); diff --git a/src/ua.c b/src/ua.c index 0467e35..e23d392 100644 --- a/src/ua.c +++ b/src/ua.c @@ -837,7 +837,8 @@ void ua_hangup(struct ua *ua, struct call *call, (void)call_hangup(call, scode, reason); - ua_event(ua, UA_EVENT_CALL_CLOSED, call, reason); + ua_event(ua, UA_EVENT_CALL_CLOSED, call, + reason ? reason : "Connection reset by user"); mem_deref(call); -- cgit v1.2.3 From d79d6c83f8548de0d05baa2ab4bcb9d1ccdc20f2 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Mon, 29 Jan 2018 17:45:11 +0100 Subject: ctrl_tcp: use re_snprintf, fix warning --- modules/ctrl_tcp/tcp_netstring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ctrl_tcp/tcp_netstring.c b/modules/ctrl_tcp/tcp_netstring.c index 7b025fd..2ad4742 100644 --- a/modules/ctrl_tcp/tcp_netstring.c +++ b/modules/ctrl_tcp/tcp_netstring.c @@ -42,7 +42,7 @@ static bool netstring_send_handler(int *err, struct mbuf *mb, void *arg) { struct netstring *netstring = arg; size_t num_len; - char num_str[10]; + char num_str[32]; if (mb->pos < NETSTRING_HEADER_SIZE) { DEBUG_WARNING("send: not enough space for netstring header\n"); @@ -67,7 +67,7 @@ static bool netstring_send_handler(int *err, struct mbuf *mb, void *arg) return false; } - sprintf(num_str, "%zu", mbuf_get_left(mb)); + re_snprintf(num_str, sizeof(num_str), "%zu", mbuf_get_left(mb)); num_len = strlen(num_str); mb->pos = NETSTRING_HEADER_SIZE - (num_len + 1); -- cgit v1.2.3 From 00252b48ee28483ad9d8f9edb43e0062b9951f84 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Mon, 29 Jan 2018 18:08:10 +0100 Subject: ctrl_tcp: correct name for module export symbol --- modules/ctrl_tcp/ctrl_tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ctrl_tcp/ctrl_tcp.c b/modules/ctrl_tcp/ctrl_tcp.c index 2d0bfcd..0f1830b 100644 --- a/modules/ctrl_tcp/ctrl_tcp.c +++ b/modules/ctrl_tcp/ctrl_tcp.c @@ -369,7 +369,7 @@ static int ctrl_close(void) } -const struct mod_export DECL_EXPORTS(ctrl) = { +const struct mod_export DECL_EXPORTS(ctrl_tcp) = { "ctrl_tcp", "application", ctrl_init, -- cgit v1.2.3 From b74fd8b108929fb41fde4085fc780b95c0982fc0 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Mon, 29 Jan 2018 18:08:45 +0100 Subject: ctrl_tcp: using sprintf is not safe, use re_snprintf instead --- modules/ctrl_tcp/netstring/netstring.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/ctrl_tcp/netstring/netstring.c b/modules/ctrl_tcp/netstring/netstring.c index d429791..0309872 100644 --- a/modules/ctrl_tcp/netstring/netstring.c +++ b/modules/ctrl_tcp/netstring/netstring.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "netstring.h" @@ -114,9 +115,9 @@ int netstring_read(char *buffer, size_t buffer_length, */ size_t netstring_num_len(size_t num) { - char num_str[10]; + char num_str[32]; - sprintf(num_str, "%zu", num); + re_snprintf(num_str, sizeof(num_str), "%zu", num); return strlen(num_str); } -- cgit v1.2.3 From 8fd2d9424a350a38780f956ce24bab25f034c3db Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Tue, 30 Jan 2018 19:25:45 +0100 Subject: openbsd: add system include path to /usr/local/include --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f5b4c25..924ccc4 100644 --- a/Makefile +++ b/Makefile @@ -66,10 +66,13 @@ ifeq ($(OS),win32) STATIC := yes endif -ifeq ($(OS),freebsd) ifneq ($(SYSROOT),) +ifeq ($(OS),freebsd) CFLAGS += -I$(SYSROOT)/local/include endif +ifeq ($(OS),openbsd) +CFLAGS += -isystem $(SYSROOT)/local/include +endif endif -- cgit v1.2.3 From d0c2cb4ab79de2fec3e1d0ad415670434cd1fc5d Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Tue, 30 Jan 2018 20:50:04 +0100 Subject: avcodec: use AV_INPUT_BUFFER_MIN_SIZE (ref #351) --- modules/avcodec/encode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/avcodec/encode.c b/modules/avcodec/encode.c index d0d5d83..d1461bb 100644 --- a/modules/avcodec/encode.c +++ b/modules/avcodec/encode.c @@ -513,7 +513,7 @@ int encode_update(struct videnc_state **vesp, const struct vidcodec *vc, goto out; } - st->mb = mbuf_alloc(FF_MIN_BUFFER_SIZE * 20); + st->mb = mbuf_alloc(AV_INPUT_BUFFER_MIN_SIZE * 20); st->mb_frag = mbuf_alloc(1024); if (!st->mb || !st->mb_frag) { err = ENOMEM; -- cgit v1.2.3 From 5c26ca770797995e81eec934ca75574e98c30939 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Tue, 30 Jan 2018 21:15:17 +0100 Subject: speex_{aec,pp}: always link to libspeexdsp --- modules/speex_aec/module.mk | 4 ---- modules/speex_pp/module.mk | 4 ---- 2 files changed, 8 deletions(-) diff --git a/modules/speex_aec/module.mk b/modules/speex_aec/module.mk index 9e29696..caa88a6 100644 --- a/modules/speex_aec/module.mk +++ b/modules/speex_aec/module.mk @@ -6,10 +6,6 @@ MOD := speex_aec $(MOD)_SRCS += speex_aec.c -ifneq ($(HAVE_SPEEXDSP),) $(MOD)_LFLAGS += "-lspeexdsp" -else -$(MOD)_LFLAGS += "-lspeex" -endif include mk/mod.mk diff --git a/modules/speex_pp/module.mk b/modules/speex_pp/module.mk index fad5f88..adcaac2 100644 --- a/modules/speex_pp/module.mk +++ b/modules/speex_pp/module.mk @@ -6,10 +6,6 @@ MOD := speex_pp $(MOD)_SRCS += speex_pp.c -ifneq ($(HAVE_SPEEXDSP),) $(MOD)_LFLAGS += "-lspeexdsp" -else -$(MOD)_LFLAGS += "-lspeex" -endif include mk/mod.mk -- cgit v1.2.3 From 3b74a456ee62174fe2fbc6b88ae4610151ccf79d Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 31 Jan 2018 17:53:53 +0100 Subject: avcodec: backwards compat for FF_MIN_BUFFER_SIZE --- modules/avcodec/.encode.c.swp | Bin 0 -> 16384 bytes modules/avcodec/encode.c | 4 ++++ 2 files changed, 4 insertions(+) create mode 100644 modules/avcodec/.encode.c.swp diff --git a/modules/avcodec/.encode.c.swp b/modules/avcodec/.encode.c.swp new file mode 100644 index 0000000..a69db2c Binary files /dev/null and b/modules/avcodec/.encode.c.swp differ diff --git a/modules/avcodec/encode.c b/modules/avcodec/encode.c index d1461bb..be365a6 100644 --- a/modules/avcodec/encode.c +++ b/modules/avcodec/encode.c @@ -24,6 +24,10 @@ #define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P #define AV_PIX_FMT_NV12 PIX_FMT_NV12 #endif + +#ifndef AV_INPUT_BUFFER_MIN_SIZE +#define AV_INPUT_BUFFER_MIN_SIZE FF_MIN_BUFFER_SIZE +#endif enum { -- cgit v1.2.3 From 7e05216db952770bda39d37ba48d1eef558e149f Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 31 Jan 2018 17:59:12 +0100 Subject: avcodec: remove swap file --- modules/avcodec/.encode.c.swp | Bin 16384 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 modules/avcodec/.encode.c.swp diff --git a/modules/avcodec/.encode.c.swp b/modules/avcodec/.encode.c.swp deleted file mode 100644 index a69db2c..0000000 Binary files a/modules/avcodec/.encode.c.swp and /dev/null differ -- cgit v1.2.3 From 14da81f1f23ed117ffae7d743c69aab0225c70f3 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 31 Jan 2018 18:06:41 +0100 Subject: avcodec: fix ccheck warning --- modules/avcodec/encode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/avcodec/encode.c b/modules/avcodec/encode.c index be365a6..cb9d63d 100644 --- a/modules/avcodec/encode.c +++ b/modules/avcodec/encode.c @@ -24,7 +24,8 @@ #define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P #define AV_PIX_FMT_NV12 PIX_FMT_NV12 #endif - + + #ifndef AV_INPUT_BUFFER_MIN_SIZE #define AV_INPUT_BUFFER_MIN_SIZE FF_MIN_BUFFER_SIZE #endif -- cgit v1.2.3 From aee247d25c1bf7c006b55f96241f87618e4db63d Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 31 Jan 2018 20:45:52 +0100 Subject: video: save and show pixel format of incoming video --- src/video.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/video.c b/src/video.c index 527f8a6..a2e58bc 100644 --- a/src/video.c +++ b/src/video.c @@ -134,6 +134,7 @@ struct vrx { struct list filtl; /**< Filters in decoding order */ struct tmr tmr_picup; /**< Picture update timer */ struct vidsz size; /**< Incoming video resolution */ + enum vidfmt fmt; /**< Incoming pixel format */ enum vidorient orient; /**< Display orientation */ char device[128]; /**< Display device name */ int pt_rx; /**< Incoming RTP payload type */ @@ -521,6 +522,7 @@ static int vrx_alloc(struct vrx *vrx, struct video *video) str_ncpy(vrx->device, video->cfg.disp_dev, sizeof(vrx->device)); vrx->ts_min = ~0; + vrx->fmt = (enum vidfmt)-1; return err; } @@ -617,6 +619,7 @@ static int video_stream_decode(struct vrx *vrx, const struct rtp_header *hdr, goto out; vrx->size = frame->size; + vrx->fmt = frame->fmt; if (!list_isempty(&vrx->filtl)) { @@ -1326,8 +1329,9 @@ static int vrx_debug(struct re_printf *pf, const struct vrx *vrx) { int err = 0; - err |= re_hprintf(pf, " rx: decode: %s\n", - vrx->vc ? vrx->vc->name : "none"); + err |= re_hprintf(pf, " rx: decode: %s %s\n", + vrx->vc ? vrx->vc->name : "none", + vidfmt_name(vrx->fmt)); err |= re_hprintf(pf, " vidisp: %s %u x %u\n", vrx->vidisp ? vidisp_get(vrx->vidisp)->name : "none", vrx->size.w, vrx->size.h); -- cgit v1.2.3 From 54a4f2c3aab5867caac077ee0949c04d86807013 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 31 Jan 2018 20:52:35 +0100 Subject: metric: fix calculation of average bitrate --- src/core.h | 2 +- src/metric.c | 4 ++-- src/stream.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core.h b/src/core.h index 6e48e5d..ba4034e 100644 --- a/src/core.h +++ b/src/core.h @@ -250,7 +250,7 @@ struct metric { void metric_init(struct metric *metric); void metric_reset(struct metric *metric); void metric_add_packet(struct metric *metric, size_t packetsize); -uint32_t metric_avg_bitrate(const struct metric *metric); +double metric_avg_bitrate(const struct metric *metric); /* diff --git a/src/metric.c b/src/metric.c index f3e8d06..85dad3c 100644 --- a/src/metric.c +++ b/src/metric.c @@ -77,7 +77,7 @@ void metric_add_packet(struct metric *metric, size_t packetsize) } -uint32_t metric_avg_bitrate(const struct metric *metric) +double metric_avg_bitrate(const struct metric *metric) { int diff; @@ -86,5 +86,5 @@ uint32_t metric_avg_bitrate(const struct metric *metric) diff = (int)(tmr_jiffies() - metric->ts_start); - return 1000 * 8 * (metric->n_bytes / diff); + return 1000.0 * 8 * (double)metric->n_bytes / (double)diff; } diff --git a/src/stream.c b/src/stream.c index 38db2d6..d8fd445 100644 --- a/src/stream.c +++ b/src/stream.c @@ -110,8 +110,8 @@ static void print_rtp_stats(const struct stream *s) , sdp_media_name(s->sdp), s->metric_tx.n_packets, s->metric_rx.n_packets, - 1.0*metric_avg_bitrate(&s->metric_tx)/1000, - 1.0*metric_avg_bitrate(&s->metric_rx)/1000, + 1.0*metric_avg_bitrate(&s->metric_tx)/1000.0, + 1.0*metric_avg_bitrate(&s->metric_rx)/1000.0, s->metric_tx.n_err, s->metric_rx.n_err ); -- cgit v1.2.3 From 671f293bbdf8f234a73d8c2e6fb75a8ee3d039ce Mon Sep 17 00:00:00 2001 From: Guillaume Rousse Date: Sat, 3 Feb 2018 18:28:15 +0100 Subject: set exact installation pathes at build time (#354) Thank you, this is a very nice contribution. Alfred --- Makefile | 2 ++ src/config.c | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 924ccc4..7f50a2d 100644 --- a/Makefile +++ b/Makefile @@ -109,6 +109,8 @@ LIBDIR := $(PREFIX)/lib MOD_PATH := $(LIBDIR)/$(PROJECT)/modules SHARE_PATH := $(PREFIX)/share/$(PROJECT) CFLAGS += -DPREFIX=\"$(PREFIX)\" +CFLAGS += -DMOD_PATH=\"$(MOD_PATH)\" +CFLAGS += -DSHARE_PATH=\"$(SHARE_PATH)\" all: sanity $(MOD_BINS) $(BIN) diff --git a/src/config.c b/src/config.c index 1d010e0..6de53f5 100644 --- a/src/config.c +++ b/src/config.c @@ -43,7 +43,7 @@ static struct config core_config = { /** Audio */ { - PREFIX "/share/baresip", + SHARE_PATH, "","", "","", "","", @@ -527,7 +527,9 @@ static int core_config_template(struct re_printf *pf, const struct config *cfg) "call_max_calls\t%u\n" "\n" "# Audio\n" -#if defined (PREFIX) +#if defined (SHARE_PATH) + "#audio_path\t\t" SHARE_PATH "\n" +#elif defined (PREFIX) "#audio_path\t\t" PREFIX "/share/baresip\n" #else "#audio_path\t\t/usr/share/baresip\n" @@ -630,7 +632,9 @@ static uint32_t count_modules(const char *path) static const char *detect_module_path(bool *valid) { static const char * const pathv[] = { -#if defined (PREFIX) +#if defined (MOD_PATH) + MOD_PATH, +#elif defined (PREFIX) "" PREFIX "/lib/baresip/modules", #else "/usr/local/lib/baresip/modules", -- cgit v1.2.3 From 74db759ddbed32127ae763ab72be552cff2aebcc Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 3 Feb 2018 18:32:38 +0100 Subject: Aucodec sample format (#352) * aucodec: merge s16 and fmt encode/decode into one having 2 different encode functions for s16 and other formats turned out to be a bit impractical. better to have 1 function where the sample format (fmt) can be specified. * update some aucodec modules * update test * update codec2 * update g7221 module --- include/baresip.h | 20 +++++-------- mk/modules.mk | 5 ---- modules/amr/amr.c | 22 +++++++++++--- modules/auloop/auloop.c | 6 ++-- modules/bv32/bv32.c | 22 ++++++++++---- modules/codec2/codec2.c | 10 +++++-- modules/g711/g711.c | 40 ++++++++++++++++++------- modules/g722/g722.c | 11 +++++-- modules/g7221/decode.c | 3 +- modules/g7221/encode.c | 2 +- modules/g7221/g7221.h | 5 ++-- modules/g726/g726.c | 11 +++++-- modules/gsm/gsm.c | 11 +++++-- modules/l16/l16.c | 33 +++++++++++++-------- modules/mpa/decode.c | 8 ++++- modules/mpa/encode.c | 6 +++- modules/mpa/mpa.h | 7 +++-- modules/opus/decode.c | 76 ++++++++++++++++++++++++++++-------------------- modules/opus/encode.c | 49 ++++++++++++++----------------- modules/opus/opus.c | 2 -- modules/opus/opus.h | 13 ++++----- src/audio.c | 35 ++++------------------ test/mock/mock_aucodec.c | 12 ++++++-- 23 files changed, 241 insertions(+), 168 deletions(-) diff --git a/include/baresip.h b/include/baresip.h index ee2cdbf..1e7e862 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -839,21 +839,17 @@ struct aucodec; typedef int (auenc_update_h)(struct auenc_state **aesp, const struct aucodec *ac, struct auenc_param *prm, const char *fmtp); -typedef int (auenc_encode_h)(struct auenc_state *aes, uint8_t *buf, - size_t *len, const int16_t *sampv, size_t sampc); -typedef int (auenc_encode_fmt_h)(struct auenc_state *aes, - uint8_t *buf, size_t *len, - int fmt, const void *sampv, size_t sampc); +typedef int (auenc_encode_h)(struct auenc_state *aes, + uint8_t *buf, size_t *len, + int fmt, const void *sampv, size_t sampc); typedef int (audec_update_h)(struct audec_state **adsp, const struct aucodec *ac, const char *fmtp); -typedef int (audec_decode_h)(struct audec_state *ads, int16_t *sampv, - size_t *sampc, const uint8_t *buf, size_t len); -typedef int (audec_decode_fmt_h)(struct audec_state *ads, - int fmt, void *sampv, size_t *sampc, - const uint8_t *buf, size_t len); +typedef int (audec_decode_h)(struct audec_state *ads, + int fmt, void *sampv, size_t *sampc, + const uint8_t *buf, size_t len); typedef int (audec_plc_h)(struct audec_state *ads, - int16_t *sampv, size_t *sampc); + int fmt, void *sampv, size_t *sampc); struct aucodec { struct le le; @@ -870,8 +866,6 @@ struct aucodec { audec_plc_h *plch; sdp_fmtp_enc_h *fmtp_ench; sdp_fmtp_cmp_h *fmtp_cmph; - auenc_encode_fmt_h *encfmth; - audec_decode_fmt_h *decfmth; }; void aucodec_register(struct list *aucodecl, struct aucodec *ac); diff --git a/mk/modules.mk b/mk/modules.mk index 6d6ba6e..a8256a1 100644 --- a/mk/modules.mk +++ b/mk/modules.mk @@ -171,11 +171,6 @@ USE_MPA := $(shell [ -f $(SYSROOT)/include/twolame.h ] || \ [ -f $(SYSROOT_ALT)/include/twolame.h ] && echo "yes") endif endif -USE_SPEEX := $(shell [ -f $(SYSROOT)/include/speex.h ] || \ - [ -f $(SYSROOT)/include/speex/speex.h ] || \ - [ -f $(SYSROOT)/local/include/speex.h ] || \ - [ -f $(SYSROOT)/local/include/speex/speex.h ] || \ - [ -f $(SYSROOT_ALT)/include/speex/speex.h ] && echo "yes") USE_SPEEX_AEC := $(shell [ -f $(SYSROOT)/include/speex/speex_echo.h ] || \ [ -f $(SYSROOT)/local/include/speex/speex_echo.h ] || \ [ -f $(SYSROOT_ALT)/include/speex/speex_echo.h ] && echo "yes") diff --git a/modules/amr/amr.c b/modules/amr/amr.c index 885a318..58343a1 100644 --- a/modules/amr/amr.c +++ b/modules/amr/amr.c @@ -16,6 +16,7 @@ #include #endif #include +#include #include #include "amr.h" @@ -205,7 +206,7 @@ static int decode_update(struct audec_state **adsp, #ifdef AMR_WB static int encode_wb(struct auenc_state *st, uint8_t *buf, size_t *len, - const int16_t *sampv, size_t sampc) + int fmt, const void *sampv, size_t sampc) { int n; @@ -215,6 +216,9 @@ static int encode_wb(struct auenc_state *st, uint8_t *buf, size_t *len, if (*len < NB_SERIAL_MAX) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + /* CMR value 15 indicates that no mode request is present */ buf[0] = 15 << 4; @@ -228,7 +232,8 @@ static int encode_wb(struct auenc_state *st, uint8_t *buf, size_t *len, } -static int decode_wb(struct audec_state *st, int16_t *sampv, size_t *sampc, +static int decode_wb(struct audec_state *st, + int fmt, void *sampv, size_t *sampc, const uint8_t *buf, size_t len) { if (*sampc < L_FRAME16k) @@ -236,6 +241,9 @@ static int decode_wb(struct audec_state *st, int16_t *sampv, size_t *sampc, if (len > NB_SERIAL_MAX) return EINVAL; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + IF2D_IF_decode(st->dec, &buf[1], sampv, 0); *sampc = L_FRAME16k; @@ -247,7 +255,7 @@ static int decode_wb(struct audec_state *st, int16_t *sampv, size_t *sampc, #ifdef AMR_NB static int encode_nb(struct auenc_state *st, uint8_t *buf, - size_t *len, const int16_t *sampv, size_t sampc) + size_t *len, int fmt, const void *sampv, size_t sampc) { int r; @@ -256,6 +264,9 @@ static int encode_nb(struct auenc_state *st, uint8_t *buf, if (*len < NB_SERIAL_MAX) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + /* CMR value 15 indicates that no mode request is present */ buf[0] = 15 << 4; @@ -269,7 +280,7 @@ static int encode_nb(struct auenc_state *st, uint8_t *buf, } -static int decode_nb(struct audec_state *st, int16_t *sampv, +static int decode_nb(struct audec_state *st, int fmt, void *sampv, size_t *sampc, const uint8_t *buf, size_t len) { if (!st || !sampv || !sampc || !buf) @@ -281,6 +292,9 @@ static int decode_nb(struct audec_state *st, int16_t *sampv, if (*sampc < L_FRAME16k) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + Decoder_Interface_Decode(st->dec, &buf[1], sampv, 0); *sampc = FRAMESIZE_NB; diff --git a/modules/auloop/auloop.c b/modules/auloop/auloop.c index 347f130..c1da518 100644 --- a/modules/auloop/auloop.c +++ b/modules/auloop/auloop.c @@ -120,12 +120,14 @@ static int codec_read(struct audio_loop *al, int16_t *sampv, size_t sampc) aubuf_read_samp(al->ab, al->sampv, al->sampc); - err = al->ac->ench(al->enc, x, &xlen, al->sampv, al->sampc); + err = al->ac->ench(al->enc, x, &xlen, + AUFMT_S16LE, al->sampv, al->sampc); if (err) goto out; if (al->ac->dech) { - err = al->ac->dech(al->dec, sampv, &sampc, x, xlen); + err = al->ac->dech(al->dec, AUFMT_S16LE, sampv, &sampc, + x, xlen); if (err) goto out; } diff --git a/modules/bv32/bv32.c b/modules/bv32/bv32.c index d3dd45c..a23241e 100644 --- a/modules/bv32/bv32.c +++ b/modules/bv32/bv32.c @@ -4,6 +4,7 @@ * Copyright (C) 2010 Creytiv.com */ #include +#include #include #include #include @@ -100,17 +101,21 @@ static int decode_update(struct audec_state **adsp, static int encode(struct auenc_state *st, uint8_t *buf, size_t *len, - const int16_t *sampv, size_t sampc) + int fmt, const void *sampv, size_t sampc) { size_t i, nframe; + short *p = (short *)sampv; nframe = sampc / NSAMP; if (*len < nframe * CODED_OCTETS) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + for (i=0; ibsc, &st->cs, (short *)&sampv[i*NSAMP]); + BV32_Encode(&st->bsc, &st->cs, &p[i*NSAMP]); BV32_BitPack((void *)&buf[i*CODED_OCTETS], &st->bsc); } @@ -120,19 +125,23 @@ static int encode(struct auenc_state *st, uint8_t *buf, size_t *len, } -static int decode(struct audec_state *st, int16_t *sampv, +static int decode(struct audec_state *st, int fmt, void *sampv, size_t *sampc, const uint8_t *buf, size_t len) { size_t i, nframe; + short *p = sampv; nframe = len / CODED_OCTETS; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + if (*sampc < NSAMP*nframe) return ENOMEM; for (i=0; ibsd); - BV32_Decode(&st->bsd, &st->ds, (short *)&sampv[i*NSAMP]); + BV32_Decode(&st->bsd, &st->ds, &p[i*NSAMP]); } *sampc = NSAMP * nframe; @@ -141,8 +150,11 @@ static int decode(struct audec_state *st, int16_t *sampv, } -static int plc(struct audec_state *st, int16_t *sampv, size_t *sampc) +static int plc(struct audec_state *st, int fmt, void *sampv, size_t *sampc) { + if (fmt != AUFMT_S16LE) + return ENOTSUP; + BV32_PLC(&st->ds, sampv); *sampc = NSAMP; diff --git a/modules/codec2/codec2.c b/modules/codec2/codec2.c index b6911dc..44e8e43 100644 --- a/modules/codec2/codec2.c +++ b/modules/codec2/codec2.c @@ -123,7 +123,7 @@ static int decode_update(struct audec_state **adsp, static int encode(struct auenc_state *aes, uint8_t *buf, - size_t *len, const int16_t *sampv, size_t sampc) + size_t *len, int fmt, const void *sampv, size_t sampc) { if (!buf || !len || !sampv) return EINVAL; @@ -133,6 +133,9 @@ static int encode(struct auenc_state *aes, uint8_t *buf, if (sampc != (size_t)codec2_samples_per_frame(aes->c2)) return EPROTO; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + codec2_encode(aes->c2, buf, (short *)sampv); *len = codec2_bits_per_frame(aes->c2)/8; @@ -141,7 +144,7 @@ static int encode(struct auenc_state *aes, uint8_t *buf, } -static int decode(struct audec_state *ads, int16_t *sampv, +static int decode(struct audec_state *ads, int fmt, void *sampv, size_t *sampc, const uint8_t *buf, size_t len) { if (!sampv || !sampc || !buf) @@ -152,6 +155,9 @@ static int decode(struct audec_state *ads, int16_t *sampv, if (len < (size_t)codec2_bits_per_frame(ads->c2)/8) return EPROTO; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + codec2_decode(ads->c2, sampv, buf); *sampc = codec2_samples_per_frame(ads->c2); diff --git a/modules/g711/g711.c b/modules/g711/g711.c index d264153..e72f117 100644 --- a/modules/g711/g711.c +++ b/modules/g711/g711.c @@ -17,8 +17,10 @@ static int pcmu_encode(struct auenc_state *aes, uint8_t *buf, - size_t *len, const int16_t *sampv, size_t sampc) + size_t *len, int fmt, const void *sampv, size_t sampc) { + const int16_t *p = sampv; + (void)aes; if (!buf || !len || !sampv) @@ -27,18 +29,23 @@ static int pcmu_encode(struct auenc_state *aes, uint8_t *buf, if (*len < sampc) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + *len = sampc; while (sampc--) - *buf++ = g711_pcm2ulaw(*sampv++); + *buf++ = g711_pcm2ulaw(*p++); return 0; } -static int pcmu_decode(struct audec_state *ads, int16_t *sampv, +static int pcmu_decode(struct audec_state *ads, int fmt, void *sampv, size_t *sampc, const uint8_t *buf, size_t len) { + int16_t *p = sampv; + (void)ads; if (!sampv || !sampc || !buf) @@ -47,18 +54,23 @@ static int pcmu_decode(struct audec_state *ads, int16_t *sampv, if (*sampc < len) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + *sampc = len; while (len--) - *sampv++ = g711_ulaw2pcm(*buf++); + *p++ = g711_ulaw2pcm(*buf++); return 0; } static int pcma_encode(struct auenc_state *aes, uint8_t *buf, - size_t *len, const int16_t *sampv, size_t sampc) + size_t *len, int fmt, const void *sampv, size_t sampc) { + const int16_t *p = sampv; + (void)aes; if (!buf || !len || !sampv) @@ -67,18 +79,23 @@ static int pcma_encode(struct auenc_state *aes, uint8_t *buf, if (*len < sampc) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + *len = sampc; while (sampc--) - *buf++ = g711_pcm2alaw(*sampv++); + *buf++ = g711_pcm2alaw(*p++); return 0; } -static int pcma_decode(struct audec_state *ads, int16_t *sampv, +static int pcma_decode(struct audec_state *ads, int fmt, void *sampv, size_t *sampc, const uint8_t *buf, size_t len) { + int16_t *p = sampv; + (void)ads; if (!sampv || !sampc || !buf) @@ -87,10 +104,13 @@ static int pcma_decode(struct audec_state *ads, int16_t *sampv, if (*sampc < len) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + *sampc = len; while (len--) - *sampv++ = g711_alaw2pcm(*buf++); + *p++ = g711_alaw2pcm(*buf++); return 0; } @@ -98,12 +118,12 @@ static int pcma_decode(struct audec_state *ads, int16_t *sampv, static struct aucodec pcmu = { LE_INIT, "0", "PCMU", 8000, 8000, 1, NULL, - NULL, pcmu_encode, NULL, pcmu_decode, NULL, NULL, NULL, NULL, NULL + NULL, pcmu_encode, NULL, pcmu_decode, NULL, NULL, NULL }; static struct aucodec pcma = { LE_INIT, "8", "PCMA", 8000, 8000, 1, NULL, - NULL, pcma_encode, NULL, pcma_decode, NULL, NULL, NULL, NULL, NULL + NULL, pcma_encode, NULL, pcma_decode, NULL, NULL, NULL }; diff --git a/modules/g722/g722.c b/modules/g722/g722.c index 16d1f98..dd2a943 100644 --- a/modules/g722/g722.c +++ b/modules/g722/g722.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #define SPANDSP_EXPOSE_INTERNAL_STRUCTURES 1 #include @@ -125,10 +126,13 @@ static int decode_update(struct audec_state **adsp, static int encode(struct auenc_state *st, uint8_t *buf, size_t *len, - const int16_t *sampv, size_t sampc) + int fmt, const void *sampv, size_t sampc) { int n; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + n = g722_encode(&st->enc, buf, sampv, (int)sampc); if (n <= 0) { return EPROTO; @@ -143,7 +147,7 @@ static int encode(struct auenc_state *st, uint8_t *buf, size_t *len, } -static int decode(struct audec_state *st, int16_t *sampv, size_t *sampc, +static int decode(struct audec_state *st, int fmt, void *sampv, size_t *sampc, const uint8_t *buf, size_t len) { int n; @@ -151,6 +155,9 @@ static int decode(struct audec_state *st, int16_t *sampv, size_t *sampc, if (!st || !sampv || !buf) return EINVAL; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + n = g722_decode(&st->dec, sampv, buf, (int)len); if (n < 0) return EPROTO; diff --git a/modules/g7221/decode.c b/modules/g7221/decode.c index 0f7155f..298a8ae 100644 --- a/modules/g7221/decode.c +++ b/modules/g7221/decode.c @@ -48,7 +48,8 @@ int g7221_decode_update(struct audec_state **adsp, const struct aucodec *ac, } -int g7221_decode(struct audec_state *ads, int16_t *sampv, size_t *sampc, +int g7221_decode(struct audec_state *ads, + int fmt, void *sampv, size_t *sampc, const uint8_t *buf, size_t len) { size_t framec; diff --git a/modules/g7221/encode.c b/modules/g7221/encode.c index 8345f5f..8dec82f 100644 --- a/modules/g7221/encode.c +++ b/modules/g7221/encode.c @@ -50,7 +50,7 @@ int g7221_encode_update(struct auenc_state **aesp, const struct aucodec *ac, int g7221_encode(struct auenc_state *aes, uint8_t *buf, size_t *len, - const int16_t *sampv, size_t sampc) + int fmt, const void *sampv, size_t sampc) { size_t framec; diff --git a/modules/g7221/g7221.h b/modules/g7221/g7221.h index 635fc01..2c16d4c 100644 --- a/modules/g7221/g7221.h +++ b/modules/g7221/g7221.h @@ -13,13 +13,14 @@ struct g7221_aucodec { int g7221_encode_update(struct auenc_state **aesp, const struct aucodec *ac, struct auenc_param *prm, const char *fmtp); int g7221_encode(struct auenc_state *aes, uint8_t *buf, size_t *len, - const int16_t *sampv, size_t sampc); + int fmt, const void *sampv, size_t sampc); /* Decode */ int g7221_decode_update(struct audec_state **adsp, const struct aucodec *ac, const char *fmtp); -int g7221_decode(struct audec_state *ads, int16_t *sampv, size_t *sampc, +int g7221_decode(struct audec_state *ads, + int fmt, void *sampv, size_t *sampc, const uint8_t *buf, size_t len); diff --git a/modules/g726/g726.c b/modules/g726/g726.c index fd4e462..8334b84 100644 --- a/modules/g726/g726.c +++ b/modules/g726/g726.c @@ -5,6 +5,7 @@ */ #include +#include #include #define SPANDSP_EXPOSE_INTERNAL_STRUCTURES 1 #include @@ -119,11 +120,14 @@ static int decode_update(struct audec_state **adsp, static int encode(struct auenc_state *st, uint8_t *buf, - size_t *len, const int16_t *sampv, size_t sampc) + size_t *len, int fmt, const void *sampv, size_t sampc) { if (!buf || !len || !sampv) return EINVAL; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + if (*len < MAX_PACKET) return ENOMEM; @@ -133,12 +137,15 @@ static int encode(struct auenc_state *st, uint8_t *buf, } -static int decode(struct audec_state *st, int16_t *sampv, +static int decode(struct audec_state *st, int fmt, void *sampv, size_t *sampc, const uint8_t *buf, size_t len) { if (!sampv || !sampc || !buf) return EINVAL; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + *sampc = g726_decode(&st->st, sampv, buf, (int)len); return 0; diff --git a/modules/gsm/gsm.c b/modules/gsm/gsm.c index be225d8..da7fba7 100644 --- a/modules/gsm/gsm.c +++ b/modules/gsm/gsm.c @@ -5,6 +5,7 @@ */ #include /* please report if you have problems finding this file */ #include +#include #include @@ -113,13 +114,16 @@ static int decode_update(struct audec_state **adsp, static int encode(struct auenc_state *st, uint8_t *buf, size_t *len, - const int16_t *sampv, size_t sampc) + int fmt, const void *sampv, size_t sampc) { if (sampc != FRAME_SIZE) return EPROTO; if (*len < sizeof(gsm_frame)) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + gsm_encode(st->enc, (gsm_signal *)sampv, buf); *len = sizeof(gsm_frame); @@ -128,7 +132,7 @@ static int encode(struct auenc_state *st, uint8_t *buf, size_t *len, } -static int decode(struct audec_state *st, int16_t *sampv, size_t *sampc, +static int decode(struct audec_state *st, int fmt, void *sampv, size_t *sampc, const uint8_t *buf, size_t len) { int ret; @@ -138,6 +142,9 @@ static int decode(struct audec_state *st, int16_t *sampv, size_t *sampc, if (len < sizeof(gsm_frame)) return EBADMSG; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + ret = gsm_decode(st->dec, (gsm_byte *)buf, (gsm_signal *)sampv); if (ret) return EPROTO; diff --git a/modules/l16/l16.c b/modules/l16/l16.c index ce131a0..3f324c9 100644 --- a/modules/l16/l16.c +++ b/modules/l16/l16.c @@ -4,6 +4,7 @@ * Copyright (C) 2010 - 2015 Creytiv.com */ #include +#include #include @@ -18,9 +19,10 @@ enum {NR_CODECS = 8}; static int encode(struct auenc_state *st, uint8_t *buf, size_t *len, - const int16_t *sampv, size_t sampc) + int fmt, const void *sampv, size_t sampc) { int16_t *p = (void *)buf; + const int16_t *sampv16 = sampv; (void)st; if (!buf || !len || !sampv) @@ -29,19 +31,23 @@ static int encode(struct auenc_state *st, uint8_t *buf, size_t *len, if (*len < sampc*2) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + *len = sampc*2; while (sampc--) - *p++ = htons(*sampv++); + *p++ = htons(*sampv16++); return 0; } -static int decode(struct audec_state *st, int16_t *sampv, size_t *sampc, +static int decode(struct audec_state *st, int fmt, void *sampv, size_t *sampc, const uint8_t *buf, size_t len) { int16_t *p = (void *)buf; + int16_t *sampv16 = sampv; (void)st; if (!buf || !len || !sampv) @@ -50,11 +56,14 @@ static int decode(struct audec_state *st, int16_t *sampv, size_t *sampc, if (*sampc < len/2) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + *sampc = len/2; len /= 2; while (len--) - *sampv++ = ntohs(*p++); + *sampv16++ = ntohs(*p++); return 0; } @@ -62,14 +71,14 @@ static int decode(struct audec_state *st, int16_t *sampv, size_t *sampc, /* See RFC 3551 */ static struct aucodec l16v[NR_CODECS] = { -{LE_INIT, "10", "L16", 44100, 44100, 2, 0, 0, encode, 0, decode, 0, 0, 0,0,0}, -{LE_INIT, 0, "L16", 32000, 32000, 2, 0, 0, encode, 0, decode, 0, 0, 0,0,0}, -{LE_INIT, 0, "L16", 16000, 16000, 2, 0, 0, encode, 0, decode, 0, 0, 0,0,0}, -{LE_INIT, 0, "L16", 8000, 8000, 2, 0, 0, encode, 0, decode, 0, 0, 0,0,0}, -{LE_INIT, "11", "L16", 44100, 44100, 1, 0, 0, encode, 0, decode, 0, 0, 0,0,0}, -{LE_INIT, 0, "L16", 32000, 32000, 1, 0, 0, encode, 0, decode, 0, 0, 0,0,0}, -{LE_INIT, 0, "L16", 16000, 16000, 1, 0, 0, encode, 0, decode, 0, 0, 0,0,0}, -{LE_INIT, 0, "L16", 8000, 8000, 1, 0, 0, encode, 0, decode, 0, 0, 0,0,0}, +{LE_INIT, "10", "L16", 44100, 44100, 2, 0, 0, encode, 0, decode, 0, 0, 0}, +{LE_INIT, 0, "L16", 32000, 32000, 2, 0, 0, encode, 0, decode, 0, 0, 0}, +{LE_INIT, 0, "L16", 16000, 16000, 2, 0, 0, encode, 0, decode, 0, 0, 0}, +{LE_INIT, 0, "L16", 8000, 8000, 2, 0, 0, encode, 0, decode, 0, 0, 0}, +{LE_INIT, "11", "L16", 44100, 44100, 1, 0, 0, encode, 0, decode, 0, 0, 0}, +{LE_INIT, 0, "L16", 32000, 32000, 1, 0, 0, encode, 0, decode, 0, 0, 0}, +{LE_INIT, 0, "L16", 16000, 16000, 1, 0, 0, encode, 0, decode, 0, 0, 0}, +{LE_INIT, 0, "L16", 8000, 8000, 1, 0, 0, encode, 0, decode, 0, 0, 0}, }; diff --git a/modules/mpa/decode.c b/modules/mpa/decode.c index 4e2a720..b7aaf41 100644 --- a/modules/mpa/decode.c +++ b/modules/mpa/decode.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -110,7 +111,8 @@ int mpa_decode_update(struct audec_state **adsp, const struct aucodec *ac, } -int mpa_decode_frm(struct audec_state *ads, int16_t *sampv, size_t *sampc, +int mpa_decode_frm(struct audec_state *ads, + int fmt, void *sampv_void, size_t *sampc, const uint8_t *buf, size_t len) { int result, channels, encoding, i; @@ -118,6 +120,7 @@ int mpa_decode_frm(struct audec_state *ads, int16_t *sampv, size_t *sampc, size_t n; spx_uint32_t intermediate_len; spx_uint32_t out_len; + int16_t *sampv = sampv_void; #ifdef DEBUG debug("MPA dec start %d %ld\n",len, *sampc); @@ -132,6 +135,9 @@ int mpa_decode_frm(struct audec_state *ads, int16_t *sampv, size_t *sampc, return EPROTO; } + if (fmt != AUFMT_S16LE) + return ENOTSUP; + n = 0; result = mpg123_decode(ads->dec, buf+4, len-4, (unsigned char*)ads->intermediate_buffer, diff --git a/modules/mpa/encode.c b/modules/mpa/encode.c index d13bc0a..8c8968a 100644 --- a/modules/mpa/encode.c +++ b/modules/mpa/encode.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -136,7 +137,7 @@ out: int mpa_encode_frm(struct auenc_state *aes, uint8_t *buf, size_t *len, - const int16_t *sampv, size_t sampc) + int fmt, const void *sampv, size_t sampc) { int n; spx_uint32_t intermediate_len,in_len; @@ -144,6 +145,9 @@ int mpa_encode_frm(struct auenc_state *aes, uint8_t *buf, size_t *len, if (!aes || !buf || !len || !sampv) return EINVAL; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + if (aes->resampler) { in_len = (uint32_t)sampc/2; intermediate_len = sizeof(aes->intermediate_buffer) diff --git a/modules/mpa/mpa.h b/modules/mpa/mpa.h index 0db2528..170cc3c 100644 --- a/modules/mpa/mpa.h +++ b/modules/mpa/mpa.h @@ -24,14 +24,15 @@ struct mpa_param { int mpa_encode_update(struct auenc_state **aesp, const struct aucodec *ac, struct auenc_param *prm, const char *fmtp); int mpa_encode_frm(struct auenc_state *aes, uint8_t *buf, size_t *len, - const int16_t *sampv, size_t sampc); + int fmt, const void *sampv, size_t sampc); /* Decode */ int mpa_decode_update(struct audec_state **adsp, const struct aucodec *ac, const char *fmtp); -int mpa_decode_frm(struct audec_state *ads, int16_t *sampv, size_t *sampc, - const uint8_t *buf, size_t len); +int mpa_decode_frm(struct audec_state *ads, + int fmt, void *sampv, size_t *sampc, + const uint8_t *buf, size_t len); /* SDP */ void mpa_decode_fmtp(struct mpa_param *prm, const char *fmtp); diff --git a/modules/opus/decode.c b/modules/opus/decode.c index a09f2ff..a4b8721 100644 --- a/modules/opus/decode.c +++ b/modules/opus/decode.c @@ -64,7 +64,8 @@ int opus_decode_update(struct audec_state **adsp, const struct aucodec *ac, } -int opus_decode_frm(struct audec_state *ads, int16_t *sampv, size_t *sampc, +int opus_decode_frm(struct audec_state *ads, + int fmt, void *sampv, size_t *sampc, const uint8_t *buf, size_t len) { int n; @@ -72,11 +73,29 @@ int opus_decode_frm(struct audec_state *ads, int16_t *sampv, size_t *sampc, if (!ads || !sampv || !sampc || !buf) return EINVAL; - n = opus_decode(ads->dec, buf, (opus_int32)len, - sampv, (int)(*sampc/ads->ch), 0); - if (n < 0) { - warning("opus: decode error: %s\n", opus_strerror(n)); - return EPROTO; + switch (fmt) { + + case AUFMT_S16LE: + n = opus_decode(ads->dec, buf, (opus_int32)len, + sampv, (int)(*sampc/ads->ch), 0); + if (n < 0) { + warning("opus: decode error: %s\n", opus_strerror(n)); + return EPROTO; + } + break; + + case AUFMT_FLOAT: + n = opus_decode_float(ads->dec, buf, (opus_int32)len, + sampv, (int)(*sampc/ads->ch), 0); + if (n < 0) { + warning("opus: float decode error: %s\n", + opus_strerror(n)); + return EPROTO; + } + break; + + default: + return ENOTSUP; } *sampc = n * ads->ch; @@ -85,40 +104,33 @@ int opus_decode_frm(struct audec_state *ads, int16_t *sampv, size_t *sampc, } -int opus_decode_format_frm(struct audec_state *ads, - int fmt, void *sampv, size_t *sampc, - const uint8_t *buf, size_t len) +int opus_decode_pkloss(struct audec_state *ads, + int fmt, void *sampv, size_t *sampc) { int n; - if (!ads || !sampv || !sampc || !buf) + if (!ads || !sampv || !sampc) return EINVAL; - if (fmt != AUFMT_FLOAT) - return ENOTSUP; - n = opus_decode_float(ads->dec, buf, (opus_int32)len, - sampv, (int)(*sampc/ads->ch), 0); - if (n < 0) { - warning("opus: decode error: %s\n", opus_strerror(n)); - return EPROTO; - } + switch (fmt) { - *sampc = n * ads->ch; - - return 0; -} + case AUFMT_S16LE: + n = opus_decode(ads->dec, NULL, 0, + sampv, (int)(*sampc/ads->ch), 0); + if (n < 0) + return EPROTO; + break; + case AUFMT_FLOAT: + n = opus_decode_float(ads->dec, NULL, 0, + sampv, (int)(*sampc/ads->ch), 0); + if (n < 0) + return EPROTO; + break; -int opus_decode_pkloss(struct audec_state *ads, int16_t *sampv, size_t *sampc) -{ - int n; - - if (!ads || !sampv || !sampc) - return EINVAL; - - n = opus_decode(ads->dec, NULL, 0, sampv, (int)(*sampc/ads->ch), 0); - if (n < 0) - return EPROTO; + default: + return ENOTSUP; + } *sampc = n * ads->ch; diff --git a/modules/opus/encode.c b/modules/opus/encode.c index 7450d92..7baf4f8 100644 --- a/modules/opus/encode.c +++ b/modules/opus/encode.c @@ -172,42 +172,37 @@ int opus_encode_update(struct auenc_state **aesp, const struct aucodec *ac, int opus_encode_frm(struct auenc_state *aes, uint8_t *buf, size_t *len, - const int16_t *sampv, size_t sampc) + int fmt, const void *sampv, size_t sampc) { opus_int32 n; if (!aes || !buf || !len || !sampv) return EINVAL; - n = opus_encode(aes->enc, sampv, (int)(sampc/aes->ch), - buf, (opus_int32)(*len)); - if (n < 0) { - warning("opus: encode error: %s\n", opus_strerror((int)n)); - return EPROTO; - } - - *len = n; - - return 0; -} + switch (fmt) { + case AUFMT_S16LE: + n = opus_encode(aes->enc, sampv, (int)(sampc/aes->ch), + buf, (opus_int32)(*len)); + if (n < 0) { + warning("opus: encode error: %s\n", + opus_strerror((int)n)); + return EPROTO; + } + break; + + case AUFMT_FLOAT: + n = opus_encode_float(aes->enc, sampv, (int)(sampc/aes->ch), + buf, (opus_int32)(*len)); + if (n < 0) { + warning("opus: float encode error: %s\n", + opus_strerror((int)n)); + return EPROTO; + } + break; -int opus_encode_format_frm(struct auenc_state *aes, uint8_t *buf, size_t *len, - int fmt, const void *sampv, size_t sampc) -{ - opus_int32 n; - - if (!aes || !buf || !len || !sampv) - return EINVAL; - - if (fmt != AUFMT_FLOAT) + default: return ENOTSUP; - - n = opus_encode_float(aes->enc, sampv, (int)(sampc/aes->ch), - buf, (opus_int32)(*len)); - if (n < 0) { - warning("opus: encode error: %s\n", opus_strerror((int)n)); - return EPROTO; } *len = n; diff --git a/modules/opus/opus.c b/modules/opus/opus.c index 8346680..7acccec 100644 --- a/modules/opus/opus.c +++ b/modules/opus/opus.c @@ -69,8 +69,6 @@ static struct aucodec opus = { .decupdh = opus_decode_update, .dech = opus_decode_frm, .plch = opus_decode_pkloss, - .encfmth = opus_encode_format_frm, - .decfmth = opus_decode_format_frm, }; diff --git a/modules/opus/opus.h b/modules/opus/opus.h index 9e79bd5..70fa0e3 100644 --- a/modules/opus/opus.h +++ b/modules/opus/opus.h @@ -19,20 +19,17 @@ struct opus_param { int opus_encode_update(struct auenc_state **aesp, const struct aucodec *ac, struct auenc_param *prm, const char *fmtp); int opus_encode_frm(struct auenc_state *aes, uint8_t *buf, size_t *len, - const int16_t *sampv, size_t sampc); -int opus_encode_format_frm(struct auenc_state *aes, uint8_t *buf, size_t *len, - int fmt, const void *sampv, size_t sampc); + int fmt, const void *sampv, size_t sampc); /* Decode */ int opus_decode_update(struct audec_state **adsp, const struct aucodec *ac, const char *fmtp); -int opus_decode_frm(struct audec_state *ads, int16_t *sampv, size_t *sampc, +int opus_decode_frm(struct audec_state *ads, + int fmt, void *sampv, size_t *sampc, const uint8_t *buf, size_t len); -int opus_decode_format_frm(struct audec_state *ads, - int fmt, void *sampv, size_t *sampc, - const uint8_t *buf, size_t len); -int opus_decode_pkloss(struct audec_state *st, int16_t *sampv, size_t *sampc); +int opus_decode_pkloss(struct audec_state *st, + int fmt, void *sampv, size_t *sampc); /* SDP */ diff --git a/src/audio.c b/src/audio.c index b5ce913..dd5369f 100644 --- a/src/audio.c +++ b/src/audio.c @@ -450,19 +450,8 @@ static void encode_rtp_send(struct audio *a, struct autx *tx, len = mbuf_get_space(tx->mb); - if (tx->enc_fmt == AUFMT_S16LE) { - err = tx->ac->ench(tx->enc, mbuf_buf(tx->mb), &len, - sampv, sampc); - } - else if (tx->ac->encfmth) { - err = tx->ac->encfmth(tx->enc, mbuf_buf(tx->mb), &len, - tx->enc_fmt, sampv, sampc); - } - else { - warning("audio: sample format not supported by encoder (%s)\n", - aufmt_name(tx->enc_fmt)); - return; - } + err = tx->ac->ench(tx->enc, mbuf_buf(tx->mb), &len, + tx->enc_fmt, sampv, sampc); if ((err & 0xffff0000) == 0x00010000) { /* MPA needs some special treatment here */ @@ -766,27 +755,15 @@ static int aurx_stream_decode(struct aurx *rx, struct mbuf *mb) if (mbuf_get_left(mb)) { - if (rx->dec_fmt == AUFMT_S16LE) { - err = rx->ac->dech(rx->dec, rx->sampv, &sampc, - mbuf_buf(mb), mbuf_get_left(mb)); + err = rx->ac->dech(rx->dec, + rx->dec_fmt, rx->sampv, &sampc, + mbuf_buf(mb), mbuf_get_left(mb)); - } - else if (rx->ac->decfmth) { - err = rx->ac->decfmth(rx->dec, - rx->dec_fmt, rx->sampv, &sampc, - mbuf_buf(mb), mbuf_get_left(mb)); - } - else { - warning("audio: sample format not supported" - " by decoder (%s)\n", - aufmt_name(rx->dec_fmt)); - return ENOTSUP; - } } else if (rx->ac->plch && rx->dec_fmt == AUFMT_S16LE) { sampc = rx->ac->srate * rx->ac->ch * rx->ptime / 1000; - err = rx->ac->plch(rx->dec, rx->sampv, &sampc); + err = rx->ac->plch(rx->dec, rx->dec_fmt, rx->sampv, &sampc); } else { /* no PLC in the codec, might be done in filters below */ diff --git a/test/mock/mock_aucodec.c b/test/mock/mock_aucodec.c index fd91721..8115a36 100644 --- a/test/mock/mock_aucodec.c +++ b/test/mock/mock_aucodec.c @@ -16,9 +16,10 @@ static int mock_l16_encode(struct auenc_state *st, uint8_t *buf, size_t *len, - const int16_t *sampv, size_t sampc) + int fmt, const void *sampv_void, size_t sampc) { int16_t *p = (void *)buf; + const int16_t *sampv = sampv_void; (void)st; if (!buf || !len || !sampv) @@ -27,6 +28,9 @@ static int mock_l16_encode(struct auenc_state *st, uint8_t *buf, size_t *len, if (*len < sampc*2) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + *len = 2 + sampc*2; *p++ = L16_HEADER; @@ -39,10 +43,11 @@ static int mock_l16_encode(struct auenc_state *st, uint8_t *buf, size_t *len, static int mock_l16_decode(struct audec_state *st, - int16_t *sampv, size_t *sampc, + int fmt, void *sampv_void, size_t *sampc, const uint8_t *buf, size_t len) { int16_t *p = (void *)buf; + int16_t *sampv = sampv_void; uint16_t hdr; (void)st; @@ -55,6 +60,9 @@ static int mock_l16_decode(struct audec_state *st, if (*sampc < len/2) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + *sampc = (len - 2)/2; hdr = *p++; -- cgit v1.2.3 From 69452253ee62ffbc58b4e17e84a66333641a67dc Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 3 Feb 2018 18:46:26 +0100 Subject: audio: check sample formats --- src/audio.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/audio.c b/src/audio.c index dd5369f..358127e 100644 --- a/src/audio.c +++ b/src/audio.c @@ -522,7 +522,8 @@ static void poll_aubuf_tx(struct audio *a) aubuf_read(tx->aubuf, (uint8_t *)tx->sampv, num_bytes); } - else { + else if (tx->enc_fmt == AUFMT_S16LE) { + /* Convert from ausrc format to 16-bit format */ void *tmp_sampv; @@ -544,6 +545,11 @@ static void poll_aubuf_tx(struct audio *a) mem_deref(tmp_sampv); } + else { + warning("audio: tx: invalid sample formats (%s -> %s)\n", + aufmt_name(tx->src_fmt), + aufmt_name(tx->enc_fmt)); + } /* optional resampler */ if (tx->resamp.resample) { @@ -833,7 +839,7 @@ static int aurx_stream_decode(struct aurx *rx, struct mbuf *mb) if (err) goto out; } - else { + else if (rx->dec_fmt == AUFMT_S16LE) { /* Convert from 16-bit to auplay format */ void *tmp_sampv; @@ -860,6 +866,11 @@ static int aurx_stream_decode(struct aurx *rx, struct mbuf *mb) if (err) goto out; } + else { + warning("audio: decode: invalid sample formats (%s -> %s)\n", + aufmt_name(rx->dec_fmt), + aufmt_name(rx->play_fmt)); + } rx->aubuf_started = true; -- cgit v1.2.3 From 43f4f5e8c8f0b14c2aa99c92cb6da2e8bcb72642 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 4 Feb 2018 20:31:52 +0100 Subject: silk: updated aucodec API --- modules/silk/silk.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/silk/silk.c b/modules/silk/silk.c index dee296c..5bd9be5 100644 --- a/modules/silk/silk.c +++ b/modules/silk/silk.c @@ -4,6 +4,7 @@ * Copyright (C) 2010 - 2015 Creytiv.com */ #include +#include #include #include @@ -155,13 +156,15 @@ static int decode_update(struct audec_state **adsp, static int encode(struct auenc_state *st, uint8_t *buf, size_t *len, - const int16_t *sampv, size_t sampc) + int fmt, const void *sampv, size_t sampc) { int ret; int16_t nBytesOut; if (*len < MAX_BYTES_PER_FRAME) return ENOMEM; + if (fmt != AUFMT_S16LE) + return ENOTSUP; nBytesOut = *len; ret = SKP_Silk_SDK_Encode(st->enc, @@ -180,12 +183,15 @@ static int encode(struct auenc_state *st, uint8_t *buf, size_t *len, } -static int decode(struct audec_state *st, int16_t *sampv, +static int decode(struct audec_state *st, int fmt, void *sampv, size_t *sampc, const uint8_t *buf, size_t len) { int16_t nsamp = *sampc; int ret; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + ret = SKP_Silk_SDK_Decode(st->dec, &st->decControl, 0, @@ -203,11 +209,14 @@ static int decode(struct audec_state *st, int16_t *sampv, } -static int plc(struct audec_state *st, int16_t *sampv, size_t *sampc) +static int plc(struct audec_state *st, int fmt, void *sampv, size_t *sampc) { int16_t nsamp = *sampc; int ret; + if (fmt != AUFMT_S16LE) + return ENOTSUP; + ret = SKP_Silk_SDK_Decode(st->dec, &st->decControl, 1, -- cgit v1.2.3 From a9da88169dbfbc3aedc72770c9e708dbfce0effb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Tue, 6 Feb 2018 12:55:24 +0100 Subject: ctrl_tcp: add module entry to config file template (#357) --- src/config.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/config.c b/src/config.c index 6de53f5..77f4a5b 100644 --- a/src/config.c +++ b/src/config.c @@ -863,6 +863,7 @@ int config_write_template(const char *file, const struct config *cfg) (void)re_fprintf(f, "#module_app\t\t" MOD_PRE "presence"MOD_EXT"\n"); (void)re_fprintf(f, "#module_app\t\t" MOD_PRE "syslog"MOD_EXT"\n"); (void)re_fprintf(f, "#module_app\t\t" MOD_PRE "mqtt" MOD_EXT "\n"); + (void)re_fprintf(f, "#module_app\t\t" MOD_PRE "ctrl_tcp" MOD_EXT "\n"); #ifdef USE_VIDEO (void)re_fprintf(f, "module_app\t\t" MOD_PRE "vidloop"MOD_EXT"\n"); #endif @@ -879,6 +880,9 @@ int config_write_template(const char *file, const struct config *cfg) (void)re_fprintf(f, "\n"); (void)re_fprintf(f, "http_listen\t\t0.0.0.0:8000\n"); + (void)re_fprintf(f, "\n"); + (void)re_fprintf(f, "ctrl_tcp_listen\t\t0.0.0.0:4444\n"); + (void)re_fprintf(f, "\n"); (void)re_fprintf(f, "evdev_device\t\t/dev/input/event0\n"); -- cgit v1.2.3 From 3bc256b482e7ce59386264737e05c529d2f5df35 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Tue, 6 Feb 2018 18:09:16 +0100 Subject: test: make 'struct user' opaque avoid conflict with struct user defined in --- test/sip/domain.c | 3 ++- test/sip/sipsrv.h | 7 ++----- test/sip/user.c | 13 +++++++++++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/test/sip/domain.c b/test/sip/domain.c index 063e3b9..2aec1a9 100644 --- a/test/sip/domain.c +++ b/test/sip/domain.c @@ -163,7 +163,8 @@ int domain_auth(struct sip_server *srv, break; } - err = httpauth_digest_response_auth(&resp, &msg->met,usr->ha1); + err = httpauth_digest_response_auth(&resp, &msg->met, + user_ha1(usr)); if (err) return err; diff --git a/test/sip/sipsrv.h b/test/sip/sipsrv.h index a4b8bbf..1f1076c 100644 --- a/test/sip/sipsrv.h +++ b/test/sip/sipsrv.h @@ -111,12 +111,9 @@ void location_rollback(struct list *locl); * User */ -struct user { - struct le he; - uint8_t ha1[MD5_SIZE]; - char *name; -}; +struct user; int user_add(struct hash *ht, const char *username, const char *password, const char *realm); struct user *user_find(struct hash *ht, const struct pl *name); +const uint8_t *user_ha1(const struct user *usr); diff --git a/test/sip/user.c b/test/sip/user.c index 99fb47d..73a101e 100644 --- a/test/sip/user.c +++ b/test/sip/user.c @@ -7,6 +7,13 @@ #include "sipsrv.h" +struct user { + struct le he; + uint8_t ha1[MD5_SIZE]; + char *name; +}; + + static void destructor(void *arg) { struct user *usr = arg; @@ -71,3 +78,9 @@ struct user *user_find(struct hash *ht, const struct pl *name) return NULL; } + + +const uint8_t *user_ha1(const struct user *usr) +{ + return usr ? usr->ha1 : NULL; +} -- cgit v1.2.3 From 9170d8cd85718b496d288edbec60a1542c03a669 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Fri, 9 Feb 2018 13:45:22 +0100 Subject: gst1: define _POSIX_C_SOURCE to make nanosleep visible - this fixes a compile error on CentOS 7.4 --- modules/gst1/gst.c | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/gst1/gst.c b/modules/gst1/gst.c index 380334a..a500f4c 100644 --- a/modules/gst1/gst.c +++ b/modules/gst1/gst.c @@ -4,6 +4,7 @@ * Copyright (C) 2010 - 2015 Creytiv.com */ #define _DEFAULT_SOURCE 1 +#define _POSIX_C_SOURCE 199309L #include #include #include -- cgit v1.2.3 From 246e2b01accd5f6936bacd5c6092339b228d0150 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 10 Feb 2018 20:43:59 +0100 Subject: avcodec: add support for YUV444P pixel format --- modules/avcodec/decode.c | 4 ++++ modules/avcodec/encode.c | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/modules/avcodec/decode.c b/modules/avcodec/decode.c index badb192..d9ce5c7 100644 --- a/modules/avcodec/decode.c +++ b/modules/avcodec/decode.c @@ -247,6 +247,10 @@ static int ffdecode(struct viddec_state *st, struct vidframe *frame) frame->fmt = VID_FMT_NV12; break; + case AV_PIX_FMT_YUV444P: + frame->fmt = VID_FMT_YUV444P; + break; + default: warning("avcodec: decode: bad pixel format" " (%i) (%s)\n", diff --git a/modules/avcodec/encode.c b/modules/avcodec/encode.c index cb9d63d..0bdb1d3 100644 --- a/modules/avcodec/encode.c +++ b/modules/avcodec/encode.c @@ -586,6 +586,11 @@ int encode_x264(struct videnc_state *st, bool update, pln = 2; break; + case VID_FMT_YUV444P: + csp = X264_CSP_I444; + pln = 3; + break; + default: warning("avcodec: pixel format not supported (%s)\n", vidfmt_name(frame->fmt)); @@ -680,6 +685,10 @@ int encode(struct videnc_state *st, bool update, const struct vidframe *frame) pix_fmt = AV_PIX_FMT_NV12; break; + case VID_FMT_YUV444P: + pix_fmt = AV_PIX_FMT_YUV444P; + break; + default: warning("avcodec: pixel format not supported (%s)\n", vidfmt_name(frame->fmt)); -- cgit v1.2.3 From 998b7e43af9c535a167e3063aea4b0b232639662 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 10 Feb 2018 20:46:36 +0100 Subject: config: add configurable video pixel format config: videnc_format yuv420p # yuv420p, yuv444p, ... The default pixel format is still YUV420P --- include/baresip.h | 1 + modules/vidloop/vidloop.c | 20 +++++++++----------- src/config.c | 31 +++++++++++++++++++++++++++++++ src/video.c | 13 ++++--------- 4 files changed, 45 insertions(+), 20 deletions(-) diff --git a/include/baresip.h b/include/baresip.h index 1e7e862..5ca2759 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -221,6 +221,7 @@ struct config_video { uint32_t bitrate; /**< Encoder bitrate in [bit/s] */ uint32_t fps; /**< Video framerate */ bool fullscreen; /**< Enable fullscreen display */ + int enc_fmt; /**< Encoder pixelfmt (enum vidfmt) */ }; #endif diff --git a/modules/vidloop/vidloop.c b/modules/vidloop/vidloop.c index d99fa49..6deddf2 100644 --- a/modules/vidloop/vidloop.c +++ b/modules/vidloop/vidloop.c @@ -32,12 +32,6 @@ */ -/** Internal pixel-format */ -#ifndef VIDLOOP_INTERNAL_FMT -#define VIDLOOP_INTERNAL_FMT (VID_FMT_YUV420P) -#endif - - /** Video Statistics */ struct vstat { uint64_t tsamp; @@ -181,17 +175,17 @@ static void vidsrc_frame_handler(struct vidframe *frame, void *arg) ++vl->stat.frames; - if (frame->fmt != VIDLOOP_INTERNAL_FMT) { + if (frame->fmt != vl->cfg.enc_fmt) { if (!vl->need_conv) { info("vidloop: NOTE: pixel-format conversion" " needed: %s --> %s\n", vidfmt_name(frame->fmt), - vidfmt_name(VIDLOOP_INTERNAL_FMT)); + vidfmt_name(vl->cfg.enc_fmt)); vl->need_conv = true; } - if (vidframe_alloc(&f2, VIDLOOP_INTERNAL_FMT, &frame->size)) + if (vidframe_alloc(&f2, vl->cfg.enc_fmt, &frame->size)) return; vidconv(f2, frame, 0); @@ -209,7 +203,10 @@ static void vidsrc_frame_handler(struct vidframe *frame, void *arg) } if (vl->vc_enc && vl->enc) { - (void)vl->vc_enc->ench(vl->enc, false, frame); + err = vl->vc_enc->ench(vl->enc, false, frame); + if (err) { + warning("vidloop: encoder error (%m)\n", err); + } } else { vl->stat.bytes += vidframe_size(frame->fmt, &frame->size); @@ -287,10 +284,11 @@ static void print_status(struct video_loop *vl) { (void)re_fprintf(stdout, "\rstatus:" - " [%s] [%s] intra=%zu " + " [%s] [%s] fmt=%s intra=%zu " " EFPS=%.1f %u kbit/s \r", vl->vc_enc ? vl->vc_enc->name : "", vl->vc_dec ? vl->vc_dec->name : "", + vidfmt_name(vl->cfg.enc_fmt), vl->stat.n_intra, vl->stat.efps, vl->stat.bitrate); fflush(stdout); diff --git a/src/config.c b/src/config.c index 77f4a5b..8727031 100644 --- a/src/config.c +++ b/src/config.c @@ -71,6 +71,7 @@ static struct config core_config = { 500000, 25, true, + VID_FMT_YUV420P, }, #endif @@ -180,6 +181,34 @@ static int conf_get_aufmt(const struct conf *conf, const char *name, } +static int conf_get_vidfmt(const struct conf *conf, const char *name, + int *fmtp) +{ + struct pl pl; + int fmt; + int err; + + err = conf_get(conf, name, &pl); + if (err) + return err; + + for (fmt=0; fmtvideo.bitrate); (void)conf_get_u32(conf, "video_fps", &cfg->video.fps); (void)conf_get_bool(conf, "video_fullscreen", &cfg->video.fullscreen); + + conf_get_vidfmt(conf, "videnc_format", &cfg->video.enc_fmt); #else (void)size; #endif diff --git a/src/video.c b/src/video.c index a2e58bc..e1ff867 100644 --- a/src/video.c +++ b/src/video.c @@ -18,12 +18,6 @@ #include "magic.h" -/** Internal video-encoder format */ -#ifndef VIDENC_INTERNAL_FMT -#define VIDENC_INTERNAL_FMT (VID_FMT_YUV420P) -#endif - - enum { MAX_MUTED_FRAMES = 3, }; @@ -404,13 +398,14 @@ static void encode_rtp_send(struct vtx *vtx, struct vidframe *frame) lock_write_get(vtx->lock); /* Convert image */ - if (frame->fmt != VIDENC_INTERNAL_FMT) { + if (frame->fmt != vtx->video->cfg.enc_fmt) { vtx->vsrc_size = frame->size; if (!vtx->frame) { - err = vidframe_alloc(&vtx->frame, VIDENC_INTERNAL_FMT, + err = vidframe_alloc(&vtx->frame, + vtx->video->cfg.enc_fmt, &vtx->vsrc_size); if (err) goto unlock; @@ -941,7 +936,7 @@ static int set_encoder_format(struct vtx *vtx, const char *src, } vtx->mute_frame = mem_deref(vtx->mute_frame); - err = vidframe_alloc(&vtx->mute_frame, VIDENC_INTERNAL_FMT, size); + err = vidframe_alloc(&vtx->mute_frame, vtx->video->cfg.enc_fmt, size); if (err) return err; -- cgit v1.2.3 From e4d253c8d07929955ee391a365d8a74f691f6d83 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 10 Feb 2018 20:54:52 +0100 Subject: video: fix comparison between signed and unsigned integer warning --- src/video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video.c b/src/video.c index e1ff867..8954e0a 100644 --- a/src/video.c +++ b/src/video.c @@ -398,7 +398,7 @@ static void encode_rtp_send(struct vtx *vtx, struct vidframe *frame) lock_write_get(vtx->lock); /* Convert image */ - if (frame->fmt != vtx->video->cfg.enc_fmt) { + if (frame->fmt != (enum vidfmt)vtx->video->cfg.enc_fmt) { vtx->vsrc_size = frame->size; -- cgit v1.2.3 From 347310c749cf729be86afcb6f98967bfdad025fc Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 10 Feb 2018 20:58:49 +0100 Subject: vidloop: fix comparison between signed and unsigned integer warning --- modules/vidloop/vidloop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vidloop/vidloop.c b/modules/vidloop/vidloop.c index 6deddf2..a24dbd0 100644 --- a/modules/vidloop/vidloop.c +++ b/modules/vidloop/vidloop.c @@ -175,7 +175,7 @@ static void vidsrc_frame_handler(struct vidframe *frame, void *arg) ++vl->stat.frames; - if (frame->fmt != vl->cfg.enc_fmt) { + if (frame->fmt != (enum vidfmt)vl->cfg.enc_fmt) { if (!vl->need_conv) { info("vidloop: NOTE: pixel-format conversion" -- cgit v1.2.3 From bd7af305a42083ec46323cdf6de3a241ebfc89e8 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 10 Feb 2018 21:25:26 +0100 Subject: avcodec: extra logging for decode packet --- modules/avcodec/decode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/avcodec/decode.c b/modules/avcodec/decode.c index d9ce5c7..b9ee0c5 100644 --- a/modules/avcodec/decode.c +++ b/modules/avcodec/decode.c @@ -192,7 +192,9 @@ static int ffdecode(struct viddec_state *st, struct vidframe *frame) ret = avcodec_send_packet(st->ctx, &avpkt); if (ret < 0) { - warning("avcodec_send_packet error ret=%d\n", ret); + warning("avcodec: avcodec_send_packet error," + " packet=%zu bytes, ret=%d (%s)\n", + st->mb->end, ret, av_err2str(ret)); err = EBADMSG; goto out; } -- cgit v1.2.3 From 66692c70d769734c83f1e67f716a1ecd14a924c5 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 11 Feb 2018 01:01:16 +0100 Subject: stream: print a message when incoming RTP stream is established --- src/core.h | 1 + src/stream.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/core.h b/src/core.h index ba4034e..d08f1f2 100644 --- a/src/core.h +++ b/src/core.h @@ -377,6 +377,7 @@ struct stream { uint64_t ts_last; /**< Timestamp of last received RTP pkt */ bool terminated; /**< Stream is terminated flag */ uint32_t rtp_timeout_ms; /**< RTP Timeout value in [ms] */ + bool rtp_estab; /**< True if RTP stream is established */ }; int stream_alloc(struct stream **sp, const struct stream_param *prm, diff --git a/src/stream.c b/src/stream.c index d8fd445..e4fb655 100644 --- a/src/stream.c +++ b/src/stream.c @@ -223,6 +223,13 @@ static void rtp_handler(const struct sa *src, const struct rtp_header *hdr, metric_add_packet(&s->metric_rx, mbuf_get_left(mb)); + if (!s->rtp_estab) { + info("stream: incoming rtp for '%s' established" + ", receiving from %J\n", + sdp_media_name(s->sdp), src); + s->rtp_estab = true; + } + if (hdr->ssrc != s->ssrc_rx) { if (s->ssrc_rx) { flush = true; -- cgit v1.2.3 From 94aac09d6af64ddd02696c5d0e277cfd322dbb72 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 11 Feb 2018 01:17:41 +0100 Subject: log: add doxygen comments --- src/log.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/log.c b/src/log.c index 650689d..8047a05 100644 --- a/src/log.c +++ b/src/log.c @@ -21,6 +21,11 @@ static struct { }; +/** + * Register a log handler + * + * @param log Log handler + */ void log_register_handler(struct log *log) { if (!log) @@ -30,6 +35,11 @@ void log_register_handler(struct log *log) } +/** + * Unregister a log handler + * + * @param log Log handler + */ void log_unregister_handler(struct log *log) { if (!log) @@ -39,12 +49,22 @@ void log_unregister_handler(struct log *log) } +/** + * Enable debug-level logging + * + * @param enable True to enable, false to disable + */ void log_enable_debug(bool enable) { lg.debug = enable; } +/** + * Enable info-level logging + * + * @param enable True to enable, false to disable + */ void log_enable_info(bool enable) { lg.info = enable; @@ -57,6 +77,13 @@ void log_enable_stderr(bool enable) } +/** + * Print a message to the logging system + * + * @param level Log level + * @param fmt Formatted message + * @param ap Variable argument list + */ void vlog(enum log_level level, const char *fmt, va_list ap) { char buf[4096]; @@ -91,6 +118,13 @@ void vlog(enum log_level level, const char *fmt, va_list ap) } +/** + * Print a message to the logging system + * + * @param level Log level + * @param fmt Formatted message + * @param ... Variable arguments + */ void loglv(enum log_level level, const char *fmt, ...) { va_list ap; @@ -107,6 +141,12 @@ void loglv(enum log_level level, const char *fmt, ...) } +/** + * Print a DEBUG message to the logging system + * + * @param fmt Formatted message + * @param ... Variable arguments + */ void debug(const char *fmt, ...) { va_list ap; @@ -120,6 +160,12 @@ void debug(const char *fmt, ...) } +/** + * Print an INFO message to the logging system + * + * @param fmt Formatted message + * @param ... Variable arguments + */ void info(const char *fmt, ...) { va_list ap; @@ -133,6 +179,12 @@ void info(const char *fmt, ...) } +/** + * Print a WARNING message to the logging system + * + * @param fmt Formatted message + * @param ... Variable arguments + */ void warning(const char *fmt, ...) { va_list ap; @@ -143,6 +195,12 @@ void warning(const char *fmt, ...) } +/** + * Print an ERROR message to the logging system + * + * @param fmt Formatted message + * @param ... Variable arguments + */ void error_msg(const char *fmt, ...) { va_list ap; -- cgit v1.2.3 From ee7f909b4e43d78c120aa76e0fd69b7ce7edf988 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 11 Feb 2018 01:24:15 +0100 Subject: log: rename log_enable_stderr to log_enable_stdout --- include/baresip.h | 2 +- src/log.c | 13 +++++++++---- src/main.c | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/baresip.h b/include/baresip.h index 5ca2759..ae71033 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -490,7 +490,7 @@ void log_register_handler(struct log *logh); void log_unregister_handler(struct log *logh); void log_enable_debug(bool enable); void log_enable_info(bool enable); -void log_enable_stderr(bool enable); +void log_enable_stdout(bool enable); void vlog(enum log_level level, const char *fmt, va_list ap); void loglv(enum log_level level, const char *fmt, ...); void debug(const char *fmt, ...); diff --git a/src/log.c b/src/log.c index 8047a05..c9debdd 100644 --- a/src/log.c +++ b/src/log.c @@ -12,7 +12,7 @@ static struct { struct list logl; bool debug; bool info; - bool stder; + bool enable_stdout; } lg = { LIST_INIT, false, @@ -71,9 +71,14 @@ void log_enable_info(bool enable) } -void log_enable_stderr(bool enable) +/** + * Enable logging to standard-out + * + * @param enable True to enable, false to disable + */ +void log_enable_stdout(bool enable) { - lg.stder = enable; + lg.enable_stdout = enable; } @@ -92,7 +97,7 @@ void vlog(enum log_level level, const char *fmt, va_list ap) if (re_vsnprintf(buf, sizeof(buf), fmt, ap) < 0) return; - if (lg.stder) { + if (lg.enable_stdout) { bool color = level == LEVEL_WARN || level == LEVEL_ERROR; diff --git a/src/main.c b/src/main.c index 27683d4..05742d8 100644 --- a/src/main.c +++ b/src/main.c @@ -227,7 +227,7 @@ int main(int argc, char *argv[]) if (err) goto out; - log_enable_stderr(false); + log_enable_stdout(false); } info("baresip is ready.\n"); -- cgit v1.2.3 From ac4736ec5be5ca60157ac075e02478a32ef56864 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 11 Feb 2018 11:00:11 +0100 Subject: call: fix memory leak in case sipsess_connect() fails --- src/call.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/call.c b/src/call.c index b6c9357..01019a6 100644 --- a/src/call.c +++ b/src/call.c @@ -1540,7 +1540,7 @@ static int send_invite(struct call *call) ua_print_supported, call->ua); if (err) { warning("call: sipsess_connect: %m\n", err); - return err; + goto out; } err = str_dup(&call->id, @@ -1549,6 +1549,7 @@ static int send_invite(struct call *call) /* save call setup timer */ call->time_conn = time(NULL); + out: mem_deref(desc); return err; -- cgit v1.2.3 From 7bcdfd0943bfeeb5400fcc3f88d3436faeca599d Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 11 Feb 2018 11:34:38 +0100 Subject: mqtt: update README with correct JSON syntax (ref #356) --- modules/mqtt/README.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/modules/mqtt/README.md b/modules/mqtt/README.md index 6a86b84..ace3c36 100644 --- a/modules/mqtt/README.md +++ b/modules/mqtt/README.md @@ -6,7 +6,7 @@ This module implements an MQTT (Message Queue Telemetry Transport) client for publishing and subscribing to topics. -The module is using libmosquitto +The module is using libmosquitto. All messages are encoded in JSON format. Starting the MQTT broker: @@ -19,7 +19,7 @@ $ /usr/local/sbin/mosquitto -v Subscribing to all topics: ``` -$ mosquitto_sub -t /baresip/+ +$ mosquitto_sub -v -t /baresip/# ``` @@ -43,17 +43,16 @@ $ mosquitto_pub -t /baresip/xxx -m foo=42 ## Examples ``` -/baresip/event sip:aeh@iptel.org,REGISTERING -/baresip/event sip:aeh@iptel.org,REGISTER_OK -/baresip/event sip:aeh@iptel.org,SHUTDOWN +/baresip/event {"type":"REGISTERING","class":"register","accountaor":"sip:aeh@iptel.org"} +/baresip/event {"type":"REGISTER_OK","class":"register","accountaor":"sip:aeh@iptel.org","param":"200 OK"} +/baresip/event {"type":"SHUTDOWN","class":"application","accountaor":"sip:aeh@iptel.org"} ``` ``` mosquitto_pub -t /baresip/command -m "/dial music" -/baresip/command /dial music -/baresip/command_resp (null) -/baresip/event sip:aeh@iptel.org,CALL_ESTABLISHED -/baresip/event sip:aeh@iptel.org,CALL_CLOSED +/baresip/command {"command":"dial","params":"music","token":"123"} +/baresip/command_resp/123 (null) +/baresip/event {"type":"CALL_ESTABLISHED","class":"call","accountaor":"sip:aeh@iptel.org","direction":"outgoing","peeruri":"sip:music@iptel.org","id":"4d758140c42c5d55","param":"sip:music@iptel.org"} +/baresip/event {"type":"CALL_CLOSED","class":"call","accountaor":"sip:aeh@iptel.org","direction":"outgoing","peeruri":"sip:music@iptel.org","id":"4d758140c42c5d55","param":"Connection reset by user"} ``` - -- cgit v1.2.3 From 31712d25ce386ccd5a49eeb75bdb72e4c7b93b1f Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 11 Feb 2018 15:09:27 +0100 Subject: config: ifdef USE_VIDEO check for conf_get_vidfmt --- src/config.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/config.c b/src/config.c index 8727031..1c5b92c 100644 --- a/src/config.c +++ b/src/config.c @@ -181,6 +181,7 @@ static int conf_get_aufmt(const struct conf *conf, const char *name, } +#ifdef USE_VIDEO static int conf_get_vidfmt(const struct conf *conf, const char *name, int *fmtp) { @@ -207,6 +208,7 @@ static int conf_get_vidfmt(const struct conf *conf, const char *name, return ENOENT; } +#endif /** -- cgit v1.2.3 From dceae1a75e0722668967a301abc656c5821b91b3 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 11 Feb 2018 15:17:04 +0100 Subject: version 0.5.8 --- Makefile | 2 +- include/baresip.h | 2 +- mk/Doxyfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 7f50a2d..f528fdf 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ USE_VIDEO := 1 PROJECT := baresip -VERSION := 0.5.7 +VERSION := 0.5.8 DESCR := "Baresip is a modular SIP User-Agent with audio and video support" # Verbose and silent build modes diff --git a/include/baresip.h b/include/baresip.h index ae71033..e404e9b 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -13,7 +13,7 @@ extern "C" { /** Defines the Baresip version string */ -#define BARESIP_VERSION "0.5.7" +#define BARESIP_VERSION "0.5.8" #ifndef NET_MAX_NS diff --git a/mk/Doxyfile b/mk/Doxyfile index 3606286..cdc8a86 100644 --- a/mk/Doxyfile +++ b/mk/Doxyfile @@ -4,7 +4,7 @@ # Project related configuration options #--------------------------------------------------------------------------- PROJECT_NAME = baresip -PROJECT_NUMBER = 0.5.7 +PROJECT_NUMBER = 0.5.8 OUTPUT_DIRECTORY = ../baresip-dox CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English -- cgit v1.2.3 From ee62ed957fe3db1296697fb9ad2f3137daf09489 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 11 Feb 2018 18:25:40 +0100 Subject: README: add ctrl_tcp to list of modules --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 286ba4d..22d9a50 100644 --- a/README.md +++ b/README.md @@ -230,6 +230,7 @@ codec2 Codec2 low bit rate speech codec cons UDP/TCP console UI driver contact Contacts module coreaudio Apple Coreaudio driver +ctrl_tcp TCP control interface using JSON payload debug_cmd Debug commands directfb DirectFB video display module dshow Windows DirectShow video source -- cgit v1.2.3 From 5a0bb0fad2f07026970e21c0df25e4c61250007b Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 11 Feb 2018 18:28:00 +0100 Subject: config: add videnc_format to template --- src/config.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/config.c b/src/config.c index 1c5b92c..1e8b595 100644 --- a/src/config.c +++ b/src/config.c @@ -601,11 +601,14 @@ static int core_config_template(struct re_printf *pf, const struct config *cfg) "video_size\t\t%dx%d\n" "video_bitrate\t\t%u\n" "video_fps\t\t%u\n" - "video_fullscreen\tyes\n", + "video_fullscreen\tyes\n" + "videnc_format\t\t%s\n" + , default_video_device(), default_video_display(), cfg->video.width, cfg->video.height, - cfg->video.bitrate, cfg->video.fps); + cfg->video.bitrate, cfg->video.fps, + vidfmt_name(cfg->video.enc_fmt)); #endif err |= re_hprintf(pf, -- cgit v1.2.3 From 04f96ac9367394e85479ac5b66c8c4d9842b97fb Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 11 Feb 2018 18:34:14 +0100 Subject: baresip version 0.5.8 --- debian/changelog | 6 ++++ docs/ChangeLog | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ rpm/baresip.spec | 2 +- 3 files changed, 111 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 364d0ae..66c2c47 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +baresip (0.5.8) unstable; urgency=medium + + * version 0.5.8 + + -- Alfred E. Heggestad Sun, 11 Feb 2018 18:00:00 +0100 + baresip (0.5.7) unstable; urgency=medium * version 0.5.7 diff --git a/docs/ChangeLog b/docs/ChangeLog index d79818e..c1b2546 100644 --- a/docs/ChangeLog +++ b/docs/ChangeLog @@ -1,3 +1,107 @@ +2018-02-11 Alfred E. Heggestad + + * Version 0.5.8 + + * GIT URL: https://github.com/alfredh/baresip.git + * GIT tag: v0.5.8 + * NOTE: Requires libre v0.5.7 or later + Requires librem v0.5.2 or later + + * new commands: + + - /aubitrate 64000 -- Set audio bitrate + + * new modules: + + - ctrl_tcp TCP control interface using JSON payload + (thanks José Luis Millán) + + * config: + + auenc_format s16 # s16, float, .. + audec_format s16 # s16, float, .. + + videnc_format yuv420p # yuv420p, yuv444p, .. + + * baresip-core: + - account: password in SIP uri is now deprecated + - aucodec: add encoder/decoder audio sample format (#352) + - aucodec: add bitrate to encoder param + - audio: add function to set encoder bitrate + - audio: sample format for audio encoder/decoder + - call: add call_id accessor + - call: fix memory leak in case sipsess_connect() fails + - config: add configurable video pixel format + - config: set exact installation pathes at build time (#354) + (thanks Guillaume Rousse) + - event: fix memory leak + - event: add call-id to JSON dict + - log: rename log_enable_stderr to log_enable_stdout + - metric: fix calculation of average bitrate + - reg: add display-name to SIP register + - stream: print a message when incoming RTP stream is established + - timer: add tmr_jiffies_usec + - video: save and show pixel format of incoming video + - vidutil: new file for video utility functions + + * selftest: + - event: add testcase for events + - sip: make 'struct user' opaque + - ua: update password using ;auth_pass=XXX parameter + + * Modules: + + * account: update template with auth_pass parameter + + * amr: update aucodec API with audio sample format + + * avcodec: Return EPROTO when encountering missing fragments in + H264 stream, to trigger intra-frame request (#339) + (thanks Jonathan Sieber) + use AV_INPUT_BUFFER_MIN_SIZE (ref #351) + add support for YUV444P pixel format + + * avformat: use av_dump_format() + + * bv32: update aucodec API with audio sample format + + * codec2: update aucodec API with audio sample format + + * ctrl_tcp: new module for TCP control interface using JSON payload + (thanks José Luis Millán) + + * g711: update aucodec API with audio sample format + + * g722: update aucodec API with audio sample format + + * g7221: update aucodec API with audio sample format + + * g726: update aucodec API with audio sample format + + * gsm: update aucodec API with audio sample format + + * gst1: define _POSIX_C_SOURCE to make nanosleep visible + + * l16: update aucodec API with audio sample format + + * mpa: update aucodec API with audio sample format + + * mqtt: update README with correct JSON syntax (ref #356) + + * omx: fix compilation for Raspbian + + * opus: update aucodec API with audio sample format + add support for FLOAT sample format + + * silk: update aucodec API with audio sample format + + * speex: deprecate, disable as autodetected module + + * speex_aec: always link to libspeexdsp + + * speex_pp: always link to libspeexdsp + + 2017-12-25 Alfred E. Heggestad * Version 0.5.7 diff --git a/rpm/baresip.spec b/rpm/baresip.spec index de6170f..8bc1ebe 100644 --- a/rpm/baresip.spec +++ b/rpm/baresip.spec @@ -1,5 +1,5 @@ %define name baresip -%define ver 0.5.7 +%define ver 0.5.8 %define rel 1 Summary: Modular SIP useragent -- cgit v1.2.3 From 899ad127cac4a9ba132ec9548d9e09d98bb791ba Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 14 Feb 2018 12:17:39 +0100 Subject: omx: add omx prefix to debug messages --- modules/omx/module.c | 2 +- modules/omx/omx.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/omx/module.c b/modules/omx/module.c index a5b6fa8..1580f75 100644 --- a/modules/omx/module.c +++ b/modules/omx/module.c @@ -38,7 +38,7 @@ static void destructor(void *arg) } -int omx_vidisp_alloc(struct vidisp_st **vp, const struct vidisp* vd, +int omx_vidisp_alloc(struct vidisp_st **vp, const struct vidisp *vd, struct vidisp_prm *prm, const char *dev, vidisp_resize_h *resizeh, void *arg) { diff --git a/modules/omx/omx.c b/modules/omx/omx.c index 16f38bf..8a03822 100644 --- a/modules/omx/omx.c +++ b/modules/omx/omx.c @@ -116,9 +116,10 @@ static struct OMX_CALLBACKTYPE callbacks = { }; -int omx_init(struct omx_state* st) +int omx_init(struct omx_state *st) { OMX_ERRORTYPE err; + #ifdef RASPBERRY_PI bcm_host_init(); #endif @@ -135,11 +136,11 @@ int omx_init(struct omx_state* st) #endif if (!st->video_render || err != 0) { - warning("Failed to create OMX video_render component\n"); + warning("omx: Failed to create OMX video_render component\n"); return ENOENT; } else { - info("created video_render component\n"); + info("omx: created video_render component\n"); return 0; } } -- cgit v1.2.3 From 487d356161fd104caeccb0d339ffa1f981f111fe Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 14 Feb 2018 16:22:18 +0100 Subject: Revert "avcodec: Return EPROTO when encountering missing fragments in H264 stream, to trigger intra-frame request (#339)" This reverts commit 369b0c0f0e96c529823a11cfc9ab55ce7ade4451. unfortunately I have to revert this commit. in case of packet loss, it might enter a state where no frames are display, and it never gets out of this state. https://github.com/alfredh/baresip/issues/353 --- modules/avcodec/decode.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/avcodec/decode.c b/modules/avcodec/decode.c index b9ee0c5..f20585f 100644 --- a/modules/avcodec/decode.c +++ b/modules/avcodec/decode.c @@ -339,7 +339,6 @@ int decode_h264(struct viddec_state *st, struct vidframe *frame, " ignoring NAL\n"); fragment_rewind(st); ++st->stats.n_lost; - return EPROTO; } st->frag_start = st->mb->pos; @@ -358,7 +357,7 @@ int decode_h264(struct viddec_state *st, struct vidframe *frame, if (!st->frag) { debug("avcodec: ignoring fragment\n"); ++st->stats.n_lost; - return EPROTO; + return 0; } if (seq_diff(st->frag_seq, seq) != 1) { @@ -366,7 +365,7 @@ int decode_h264(struct viddec_state *st, struct vidframe *frame, fragment_rewind(st); st->frag = false; ++st->stats.n_lost; - return EPROTO; + return 0; } } -- cgit v1.2.3 From cebac871de9fdac700511c0e4e34e070133573e6 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 14 Feb 2018 16:31:45 +0100 Subject: avcodec: additional fragment debug --- modules/avcodec/decode.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/avcodec/decode.c b/modules/avcodec/decode.c index f20585f..61743e1 100644 --- a/modules/avcodec/decode.c +++ b/modules/avcodec/decode.c @@ -335,8 +335,8 @@ int decode_h264(struct viddec_state *st, struct vidframe *frame, if (fu.s) { if (st->frag) { - debug("avcodec: lost fragments;" - " ignoring NAL\n"); + debug("avcodec: start: lost fragments;" + " ignoring previous NAL\n"); fragment_rewind(st); ++st->stats.n_lost; } @@ -355,7 +355,8 @@ int decode_h264(struct viddec_state *st, struct vidframe *frame, } else { if (!st->frag) { - debug("avcodec: ignoring fragment\n"); + debug("avcodec: ignoring fragment" + " (nal=%u)\n", fu.type); ++st->stats.n_lost; return 0; } -- cgit v1.2.3 From ee14eb83087923519817f5a664a746ae310a3931 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 14 Feb 2018 16:32:11 +0100 Subject: audio: silence warning about aubuf underrun --- src/audio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/audio.c b/src/audio.c index 358127e..c21e88f 100644 --- a/src/audio.c +++ b/src/audio.c @@ -648,8 +648,10 @@ static void auplay_write_handler(void *sampv, size_t sampc, void *arg) ++rx->stats.aubuf_underrun; +#if 0 debug("audio: rx aubuf underrun (total %llu)\n", rx->stats.aubuf_underrun); +#endif } aubuf_read(rx->aubuf, sampv, num_bytes); -- cgit v1.2.3 From 6892b833505808e76660ec4a2057d750e7943091 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 14 Feb 2018 16:32:52 +0100 Subject: video: add statistics for source/disp frames --- src/video.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/video.c b/src/video.c index 8954e0a..5f55340 100644 --- a/src/video.c +++ b/src/video.c @@ -99,6 +99,11 @@ struct vtx { int efps; /**< Estimated frame-rate */ uint32_t ts_min; uint32_t ts_max; + + /** Statistics */ + struct { + uint64_t src_frames; /**< Total frames from vidsrc */ + } stats; }; @@ -138,6 +143,11 @@ struct vrx { unsigned n_picup; /**< Picture updates sent */ uint32_t ts_min; uint32_t ts_max; + + /** Statistics */ + struct { + uint64_t disp_frames; /** Total frames displayed */ + } stats; }; @@ -453,6 +463,8 @@ static void vidsrc_frame_handler(struct vidframe *frame, void *arg) ++vtx->frames; + ++vtx->stats.src_frames; + /* Is the video muted? If so insert video mute image */ if (vtx->muted) frame = vtx->mute_frame; @@ -636,6 +648,8 @@ static int video_stream_decode(struct vrx *vrx, const struct rtp_header *hdr, err |= st->vf->dech(st, frame); } + ++vrx->stats.disp_frames; + err = vidisp_display(vrx->vidisp, v->peer, frame); frame_filt = mem_deref(frame_filt); if (err == ENODEV) { @@ -1308,10 +1322,12 @@ static int vtx_debug(struct re_printf *pf, const struct vtx *vtx) err |= re_hprintf(pf, " tx: encode: %s %s\n", vtx->vc ? vtx->vc->name : "none", vtx->frame ? vidfmt_name(vtx->frame->fmt) : "?"); - err |= re_hprintf(pf, " source: %s %u x %u, fps=%d\n", + err |= re_hprintf(pf, " source: %s %u x %u, fps=%d" + " frames=%llu\n", vtx->vsrc ? vidsrc_get(vtx->vsrc)->name : "none", vtx->vsrc_size.w, - vtx->vsrc_size.h, vtx->vsrc_prm.fps); + vtx->vsrc_size.h, vtx->vsrc_prm.fps, + vtx->stats.src_frames); err |= re_hprintf(pf, " skipc=%u\n", vtx->skipc); err |= re_hprintf(pf, " time = %.3f sec\n", video_calc_seconds(vtx->ts_max - vtx->ts_min)); @@ -1327,9 +1343,10 @@ static int vrx_debug(struct re_printf *pf, const struct vrx *vrx) err |= re_hprintf(pf, " rx: decode: %s %s\n", vrx->vc ? vrx->vc->name : "none", vidfmt_name(vrx->fmt)); - err |= re_hprintf(pf, " vidisp: %s %u x %u\n", + err |= re_hprintf(pf, " vidisp: %s %u x %u frames=%llu\n", vrx->vidisp ? vidisp_get(vrx->vidisp)->name : "none", - vrx->size.w, vrx->size.h); + vrx->size.w, vrx->size.h, + vrx->stats.disp_frames); err |= re_hprintf(pf, " n_intra=%u, n_picup=%u\n", vrx->n_intra, vrx->n_picup); err |= re_hprintf(pf, " time = %.3f sec\n", -- cgit v1.2.3 From 820ae5ef5c76d511104d01813828cf79b604e100 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 14 Feb 2018 20:26:04 +0100 Subject: timestamp: new file for timestamp helpers --- src/core.h | 38 ++------------------------------- src/srcs.mk | 1 + src/timestamp.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 36 deletions(-) create mode 100644 src/timestamp.c diff --git a/src/core.h b/src/core.h index d08f1f2..4fdc509 100644 --- a/src/core.h +++ b/src/core.h @@ -505,42 +505,8 @@ static inline uint64_t calc_extended_timestamp(uint32_t num_wraps, uint32_t ts) } -static inline uint64_t timestamp_duration(const struct timestamp_recv *ts) -{ - uint64_t last_ext; - - if (!ts || !ts->is_set) - return 0; - - last_ext = calc_extended_timestamp(ts->num_wraps, ts->last); - - return last_ext - ts->first; -} - - -/* - * -1 backwards wrap-around - * 0 no wrap-around - * 1 forward wrap-around - */ -static inline int timestamp_wrap(uint32_t ts_new, uint32_t ts_old) -{ - int32_t delta; - - if (ts_new < ts_old) { - - delta = (int32_t)ts_new - (int32_t)ts_old; - - if (delta > 0) - return 1; - } - else if ((int32_t)(ts_old - ts_new) > 0) { - - return -1; - } - - return 0; -} +int timestamp_wrap(uint32_t ts_new, uint32_t ts_old); +uint64_t timestamp_duration(const struct timestamp_recv *ts); /* diff --git a/src/srcs.mk b/src/srcs.mk index 86cbe8c..be7906c 100644 --- a/src/srcs.mk +++ b/src/srcs.mk @@ -35,6 +35,7 @@ SRCS += sdp.c SRCS += sipreq.c SRCS += stream.c SRCS += timer.c +SRCS += timestamp.c SRCS += ua.c SRCS += ui.c diff --git a/src/timestamp.c b/src/timestamp.c new file mode 100644 index 0000000..dedf8d9 --- /dev/null +++ b/src/timestamp.c @@ -0,0 +1,65 @@ +/** + * @file timestamp.c Timestamp helpers + * + * Copyright (C) 2010 Creytiv.com + */ + +#include +#include +#include "core.h" + + +/** + * Check if a 32-bit timestamp wraps around + * + * @param ts_new Timestamp of the current packet + * @param ts_old Timestamp of the previous packet + * + * @return Integer describing the wrap-around + + * @retval -1 backwards wrap-around + * @retval 0 no wrap-around + * @retval 1 forward wrap-around + */ +int timestamp_wrap(uint32_t ts_new, uint32_t ts_old) +{ + int32_t delta; + + if (ts_new < ts_old) { + + delta = (int32_t)ts_new - (int32_t)ts_old; + + if (delta > 0) + return 1; + } + else if ((int32_t)(ts_old - ts_new) > 0) { + + return -1; + } + + return 0; +} + + +/** + * Calculate the total timestamp duration, in timestamp units. + * The duration is calculated as the delta between the + * last extended timestamp and the first extended timestamp. + * + * @param ts Receiver timestamp struct + * + * @return Timestamp duration + */ +uint64_t timestamp_duration(const struct timestamp_recv *ts) +{ + uint64_t last_ext; + + if (!ts || !ts->is_set) + return 0; + + last_ext = calc_extended_timestamp(ts->num_wraps, ts->last); + + return last_ext - ts->first; +} + + -- cgit v1.2.3 From 5a6ad27505c062a2453f3cdc335fe538ba9a6619 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 14 Feb 2018 19:35:17 +0000 Subject: v4l2_codec: add debug message for update --- modules/v4l2_codec/v4l2_codec.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/v4l2_codec/v4l2_codec.c b/modules/v4l2_codec/v4l2_codec.c index 814a477..7cbe9b3 100644 --- a/modules/v4l2_codec/v4l2_codec.c +++ b/modules/v4l2_codec/v4l2_codec.c @@ -349,10 +349,10 @@ static void read_handler(int flags, void *arg) rtp_ts = (90000ULL * (1000000*ts.tv_sec + ts.tv_usec)) / 1000000; #if 0 - debug("v4l2_codec: %s frame captured at %ldsec, %ldusec (%zu bytes)\n", + debug("v4l2_codec: %s frame captured at %ldsec, %ldusec (%zu bytes) rtp_ts=%u\n", keyframe ? "KEY" : " ", buf.timestamp.tv_sec, buf.timestamp.tv_usec, - (size_t)buf.bytesused); + (size_t)buf.bytesused, rtp_ts); #endif /* pass the frame to the encoders */ @@ -448,6 +448,14 @@ static int encode_packet(struct videnc_state *st, bool update, (void)st; (void)update; (void)frame; + + /* + * XXX: add support for KEY frame requests + */ + if (update) { + info("v4l2_codec: peer requested a KEY frame (ignored)\n"); + } + return 0; } -- cgit v1.2.3 From cc17be532af9f80a648c8c9e996df8786c90c24e Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 14 Feb 2018 19:37:08 +0000 Subject: v4l2_codec: fix ccheck --- modules/v4l2_codec/v4l2_codec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/v4l2_codec/v4l2_codec.c b/modules/v4l2_codec/v4l2_codec.c index 7cbe9b3..8ffd897 100644 --- a/modules/v4l2_codec/v4l2_codec.c +++ b/modules/v4l2_codec/v4l2_codec.c @@ -349,7 +349,8 @@ static void read_handler(int flags, void *arg) rtp_ts = (90000ULL * (1000000*ts.tv_sec + ts.tv_usec)) / 1000000; #if 0 - debug("v4l2_codec: %s frame captured at %ldsec, %ldusec (%zu bytes) rtp_ts=%u\n", + debug("v4l2_codec: %s frame captured at %ldsec, %ldusec" + " (%zu bytes) rtp_ts=%u\n", keyframe ? "KEY" : " ", buf.timestamp.tv_sec, buf.timestamp.tv_usec, (size_t)buf.bytesused, rtp_ts); -- cgit v1.2.3 From e2ace680d8e0f461a00152aab10bc774ba5192d0 Mon Sep 17 00:00:00 2001 From: juha-h Date: Wed, 21 Feb 2018 21:51:26 +0200 Subject: modules/menu: added "statmode_default" config variable (#359) * modules/menu: added "statmode_default" config variable - if given value "off" statsmode defaults to STATMODE_OFF - otherwise statsmode initial value is STATMODE_CALL * hopefully made travis happy --- modules/menu/menu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/menu/menu.c b/modules/menu/menu.c index 0ea87b7..aab9661 100644 --- a/modules/menu/menu.c +++ b/modules/menu/menu.c @@ -1130,7 +1130,13 @@ static int module_init(void) start_ticks = tmr_jiffies(); tmr_init(&tmr_alert); - statmode = STATMODE_CALL; + if (0 == conf_get(conf_cur(), "statmode_default", &val) && + 0 == pl_strcasecmp(&val, "off")) { + statmode = STATMODE_OFF; + } + else { + statmode = STATMODE_CALL; + } err = cmd_register(baresip_commands(), cmdv, ARRAY_SIZE(cmdv)); err |= cmd_register(baresip_commands(), dialcmdv, -- cgit v1.2.3 From 676c89f7185d07e903efc1d9b109f842d3bdeb3e Mon Sep 17 00:00:00 2001 From: Christian Oeien Date: Thu, 22 Feb 2018 10:03:47 -0600 Subject: docs: have verb in sentence (#360) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 22d9a50..df0e4e9 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,7 @@ The baresip project is using the BSD license. ## Contributing -Patches can sent via Github +Patches can be sent via Github [Pull-Requests](https://github.com/creytiv/baresip/pulls) or to the RE devel [mailing-list](http://lists.creytiv.com/mailman/listinfo/re-devel). -- cgit v1.2.3 From 1bd937ce90f34a53f5ef3ffddafb3a8e05a75214 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Fri, 23 Feb 2018 14:07:32 +0100 Subject: video: change RTP send timestamp to 64-bit - change RTP timestamp for packet_handler from 32-bit to 64-bit (extended RTP timestamp). This timestamp must be monotonically increasing, and now the application does not have to handle wrapping of send timestamp. - save first/last RTP timestamp sent --- include/baresip.h | 4 ++-- modules/vidloop/vidloop.c | 2 +- src/video.c | 31 +++++++++++++++++-------------- src/vidutil.c | 2 +- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/include/baresip.h b/include/baresip.h index e404e9b..e8b354a 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -892,7 +892,7 @@ struct videnc_state; struct viddec_state; struct vidcodec; -typedef int (videnc_packet_h)(bool marker, uint32_t rtp_ts, +typedef int (videnc_packet_h)(bool marker, uint64_t rtp_ts, const uint8_t *hdr, size_t hdr_len, const uint8_t *pld, size_t pld_len, void *arg); @@ -1012,7 +1012,7 @@ void video_set_devicename(struct video *v, const char *src, const char *disp); void video_encoder_cycle(struct video *video); int video_debug(struct re_printf *pf, const struct video *v); uint32_t video_calc_rtp_timestamp(int64_t pts, unsigned fps); -double video_calc_seconds(uint32_t rtp_ts); +double video_calc_seconds(uint64_t rtp_ts); struct stream *video_strm(const struct video *v); diff --git a/modules/vidloop/vidloop.c b/modules/vidloop/vidloop.c index a24dbd0..40301eb 100644 --- a/modules/vidloop/vidloop.c +++ b/modules/vidloop/vidloop.c @@ -116,7 +116,7 @@ static int display(struct video_loop *vl, struct vidframe *frame) } -static int packet_handler(bool marker, uint32_t rtp_ts, +static int packet_handler(bool marker, uint64_t rtp_ts, const uint8_t *hdr, size_t hdr_len, const uint8_t *pld, size_t pld_len, void *arg) diff --git a/src/video.c b/src/video.c index 5f55340..f6c4b18 100644 --- a/src/video.c +++ b/src/video.c @@ -97,8 +97,8 @@ struct vtx { bool muted; /**< Muted flag */ int frames; /**< Number of frames sent */ int efps; /**< Estimated frame-rate */ - uint32_t ts_min; - uint32_t ts_max; + uint64_t ts_base; /**< First RTP timestamp sent */ + uint64_t ts_last; /**< Last RTP timestamp sent */ /** Statistics */ struct { @@ -345,7 +345,7 @@ static int get_fps(const struct video *v) } -static int packet_handler(bool marker, uint32_t ts, +static int packet_handler(bool marker, uint64_t ts, const uint8_t *hdr, size_t hdr_len, const uint8_t *pld, size_t pld_len, void *arg) @@ -356,14 +356,12 @@ static int packet_handler(bool marker, uint32_t ts, uint32_t rtp_ts; int err; - /* NOTE: does not handle timestamp wrap around */ - if (ts < vtx->ts_min) - vtx->ts_min = ts; - if (ts > vtx->ts_max) - vtx->ts_max = ts; + if (!vtx->ts_base) + vtx->ts_base = ts; + vtx->ts_last = ts; /* add random timestamp offset */ - rtp_ts = vtx->ts_offset + ts; + rtp_ts = vtx->ts_offset + ts & 0xffffffff; err = vidqent_alloc(&qent, marker, strm->pt_enc, rtp_ts, hdr, hdr_len, pld, pld_len); @@ -508,8 +506,6 @@ static int vtx_alloc(struct vtx *vtx, struct video *video) tmr_start(&vtx->tmr_rtp, 1, rtp_tmr_handler, vtx); - vtx->ts_min = ~0; - return err; } @@ -1328,9 +1324,16 @@ static int vtx_debug(struct re_printf *pf, const struct vtx *vtx) vtx->vsrc_size.w, vtx->vsrc_size.h, vtx->vsrc_prm.fps, vtx->stats.src_frames); - err |= re_hprintf(pf, " skipc=%u\n", vtx->skipc); - err |= re_hprintf(pf, " time = %.3f sec\n", - video_calc_seconds(vtx->ts_max - vtx->ts_min)); + err |= re_hprintf(pf, " skipc=%u sendq=%u\n", + vtx->skipc, list_count(&vtx->sendq)); + + if (vtx->ts_base) { + err |= re_hprintf(pf, " time = %.3f sec\n", + video_calc_seconds(vtx->ts_last - vtx->ts_base)); + } + else { + err |= re_hprintf(pf, " time = (not started)\n"); + } return err; } diff --git a/src/vidutil.c b/src/vidutil.c index b55f216..9057688 100644 --- a/src/vidutil.c +++ b/src/vidutil.c @@ -41,7 +41,7 @@ uint32_t video_calc_rtp_timestamp(int64_t pts, unsigned fps) * * @return Timestamp in seconds */ -double video_calc_seconds(uint32_t rtp_ts) +double video_calc_seconds(uint64_t rtp_ts) { double timestamp; -- cgit v1.2.3 From 73f6d3e5c86244d468499d17321fd9abfc65b9f0 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Fri, 23 Feb 2018 14:12:51 +0100 Subject: video: fix warning --- src/video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video.c b/src/video.c index f6c4b18..4be9925 100644 --- a/src/video.c +++ b/src/video.c @@ -361,7 +361,7 @@ static int packet_handler(bool marker, uint64_t ts, vtx->ts_last = ts; /* add random timestamp offset */ - rtp_ts = vtx->ts_offset + ts & 0xffffffff; + rtp_ts = vtx->ts_offset + (ts & 0xffffffff); err = vidqent_alloc(&qent, marker, strm->pt_enc, rtp_ts, hdr, hdr_len, pld, pld_len); -- cgit v1.2.3 From 59d29c0254b9240a00ac9236cc8e92c0ae65ec8a Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 24 Feb 2018 19:11:22 +0100 Subject: vidcodec: change rtp_ts from 32-bit to 64-bit the extended RTP timestamp from the video encoder should now contain a full extended timestamp, that must never wrap. --- include/baresip.h | 6 +++--- modules/av1/encode.c | 4 ++-- modules/avcodec/encode.c | 8 ++++---- modules/gst_video/encode.c | 4 ++-- modules/gst_video1/encode.c | 4 ++-- modules/h265/encode.c | 4 ++-- modules/v4l2_codec/v4l2_codec.c | 6 +++--- modules/vp8/encode.c | 4 ++-- modules/vp9/encode.c | 6 +++--- src/h264.c | 6 +++--- src/vidutil.c | 16 ++++++++-------- test/mock/mock_vidcodec.c | 2 +- test/video.c | 4 ++-- 13 files changed, 37 insertions(+), 37 deletions(-) diff --git a/include/baresip.h b/include/baresip.h index e8b354a..e67fc8d 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -1011,7 +1011,7 @@ int video_set_source(struct video *v, const char *name, const char *dev); void video_set_devicename(struct video *v, const char *src, const char *disp); void video_encoder_cycle(struct video *video); int video_debug(struct re_printf *pf, const struct video *v); -uint32_t video_calc_rtp_timestamp(int64_t pts, unsigned fps); +uint64_t video_calc_rtp_timestamp(int64_t pts, unsigned fps); double video_calc_seconds(uint64_t rtp_ts); struct stream *video_strm(const struct video *v); @@ -1143,10 +1143,10 @@ int h264_fu_hdr_decode(struct h264_fu *fu, struct mbuf *mb); const uint8_t *h264_find_startcode(const uint8_t *p, const uint8_t *end); -int h264_packetize(uint32_t rtp_ts, const uint8_t *buf, size_t len, +int h264_packetize(uint64_t rtp_ts, const uint8_t *buf, size_t len, size_t pktsize, videnc_packet_h *pkth, void *arg); int h264_nal_send(bool first, bool last, - bool marker, uint32_t ihdr, uint32_t rtp_ts, + bool marker, uint32_t ihdr, uint64_t rtp_ts, const uint8_t *buf, size_t size, size_t maxsz, videnc_packet_h *pkth, void *arg); static inline bool h264_is_keyframe(int type) diff --git a/modules/av1/encode.c b/modules/av1/encode.c index 9e24bcc..7682b16 100644 --- a/modules/av1/encode.c +++ b/modules/av1/encode.c @@ -137,7 +137,7 @@ static inline void hdr_encode(uint8_t hdr[HDR_SIZE], bool noref, bool start, } -static inline int packetize(bool marker, uint32_t rtp_ts, +static inline int packetize(bool marker, uint64_t rtp_ts, const uint8_t *buf, size_t len, size_t maxlen, bool noref, uint8_t partid, uint16_t picid, videnc_packet_h *pkth, void *arg) @@ -222,7 +222,7 @@ int av1_encode(struct videnc_state *ves, bool update, bool keyframe = false, marker = true; const aom_codec_cx_pkt_t *pkt; uint8_t partid = 0; - uint32_t ts; + uint64_t ts; pkt = aom_codec_get_cx_data(&ves->ctx, &iter); if (!pkt) diff --git a/modules/avcodec/encode.c b/modules/avcodec/encode.c index 0bdb1d3..84e4691 100644 --- a/modules/avcodec/encode.c +++ b/modules/avcodec/encode.c @@ -346,7 +346,7 @@ static void param_handler(const struct pl *name, const struct pl *val, } -static int general_packetize(uint32_t rtp_ts, struct mbuf *mb, size_t pktsize, +static int general_packetize(uint64_t rtp_ts, struct mbuf *mb, size_t pktsize, videnc_packet_h *pkth, void *arg) { int err = 0; @@ -371,7 +371,7 @@ static int general_packetize(uint32_t rtp_ts, struct mbuf *mb, size_t pktsize, static int h263_packetize(struct videnc_state *st, - uint32_t rtp_ts, struct mbuf *mb, + uint64_t rtp_ts, struct mbuf *mb, videnc_packet_h *pkth, void *arg) { struct h263_strm h263_strm; @@ -569,7 +569,7 @@ int encode_x264(struct videnc_state *st, bool update, int i_nal; int i, err, ret; int csp, pln; - uint32_t ts; + uint64_t ts; if (!st || !frame) return EINVAL; @@ -670,7 +670,7 @@ int encode(struct videnc_state *st, bool update, const struct vidframe *frame) { int i, err, ret; int pix_fmt; - uint32_t ts; + uint64_t ts; if (!st || !frame) return EINVAL; diff --git a/modules/gst_video/encode.c b/modules/gst_video/encode.c index b6dfe8a..6377785 100644 --- a/modules/gst_video/encode.c +++ b/modules/gst_video/encode.c @@ -169,14 +169,14 @@ static void internal_appsink_new_buffer(GstElement *sink, if (buffer) { GstClockTime ts; - uint32_t rtp_ts; + uint64_t rtp_ts; guint8 *data = GST_BUFFER_DATA(buffer); guint size = GST_BUFFER_SIZE(buffer); ts = GST_BUFFER_TIMESTAMP(buffer); - rtp_ts = (uint32_t)((90000ULL*ts) / 1000000000UL ); + rtp_ts = (uint64_t)((90000ULL*ts) / 1000000000UL ); h264_packetize(rtp_ts, data, size, st->pktsize, st->pkth, st->pkth_arg); diff --git a/modules/gst_video1/encode.c b/modules/gst_video1/encode.c index d0a3d44..0c3a088 100644 --- a/modules/gst_video1/encode.c +++ b/modules/gst_video1/encode.c @@ -123,7 +123,7 @@ static GstFlowReturn appsink_new_sample_cb(GstAppSink *sink, if (sample) { GstClockTime ts; - uint32_t rtp_ts; + uint64_t rtp_ts; buffer = gst_sample_get_buffer(sample); gst_buffer_map( buffer, &info, (GstMapFlags)(GST_MAP_READ) ); @@ -139,7 +139,7 @@ static GstFlowReturn appsink_new_sample_cb(GstAppSink *sink, } else { /* convert from nanoseconds to RTP clock */ - rtp_ts = (uint32_t)((90000ULL * ts) / 1000000000UL); + rtp_ts = (uint64_t)((90000ULL * ts) / 1000000000UL); } h264_packetize(rtp_ts, data, size, st->encoder.pktsize, diff --git a/modules/h265/encode.c b/modules/h265/encode.c index f4835a3..fe5f5f9 100644 --- a/modules/h265/encode.c +++ b/modules/h265/encode.c @@ -140,7 +140,7 @@ static int open_encoder(struct videnc_state *st, const struct vidsz *size) static inline int packetize(bool marker, const uint8_t *buf, size_t len, - size_t maxlen, uint32_t rtp_ts, + size_t maxlen, uint64_t rtp_ts, videnc_packet_h *pkth, void *arg) { int err = 0; @@ -195,7 +195,7 @@ int h265_encode(struct videnc_state *st, bool update, uint32_t i, nalc = 0; int colorspace; int n, err = 0; - uint32_t ts; + uint64_t ts; if (!st || !frame) return EINVAL; diff --git a/modules/v4l2_codec/v4l2_codec.c b/modules/v4l2_codec/v4l2_codec.c index 8ffd897..faf4ad1 100644 --- a/modules/v4l2_codec/v4l2_codec.c +++ b/modules/v4l2_codec/v4l2_codec.c @@ -277,7 +277,7 @@ static void enc_destructor(void *arg) } -static void encoders_read(uint32_t rtp_ts, const uint8_t *buf, size_t sz) +static void encoders_read(uint64_t rtp_ts, const uint8_t *buf, size_t sz) { struct le *le; int err; @@ -301,7 +301,7 @@ static void read_handler(int flags, void *arg) struct v4l2_buffer buf; bool keyframe = false; struct timeval ts; - uint32_t rtp_ts; + uint64_t rtp_ts; int err; if (flags & FD_EXCEPT) { @@ -350,7 +350,7 @@ static void read_handler(int flags, void *arg) #if 0 debug("v4l2_codec: %s frame captured at %ldsec, %ldusec" - " (%zu bytes) rtp_ts=%u\n", + " (%zu bytes) rtp_ts=%llu\n", keyframe ? "KEY" : " ", buf.timestamp.tv_sec, buf.timestamp.tv_usec, (size_t)buf.bytesused, rtp_ts); diff --git a/modules/vp8/encode.c b/modules/vp8/encode.c index 83f136b..6707ead 100644 --- a/modules/vp8/encode.c +++ b/modules/vp8/encode.c @@ -157,7 +157,7 @@ static inline void hdr_encode(uint8_t hdr[HDR_SIZE], bool noref, bool start, static inline int packetize(bool marker, const uint8_t *buf, size_t len, size_t maxlen, bool noref, uint8_t partid, - uint16_t picid, uint32_t rtp_ts, + uint16_t picid, uint64_t rtp_ts, videnc_packet_h *pkth, void *arg) { uint8_t hdr[HDR_SIZE]; @@ -236,7 +236,7 @@ int vp8_encode(struct videnc_state *ves, bool update, bool keyframe = false, marker = true; const vpx_codec_cx_pkt_t *pkt; uint8_t partid = 0; - uint32_t ts; + uint64_t ts; pkt = vpx_codec_get_cx_data(&ves->ctx, &iter); if (!pkt) diff --git a/modules/vp9/encode.c b/modules/vp9/encode.c index 9de4d73..2a98026 100644 --- a/modules/vp9/encode.c +++ b/modules/vp9/encode.c @@ -172,7 +172,7 @@ static inline void hdr_encode(uint8_t hdr[HDR_SIZE], bool start, bool end, static int send_packet(struct videnc_state *ves, bool marker, const uint8_t *hdr, size_t hdr_len, const uint8_t *pld, size_t pld_len, - uint32_t rtp_ts) + uint64_t rtp_ts) { ves->n_bytes += (hdr_len + pld_len); @@ -184,7 +184,7 @@ static int send_packet(struct videnc_state *ves, bool marker, static inline int packetize(struct videnc_state *ves, bool marker, const uint8_t *buf, size_t len, size_t maxlen, uint16_t picid, - uint32_t rtp_ts) + uint64_t rtp_ts) { uint8_t hdr[HDR_SIZE]; bool start = true; @@ -280,7 +280,7 @@ int vp9_encode(struct videnc_state *ves, bool update, for (;;) { bool marker = true; const vpx_codec_cx_pkt_t *pkt; - uint32_t ts; + uint64_t ts; pkt = vpx_codec_get_cx_data(&ves->ctx, &iter); if (!pkt) diff --git a/src/h264.c b/src/h264.c index 2bb4a26..4ee36dc 100644 --- a/src/h264.c +++ b/src/h264.c @@ -104,7 +104,7 @@ const uint8_t *h264_find_startcode(const uint8_t *p, const uint8_t *end) static int rtp_send_data(const uint8_t *hdr, size_t hdr_sz, const uint8_t *buf, size_t sz, - bool eof, uint32_t rtp_ts, + bool eof, uint64_t rtp_ts, videnc_packet_h *pkth, void *arg) { return pkth(eof, rtp_ts, hdr, hdr_sz, buf, sz, arg); @@ -112,7 +112,7 @@ static int rtp_send_data(const uint8_t *hdr, size_t hdr_sz, int h264_nal_send(bool first, bool last, - bool marker, uint32_t ihdr, uint32_t rtp_ts, + bool marker, uint32_t ihdr, uint64_t rtp_ts, const uint8_t *buf, size_t size, size_t maxsz, videnc_packet_h *pkth, void *arg) { @@ -153,7 +153,7 @@ int h264_nal_send(bool first, bool last, } -int h264_packetize(uint32_t rtp_ts, const uint8_t *buf, size_t len, +int h264_packetize(uint64_t rtp_ts, const uint8_t *buf, size_t len, size_t pktsize, videnc_packet_h *pkth, void *arg) { const uint8_t *start = buf; diff --git a/src/vidutil.c b/src/vidutil.c index 9057688..26d17eb 100644 --- a/src/vidutil.c +++ b/src/vidutil.c @@ -14,23 +14,23 @@ * Calculate the RTP timestamp from Presentation Time Stamp (PTS) * or Decoding Time Stamp (DTS) and framerate. * - * @note The calculated RTP Timestamp may wrap around. + * @note The calculated RTP Timestamp may NOT wrap around. * * @param pts Presentation Time Stamp (PTS) * @param fps Framerate in [frames per second] * - * @return RTP Timestamp + * @return Extended RTP Timestamp */ -uint32_t video_calc_rtp_timestamp(int64_t pts, unsigned fps) +uint64_t video_calc_rtp_timestamp(int64_t pts, unsigned fps) { - uint64_t rtp_ts; + uint64_t rtp_ts; - if (!fps) - return 0; + if (!fps) + return 0; - rtp_ts = ((uint64_t)VIDEO_SRATE * pts) / fps; + rtp_ts = ((uint64_t)VIDEO_SRATE * pts) / fps; - return (uint32_t)rtp_ts; + return rtp_ts; } diff --git a/test/mock/mock_vidcodec.c b/test/mock/mock_vidcodec.c index 9609e65..9571f73 100644 --- a/test/mock/mock_vidcodec.c +++ b/test/mock/mock_vidcodec.c @@ -88,7 +88,7 @@ static int mock_encode(struct videnc_state *ves, bool update, { struct mbuf *hdr; uint8_t payload[2] = {0,0}; - uint32_t rtp_ts; + uint64_t rtp_ts; int err; (void)update; diff --git a/test/video.c b/test/video.c index 09c5e77..c2b829b 100644 --- a/test/video.c +++ b/test/video.c @@ -30,8 +30,8 @@ int test_video(void) ASSERT_EQ( 300000000, video_calc_rtp_timestamp( 100000, 30)); ASSERT_EQ(3000000000, video_calc_rtp_timestamp(1000000, 30)); - ASSERT_EQ(4294965000, video_calc_rtp_timestamp(1431655, 30)); - ASSERT_EQ( 704, video_calc_rtp_timestamp(1431656, 30)); + ASSERT_EQ(4294965000ULL, video_calc_rtp_timestamp(1431655, 30)); + ASSERT_EQ(4294968000ULL, video_calc_rtp_timestamp(1431656, 30)); out: return err; -- cgit v1.2.3 From 9780a6260a226f2c19673284730c25d381db074d Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 25 Feb 2018 13:45:13 +0100 Subject: video: change video_fps from int to double float --- include/baresip.h | 8 ++++---- modules/cairo/cairo.c | 2 +- src/conf.c | 18 ++++++++++++++++++ src/config.c | 6 +++--- src/core.h | 1 + src/video.c | 12 +++++------- src/vidutil.c | 2 +- test/mock/mock_vidcodec.c | 2 +- test/mock/mock_vidsrc.c | 4 ++-- 9 files changed, 36 insertions(+), 19 deletions(-) diff --git a/include/baresip.h b/include/baresip.h index e67fc8d..c775183 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -219,7 +219,7 @@ struct config_video { char disp_dev[128]; /**< Video display device */ unsigned width, height; /**< Video resolution */ uint32_t bitrate; /**< Encoder bitrate in [bit/s] */ - uint32_t fps; /**< Video framerate */ + double fps; /**< Video framerate */ bool fullscreen; /**< Enable fullscreen display */ int enc_fmt; /**< Encoder pixelfmt (enum vidfmt) */ }; @@ -760,7 +760,7 @@ struct vidsrc_st; /** Video Source parameters */ struct vidsrc_prm { int orient; /**< Wanted picture orientation (enum vidorient) */ - int fps; /**< Wanted framerate */ + double fps; /**< Wanted framerate */ }; typedef void (vidsrc_frame_h)(struct vidframe *frame, void *arg); @@ -884,7 +884,7 @@ const struct aucodec *aucodec_find(const struct list *aucodecl, struct videnc_param { unsigned bitrate; /**< Encoder bitrate in [bit/s] */ unsigned pktsize; /**< RTP packetsize in [bytes] */ - unsigned fps; /**< Video framerate */ + double fps; /**< Video framerate */ uint32_t max_fs; }; @@ -1011,7 +1011,7 @@ int video_set_source(struct video *v, const char *name, const char *dev); void video_set_devicename(struct video *v, const char *src, const char *disp); void video_encoder_cycle(struct video *video); int video_debug(struct re_printf *pf, const struct video *v); -uint64_t video_calc_rtp_timestamp(int64_t pts, unsigned fps); +uint64_t video_calc_rtp_timestamp(int64_t pts, double fps); double video_calc_seconds(uint64_t rtp_ts); struct stream *video_strm(const struct video *v); diff --git a/modules/cairo/cairo.c b/modules/cairo/cairo.c index 2af2a12..e6d5c1b 100644 --- a/modules/cairo/cairo.c +++ b/modules/cairo/cairo.c @@ -138,7 +138,7 @@ static void process(struct vidsrc_st *st) draw_text(st, xoffs, yoffs + FONT_SIZE, "%H", fmt_gmtime, NULL); - draw_text(st, xoffs, yoffs + FONT_SIZE*2, "%u x %u @ %d fps", + draw_text(st, xoffs, yoffs + FONT_SIZE*2, "%u x %u @ %.2f fps", st->size.w, st->size.h, st->prm.fps); draw_logo(st); diff --git a/src/conf.c b/src/conf.c index 2046216..2bb7d5a 100644 --- a/src/conf.c +++ b/src/conf.c @@ -289,6 +289,24 @@ int conf_get_sa(const struct conf *conf, const char *name, struct sa *sa) } +int conf_get_float(const struct conf *conf, const char *name, double *val) +{ + struct pl opt; + int err; + + if (!conf || !name || !val) + return EINVAL; + + err = conf_get(conf, name, &opt); + if (err) + return err; + + *val = pl_float(&opt); + + return 0; +} + + /** * Configure the system with default settings * diff --git a/src/config.c b/src/config.c index 1e8b595..14bf651 100644 --- a/src/config.c +++ b/src/config.c @@ -319,7 +319,7 @@ int config_parse_conf(struct config *cfg, const struct conf *conf) cfg->video.height = size.h; } (void)conf_get_u32(conf, "video_bitrate", &cfg->video.bitrate); - (void)conf_get_u32(conf, "video_fps", &cfg->video.fps); + (void)conf_get_float(conf, "video_fps", &cfg->video.fps); (void)conf_get_bool(conf, "video_fullscreen", &cfg->video.fullscreen); conf_get_vidfmt(conf, "videnc_format", &cfg->video.enc_fmt); @@ -410,7 +410,7 @@ int config_print(struct re_printf *pf, const struct config *cfg) "video_display\t\t%s,%s\n" "video_size\t\t\"%ux%u\"\n" "video_bitrate\t\t%u\n" - "video_fps\t\t%u\n" + "video_fps\t\t%.2f\n" "\n" #endif "# AVT\n" @@ -600,7 +600,7 @@ static int core_config_template(struct re_printf *pf, const struct config *cfg) "#video_display\t\t%s\n" "video_size\t\t%dx%d\n" "video_bitrate\t\t%u\n" - "video_fps\t\t%u\n" + "video_fps\t\t%.2f\n" "video_fullscreen\tyes\n" "videnc_format\t\t%s\n" , diff --git a/src/core.h b/src/core.h index 4fdc509..c66dffc 100644 --- a/src/core.h +++ b/src/core.h @@ -201,6 +201,7 @@ int conf_get_range(const struct conf *conf, const char *name, struct range *rng); int conf_get_csv(const struct conf *conf, const char *name, char *str1, size_t sz1, char *str2, size_t sz2); +int conf_get_float(const struct conf *conf, const char *name, double *val); /* diff --git a/src/video.c b/src/video.c index 4be9925..699fd01 100644 --- a/src/video.c +++ b/src/video.c @@ -329,16 +329,14 @@ static void video_destructor(void *arg) } -static int get_fps(const struct video *v) +static double get_fps(const struct video *v) { const char *attr; /* RFC4566 */ attr = sdp_media_rattr(stream_sdpmedia(v->strm), "framerate"); if (attr) { - /* NOTE: fractional values are ignored */ - const double fps = atof(attr); - return (int)fps; + return atof(attr); } else return v->cfg.fps; @@ -834,7 +832,7 @@ int video_alloc(struct video **vp, const struct stream_param *stream_prm, } err |= sdp_media_set_lattr(stream_sdpmedia(v->strm), true, - "framerate", "%d", v->cfg.fps); + "framerate", "%.2f", v->cfg.fps); /* RFC 4585 */ err |= sdp_media_set_lattr(stream_sdpmedia(v->strm), true, @@ -1156,7 +1154,7 @@ int video_encoder_set(struct video *v, struct vidcodec *vc, prm.fps = get_fps(v); prm.max_fs = -1; - info("Set video encoder: %s %s (%u bit/s, %u fps)\n", + info("Set video encoder: %s %s (%u bit/s, %.2f fps)\n", vc->name, vc->variant, prm.bitrate, prm.fps); vtx->enc = mem_deref(vtx->enc); @@ -1318,7 +1316,7 @@ static int vtx_debug(struct re_printf *pf, const struct vtx *vtx) err |= re_hprintf(pf, " tx: encode: %s %s\n", vtx->vc ? vtx->vc->name : "none", vtx->frame ? vidfmt_name(vtx->frame->fmt) : "?"); - err |= re_hprintf(pf, " source: %s %u x %u, fps=%d" + err |= re_hprintf(pf, " source: %s %u x %u, fps=%.2f" " frames=%llu\n", vtx->vsrc ? vidsrc_get(vtx->vsrc)->name : "none", vtx->vsrc_size.w, diff --git a/src/vidutil.c b/src/vidutil.c index 26d17eb..abdddf7 100644 --- a/src/vidutil.c +++ b/src/vidutil.c @@ -21,7 +21,7 @@ * * @return Extended RTP Timestamp */ -uint64_t video_calc_rtp_timestamp(int64_t pts, unsigned fps) +uint64_t video_calc_rtp_timestamp(int64_t pts, double fps) { uint64_t rtp_ts; diff --git a/test/mock/mock_vidcodec.c b/test/mock/mock_vidcodec.c index 9571f73..93f7a7f 100644 --- a/test/mock/mock_vidcodec.c +++ b/test/mock/mock_vidcodec.c @@ -22,7 +22,7 @@ struct hdr { struct videnc_state { int64_t pts; - unsigned fps; + double fps; videnc_packet_h *pkth; void *arg; }; diff --git a/test/mock/mock_vidsrc.c b/test/mock/mock_vidsrc.c index 8f92bc4..ad6b165 100644 --- a/test/mock/mock_vidsrc.c +++ b/test/mock/mock_vidsrc.c @@ -14,7 +14,7 @@ struct vidsrc_st { struct vidframe *frame; struct tmr tmr; - int fps; + double fps; vidsrc_frame_h *frameh; void *arg; }; @@ -71,7 +71,7 @@ static int mock_vidsrc_alloc(struct vidsrc_st **stp, const struct vidsrc *vs, tmr_start(&st->tmr, 0, tmr_handler, st); - info("mock_vidsrc: new instance with size %u x %u (%d fps)\n", + info("mock_vidsrc: new instance with size %u x %u (%.2f fps)\n", size->w, size->h, prm->fps); out: -- cgit v1.2.3 From c9b880ca5aa6c31d53bf9d378c0799c363cafee2 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Mon, 26 Feb 2018 19:08:05 +0100 Subject: av1: update to latest aom library --- modules/av1/decode.c | 2 +- modules/av1/encode.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/av1/decode.c b/modules/av1/decode.c index 21ccc75..4987842 100644 --- a/modules/av1/decode.c +++ b/modules/av1/decode.c @@ -258,7 +258,7 @@ int av1_decode(struct viddec_state *vds, struct vidframe *frame, } res = aom_codec_decode(&vds->ctx, vds->mb->buf, - (unsigned int)vds->mb->end, NULL, 1); + (unsigned int)vds->mb->end, NULL); if (res) { debug("av1: decode error: %s\n", aom_codec_err_to_string(res)); err = EPROTO; diff --git a/modules/av1/encode.c b/modules/av1/encode.c index 7682b16..6c8e11b 100644 --- a/modules/av1/encode.c +++ b/modules/av1/encode.c @@ -210,7 +210,7 @@ int av1_encode(struct videnc_state *ves, bool update, } res = aom_codec_encode(&ves->ctx, img, ves->pts++, 1, - flags, AOM_DL_REALTIME); + flags); if (res) { warning("av1: enc error: %s\n", aom_codec_err_to_string(res)); return ENOMEM; -- cgit v1.2.3 From b43fc6f8b387b64ee06cdc3669ae63300e2eb947 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Mon, 26 Feb 2018 19:08:49 +0100 Subject: av1: use double for fps --- modules/av1/encode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/av1/encode.c b/modules/av1/encode.c index 6c8e11b..d090a86 100644 --- a/modules/av1/encode.c +++ b/modules/av1/encode.c @@ -23,7 +23,7 @@ struct videnc_state { aom_codec_ctx_t ctx; struct vidsz size; aom_codec_pts_t pts; - unsigned fps; + double fps; unsigned bitrate; unsigned pktsize; bool ctxup; -- cgit v1.2.3 From 3d59a60117b6b8f6326143d51388c6518c1ddc34 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Mon, 26 Feb 2018 19:33:56 +0100 Subject: avcodec: print decoder framerate --- modules/avcodec/decode.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/avcodec/decode.c b/modules/avcodec/decode.c index 61743e1..63c704f 100644 --- a/modules/avcodec/decode.c +++ b/modules/avcodec/decode.c @@ -37,6 +37,7 @@ struct viddec_state { size_t frag_start; bool frag; uint16_t frag_seq; + double fps; struct { unsigned n_key; @@ -237,6 +238,8 @@ static int ffdecode(struct viddec_state *st, struct vidframe *frame) if (got_picture) { + double fps; + #if LIBAVCODEC_VERSION_INT >= ((53<<16)+(5<<8)+0) switch (st->pict->format) { @@ -270,6 +273,14 @@ static int ffdecode(struct viddec_state *st, struct vidframe *frame) } frame->size.w = st->ctx->width; frame->size.h = st->ctx->height; + + /* get the framerate of the decoded bitstream */ + fps = av_q2d(st->ctx->framerate); + if (st->fps != fps) { + st->fps = fps; + debug("avcodec: current decoder framerate" + " is %.2f fps\n", fps); + } } out: -- cgit v1.2.3 From 2cabf848d01cf39d52ed8c19e56b087265d3eb32 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Mon, 26 Feb 2018 21:37:59 +0100 Subject: avcodec: print fps with float format --- modules/avcodec/encode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/avcodec/encode.c b/modules/avcodec/encode.c index 84e4691..0f885f4 100644 --- a/modules/avcodec/encode.c +++ b/modules/avcodec/encode.c @@ -547,7 +547,7 @@ int encode_update(struct videnc_state **vesp, const struct vidcodec *vc, fmt_param_apply(&sdp_fmtp, param_handler, st); } - debug("avcodec: video encoder %s: %d fps, %d bit/s, pktsize=%u\n", + debug("avcodec: video encoder %s: %.2f fps, %d bit/s, pktsize=%u\n", vc->name, prm->fps, prm->bitrate, prm->pktsize); out: -- cgit v1.2.3 From 4607541a55e93b49a7fc91b29b161bae072f8c69 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Mon, 26 Feb 2018 21:38:24 +0100 Subject: cairo: print logo resolution with 1 decimal --- modules/cairo/cairo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/cairo/cairo.c b/modules/cairo/cairo.c index e6d5c1b..5e95b52 100644 --- a/modules/cairo/cairo.c +++ b/modules/cairo/cairo.c @@ -227,7 +227,7 @@ static int load_logo(struct vidsrc_st *st, const char *filename) cairo_set_source_surface(st->cr_logo, logo, 0, 0); cairo_paint(st->cr_logo); - info("cairo: scaling logo '%s' from %d x %d to %f x %f\n", + info("cairo: scaling logo '%s' from %d x %d to %.1f x %.1f\n", filename, cairo_image_surface_get_width(logo), cairo_image_surface_get_height(logo), -- cgit v1.2.3 From 7cb859a09bc7769b0d0b4a0526a46cefb478552d Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Tue, 27 Feb 2018 18:39:20 +0100 Subject: video: use double float for estimated framerate --- src/call.c | 3 +++ src/video.c | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/call.c b/src/call.c index 01019a6..0868f68 100644 --- a/src/call.c +++ b/src/call.c @@ -1002,6 +1002,9 @@ int call_status(struct re_printf *pf, const struct call *call) err |= video_print(pf, call->video); #endif + /* remove old junk */ + err |= re_hprintf(pf, " "); + return err; } diff --git a/src/video.c b/src/video.c index 699fd01..4caf728 100644 --- a/src/video.c +++ b/src/video.c @@ -96,7 +96,7 @@ struct vtx { bool picup; /**< Send picture update */ bool muted; /**< Muted flag */ int frames; /**< Number of frames sent */ - int efps; /**< Estimated frame-rate */ + double efps; /**< Estimated frame-rate */ uint64_t ts_base; /**< First RTP timestamp sent */ uint64_t ts_last; /**< Last RTP timestamp sent */ @@ -138,7 +138,7 @@ struct vrx { char device[128]; /**< Display device name */ int pt_rx; /**< Incoming RTP payload type */ int frames; /**< Number of frames received */ - int efps; /**< Estimated frame-rate */ + double efps; /**< Estimated frame-rate */ unsigned n_intra; /**< Intra-frames decoded */ unsigned n_picup; /**< Picture updates sent */ uint32_t ts_min; @@ -962,8 +962,8 @@ static void tmr_handler(void *arg) tmr_start(&v->tmr, TMR_INTERVAL * 1000, tmr_handler, v); /* Estimate framerates */ - v->vtx.efps = v->vtx.frames / TMR_INTERVAL; - v->vrx.efps = v->vrx.frames / TMR_INTERVAL; + v->vtx.efps = (double)v->vtx.frames / (double)TMR_INTERVAL; + v->vrx.efps = (double)v->vrx.frames / (double)TMR_INTERVAL; v->vtx.frames = 0; v->vrx.frames = 0; @@ -1393,7 +1393,7 @@ int video_print(struct re_printf *pf, const struct video *v) if (!v) return 0; - return re_hprintf(pf, " efps=%d/%d", v->vtx.efps, v->vrx.efps); + return re_hprintf(pf, " efps=%.1f/%.1f", v->vtx.efps, v->vrx.efps); } -- cgit v1.2.3 From 0c9c50aacf29a8d64f5490a7b4b88c7ea7fd3159 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Tue, 27 Feb 2018 17:44:30 +0000 Subject: v4l2_codec: use %f to print fps --- modules/v4l2_codec/v4l2_codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/v4l2_codec/v4l2_codec.c b/modules/v4l2_codec/v4l2_codec.c index faf4ad1..d15e7ac 100644 --- a/modules/v4l2_codec/v4l2_codec.c +++ b/modules/v4l2_codec/v4l2_codec.c @@ -430,7 +430,7 @@ static int encode_update(struct videnc_state **vesp, const struct vidcodec *vc, list_append(&v4l2.encoderl, &st->le, st); - info("v4l2_codec: video encoder %s: %d fps, %d bit/s, pktsize=%u\n", + info("v4l2_codec: video encoder %s: %.2f fps, %d bit/s, pktsize=%u\n", vc->name, prm->fps, prm->bitrate, prm->pktsize); if (err) -- cgit v1.2.3 From 1d794ae47c6465c5f18df16a3e70cd98d3e013aa Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Tue, 27 Feb 2018 19:41:39 +0100 Subject: avformat: use double float for fps --- modules/avformat/avformat.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/avformat/avformat.c b/modules/avformat/avformat.c index 0a2b473..62f6fda 100644 --- a/modules/avformat/avformat.c +++ b/modules/avformat/avformat.c @@ -66,7 +66,6 @@ struct vidsrc_st { vidsrc_frame_h *frameh; void *arg; int sindex; - int fps; }; @@ -244,7 +243,7 @@ static int alloc(struct vidsrc_st **stp, const struct vidsrc *vs, bool found_stream = false; uint32_t i; int ret, err = 0; - int input_fps = 0; + double input_fps = 0; (void)mctx; (void)errorh; @@ -262,7 +261,6 @@ static int alloc(struct vidsrc_st **stp, const struct vidsrc *vs, st->sz = *size; st->frameh = frameh; st->arg = arg; - st->fps = prm->fps; /* * avformat_open_input() was added in lavf 53.2.0 according to @@ -283,7 +281,7 @@ static int alloc(struct vidsrc_st **stp, const struct vidsrc *vs, /* Params */ memset(&prms, 0, sizeof(prms)); - prms.time_base = (AVRational){1, prm->fps}; + prms.time_base = av_d2q(prm->fps, INT_MAX); prms.channels = 1; prms.width = size->w; prms.height = size->h; @@ -320,7 +318,6 @@ static int alloc(struct vidsrc_st **stp, const struct vidsrc *vs, for (i=0; iic->nb_streams; i++) { const struct AVStream *strm = st->ic->streams[i]; AVCodecContext *ctx; - double dfps; #if LIBAVFORMAT_VERSION_INT >= ((57<<16) + (33<<8) + 100) @@ -355,14 +352,17 @@ static int alloc(struct vidsrc_st **stp, const struct vidsrc *vs, st->sindex = strm->index; st->time_base = strm->time_base; - dfps = av_q2d(strm->avg_frame_rate); - input_fps = (int)dfps; - if (st->fps != input_fps) { - info("avformat: updating %i fps from config to native " - "input material fps %i\n", st->fps, input_fps); - st->fps = input_fps; + input_fps = av_q2d(strm->avg_frame_rate); + if (prm->fps != input_fps) { + info("avformat: updating %.2f fps from config" + " to native " + "input material fps %.2f\n", + prm->fps, input_fps); + + prm->fps = input_fps; + #if LIBAVFORMAT_VERSION_INT < ((52<<16) + (110<<8) + 0) - prms.time_base = (AVRational){1, st->fps}; + prms.time_base = av_d2q(input_fps, INT_MAX); #endif } -- cgit v1.2.3 From e3dbaea50b75bf2da6e7bc5baa1e82ba5adcd655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Fri, 2 Mar 2018 13:59:29 +0100 Subject: Fix #326. Documentation typo (#363) --- modules/ctrl_tcp/ctrl_tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ctrl_tcp/ctrl_tcp.c b/modules/ctrl_tcp/ctrl_tcp.c index 0f1830b..e030551 100644 --- a/modules/ctrl_tcp/ctrl_tcp.c +++ b/modules/ctrl_tcp/ctrl_tcp.c @@ -71,7 +71,7 @@ "class" : "call", "type" : "CALL_CLOSED", "param" : "Connection reset by peer", - "account" : "sip:alice@atlanta.com", + "accountaor" : "sip:alice@atlanta.com", "direction" : "incoming", "peer" : "sip:bob@biloxy.com", "id" : "73a12546589651f8" -- cgit v1.2.3 From 7c27675cb85790652320cf231055ffee830ee595 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 4 Mar 2018 12:33:30 +0100 Subject: h264: add function to convert NAL unit type to a string --- include/baresip.h | 1 + src/h264.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/baresip.h b/include/baresip.h index c775183..fc675af 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -1149,6 +1149,7 @@ int h264_nal_send(bool first, bool last, bool marker, uint32_t ihdr, uint64_t rtp_ts, const uint8_t *buf, size_t size, size_t maxsz, videnc_packet_h *pkth, void *arg); +const char *h264_nalunit_name(int type); static inline bool h264_is_keyframe(int type) { return type == H264_NAL_SPS; diff --git a/src/h264.c b/src/h264.c index 4ee36dc..5f56d9d 100644 --- a/src/h264.c +++ b/src/h264.c @@ -180,3 +180,26 @@ int h264_packetize(uint64_t rtp_ts, const uint8_t *buf, size_t len, return err; } + + +const char *h264_nalunit_name(int type) +{ + switch (type) { + + case H264_NAL_SLICE: return "SLICE"; + case H264_NAL_DPA: return "DPA"; + case H264_NAL_DPB: return "DPB"; + case H264_NAL_DPC: return "DPC"; + case H264_NAL_IDR_SLICE: return "IDR_SLICE"; + case H264_NAL_SEI: return "SEI"; + case H264_NAL_SPS: return "SPS"; + case H264_NAL_PPS: return "PPS"; + case H264_NAL_AUD: return "AUD"; + case H264_NAL_FILLER_DATA: return "FILLER"; + + case H264_NAL_FU_A: return "FU-A"; + case H264_NAL_FU_B: return "FU-B"; + } + + return "???"; +} -- cgit v1.2.3 From bce086111a2875545f9e61bd53ccd0a76826c899 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 4 Mar 2018 12:40:43 +0100 Subject: avcodec: print NAL unit type as string --- modules/avcodec/decode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/avcodec/decode.c b/modules/avcodec/decode.c index 63c704f..35260dc 100644 --- a/modules/avcodec/decode.c +++ b/modules/avcodec/decode.c @@ -302,10 +302,11 @@ int decode_h264(struct viddec_state *st, struct vidframe *frame, return err; #if 0 - re_printf("avcodec: decode: %s %s type=%2d \n", + re_printf("avcodec: decode: %s %s type=%2d %s \n", marker ? "[M]" : " ", h264_is_keyframe(h264_hdr.type) ? "" : " ", - h264_hdr.type); + h264_hdr.type, + h264_nalunit_name(h264_hdr.type)); #endif if (h264_hdr.f) { -- cgit v1.2.3 From 531394e97f3d97810881697fcf0de8cabc089b9f Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Mon, 5 Mar 2018 19:37:52 +1300 Subject: debian/changelog: fixed typo in name of month (Des) --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 66c2c47..caf1926 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,7 +8,7 @@ baresip (0.5.7) unstable; urgency=medium * version 0.5.7 - -- Alfred E. Heggestad Mon, 25 Des 2017 10:00:00 +0100 + -- Alfred E. Heggestad Mon, 25 Dec 2017 10:00:00 +0100 baresip (0.5.6) unstable; urgency=medium -- cgit v1.2.3 From 82c927f7f585fefb7a63ff22434b636949ac2f84 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Fri, 9 Mar 2018 18:18:48 +0100 Subject: h265: use double for fps --- modules/h265/encode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/h265/encode.c b/modules/h265/encode.c index fe5f5f9..62b16e0 100644 --- a/modules/h265/encode.c +++ b/modules/h265/encode.c @@ -17,7 +17,7 @@ struct videnc_state { x265_param *param; x265_encoder *x265; int64_t pts; - unsigned fps; + double fps; unsigned bitrate; unsigned pktsize; videnc_packet_h *pkth; @@ -36,7 +36,7 @@ static void destructor(void *arg) } -static int set_params(struct videnc_state *st, unsigned fps, unsigned bitrate) +static int set_params(struct videnc_state *st, double fps, unsigned bitrate) { st->param = x265_param_alloc(); if (!st->param) { -- cgit v1.2.3 From 2287918ed654045917e8c2a691669969cd62d80f Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Fri, 9 Mar 2018 18:35:05 +0100 Subject: vidloop: use %f to print fps --- modules/vidloop/vidloop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/vidloop/vidloop.c b/modules/vidloop/vidloop.c index 40301eb..6d6e571 100644 --- a/modules/vidloop/vidloop.c +++ b/modules/vidloop/vidloop.c @@ -250,7 +250,7 @@ static int enable_codec(struct video_loop *vl, const char *name) return ENOENT; } - info("vidloop: enabled encoder %s (%u fps, %u bit/s)\n", + info("vidloop: enabled encoder %s (%.2f fps, %u bit/s)\n", vl->vc_enc->name, prm.fps, prm.bitrate); vl->vc_dec = vidcodec_find_decoder(vidcodecl, name); @@ -336,7 +336,7 @@ static int vsrc_reopen(struct video_loop *vl, const struct vidsz *sz) struct vidsrc_prm prm; int err; - info("vidloop: %s,%s: open video source: %u x %u at %u fps\n", + info("vidloop: %s,%s: open video source: %u x %u at %.2f fps\n", vl->cfg.src_mod, vl->cfg.src_dev, sz->w, sz->h, vl->cfg.fps); -- cgit v1.2.3 From 57bd2be20bcc484499c5d57a96ebaa8a85787735 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 11 Mar 2018 21:19:33 +0100 Subject: b2bua: add handling of all inbound SIP requests --- include/baresip.h | 1 + modules/b2bua/b2bua.c | 5 ++++- src/ua.c | 25 +++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/baresip.h b/include/baresip.h index fc675af..11dd294 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -640,6 +640,7 @@ struct list *ua_calls(const struct ua *ua); enum presence_status ua_presence_status(const struct ua *ua); void ua_presence_status_set(struct ua *ua, const enum presence_status status); void ua_set_media_af(struct ua *ua, int af_media); +void ua_set_catchall(struct ua *ua, bool enabled); /* One instance */ diff --git a/modules/b2bua/b2bua.c b/modules/b2bua/b2bua.c index 7386a29..5e2bd1a 100644 --- a/modules/b2bua/b2bua.c +++ b/modules/b2bua/b2bua.c @@ -211,10 +211,13 @@ static int module_init(void) if (err) return err; - err = uag_event_register(ua_event_handler, 0); + err = uag_event_register(ua_event_handler, NULL); if (err) return err; + /* The inbound UA will handle all non-matching requests */ + ua_set_catchall(ua_in, true); + debug("b2bua: module loaded\n"); return 0; diff --git a/src/ua.c b/src/ua.c index e23d392..6ea69c7 100644 --- a/src/ua.c +++ b/src/ua.c @@ -30,6 +30,7 @@ struct ua { int af; /**< Preferred Address Family */ int af_media; /**< Preferred Address Family for media */ enum presence_status my_status; /**< Presence Status */ + bool catchall; /**< Catch all inbound requests */ }; struct ua_eh { @@ -1659,6 +1660,14 @@ struct ua *uag_find(const struct pl *cuser) return ua; } + /* Last resort, try any catchall UAs */ + for (le = uag.ual.head; le; le = le->next) { + struct ua *ua = le->data; + + if (ua->catchall) + return ua; + } + return NULL; } @@ -1896,6 +1905,22 @@ void ua_set_media_af(struct ua *ua, int af_media) } +/** + * Enable handling of all inbound requests, even if + * the request uri is not matching. + * + * @param ua User-Agent + * @param enable True to enable, false to disable + */ +void ua_set_catchall(struct ua *ua, bool enabled) +{ + if (!ua) + return; + + ua->catchall = enabled; +} + + int uag_set_extra_params(const char *eprm) { uag.eprm = mem_deref(uag.eprm); -- cgit v1.2.3 From 32d825255e4d1a5c0a3c69f71b48a71bb5213257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Wed, 14 Mar 2018 13:06:29 +0100 Subject: Fix #370. ctrl_tcp: wrong assignent (#371) --- modules/ctrl_tcp/ctrl_tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ctrl_tcp/ctrl_tcp.c b/modules/ctrl_tcp/ctrl_tcp.c index e030551..1bba161 100644 --- a/modules/ctrl_tcp/ctrl_tcp.c +++ b/modules/ctrl_tcp/ctrl_tcp.c @@ -247,7 +247,7 @@ static void tcp_conn_handler(const struct sa *peer, void *arg) /* only one connection allowed */ st->tc = mem_deref(st->tc); - st->tc = mem_deref(st->ns); + st->ns = mem_deref(st->ns); (void)tcp_accept(&st->tc, st->ts, NULL, NULL, tcp_close_handler, st); (void)netstring_insert(&st->ns, st->tc, 0, command_handler, st); -- cgit v1.2.3 From 7e1daf04d56cedca346aa0618848ee4f6e1fa8c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Wed, 14 Mar 2018 13:07:01 +0100 Subject: Fix #369. ctrl_tcp: documentation typo (#372) --- modules/ctrl_tcp/ctrl_tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ctrl_tcp/ctrl_tcp.c b/modules/ctrl_tcp/ctrl_tcp.c index 1bba161..713f9f4 100644 --- a/modules/ctrl_tcp/ctrl_tcp.c +++ b/modules/ctrl_tcp/ctrl_tcp.c @@ -73,7 +73,7 @@ "param" : "Connection reset by peer", "accountaor" : "sip:alice@atlanta.com", "direction" : "incoming", - "peer" : "sip:bob@biloxy.com", + "peeruri" : "sip:bob@biloxy.com", "id" : "73a12546589651f8" } \endverbatim -- cgit v1.2.3 From 5855ca50919828adf8102390710995d7446bf8b8 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Thu, 15 Mar 2018 21:50:04 +0100 Subject: ua: send event if reg_register fails (ref #364) --- src/ua.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ua.c b/src/ua.c index 6ea69c7..565508e 100644 --- a/src/ua.c +++ b/src/ua.c @@ -202,6 +202,8 @@ int ua_register(struct ua *ua) acc->regint, acc->outboundv[i]); if (err) { warning("ua: SIP register failed: %m\n", err); + + ua_event(ua, UA_EVENT_REGISTER_FAIL, NULL, "%m", err); goto out; } } -- cgit v1.2.3 From f463956c3350c2550f93571b4115b9e82e29671f Mon Sep 17 00:00:00 2001 From: Encamy Date: Thu, 15 Mar 2018 23:56:27 +0300 Subject: Update Windows project (#373) *Updated MSVS project to VS15 and added several files to project settings --- mk/win32/baresip.sln | 9 +++++++-- mk/win32/baresip.vcxproj | 19 ++++++++++++++----- mk/win32/baresip.vcxproj.filters | 5 +++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/mk/win32/baresip.sln b/mk/win32/baresip.sln index 7c791e8..a448d34 100644 --- a/mk/win32/baresip.sln +++ b/mk/win32/baresip.sln @@ -1,6 +1,8 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual C++ Express 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.10 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "baresip-win32", "baresip.vcxproj", "{4B89C2D8-FB32-4D7C-9019-752A5664781C}" ProjectSection(ProjectDependencies) = postProject {3E767371-A72B-4F5C-A695-8F844B0889C5} = {3E767371-A72B-4F5C-A695-8F844B0889C5} @@ -36,4 +38,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8F3E56DF-4B18-4499-B228-37DC5DC474F9} + EndGlobalSection EndGlobal diff --git a/mk/win32/baresip.vcxproj b/mk/win32/baresip.vcxproj index c321b5f..c561e77 100644 --- a/mk/win32/baresip.vcxproj +++ b/mk/win32/baresip.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -46,11 +46,14 @@ ..\..\$(Platform)\$(Configuration)\tmp\mk\win32\ false + + BasicDesignGuidelineRules.ruleset + Disabled include;..\..\include;..\..\..\re\include;..\..\..\rem\include;..\..\..\misc;..\..\..\dirent\include;%(AdditionalIncludeDirectories) - WIN32;STATIC;HAVE_IO_H;HAVE_SELECT;USE_VIDEO;_CRT_SECURE_NO_DEPRECATE;FD_SETSIZE=1024;%(PreprocessorDefinitions) + WIN32;STATIC;HAVE_IO_H;HAVE_SELECT;USE_VIDEO;_CRT_SECURE_NO_DEPRECATE;FD_SETSIZE=1024;SHARE_PATH="/usr/share/baresip";%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug @@ -61,6 +64,7 @@ CompileAsC 4142;%(DisableSpecificWarnings) $(IntDir)%(RelativeDir)%(Filename).obj + %(AdditionalOptions) winmm.lib ..\..\..\re\$(Platform)\$(Configuration)\bin\re-win32.lib ..\..\..\rem\$(Platform)\$(Configuration)\bin\rem-win32.lib %(AdditionalOptions) @@ -70,13 +74,13 @@ $(OutDir)baresip-win32.pdb Console MachineX86 - %(AdditionalDependencies) + Iphlpapi.lib;%(AdditionalDependencies) include;..\..\include;..\..\..\re\include;..\..\..\rem\include;..\..\..\misc;..\..\..\dirent\include;%(AdditionalIncludeDirectories) - WIN32;STATIC;HAVE_IO_H;HAVE_SELECT;USE_VIDEO;_CRT_SECURE_NO_DEPRECATE;FD_SETSIZE=1024;%(PreprocessorDefinitions) + WIN32;STATIC;HAVE_IO_H;HAVE_SELECT;USE_VIDEO;_CRT_SECURE_NO_DEPRECATE;FD_SETSIZE=1024;SHARE_PATH="/usr/share/baresip";%(PreprocessorDefinitions) MultiThreaded @@ -94,7 +98,7 @@ true true MachineX86 - %(AdditionalDependencies) + Iphlpapi.lib;%(AdditionalDependencies) @@ -197,6 +201,11 @@ + + + + + diff --git a/mk/win32/baresip.vcxproj.filters b/mk/win32/baresip.vcxproj.filters index 5098a2b..26999f5 100644 --- a/mk/win32/baresip.vcxproj.filters +++ b/mk/win32/baresip.vcxproj.filters @@ -362,5 +362,10 @@ modules\winwave + + + + + \ No newline at end of file -- cgit v1.2.3 From ae2ecef8866733f7b71227876424e67722efae90 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 21 Mar 2018 09:44:42 +0100 Subject: swscale: add support for YUV444P pixel format --- modules/swscale/swscale.c | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/swscale/swscale.c b/modules/swscale/swscale.c index 5cd8905..a33a3ae 100644 --- a/modules/swscale/swscale.c +++ b/modules/swscale/swscale.c @@ -26,6 +26,7 @@ static enum AVPixelFormat vidfmt_to_avpixfmt(enum vidfmt fmt) switch (fmt) { case VID_FMT_YUV420P: return AV_PIX_FMT_YUV420P; + case VID_FMT_YUV444P: return AV_PIX_FMT_YUV444P; case VID_FMT_NV12: return AV_PIX_FMT_NV12; case VID_FMT_NV21: return AV_PIX_FMT_NV21; default: return AV_PIX_FMT_NONE; -- cgit v1.2.3 From 78b4031dd0334b55ea4f92dd93ff27dc20755355 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 21 Mar 2018 14:55:15 +0100 Subject: timer: make tmr_jiffies_usec() public --- include/baresip.h | 7 +++++++ src/core.h | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/baresip.h b/include/baresip.h index 11dd294..10758d9 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -1189,6 +1189,13 @@ int event_encode_dict(struct odict *od, struct ua *ua, enum ua_event ev, struct call *call, const char *prm); +/* + * Timer + */ + +uint64_t tmr_jiffies_usec(void); + + /* * Baresip instance */ diff --git a/src/core.h b/src/core.h index c66dffc..6e56fed 100644 --- a/src/core.h +++ b/src/core.h @@ -508,10 +508,3 @@ static inline uint64_t calc_extended_timestamp(uint32_t num_wraps, uint32_t ts) int timestamp_wrap(uint32_t ts_new, uint32_t ts_old); uint64_t timestamp_duration(const struct timestamp_recv *ts); - - -/* - * Timer - */ - -uint64_t tmr_jiffies_usec(void); -- cgit v1.2.3 From 74b228ad7ee5f46788707f74904101b3ccab2ba7 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 21 Mar 2018 19:59:12 +0100 Subject: vidloop: added printing of statistics --- modules/vidloop/vidloop.c | 156 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 152 insertions(+), 4 deletions(-) diff --git a/modules/vidloop/vidloop.c b/modules/vidloop/vidloop.c index 6d6e571..446ca02 100644 --- a/modules/vidloop/vidloop.c +++ b/modules/vidloop/vidloop.c @@ -52,13 +52,27 @@ struct video_loop { struct viddec_state *dec; struct vidisp_st *vidisp; struct vidsrc_st *vsrc; + struct vidsrc_prm srcprm; struct list filtencl; struct list filtdecl; struct vstat stat; struct tmr tmr_bw; + struct vidsz src_size; + struct vidsz disp_size; + enum vidfmt src_fmt; + uint64_t ts_start; /* usec */ + uint64_t ts_last; /* usec */ uint16_t seq; bool need_conv; + bool started; int err; + + struct { + uint64_t src_frames; + uint64_t enc_bytes; + uint64_t enc_packets; + uint64_t disp_frames; + } stats; }; @@ -102,14 +116,20 @@ static int display(struct video_loop *vl, struct vidframe *frame) warning("vidloop: error in video-filters (%m)\n", err); } + /* save the displayed frame info */ + vl->disp_size = frame->size; + ++vl->stats.disp_frames; + /* display frame */ err = vidisp_display(vl->vidisp, "Video Loop", frame); if (err == ENODEV) { info("vidloop: video-display was closed\n"); vl->vidisp = mem_deref(vl->vidisp); vl->err = err; + goto out; } + out: mem_deref(frame_filt); return err; @@ -128,6 +148,9 @@ static int packet_handler(bool marker, uint64_t rtp_ts, int err = 0; (void)rtp_ts; + ++vl->stats.enc_packets; + vl->stats.enc_bytes += (hdr_len + pld_len); + mb = mbuf_alloc(hdr_len + pld_len); if (!mb) return ENOMEM; @@ -171,8 +194,19 @@ static void vidsrc_frame_handler(struct vidframe *frame, void *arg) struct video_loop *vl = arg; struct vidframe *f2 = NULL; struct le *le; + const uint64_t now = tmr_jiffies_usec(); int err = 0; + /* save the timing info */ + if (!gvl->ts_start) + gvl->ts_start = now; + gvl->ts_last = now; + + /* save the video frame info */ + vl->src_size = frame->size; + vl->src_fmt = frame->fmt; + ++vl->stats.src_frames; + ++vl->stat.frames; if (frame->fmt != (enum vidfmt)vl->cfg.enc_fmt) { @@ -206,6 +240,7 @@ static void vidsrc_frame_handler(struct vidframe *frame, void *arg) err = vl->vc_enc->ench(vl->enc, false, frame); if (err) { warning("vidloop: encoder error (%m)\n", err); + goto out; } } else { @@ -213,14 +248,126 @@ static void vidsrc_frame_handler(struct vidframe *frame, void *arg) (void)display(vl, frame); } + out: mem_deref(f2); } +static int print_stats(struct re_printf *pf, const struct video_loop *vl) +{ + const struct config_video *cfg = &vl->cfg; + double real_dur = .0; + int err = 0; + + if (vl->ts_start) + real_dur = 0.000001 * (double)(vl->ts_last - vl->ts_start); + + err |= re_hprintf(pf, "~~~~~ Videoloop summary: ~~~~~\n"); + + /* Source */ + if (vl->vsrc) { + double avg_fps = .0; + + if (vl->stats.src_frames >= 2) + avg_fps = (vl->stats.src_frames-1) / real_dur; + + err |= re_hprintf(pf, + "* Source\n" + " resolution %u x %u (actual %u x %u)\n" + " pixformat %s\n" + " frames %llu\n" + " framerate %.2f fps (avg %.2f fps)\n" + "\n" + , + cfg->width, cfg->height, + vl->src_size.w, vl->src_size.h, + vidfmt_name(vl->src_fmt), + vl->stats.src_frames, + vl->srcprm.fps, avg_fps); + } + + /* Video conversion */ + if (vl->need_conv) { + err |= re_hprintf(pf, + "* Vidconv\n" + " pixformat %s\n" + "\n" + , + vidfmt_name(cfg->enc_fmt)); + } + + /* Filters */ + if (!list_isempty(baresip_vidfiltl())) { + struct le *le; + + err |= re_hprintf(pf, + "* Filters (%u):", + list_count(baresip_vidfiltl())); + + for (le = list_head(baresip_vidfiltl()); le; le = le->next) { + struct vidfilt *vf = le->data; + err |= re_hprintf(pf, " %s", vf->name); + } + err |= re_hprintf(pf, "\n\n"); + } + + /* Encoder */ + if (vl->vc_enc) { + double avg_bitrate; + double avg_pktrate; + + avg_bitrate = 8.0 * (double)vl->stats.enc_bytes / real_dur; + avg_pktrate = (double)vl->stats.enc_packets / real_dur; + + err |= re_hprintf(pf, + "* Encoder\n" + " module %s\n" + " bitrate %u bit/s (avg %.1f bit/s)\n" + " packets %llu (avg %.1f pkt/s)\n" + "\n" + , + vl->vc_enc->name, + cfg->bitrate, avg_bitrate, + vl->stats.enc_packets, avg_pktrate); + } + + /* Decoder */ + if (vl->vc_dec) { + err |= re_hprintf(pf, + "* Decoder\n" + " module %s\n" + " key-frames %zu\n" + "\n" + , + vl->vc_dec->name, + vl->stat.n_intra); + } + + /* Display */ + if (vl->vidisp) { + err |= re_hprintf(pf, + "* Display\n" + " resolution %u x %u\n" + " fullscreen %s\n" + " frames %llu\n" + "\n" + , + vl->disp_size.w, vl->disp_size.h, + cfg->fullscreen ? "Yes" : "No", + vl->stats.disp_frames); + } + + return err; +} + + static void vidloop_destructor(void *arg) { struct video_loop *vl = arg; + if (vl->started) + re_printf("%H\n", print_stats, vl); + tmr_cancel(&vl->tmr_bw); mem_deref(vl->vsrc); mem_deref(vl->enc); @@ -333,19 +480,18 @@ static void timeout_bw(void *arg) static int vsrc_reopen(struct video_loop *vl, const struct vidsz *sz) { - struct vidsrc_prm prm; int err; info("vidloop: %s,%s: open video source: %u x %u at %.2f fps\n", vl->cfg.src_mod, vl->cfg.src_dev, sz->w, sz->h, vl->cfg.fps); - prm.orient = VIDORIENT_PORTRAIT; - prm.fps = vl->cfg.fps; + vl->srcprm.orient = VIDORIENT_PORTRAIT; + vl->srcprm.fps = vl->cfg.fps; vl->vsrc = mem_deref(vl->vsrc); err = vidsrc_alloc(&vl->vsrc, baresip_vidsrcl(), - vl->cfg.src_mod, NULL, &prm, sz, + vl->cfg.src_mod, NULL, &vl->srcprm, sz, NULL, vl->cfg.src_dev, vidsrc_frame_handler, NULL, vl); if (err) { @@ -460,6 +606,8 @@ static int vidloop_start(struct re_printf *pf, void *arg) return err; } + gvl->started = true; + return err; } -- cgit v1.2.3 From 02731ddef2cadd01e21bef6d3bcd94f0668f8a10 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 28 Mar 2018 08:50:57 +0200 Subject: avcodec: add backwards define for PIX_FMT_YUV444P --- modules/avcodec/decode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/avcodec/decode.c b/modules/avcodec/decode.c index 35260dc..00f6654 100644 --- a/modules/avcodec/decode.c +++ b/modules/avcodec/decode.c @@ -20,6 +20,7 @@ #define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P #define AV_PIX_FMT_YUVJ420P PIX_FMT_YUVJ420P #define AV_PIX_FMT_NV12 PIX_FMT_NV12 +#define AV_PIX_FMT_YUV444P PIX_FMT_YUV444P #endif -- cgit v1.2.3 From b17201c25abe91becb386ac0ee1736664ce018f7 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 28 Mar 2018 08:54:32 +0200 Subject: avcodec: move backward defines to internal header file --- modules/avcodec/avcodec.h | 8 ++++++++ modules/avcodec/decode.c | 8 -------- modules/avcodec/encode.c | 6 ------ 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/modules/avcodec/avcodec.h b/modules/avcodec/avcodec.h index f3a2b70..3511145 100644 --- a/modules/avcodec/avcodec.h +++ b/modules/avcodec/avcodec.h @@ -16,6 +16,14 @@ #endif +#if LIBAVUTIL_VERSION_MAJOR < 52 +#define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P +#define AV_PIX_FMT_YUVJ420P PIX_FMT_YUVJ420P +#define AV_PIX_FMT_NV12 PIX_FMT_NV12 +#define AV_PIX_FMT_YUV444P PIX_FMT_YUV444P +#endif + + extern const uint8_t h264_level_idc; extern AVCodec *avcodec_h264enc; extern AVCodec *avcodec_h264dec; diff --git a/modules/avcodec/decode.c b/modules/avcodec/decode.c index 00f6654..0129490 100644 --- a/modules/avcodec/decode.c +++ b/modules/avcodec/decode.c @@ -16,14 +16,6 @@ #include "avcodec.h" -#if LIBAVUTIL_VERSION_MAJOR < 52 -#define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P -#define AV_PIX_FMT_YUVJ420P PIX_FMT_YUVJ420P -#define AV_PIX_FMT_NV12 PIX_FMT_NV12 -#define AV_PIX_FMT_YUV444P PIX_FMT_YUV444P -#endif - - enum { DECODE_MAXSZ = 524288, }; diff --git a/modules/avcodec/encode.c b/modules/avcodec/encode.c index 0f885f4..ea543d8 100644 --- a/modules/avcodec/encode.c +++ b/modules/avcodec/encode.c @@ -20,12 +20,6 @@ #include "avcodec.h" -#if LIBAVUTIL_VERSION_MAJOR < 52 -#define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P -#define AV_PIX_FMT_NV12 PIX_FMT_NV12 -#endif - - #ifndef AV_INPUT_BUFFER_MIN_SIZE #define AV_INPUT_BUFFER_MIN_SIZE FF_MIN_BUFFER_SIZE #endif -- cgit v1.2.3 From 2b1b6f746904957e8c59647489ec21b33afc7256 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 11 Mar 2018 03:06:40 +0100 Subject: avcodec: check version for getting decoder framerate --- modules/avcodec/decode.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/avcodec/decode.c b/modules/avcodec/decode.c index 0129490..edc8281 100644 --- a/modules/avcodec/decode.c +++ b/modules/avcodec/decode.c @@ -267,6 +267,7 @@ static int ffdecode(struct viddec_state *st, struct vidframe *frame) frame->size.w = st->ctx->width; frame->size.h = st->ctx->height; +#if LIBAVCODEC_VERSION_INT >= ((55<<16)+(57<<8)+100) /* get the framerate of the decoded bitstream */ fps = av_q2d(st->ctx->framerate); if (st->fps != fps) { @@ -274,6 +275,9 @@ static int ffdecode(struct viddec_state *st, struct vidframe *frame) debug("avcodec: current decoder framerate" " is %.2f fps\n", fps); } +#else + (void)fps; +#endif } out: -- cgit v1.2.3 From c0fd5cbf4e5a2a06a914fca439b5dbdbcd5d363c Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 28 Mar 2018 14:44:23 +0100 Subject: avcodec: check version 56.1.0 --- modules/avcodec/decode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/avcodec/decode.c b/modules/avcodec/decode.c index edc8281..759535c 100644 --- a/modules/avcodec/decode.c +++ b/modules/avcodec/decode.c @@ -267,7 +267,7 @@ static int ffdecode(struct viddec_state *st, struct vidframe *frame) frame->size.w = st->ctx->width; frame->size.h = st->ctx->height; -#if LIBAVCODEC_VERSION_INT >= ((55<<16)+(57<<8)+100) +#if LIBAVCODEC_VERSION_INT > ((56<<16)+(1<<8)+0) /* get the framerate of the decoded bitstream */ fps = av_q2d(st->ctx->framerate); if (st->fps != fps) { -- cgit v1.2.3 From 02e95b4086a02ef0aafaebc06730442e1c0c7610 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Thu, 29 Mar 2018 19:53:32 +0200 Subject: audio: move n_discard to stats section --- src/audio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/audio.c b/src/audio.c index c21e88f..8222c37 100644 --- a/src/audio.c +++ b/src/audio.c @@ -152,11 +152,11 @@ struct aurx { enum aufmt dec_fmt; bool need_conv; /**< Sample format conversion needed */ struct timestamp_recv ts_recv;/**< Receive timestamp state */ - uint64_t n_discard; struct { uint64_t aubuf_overrun; uint64_t aubuf_underrun; + uint64_t n_discard; } stats; }; @@ -996,7 +996,7 @@ static void stream_recv_handler(const struct rtp_header *hdr, #endif if (discard) { - ++a->rx.n_discard; + ++rx->stats.n_discard; return; } @@ -1988,7 +1988,7 @@ int audio_debug(struct re_printf *pf, const struct audio *a) ); err |= re_hprintf(pf, " player: %s\n", aufmt_name(rx->play_fmt)); err |= re_hprintf(pf, " n_discard:%llu\n", - rx->n_discard); + rx->stats.n_discard); if (rx->level_set) { err |= re_hprintf(pf, " level %.3f dBov\n", rx->level_last); -- cgit v1.2.3 From aadb1c53c1bf95680354425aff4ac24310cd9a88 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Thu, 29 Mar 2018 19:58:06 +0200 Subject: update doxygen comments --- src/audio.c | 4 ++-- src/ua.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/audio.c b/src/audio.c index 8222c37..3b99b38 100644 --- a/src/audio.c +++ b/src/audio.c @@ -97,7 +97,7 @@ struct autx { bool muted; /**< Audio source is muted */ int cur_key; /**< Currently transmitted event */ enum aufmt src_fmt; /**< Sample format for audio source */ - enum aufmt enc_fmt; + enum aufmt enc_fmt; /**< Sample format for encoder */ bool need_conv; /**< Sample format conversion needed */ struct { @@ -149,7 +149,7 @@ struct aurx { double level_last; bool level_set; enum aufmt play_fmt; /**< Sample format for audio playback*/ - enum aufmt dec_fmt; + enum aufmt dec_fmt; /**< Sample format for decoder */ bool need_conv; /**< Sample format conversion needed */ struct timestamp_recv ts_recv;/**< Receive timestamp state */ diff --git a/src/ua.c b/src/ua.c index 565508e..76023d5 100644 --- a/src/ua.c +++ b/src/ua.c @@ -1911,8 +1911,8 @@ void ua_set_media_af(struct ua *ua, int af_media) * Enable handling of all inbound requests, even if * the request uri is not matching. * - * @param ua User-Agent - * @param enable True to enable, false to disable + * @param ua User-Agent + * @param enabled True to enable, false to disable */ void ua_set_catchall(struct ua *ua, bool enabled) { -- cgit v1.2.3 From 01116a34b60191e97831860a96be81fafc5026ec Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Thu, 29 Mar 2018 21:55:48 +0200 Subject: test: add testcase for media encryption --- include/baresip.h | 1 + src/audio.c | 13 ++++++ test/call.c | 61 +++++++++++++++++++++++- test/main.c | 1 + test/mock/mock_menc.c | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++ test/srcs.mk | 1 + test/test.h | 9 ++++ 7 files changed, 210 insertions(+), 1 deletion(-) create mode 100644 test/mock/mock_menc.c diff --git a/include/baresip.h b/include/baresip.h index 10758d9..299bcd8 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -995,6 +995,7 @@ int audio_level_get(const struct audio *au, double *level); int audio_debug(struct re_printf *pf, const struct audio *a); struct stream *audio_strm(const struct audio *a); int audio_set_bitrate(struct audio *au, uint32_t bitrate); +bool audio_rxaubuf_started(struct audio *au); /* diff --git a/src/audio.c b/src/audio.c index 3b99b38..3061ddc 100644 --- a/src/audio.c +++ b/src/audio.c @@ -2180,3 +2180,16 @@ int audio_set_bitrate(struct audio *au, uint32_t bitrate) return 0; } + + +bool audio_rxaubuf_started(struct audio *au) +{ + struct aurx *rx; + + if (!au) + return false; + + rx = &au->rx; + + return rx->aubuf_started; +} diff --git a/test/call.c b/test/call.c index 73f3ebd..2472afe 100644 --- a/test/call.c +++ b/test/call.c @@ -830,8 +830,15 @@ static void float_sample_handler(const void *sampv, size_t sampc, void *arg) (void)sampv; (void)sampc; - if (sampc && fix->a.n_established && fix->b.n_established) + /* Wait until the call is established and the incoming + * audio samples are successfully decoded. + */ + if (sampc && fix->a.n_established && fix->b.n_established && + audio_rxaubuf_started(call_audio(ua_call(fix->a.ua))) && + audio_rxaubuf_started(call_audio(ua_call(fix->b.ua))) + ) { re_cancel(); + } } @@ -906,3 +913,55 @@ int test_call_format_float(void) out: return err; } + + +int test_call_mediaenc(void) +{ + struct fixture fix, *f = &fix; + struct ausrc *ausrc = NULL; + struct auplay *auplay = NULL; + int err = 0; + + mock_menc_register(); + + /* Enable a dummy media encryption protocol */ + fixture_init_prm(f, ";mediaenc=xrtp;ptime=1"); + + err = mock_ausrc_register(&ausrc); + TEST_ERR(err); + err = mock_auplay_register(&auplay, float_sample_handler, f); + TEST_ERR(err); + + f->estab_action = ACTION_NOTHING; + + f->behaviour = BEHAVIOUR_ANSWER; + + /* Make a call from A to B */ + err = ua_connect(f->a.ua, 0, NULL, f->buri, NULL, VIDMODE_OFF); + TEST_ERR(err); + + /* run main-loop with timeout, wait for events */ + err = re_main_timeout(5000); + TEST_ERR(err); + TEST_ERR(fix.err); + + ASSERT_EQ(1, fix.a.n_established); + ASSERT_EQ(0, fix.a.n_closed); + + ASSERT_EQ(1, fix.b.n_established); + ASSERT_EQ(0, fix.b.n_closed); + + /* XXX: verify that the call was encrypted */ + + out: + fixture_close(f); + mem_deref(auplay); + mem_deref(ausrc); + + mock_menc_unregister(); + + if (fix.err) + return fix.err; + + return err; +} diff --git a/test/main.c b/test/main.c index 09ff19e..01937f4 100644 --- a/test/main.c +++ b/test/main.c @@ -30,6 +30,7 @@ static const struct test tests[] = { TEST(test_call_answer_hangup_b), TEST(test_call_reject), TEST(test_call_rtp_timeout), + TEST(test_call_mediaenc), TEST(test_call_multiple), TEST(test_call_max), TEST(test_call_dtmf), diff --git a/test/mock/mock_menc.c b/test/mock/mock_menc.c new file mode 100644 index 0000000..b554646 --- /dev/null +++ b/test/mock/mock_menc.c @@ -0,0 +1,125 @@ +/** + * @file mock/mock_menc.c Mock media encryption + * + * Copyright (C) 2010 - 2018 Creytiv.com + */ + +#include +#include +#include +#include "../test.h" + + +#define SECRET_KEY 0xdd + + +struct menc_media { + void *rtpsock; + struct udp_helper *uh_rtp; +}; + + +/* + * Encrypt/decrypt an RTP payload with a dummy key. + * We use a simple XOR scheme for simplicity. + */ +static void mock_crypt(struct mbuf *mb) +{ + size_t i, len = mbuf_get_left(mb); + + for (i = RTP_HEADER_SIZE; i < len; i++) { + mb->buf[mb->pos + i] ^= SECRET_KEY; + } +} + + +static void media_destructor(void *data) +{ + struct menc_media *mm = data; + + mem_deref(mm->uh_rtp); + mem_deref(mm->rtpsock); +} + + +static bool send_handler(int *err, struct sa *dst, struct mbuf *mb, void *arg) +{ + struct menc_media *mm = arg; + (void)mm; + (void)dst; + + mock_crypt(mb); + + return false; /* continue processing */ +} + + +static bool recv_handler(struct sa *src, struct mbuf *mb, void *arg) +{ + struct menc_media *mm = arg; + (void)mm; + (void)src; + + mock_crypt(mb); + + return false; /* continue processing */ +} + + +static int mock_media_alloc(struct menc_media **mmp, struct menc_sess *sess, + struct rtp_sock *rtp, int proto, + void *rtpsock, void *rtcpsock, + struct sdp_media *sdpm) +{ + struct menc_media *mm; + const int layer = 10; /* above zero */ + int err = 0; + (void)sess; + (void)rtp; + (void)rtcpsock; + + if (!mmp || !sdpm) + return EINVAL; + if (proto != IPPROTO_UDP) + return EPROTONOSUPPORT; + + mm = *mmp; + if (!mm) { + mm = mem_zalloc(sizeof(*mm), media_destructor); + if (!mm) + return ENOMEM; + + mm->rtpsock = mem_ref(rtpsock); + err = udp_register_helper(&mm->uh_rtp, rtpsock, layer, + send_handler, recv_handler, mm); + if (err) + goto out; + + *mmp = mm; + } + + out: + if (err) + mem_deref(mm); + + return err; +} + + +static struct menc menc_mock = { + .id = "XRTP", + .sdp_proto = "RTP/XAVP", + .mediah = mock_media_alloc +}; + + +void mock_menc_register(void) +{ + menc_register(baresip_mencl(), &menc_mock); +} + + +void mock_menc_unregister(void) +{ + menc_unregister(&menc_mock); +} diff --git a/test/srcs.mk b/test/srcs.mk index bdb0d0b..6cd6d3d 100644 --- a/test/srcs.mk +++ b/test/srcs.mk @@ -44,6 +44,7 @@ endif TEST_SRCS += mock/mock_aucodec.c TEST_SRCS += mock/mock_auplay.c TEST_SRCS += mock/mock_ausrc.c +TEST_SRCS += mock/mock_menc.c ifneq ($(USE_VIDEO),) TEST_SRCS += mock/mock_vidsrc.c TEST_SRCS += mock/mock_vidcodec.c diff --git a/test/test.h b/test/test.h index 7977272..8072cfd 100644 --- a/test/test.h +++ b/test/test.h @@ -149,6 +149,14 @@ int mock_auplay_register(struct auplay **auplayp, mock_sample_h *sampleh, void *arg); +/* + * Mock Media encryption + */ + +void mock_menc_register(void); +void mock_menc_unregister(void); + + /* * Mock Video-source */ @@ -208,6 +216,7 @@ int test_call_video(void); int test_call_aulevel(void); int test_call_progress(void); int test_call_format_float(void); +int test_call_mediaenc(void); #ifdef USE_VIDEO int test_video(void); -- cgit v1.2.3 From 6297d5c1a62bd9042cb825a2af0ced23013d429d Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Thu, 29 Mar 2018 22:09:16 +0200 Subject: test: shorter packet time and longer timeout --- test/call.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/call.c b/test/call.c index 2472afe..07db256 100644 --- a/test/call.c +++ b/test/call.c @@ -849,7 +849,7 @@ static int test_media_base(enum audio_mode txmode) struct auplay *auplay = NULL; int err = 0; - fixture_init(f); + fixture_init_prm(f, ";ptime=1"); conf_config()->audio.txmode = txmode; @@ -870,7 +870,7 @@ static int test_media_base(enum audio_mode txmode) TEST_ERR(err); /* run main-loop with timeout, wait for events */ - err = re_main_timeout(5000); + err = re_main_timeout(15000); TEST_ERR(err); TEST_ERR(fix.err); -- cgit v1.2.3 From 33d6034d07fbf5c64ee316055cf58d54f062276f Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Thu, 29 Mar 2018 22:21:40 +0200 Subject: audio: check if txmode is supported --- src/audio.c | 8 +++++++- test/call.c | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/audio.c b/src/audio.c index 3061ddc..b2b3cca 100644 --- a/src/audio.c +++ b/src/audio.c @@ -1537,6 +1537,10 @@ static int start_source(struct autx *tx, struct audio *a) } switch (a->cfg.txmode) { + + case AUDIO_MODE_POLL: + break; + #ifdef HAVE_PTHREAD case AUDIO_MODE_THREAD: if (!tx->u.thr.run) { @@ -1552,7 +1556,9 @@ static int start_source(struct autx *tx, struct audio *a) #endif default: - break; + warning("audio: tx mode not supported (%d)\n", + a->cfg.txmode); + return ENOTSUP; } tx->ausrc_prm = prm; diff --git a/test/call.c b/test/call.c index 07db256..ec12524 100644 --- a/test/call.c +++ b/test/call.c @@ -905,8 +905,10 @@ int test_call_format_float(void) err = test_media_base(AUDIO_MODE_POLL); ASSERT_EQ(0, err); +#ifdef HAVE_PTHREAD err = test_media_base(AUDIO_MODE_THREAD); ASSERT_EQ(0, err); +#endif conf_config()->audio.txmode = AUDIO_MODE_POLL; -- cgit v1.2.3 From 3e07f0b88e5d5ceb24d2663549465b40fd7f18f1 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Mon, 2 Apr 2018 18:31:52 +0200 Subject: make struct vidsrc and vidisp public --- include/baresip.h | 18 ++++++++++++++++++ src/core.h | 30 ------------------------------ 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/include/baresip.h b/include/baresip.h index 299bcd8..840687f 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -777,6 +777,13 @@ typedef int (vidsrc_alloc_h)(struct vidsrc_st **vsp, const struct vidsrc *vs, typedef void (vidsrc_update_h)(struct vidsrc_st *st, struct vidsrc_prm *prm, const char *dev); +struct vidsrc { + struct le le; + const char *name; + vidsrc_alloc_h *alloch; + vidsrc_update_h *updateh; +}; + int vidsrc_register(struct vidsrc **vp, struct list *vidsrcl, const char *name, vidsrc_alloc_h *alloch, vidsrc_update_h *updateh); const struct vidsrc *vidsrc_find(const struct list *vidsrcl, const char *name); @@ -785,6 +792,7 @@ int vidsrc_alloc(struct vidsrc_st **stp, struct list *vidsrcl, struct media_ctx **ctx, struct vidsrc_prm *prm, const struct vidsz *size, const char *fmt, const char *dev, vidsrc_frame_h *frameh, vidsrc_error_h *errorh, void *arg); +struct vidsrc *vidsrc_get(struct vidsrc_st *st); /* @@ -812,6 +820,15 @@ typedef int (vidisp_disp_h)(struct vidisp_st *st, const char *title, const struct vidframe *frame); typedef void (vidisp_hide_h)(struct vidisp_st *st); +struct vidisp { + struct le le; + const char *name; + vidisp_alloc_h *alloch; + vidisp_update_h *updateh; + vidisp_disp_h *disph; + vidisp_hide_h *hideh; +}; + int vidisp_register(struct vidisp **vp, struct list *vidispl, const char *name, vidisp_alloc_h *alloch, vidisp_update_h *updateh, vidisp_disp_h *disph, vidisp_hide_h *hideh); @@ -822,6 +839,7 @@ int vidisp_alloc(struct vidisp_st **stp, struct list *vidispl, int vidisp_display(struct vidisp_st *st, const char *title, const struct vidframe *frame); const struct vidisp *vidisp_find(const struct list *vidispl, const char *name); +struct vidisp *vidisp_get(struct vidisp_st *st); /* diff --git a/src/core.h b/src/core.h index 6e56fed..ca11ab8 100644 --- a/src/core.h +++ b/src/core.h @@ -421,36 +421,6 @@ struct tls *uag_tls(void); const char *uag_allowed_methods(void); -/* - * Video Display - */ - -struct vidisp { - struct le le; - const char *name; - vidisp_alloc_h *alloch; - vidisp_update_h *updateh; - vidisp_disp_h *disph; - vidisp_hide_h *hideh; -}; - -struct vidisp *vidisp_get(struct vidisp_st *st); - - -/* - * Video Source - */ - -struct vidsrc { - struct le le; - const char *name; - vidsrc_alloc_h *alloch; - vidsrc_update_h *updateh; -}; - -struct vidsrc *vidsrc_get(struct vidsrc_st *st); - - /* * Video Stream */ -- cgit v1.2.3 From 63a87cbe9e36456a9f03698b59858a83c83e068a Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Mon, 2 Apr 2018 18:32:12 +0200 Subject: vidloop: add source and display name to summary --- modules/vidloop/vidloop.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/vidloop/vidloop.c b/modules/vidloop/vidloop.c index 446ca02..0c41d72 100644 --- a/modules/vidloop/vidloop.c +++ b/modules/vidloop/vidloop.c @@ -266,6 +266,7 @@ static int print_stats(struct re_printf *pf, const struct video_loop *vl) /* Source */ if (vl->vsrc) { + struct vidsrc *vs = vidsrc_get(vl->vsrc); double avg_fps = .0; if (vl->stats.src_frames >= 2) @@ -273,12 +274,14 @@ static int print_stats(struct re_printf *pf, const struct video_loop *vl) err |= re_hprintf(pf, "* Source\n" + " module %s\n" " resolution %u x %u (actual %u x %u)\n" " pixformat %s\n" " frames %llu\n" " framerate %.2f fps (avg %.2f fps)\n" "\n" , + vs->name, cfg->width, cfg->height, vl->src_size.w, vl->src_size.h, vidfmt_name(vl->src_fmt), @@ -345,13 +348,17 @@ static int print_stats(struct re_printf *pf, const struct video_loop *vl) /* Display */ if (vl->vidisp) { + struct vidisp *vd = vidisp_get(vl->vidisp); + err |= re_hprintf(pf, "* Display\n" + " module %s\n" " resolution %u x %u\n" " fullscreen %s\n" " frames %llu\n" "\n" , + vd->name, vl->disp_size.w, vl->disp_size.h, cfg->fullscreen ? "Yes" : "No", vl->stats.disp_frames); -- cgit v1.2.3 From 0d04bfc7b18dbb85777d7563fb1fc6e2eae94f9d Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Thu, 5 Apr 2018 10:20:22 +0200 Subject: test: cast unused variable to void --- test/mock/mock_menc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/test/mock/mock_menc.c b/test/mock/mock_menc.c index b554646..cbd2a5f 100644 --- a/test/mock/mock_menc.c +++ b/test/mock/mock_menc.c @@ -46,6 +46,7 @@ static bool send_handler(int *err, struct sa *dst, struct mbuf *mb, void *arg) { struct menc_media *mm = arg; (void)mm; + (void)err; (void)dst; mock_crypt(mb); -- cgit v1.2.3 From 9565d03c87f9c99bddcba04b44f70a84c9c935d9 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Thu, 5 Apr 2018 15:52:21 +0200 Subject: fakevideo: draw 3 vertical RGB bars --- modules/fakevideo/fakevideo.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/fakevideo/fakevideo.c b/modules/fakevideo/fakevideo.c index e0552d6..946e181 100644 --- a/modules/fakevideo/fakevideo.c +++ b/modules/fakevideo/fakevideo.c @@ -95,6 +95,7 @@ static int src_alloc(struct vidsrc_st **stp, const struct vidsrc *vs, vidsrc_error_h *errorh, void *arg) { struct vidsrc_st *st; + unsigned x; int err; (void)ctx; @@ -118,6 +119,21 @@ static int src_alloc(struct vidsrc_st **stp, const struct vidsrc *vs, if (err) goto out; + /* Pattern of three vertical bars in RGB */ + for (x=0; xw; x++) { + + uint8_t r=0, g=0, b=0; + + if (x < size->w/3) + r = 255; + else if (x < size->w*2/3) + g = 255; + else + b = 255; + + vidframe_draw_vline(st->frame, x, 0, size->h, r, g, b); + } + st->run = true; err = pthread_create(&st->thread, NULL, read_thread, st); if (err) { -- cgit v1.2.3 From a72f343dd192b02f062b78cc1cb34e0830fb5c5c Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Fri, 6 Apr 2018 18:50:16 +0200 Subject: config: refresh template --- src/config.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/config.c b/src/config.c index 14bf651..de6f80a 100644 --- a/src/config.c +++ b/src/config.c @@ -389,7 +389,7 @@ int config_print(struct re_printf *pf, const struct config *cfg) "\n" "# Call\n" "call_local_timeout\t%u\n" - "call_max_calls\t%u\n" + "call_max_calls\t\t%u\n" "\n" "# Audio\n" "audio_path\t\t%s\n" @@ -411,6 +411,8 @@ int config_print(struct re_printf *pf, const struct config *cfg) "video_size\t\t\"%ux%u\"\n" "video_bitrate\t\t%u\n" "video_fps\t\t%.2f\n" + "video_fullscreen\t%s\n" + "videnc_format\t\t%s\n" "\n" #endif "# AVT\n" @@ -453,6 +455,8 @@ int config_print(struct re_printf *pf, const struct config *cfg) cfg->video.disp_mod, cfg->video.disp_dev, cfg->video.width, cfg->video.height, cfg->video.bitrate, cfg->video.fps, + cfg->video.fullscreen ? "yes" : "no", + vidfmt_name(cfg->video.enc_fmt), #endif cfg->avt.rtp_tos, @@ -557,7 +561,7 @@ static int core_config_template(struct re_printf *pf, const struct config *cfg) "\n" "# Call\n" "call_local_timeout\t%u\n" - "call_max_calls\t%u\n" + "call_max_calls\t\t%u\n" "\n" "# Audio\n" #if defined (SHARE_PATH) -- cgit v1.2.3 From 87907a9016d1c84618a1a3e344bc7c5403056266 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Fri, 6 Apr 2018 19:05:50 +0200 Subject: fakevideo: add support for non-threaded --- mk/modules.mk | 2 -- modules/fakevideo/fakevideo.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/mk/modules.mk b/mk/modules.mk index a8256a1..a479e6a 100644 --- a/mk/modules.mk +++ b/mk/modules.mk @@ -281,10 +281,8 @@ MODULES += aubridge aufile endif ifneq ($(USE_VIDEO),) MODULES += vidloop selfview vidbridge -ifneq ($(HAVE_PTHREAD),) MODULES += fakevideo endif -endif ifneq ($(USE_ALSA),) diff --git a/modules/fakevideo/fakevideo.c b/modules/fakevideo/fakevideo.c index 946e181..03d0200 100644 --- a/modules/fakevideo/fakevideo.c +++ b/modules/fakevideo/fakevideo.c @@ -31,8 +31,13 @@ struct vidsrc_st { const struct vidsrc *vs; /* inheritance */ struct vidframe *frame; +#ifdef HAVE_PTHREAD pthread_t thread; bool run; +#else + struct tmr tmr; + uint64_t ts; +#endif int fps; vidsrc_frame_h *frameh; void *arg; @@ -47,6 +52,7 @@ static struct vidsrc *vidsrc; static struct vidisp *vidisp; +#ifdef HAVE_PTHREAD static void *read_thread(void *arg) { struct vidsrc_st *st = arg; @@ -66,16 +72,38 @@ static void *read_thread(void *arg) return NULL; } +#else +static void tmr_handler(void *arg) +{ + struct vidsrc_st *st = arg; + const uint64_t now = tmr_jiffies(); + + tmr_start(&st->tmr, 4, tmr_handler, st); + + if (!st->ts) + st->ts = now; + + if (now >= st->ts) { + st->frameh(st->frame, st->arg); + + st->ts += (1000/st->fps); + } +} +#endif static void src_destructor(void *arg) { struct vidsrc_st *st = arg; +#ifdef HAVE_PTHREAD if (st->run) { st->run = false; pthread_join(st->thread, NULL); } +#else + tmr_cancel(&st->tmr); +#endif mem_deref(st->frame); } @@ -134,12 +162,16 @@ static int src_alloc(struct vidsrc_st **stp, const struct vidsrc *vs, vidframe_draw_vline(st->frame, x, 0, size->h, r, g, b); } +#ifdef HAVE_PTHREAD st->run = true; err = pthread_create(&st->thread, NULL, read_thread, st); if (err) { st->run = false; goto out; } +#else + tmr_start(&st->tmr, 1, tmr_handler, st); +#endif out: if (err) -- cgit v1.2.3 From 4c7f08692078199914aafabb0ef19c2c9b5ff1be Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Fri, 6 Apr 2018 19:40:59 +0200 Subject: config: default devices for win32 --- src/config.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/config.c b/src/config.c index de6f80a..6c336d9 100644 --- a/src/config.c +++ b/src/config.c @@ -508,6 +508,8 @@ static const char *default_video_device(void) return "avcapture,nil"; #endif +#elif defined (WIN32) + return "dshow,nil"; #else return "v4l2,/dev/video0"; #endif @@ -518,6 +520,8 @@ static const char *default_video_display(void) { #ifdef DARWIN return "opengl,nil"; +#elif defined (WIN32) + return "sdl2,nil"; #else return "x11,nil"; #endif -- cgit v1.2.3 From b3bd9972e0633451eecff834297d3cc139d69b4b Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 7 Apr 2018 12:24:19 +0200 Subject: v4l2: print actual framerate --- modules/v4l2/v4l2.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/modules/v4l2/v4l2.c b/modules/v4l2/v4l2.c index 983ad53..20ad762 100644 --- a/modules/v4l2/v4l2.c +++ b/modules/v4l2/v4l2.c @@ -106,6 +106,28 @@ static void print_video_input(const struct vidsrc_st *st) } +static void print_framerate(const struct vidsrc_st *st) +{ + struct v4l2_streamparm streamparm; + struct v4l2_fract tpf; + double fps; + + memset(&streamparm, 0, sizeof(streamparm)); + + streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + if (v4l2_ioctl(st->fd, VIDIOC_G_PARM, &streamparm) != 0) { + warning("v4l2: VIDIOC_G_PARM error (%m)\n", errno); + return; + } + + tpf = streamparm.parm.capture.timeperframe; + fps = (double)tpf.denominator / (double)tpf.numerator; + + info("v4l2: current framerate is %.2f fps\n", fps); +} + + static int xioctl(int fd, unsigned long int request, void *arg) { int r; @@ -470,6 +492,8 @@ static int alloc(struct vidsrc_st **stp, const struct vidsrc *vs, print_video_input(st); + print_framerate(st); + err = start_capturing(st); if (err) goto out; -- cgit v1.2.3 From 09c1b0287be9a7c33dffb11d2bad9286142be3a2 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 11 Mar 2018 21:57:09 +0100 Subject: vidsrc: add timestamp to the frame API timestamps for v4l and v4l2 test: add timestamp to vidsrc mock v4l2: print framerate vidloop: save timestamps and print duration test with timebase of 65536 v4l2: scale timestamp to VIDEO_TIMEBASE minor fixes --- include/baresip.h | 10 ++++++++- modules/avcapture/avcapture.m | 6 +++++- modules/avformat/avformat.c | 10 ++++++++- modules/cairo/cairo.c | 19 +++++++++++------ modules/fakevideo/fakevideo.c | 6 +++++- modules/rst/video.c | 6 +++++- modules/v4l/v4l.c | 11 +++++++--- modules/v4l2/v4l2.c | 13 +++++++++--- modules/vidbridge/src.c | 11 ++++++---- modules/vidbridge/vidbridge.h | 4 +++- modules/vidloop/vidloop.c | 48 +++++++++++++++++++++++++++++++++++++------ modules/x11grab/x11grab.c | 11 +++++++--- src/video.c | 5 ++++- src/vidutil.c | 6 ++++++ test/mock/mock_vidsrc.c | 5 ++++- 15 files changed, 138 insertions(+), 33 deletions(-) diff --git a/include/baresip.h b/include/baresip.h index 840687f..2578888 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -21,6 +21,12 @@ extern "C" { #endif +/* + * Clock-rate for video timestamp + */ +#define VIDEO_TIMEBASE 1000000U + + /* forward declarations */ struct sa; struct sdp_media; @@ -764,7 +770,8 @@ struct vidsrc_prm { double fps; /**< Wanted framerate */ }; -typedef void (vidsrc_frame_h)(struct vidframe *frame, void *arg); +typedef void (vidsrc_frame_h)(struct vidframe *frame, uint64_t timestamp, + void *arg); typedef void (vidsrc_error_h)(int err, void *arg); typedef int (vidsrc_alloc_h)(struct vidsrc_st **vsp, const struct vidsrc *vs, @@ -1034,6 +1041,7 @@ int video_debug(struct re_printf *pf, const struct video *v); uint64_t video_calc_rtp_timestamp(int64_t pts, double fps); double video_calc_seconds(uint64_t rtp_ts); struct stream *video_strm(const struct video *v); +double video_timestamp_to_seconds(uint64_t timestamp); /* diff --git a/modules/avcapture/avcapture.m b/modules/avcapture/avcapture.m index f276c96..7420cfe 100644 --- a/modules/avcapture/avcapture.m +++ b/modules/avcapture/avcapture.m @@ -234,7 +234,9 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)conn { const CVImageBufferRef b = CMSampleBufferGetImageBuffer(sampleBuffer); + CMTime ts = CMSampleBufferGetOutputPresentationTimeStamp(sampleBuffer); struct vidframe vf; + uint64_t timestamp; (void)captureOutput; (void)conn; @@ -246,8 +248,10 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer vidframe_set_pixbuf(&vf, b); + timestamp = CMTimeGetSeconds(ts) * VIDEO_TIMEBASE; + if (vidframe_isvalid(&vf)) - vsrc->frameh(&vf, vsrc->arg); + vsrc->frameh(&vf, timestamp, vsrc->arg); CVPixelBufferUnlockBaseAddress(b, 0); } diff --git a/modules/avformat/avformat.c b/modules/avformat/avformat.c index 62f6fda..af20082 100644 --- a/modules/avformat/avformat.c +++ b/modules/avformat/avformat.c @@ -100,6 +100,8 @@ static void handle_packet(struct vidsrc_st *st, AVPacket *pkt) struct vidframe vf; struct vidsz sz; unsigned i; + int64_t pts; + uint64_t timestamp; if (st->codec) { int got_pict, ret; @@ -147,6 +149,12 @@ static void handle_packet(struct vidsrc_st *st, AVPacket *pkt) return; } + pts = av_frame_get_best_effort_timestamp(frame); + const AVRational time_base = st->time_base; + + /* convert timestamp */ + timestamp = pts * VIDEO_TIMEBASE * time_base.num / time_base.den; + #if LIBAVCODEC_VERSION_INT >= ((53<<16)+(5<<8)+0) switch (frame->format) { @@ -172,7 +180,7 @@ static void handle_packet(struct vidsrc_st *st, AVPacket *pkt) vf.linesize[i] = frame->linesize[i]; } - st->frameh(&vf, st->arg); + st->frameh(&vf, timestamp, st->arg); out: if (frame) { diff --git a/modules/cairo/cairo.c b/modules/cairo/cairo.c index 5e95b52..2422d6b 100644 --- a/modules/cairo/cairo.c +++ b/modules/cairo/cairo.c @@ -129,7 +129,7 @@ static void draw_logo(struct vidsrc_st *st) } -static void process(struct vidsrc_st *st) +static void process(struct vidsrc_st *st, uint64_t timestamp) { struct vidframe f; unsigned xoffs = 2, yoffs = 24; @@ -141,6 +141,9 @@ static void process(struct vidsrc_st *st) draw_text(st, xoffs, yoffs + FONT_SIZE*2, "%u x %u @ %.2f fps", st->size.w, st->size.h, st->prm.fps); + draw_text(st, xoffs, yoffs + FONT_SIZE*3, "Time: %.3f sec", + timestamp / (double)VIDEO_TIMEBASE); + draw_logo(st); st->step += 0.02 / st->prm.fps; @@ -148,29 +151,33 @@ static void process(struct vidsrc_st *st) vidframe_init_buf(&f, VID_FMT_RGB32, &st->size, cairo_image_surface_get_data(st->surface)); - st->frameh(&f, st->arg); + st->frameh(&f, timestamp, st->arg); } static void *read_thread(void *arg) { struct vidsrc_st *st = arg; - uint64_t ts = 0; + uint64_t ts = 0, ts_start; while (st->run) { uint64_t now; + uint64_t timestamp; sys_msleep(2); now = tmr_jiffies(); - if (!ts) - ts = now; + if (!ts) { + ts = ts_start = now; + } if (ts > now) continue; - process(st); + timestamp = (ts - ts_start) * VIDEO_TIMEBASE / 1000; + + process(st, timestamp); ts += 1000/st->prm.fps; } diff --git a/modules/fakevideo/fakevideo.c b/modules/fakevideo/fakevideo.c index 03d0200..53b9c9a 100644 --- a/modules/fakevideo/fakevideo.c +++ b/modules/fakevideo/fakevideo.c @@ -60,12 +60,16 @@ static void *read_thread(void *arg) while (st->run) { + uint64_t timestamp; + if (tmr_jiffies() < ts) { sys_msleep(4); continue; } - st->frameh(st->frame, st->arg); + timestamp = ts * VIDEO_TIMEBASE / 1000; + + st->frameh(st->frame, timestamp, st->arg); ts += (1000/st->fps); } diff --git a/modules/rst/video.c b/modules/rst/video.c index bf59daf..c12ca0a 100644 --- a/modules/rst/video.c +++ b/modules/rst/video.c @@ -62,6 +62,8 @@ static void *video_thread(void *arg) while (st->run) { + uint64_t timestamp; + sys_msleep(4); now = tmr_jiffies(); @@ -69,8 +71,10 @@ static void *video_thread(void *arg) if (ts > now) continue; + timestamp = ts * VIDEO_TIMEBASE / 1000; + pthread_mutex_lock(&st->mutex); - st->frameh(st->frame, st->arg); + st->frameh(st->frame, timestamp, st->arg); pthread_mutex_unlock(&st->mutex); ts += 1000/st->prm.fps; diff --git a/modules/v4l/v4l.c b/modules/v4l/v4l.c index a171021..9f65cf6 100644 --- a/modules/v4l/v4l.c +++ b/modules/v4l/v4l.c @@ -117,13 +117,14 @@ static int v4l_get_win(int fd, int width, int height) } -static void call_frame_handler(struct vidsrc_st *st, uint8_t *buf) +static void call_frame_handler(struct vidsrc_st *st, uint8_t *buf, + uint64_t timestamp) { struct vidframe frame; vidframe_init_buf(&frame, st->fmt, &st->size, buf); - st->frameh(&frame, st->arg); + st->frameh(&frame, timestamp, st->arg); } @@ -133,6 +134,7 @@ static void *read_thread(void *arg) while (st->run) { ssize_t n; + uint64_t timestamp; n = read(st->fd, st->mb->buf, st->mb->size); if ((ssize_t)st->mb->size != n) { @@ -141,7 +143,10 @@ static void *read_thread(void *arg) continue; } - call_frame_handler(st, st->mb->buf); + /* XXX: review this */ + timestamp = tmr_jiffies() * 1000; + + call_frame_handler(st, st->mb->buf, timestamp); } return NULL; diff --git a/modules/v4l2/v4l2.c b/modules/v4l2/v4l2.c index 20ad762..228ec10 100644 --- a/modules/v4l2/v4l2.c +++ b/modules/v4l2/v4l2.c @@ -353,19 +353,22 @@ static int start_capturing(struct vidsrc_st *st) } -static void call_frame_handler(struct vidsrc_st *st, uint8_t *buf) +static void call_frame_handler(struct vidsrc_st *st, uint8_t *buf, + uint64_t timestamp) { struct vidframe frame; vidframe_init_buf(&frame, match_fmt(st->pixfmt), &st->sz, buf); - st->frameh(&frame, st->arg); + st->frameh(&frame, timestamp, st->arg); } static int read_frame(struct vidsrc_st *st) { struct v4l2_buffer buf; + struct timeval ts; + uint64_t timestamp; memset(&buf, 0, sizeof(buf)); @@ -393,7 +396,11 @@ static int read_frame(struct vidsrc_st *st) warning("v4l2: index >= n_buffers\n"); } - call_frame_handler(st, st->buffers[buf.index].start); + ts = buf.timestamp; + timestamp = 1000000U * ts.tv_sec + ts.tv_usec; + timestamp = timestamp * VIDEO_TIMEBASE / 1000000U; + + call_frame_handler(st, st->buffers[buf.index].start, timestamp); if (-1 == xioctl (st->fd, VIDIOC_QBUF, &buf)) { warning("v4l2: VIDIOC_QBUF\n"); diff --git a/modules/vidbridge/src.c b/modules/vidbridge/src.c index 5e7d08a..2ead7cc 100644 --- a/modules/vidbridge/src.c +++ b/modules/vidbridge/src.c @@ -30,11 +30,10 @@ int vidbridge_src_alloc(struct vidsrc_st **stp, const struct vidsrc *vs, struct vidsrc_st *st; int err; (void)ctx; - (void)prm; (void)fmt; (void)errorh; - if (!stp || !size || !frameh) + if (!stp || !prm || !size || !frameh) return EINVAL; st = mem_zalloc(sizeof(*st), destructor); @@ -44,6 +43,7 @@ int vidbridge_src_alloc(struct vidsrc_st **stp, const struct vidsrc *vs, st->vs = vs; st->frameh = frameh; st->arg = arg; + st->fps = prm->fps; err = str_dup(&st->device, dev); if (err) @@ -82,12 +82,15 @@ struct vidsrc_st *vidbridge_src_find(const char *device) } -void vidbridge_src_input(const struct vidsrc_st *st, +void vidbridge_src_input(struct vidsrc_st *st, const struct vidframe *frame) { if (!st || !frame) return; + /* XXX: Read from vidisp input */ + st->timestamp += VIDEO_TIMEBASE / st->fps; + if (st->frameh) - st->frameh((struct vidframe *)frame, st->arg); + st->frameh((struct vidframe *)frame, st->timestamp, st->arg); } diff --git a/modules/vidbridge/vidbridge.h b/modules/vidbridge/vidbridge.h index 0fbf68e..74b2e24 100644 --- a/modules/vidbridge/vidbridge.h +++ b/modules/vidbridge/vidbridge.h @@ -10,6 +10,8 @@ struct vidsrc_st { struct le le; struct vidisp_st *vidisp; + uint64_t timestamp; + double fps; char *device; vidsrc_frame_h *frameh; void *arg; @@ -43,5 +45,5 @@ int vidbridge_src_alloc(struct vidsrc_st **stp, const struct vidsrc *vs, const char *dev, vidsrc_frame_h *frameh, vidsrc_error_h *errorh, void *arg); struct vidsrc_st *vidbridge_src_find(const char *device); -void vidbridge_src_input(const struct vidsrc_st *st, +void vidbridge_src_input(struct vidsrc_st *st, const struct vidframe *frame); diff --git a/modules/vidloop/vidloop.c b/modules/vidloop/vidloop.c index 0c41d72..ca7979b 100644 --- a/modules/vidloop/vidloop.c +++ b/modules/vidloop/vidloop.c @@ -73,6 +73,10 @@ struct video_loop { uint64_t enc_packets; uint64_t disp_frames; } stats; + + bool timestamp_set; + uint64_t timestamp_base; /* lowest timestamp */ + uint64_t timestamp_last; /* most recent timestamp */ }; @@ -189,7 +193,21 @@ static int packet_handler(bool marker, uint64_t rtp_ts, } -static void vidsrc_frame_handler(struct vidframe *frame, void *arg) +static double stream_duration(const struct video_loop *vl) +{ + uint64_t dur; + + if (vl->timestamp_set) + dur = vl->timestamp_last - vl->timestamp_base; + else + dur = 0; + + return video_timestamp_to_seconds(dur); +} + + +static void vidsrc_frame_handler(struct vidframe *frame, uint64_t timestamp, + void *arg) { struct video_loop *vl = arg; struct vidframe *f2 = NULL; @@ -207,6 +225,20 @@ static void vidsrc_frame_handler(struct vidframe *frame, void *arg) vl->src_fmt = frame->fmt; ++vl->stats.src_frames; + /* Timestamp logic */ + if (vl->timestamp_set) { + if (timestamp <= vl->timestamp_base) { + info("vidloop: timestamp wrapped -- reset base\n"); + vl->timestamp_base = timestamp; + } + vl->timestamp_last = timestamp; + } + else { + vl->timestamp_base = timestamp; + vl->timestamp_last = timestamp; + vl->timestamp_set = true; + } + ++vl->stat.frames; if (frame->fmt != (enum vidfmt)vl->cfg.enc_fmt) { @@ -259,8 +291,9 @@ static int print_stats(struct re_printf *pf, const struct video_loop *vl) double real_dur = .0; int err = 0; - if (vl->ts_start) - real_dur = 0.000001 * (double)(vl->ts_last - vl->ts_start); + if (vl->ts_start) { + real_dur = stream_duration(vl); + } err |= re_hprintf(pf, "~~~~~ Videoloop summary: ~~~~~\n"); @@ -279,6 +312,7 @@ static int print_stats(struct re_printf *pf, const struct video_loop *vl) " pixformat %s\n" " frames %llu\n" " framerate %.2f fps (avg %.2f fps)\n" + " duration %.3f sec\n" "\n" , vs->name, @@ -286,7 +320,8 @@ static int print_stats(struct re_printf *pf, const struct video_loop *vl) vl->src_size.w, vl->src_size.h, vidfmt_name(vl->src_fmt), vl->stats.src_frames, - vl->srcprm.fps, avg_fps); + vl->srcprm.fps, avg_fps, + real_dur); } /* Video conversion */ @@ -438,8 +473,9 @@ static void print_status(struct video_loop *vl) { (void)re_fprintf(stdout, "\rstatus:" - " [%s] [%s] fmt=%s intra=%zu " + " %.3f sec [%s] [%s] fmt=%s intra=%zu " " EFPS=%.1f %u kbit/s \r", + stream_duration(vl), vl->vc_enc ? vl->vc_enc->name : "", vl->vc_dec ? vl->vc_dec->name : "", vidfmt_name(vl->cfg.enc_fmt), @@ -478,7 +514,7 @@ static void timeout_bw(void *arg) return; } - tmr_start(&vl->tmr_bw, 2000, timeout_bw, vl); + tmr_start(&vl->tmr_bw, 500, timeout_bw, vl); calc_bitrate(vl); print_status(vl); diff --git a/modules/x11grab/x11grab.c b/modules/x11grab/x11grab.c index d3aa287..36f37c1 100644 --- a/modules/x11grab/x11grab.c +++ b/modules/x11grab/x11grab.c @@ -100,13 +100,14 @@ static inline uint8_t *x11grab_read(struct vidsrc_st *st) } -static void call_frame_handler(struct vidsrc_st *st, uint8_t *buf) +static void call_frame_handler(struct vidsrc_st *st, uint8_t *buf, + uint64_t timestamp) { struct vidframe frame; vidframe_init_buf(&frame, st->pixfmt, &st->size, buf); - st->frameh(&frame, st->arg); + st->frameh(&frame, timestamp, st->arg); } @@ -118,6 +119,8 @@ static void *read_thread(void *arg) while (st->run) { + uint64_t timestamp; + if (tmr_jiffies() < ts) { sys_msleep(4); continue; @@ -127,9 +130,11 @@ static void *read_thread(void *arg) if (!buf) continue; + timestamp = ts * VIDEO_TIMEBASE / 1000; + ts += (1000/st->fps); - call_frame_handler(st, buf); + call_frame_handler(st, buf, timestamp); } return NULL; diff --git a/src/video.c b/src/video.c index 4caf728..e21b626 100644 --- a/src/video.c +++ b/src/video.c @@ -453,10 +453,13 @@ static void encode_rtp_send(struct vtx *vtx, struct vidframe *frame) * * @note This function has REAL-TIME properties */ -static void vidsrc_frame_handler(struct vidframe *frame, void *arg) +static void vidsrc_frame_handler(struct vidframe *frame, uint64_t timestamp, + void *arg) { struct vtx *vtx = arg; + /* XXX: save timestamp(s) and pass to encoder */ + ++vtx->frames; ++vtx->stats.src_frames; diff --git a/src/vidutil.c b/src/vidutil.c index abdddf7..4df0d73 100644 --- a/src/vidutil.c +++ b/src/vidutil.c @@ -50,3 +50,9 @@ double video_calc_seconds(uint64_t rtp_ts) return timestamp; } + + +double video_timestamp_to_seconds(uint64_t timestamp) +{ + return (double)timestamp / (double)VIDEO_TIMEBASE; +} diff --git a/test/mock/mock_vidsrc.c b/test/mock/mock_vidsrc.c index ad6b165..781e04a 100644 --- a/test/mock/mock_vidsrc.c +++ b/test/mock/mock_vidsrc.c @@ -14,6 +14,7 @@ struct vidsrc_st { struct vidframe *frame; struct tmr tmr; + uint64_t timestamp; double fps; vidsrc_frame_h *frameh; void *arg; @@ -27,7 +28,9 @@ static void tmr_handler(void *arg) tmr_start(&st->tmr, 1000/st->fps, tmr_handler, st); if (st->frameh) - st->frameh(st->frame, st->arg); + st->frameh(st->frame, st->timestamp, st->arg); + + st->timestamp += VIDEO_TIMEBASE / st->fps; } -- cgit v1.2.3 From dcd6d24ee1fa7bbc14f363ae43a579f1db9f01a2 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 8 Apr 2018 18:24:03 +0200 Subject: fakevideo: fix threaded and non-threaded build --- modules/fakevideo/fakevideo.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/modules/fakevideo/fakevideo.c b/modules/fakevideo/fakevideo.c index 53b9c9a..dcbd0e5 100644 --- a/modules/fakevideo/fakevideo.c +++ b/modules/fakevideo/fakevideo.c @@ -36,9 +36,9 @@ struct vidsrc_st { bool run; #else struct tmr tmr; - uint64_t ts; #endif - int fps; + uint64_t ts; + double fps; vidsrc_frame_h *frameh; void *arg; }; @@ -52,26 +52,29 @@ static struct vidsrc *vidsrc; static struct vidisp *vidisp; +static void process_frame(struct vidsrc_st *st) +{ + st->ts += (VIDEO_TIMEBASE / st->fps); + + st->frameh(st->frame, st->ts, st->arg); +} + + #ifdef HAVE_PTHREAD static void *read_thread(void *arg) { struct vidsrc_st *st = arg; - uint64_t ts = tmr_jiffies(); - while (st->run) { + st->ts = tmr_jiffies_usec(); - uint64_t timestamp; + while (st->run) { - if (tmr_jiffies() < ts) { + if (tmr_jiffies_usec() < st->ts) { sys_msleep(4); continue; } - timestamp = ts * VIDEO_TIMEBASE / 1000; - - st->frameh(st->frame, timestamp, st->arg); - - ts += (1000/st->fps); + process_frame(st); } return NULL; @@ -80,7 +83,7 @@ static void *read_thread(void *arg) static void tmr_handler(void *arg) { struct vidsrc_st *st = arg; - const uint64_t now = tmr_jiffies(); + const uint64_t now = tmr_jiffies_usec(); tmr_start(&st->tmr, 4, tmr_handler, st); @@ -88,9 +91,7 @@ static void tmr_handler(void *arg) st->ts = now; if (now >= st->ts) { - st->frameh(st->frame, st->arg); - - st->ts += (1000/st->fps); + process_frame(st); } } #endif -- cgit v1.2.3 From 6641895c3641e792de6f16a9967bc2becfb513a4 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 8 Apr 2018 20:13:57 +0200 Subject: dshow: convert sample_time to timestamp --- modules/dshow/dshow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/dshow/dshow.cpp b/modules/dshow/dshow.cpp index d081f69..46aef3e 100644 --- a/modules/dshow/dshow.cpp +++ b/modules/dshow/dshow.cpp @@ -99,12 +99,13 @@ public: STDMETHOD(BufferCB) (double sample_time, BYTE *buf, long buf_len) { struct vidframe vidframe; + uint64_t timestamp = sample_time * VIDEO_TIMEBASE; /* XXX: should be VID_FMT_BGR24 */ vidframe_init_buf(&vidframe, VID_FMT_RGB32, &src->size, buf); if (src->frameh) - src->frameh(&vidframe, src->arg); + src->frameh(&vidframe, timestamp, src->arg); return S_OK; } -- cgit v1.2.3 From 3ecf6b57adf5f626eea550532ca44ed7511e770e Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Thu, 12 Apr 2018 21:53:39 +0200 Subject: update doxygen comments --- include/baresip.h | 11 ++++++++++- src/h264.c | 7 +++++++ src/vidisp.c | 7 +++++++ src/vidsrc.c | 7 +++++++ src/vidutil.c | 7 +++++++ 5 files changed, 38 insertions(+), 1 deletion(-) diff --git a/include/baresip.h b/include/baresip.h index 2578888..3952f6b 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -770,6 +770,13 @@ struct vidsrc_prm { double fps; /**< Wanted framerate */ }; +/** + * Provides video frames to the core + * + * @param frame Video frame + * @param timestamp Frame timestamp in VIDEO_TIMEBASE units + * @param arg Handler argument + */ typedef void (vidsrc_frame_h)(struct vidframe *frame, uint64_t timestamp, void *arg); typedef void (vidsrc_error_h)(int err, void *arg); @@ -784,6 +791,7 @@ typedef int (vidsrc_alloc_h)(struct vidsrc_st **vsp, const struct vidsrc *vs, typedef void (vidsrc_update_h)(struct vidsrc_st *st, struct vidsrc_prm *prm, const char *dev); +/** Defines a video source */ struct vidsrc { struct le le; const char *name; @@ -827,6 +835,7 @@ typedef int (vidisp_disp_h)(struct vidisp_st *st, const char *title, const struct vidframe *frame); typedef void (vidisp_hide_h)(struct vidisp_st *st); +/** Defines a Video display */ struct vidisp { struct le le; const char *name; @@ -910,7 +919,7 @@ const struct aucodec *aucodec_find(const struct list *aucodecl, struct videnc_param { unsigned bitrate; /**< Encoder bitrate in [bit/s] */ unsigned pktsize; /**< RTP packetsize in [bytes] */ - double fps; /**< Video framerate */ + double fps; /**< Video framerate (max) */ uint32_t max_fs; }; diff --git a/src/h264.c b/src/h264.c index 5f56d9d..3786559 100644 --- a/src/h264.c +++ b/src/h264.c @@ -182,6 +182,13 @@ int h264_packetize(uint64_t rtp_ts, const uint8_t *buf, size_t len, } +/** + * Get the name of an H.264 nal unit + * + * @param type NAL unit type + * + * @return A string containing the NAL unit name + */ const char *h264_nalunit_name(int type) { switch (type) { diff --git a/src/vidisp.c b/src/vidisp.c index d267f58..2a2def6 100644 --- a/src/vidisp.c +++ b/src/vidisp.c @@ -126,6 +126,13 @@ int vidisp_display(struct vidisp_st *st, const char *title, } +/** + * Get the video display module from a video display state + * + * @param st Video display state + * + * @return Video display module + */ struct vidisp *vidisp_get(struct vidisp_st *st) { return st ? st->vd : NULL; diff --git a/src/vidsrc.c b/src/vidsrc.c index 2c8f9ff..03a039a 100644 --- a/src/vidsrc.c +++ b/src/vidsrc.c @@ -119,6 +119,13 @@ int vidsrc_alloc(struct vidsrc_st **stp, struct list *vidsrcl, } +/** + * Get the video source module from a video source state + * + * @param st Video source state + * + * @return Video source module + */ struct vidsrc *vidsrc_get(struct vidsrc_st *st) { return st ? st->vs : NULL; diff --git a/src/vidutil.c b/src/vidutil.c index 4df0d73..a6d0b61 100644 --- a/src/vidutil.c +++ b/src/vidutil.c @@ -52,6 +52,13 @@ double video_calc_seconds(uint64_t rtp_ts) } +/** + * Convert a video timestamp to seconds + * + * @param timestamp Timestamp in VIDEO_TIMEBASE units + * + * @return Timestamp in seconds + */ double video_timestamp_to_seconds(uint64_t timestamp) { return (double)timestamp / (double)VIDEO_TIMEBASE; -- cgit v1.2.3 From 01f5b7fd8ef4526379ac8b19bc694a7468d3944e Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 15 Apr 2018 13:04:25 +0200 Subject: version 0.5.9 --- Makefile | 2 +- include/baresip.h | 2 +- mk/Doxyfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index f528fdf..31e2f4a 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ USE_VIDEO := 1 PROJECT := baresip -VERSION := 0.5.8 +VERSION := 0.5.9 DESCR := "Baresip is a modular SIP User-Agent with audio and video support" # Verbose and silent build modes diff --git a/include/baresip.h b/include/baresip.h index 3952f6b..57369ef 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -13,7 +13,7 @@ extern "C" { /** Defines the Baresip version string */ -#define BARESIP_VERSION "0.5.8" +#define BARESIP_VERSION "0.5.9" #ifndef NET_MAX_NS diff --git a/mk/Doxyfile b/mk/Doxyfile index cdc8a86..1697721 100644 --- a/mk/Doxyfile +++ b/mk/Doxyfile @@ -4,7 +4,7 @@ # Project related configuration options #--------------------------------------------------------------------------- PROJECT_NAME = baresip -PROJECT_NUMBER = 0.5.8 +PROJECT_NUMBER = 0.5.9 OUTPUT_DIRECTORY = ../baresip-dox CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English -- cgit v1.2.3 From a7fd4a25c8a1e0f292d4922f9261e1756e444a28 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 21 Apr 2018 15:22:07 +0200 Subject: update changelog for version 0.5.9 --- debian/changelog | 6 +++++ docs/ChangeLog | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ rpm/baresip.spec | 2 +- 3 files changed, 81 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index caf1926..48c2be2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +baresip (0.5.9) unstable; urgency=medium + + * version 0.5.9 + + -- Alfred E. Heggestad Sat, 21 Apr 2018 12:00:00 +0200 + baresip (0.5.8) unstable; urgency=medium * version 0.5.8 diff --git a/docs/ChangeLog b/docs/ChangeLog index c1b2546..c598849 100644 --- a/docs/ChangeLog +++ b/docs/ChangeLog @@ -1,3 +1,77 @@ +2018-04-21 Alfred E. Heggestad + + * Version 0.5.9 + + * GIT URL: https://github.com/alfredh/baresip.git + * GIT tag: v0.5.9 + * NOTE: Requires libre v0.5.7 or later + Requires librem v0.5.2 or later + + * build: + - Updated MSVS project to VS15 and added several files + to project settings (thanks Encamy) + + * config: + + video_fps 29.97 # float + + * baresip-core: + - conf: add conf_get_float + - timer: add tmr_jiffies_usec + - timestamp: new file for timestamp helpers + - ua: add catchall flag to struct ua + - ua: add ua_set_catchall + - ua: uag_find: return match if catchall flag is set + - vidcodec: change rtp_ts from 32-bit to 64-bit + - videnc: change framerate to double float + - video: change framerate to double float + - vidsrc: add frame timestamp + - vidsrc: change framerate to double float + + * selftest: + - mediaenc: add testcase for media encryption + + * Modules: + + * avcapture: add support for video frame timestamp + + * avcodec: fix compiling with old ffmpeg versions + print framerate of decoded bitstream + + * avformat: add support for video frame timestamp + + * b2bua: add handling of all inbound SIP requests + + * cairo: add support for video frame timestamp + + * ctrl_tcp: Fix #369. documentation typo (#372) + Fix #370. wrong assignent (#371) + (thanks José Luis Millán) + + * dshow: add support for video frame timestamp + + * fakevideo: add support for video frame timestamp + add support for timer polling (no pthreads) + + * menu: added "statmode_default" config variable (#359) + (thanks Juha Heinanen) + + * rst: add support for video frame timestamp + + * swscale: add YUV444P pixel format + + * v4l: add support for video frame timestamp + + * v4l2: add support for video frame timestamp + show actual framerate + + * vidbridge: add support for video frame timestamp + + * vidloop: add videoloop summary + + * x11grab: add support for video frame timestamp + + 2018-02-11 Alfred E. Heggestad * Version 0.5.8 diff --git a/rpm/baresip.spec b/rpm/baresip.spec index 8bc1ebe..27d1088 100644 --- a/rpm/baresip.spec +++ b/rpm/baresip.spec @@ -1,5 +1,5 @@ %define name baresip -%define ver 0.5.8 +%define ver 0.5.9 %define rel 1 Summary: Modular SIP useragent -- cgit v1.2.3