Skip to content

Commit

Permalink
Merge branch 'bfcp' into v3.14.0_patch
Browse files Browse the repository at this point in the history
  • Loading branch information
nicotyze committed Aug 7, 2024
2 parents 0910c43 + 362590f commit 8b0de44
Show file tree
Hide file tree
Showing 20 changed files with 1,155 additions and 62 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ set(SRCS
src/aureceiver.c
src/ausrc.c
src/baresip.c
src/bfcp.c
src/bundle.c
src/call.c
src/cmd.c
Expand Down
1 change: 1 addition & 0 deletions cmake/modules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ set(MODULES
wincons
winwave
x11
x11_grab

CACHE STRING "List of modules like 'turn;pipewire;alsa'"
)
Expand Down
16 changes: 16 additions & 0 deletions include/baresip.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ void call_set_video_ldir(struct call *call, enum sdp_dir dir);
int call_set_video_dir(struct call *call, enum sdp_dir dir);
int call_update_media(struct call *call);
int call_send_digit(struct call *call, char key);
int call_send_pfu(struct call *call, const char* content,
const char* label);
bool call_has_audio(const struct call *call);
bool call_has_video(const struct call *call);
bool call_early_video_available(const struct call *call);
Expand All @@ -253,6 +255,7 @@ const char *call_alerturi(const struct call *call);
const char *call_diverteruri(const struct call *call);
struct audio *call_audio(const struct call *call);
struct video *call_video(const struct call *call);
struct video *call_slides(const struct call *call);
struct list *call_streaml(const struct call *call);
struct ua *call_get_ua(const struct call *call);
bool call_is_onhold(const struct call *call);
Expand Down Expand Up @@ -363,6 +366,7 @@ struct config_sip {
enum tls_resume_mode tls_resume; /** TLS resumption mode */
uint8_t tos; /**< Type-of-Service for SIP */
uint32_t reg_filt; /**< Registrar filter transport mask*/
bool media_control; /**< Media Control over SIP */
};

/** Call config */
Expand Down Expand Up @@ -446,6 +450,11 @@ struct config_net {
bool use_getaddrinfo; /**< Use getaddrinfo for A/AAAA records */
};

/** BFCP **/
struct config_bfcp {
char proto[16]; /**< BFCP Transport */
char floorctrl[16]; /**< BFCP floor control role */
};

/** Core configuration */
struct config {
Expand All @@ -457,9 +466,12 @@ struct config {
struct config_audio audio;

struct config_video video;
struct config_video slides;

struct config_avt avt;

struct config_net net;
struct config_bfcp bfcp;
};

int config_parse_conf(struct config *cfg, const struct conf *conf);
Expand Down Expand Up @@ -857,6 +869,7 @@ enum ua_event {
UA_EVENT_CALL_DTMF_END,
UA_EVENT_CALL_RTPESTAB,
UA_EVENT_CALL_RTCP,
UA_EVENT_CALL_VIDEO_DISP,
UA_EVENT_CALL_MENC,
UA_EVENT_VU_TX,
UA_EVENT_VU_RX,
Expand Down Expand Up @@ -1143,6 +1156,7 @@ struct vidisp_st;
/** Video Display parameters */
struct vidisp_prm {
bool fullscreen; /**< Enable fullscreen display */
char content[64];
};

typedef void (vidisp_resize_h)(const struct vidsz *size, void *arg);
Expand Down Expand Up @@ -1448,6 +1462,7 @@ const char *video_get_disp_dev(const struct video *v);
int video_debug(struct re_printf *pf, const struct video *v);
struct stream *video_strm(const struct video *v);
const struct vidcodec *video_codec(const struct video *vid, bool tx);
void video_encode_refresh(struct video *v);
void video_sdp_attr_decode(struct video *v);
void video_req_keyframe(struct video *vid);

Expand Down Expand Up @@ -1514,6 +1529,7 @@ const char *stream_peer(const struct stream *strm);
int stream_bundle_init(struct stream *strm, bool offerer);
int stream_debug(struct re_printf *pf, const struct stream *s);
void stream_enable_rtp_timeout(struct stream *strm, uint32_t timeout_ms);
void print_rtp_stats(const struct stream *s);


/**
Expand Down
8 changes: 6 additions & 2 deletions modules/avcodec/sdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ int avcodec_h264_fmtp_enc(struct mbuf *mb, const struct sdp_format *fmt,
uint8_t profile_idc = 0x42; /* baseline profile */
uint8_t profile_iop = 0xe0;
uint8_t h264_level_idc = 0x1f;
char append[64] = "";
(void)offer;

if (!mb || !fmt || !vc)
return 0;

conf_get_str(conf_cur(), "avcodec_profile_level_id",
profile_level_id, sizeof(profile_level_id));
conf_get_str(conf_cur(), "video_fmtp_append",
append, sizeof(append));

if (str_isset(profile_level_id)) {
struct pl prof;
Expand All @@ -67,10 +70,11 @@ int avcodec_h264_fmtp_enc(struct mbuf *mb, const struct sdp_format *fmt,
out:
return mbuf_printf(mb, "a=fmtp:%s"
" %s"
";profile-level-id=%02x%02x%02x"
";profile-level-id=%02x%02x%02x%s"
"\r\n",
fmt->id, vc->variant,
profile_idc, profile_iop, h264_level_idc);
profile_idc, profile_iop, h264_level_idc,
append);
}


Expand Down
2 changes: 1 addition & 1 deletion modules/ice/ice.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ static int cand_gather_relayed(struct mnat_media *m, struct comp *comp,
err = turnc_alloc(&turnc, stun_conf(icem_stun(m->icem)),
IPPROTO_UDP, comp->sock, layer, &m->sess->srv,
username, password,
60, turnc_handler, comp);
60, NULL, turnc_handler, comp);
if (err)
return err;

Expand Down
15 changes: 8 additions & 7 deletions modules/menu/static_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ static int switch_video_source(struct re_printf *pf, void *arg)
{
const struct cmd_arg *carg = arg;
struct pl pl_driver, pl_device;
struct config_video *vidcfg;
struct config_video *vidcfg, *slidescfg;
struct config *cfg;
struct video *v;
const struct vidsrc *vs;
Expand Down Expand Up @@ -1376,10 +1376,8 @@ static int switch_video_source(struct re_printf *pf, void *arg)
return EINVAL;
}

vidcfg = &cfg->video;

str_ncpy(vidcfg->src_mod, driver, sizeof(vidcfg->src_mod));
str_ncpy(vidcfg->src_dev, device, sizeof(vidcfg->src_dev));
vidcfg= &cfg->video;
slidescfg = &cfg->slides;

for (leu = list_head(uag_list()); leu; leu = leu->next) {
struct ua *ua = leu->data;
Expand All @@ -1388,8 +1386,11 @@ static int switch_video_source(struct re_printf *pf, void *arg)
struct call *call = le->data;

v = call_video(call);

err = video_set_source(v, driver, device);
err = video_set_source(v, vidcfg->src_mod,
vidcfg->src_dev);
v = call_slides(call);
err |= video_set_source(v, slidescfg->src_mod,
slidescfg->src_dev);
if (err) {
(void)re_hprintf(pf,
"failed to set video-source"
Expand Down
6 changes: 5 additions & 1 deletion modules/srtp/srtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static const char aes_cm_128_hmac_sha1_80[] = "AES_CM_128_HMAC_SHA1_80";
static const char aes_128_gcm[] = "AEAD_AES_128_GCM";
static const char aes_256_gcm[] = "AEAD_AES_256_GCM";

static const char *preferred_suite = aes_cm_128_hmac_sha1_80;
static const char *default_suite = aes_cm_128_hmac_sha1_80;


static void destructor(void *arg)
Expand Down Expand Up @@ -487,6 +487,7 @@ static int media_alloc(struct menc_media **stp, struct menc_sess *sess,
int layer = 10; /* above zero */
int err = 0;
bool mux = (rtpsock == rtcpsock);
char preferred_suite[64] = "";
(void)sess;
(void)rtp;
(void)raddr_rtp;
Expand Down Expand Up @@ -537,6 +538,9 @@ static int media_alloc(struct menc_media **stp, struct menc_sess *sess,
goto out;

/* set our preferred crypto-suite */
str_ncpy(preferred_suite, default_suite, sizeof(default_suite));
conf_get_str(conf_cur(), "preferred_crypto_suite",
preferred_suite, sizeof(preferred_suite));
err |= str_dup(&st->crypto_suite, preferred_suite);
if (err)
goto out;
Expand Down
24 changes: 18 additions & 6 deletions modules/turn/turn.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct mnat_media {
struct tls_conn *tlsc;
struct mbuf *mb;
unsigned ix;
uint64_t token;
} compv[COMPC];
};

Expand Down Expand Up @@ -196,16 +197,27 @@ static void turn_handler(int err, uint16_t scode, const char *reason,
void *arg)
{
struct comp *comp = arg;
uint64_t token;
struct mnat_media *m = comp->m;
(void)mapped_addr;
(void)msg;

if (!err && !scode) {

const struct comp *other = &m->compv[comp->ix ^ 1];
struct comp *other = &m->compv[comp->ix ^ 1];

if (comp->ix == 0)
sdp_media_set_laddr(m->sdpm, relay_addr);
struct stun_attr *token_attr = stun_msg_attr(msg, STUN_ATTR_RSV_TOKEN);
if (token_attr)
token = token_attr->v.uint64;

if (comp->ix == 0) {
sdp_media_set_laddr(m->sdpm, relay_addr);
err = turnc_alloc(&other->turnc, NULL,
IPPROTO_UDP, other->sock, LAYER,
&m->sess->srv, m->sess->user, m->sess->pass,
TURN_DEFAULT_LIFETIME, &token,
turn_handler, other);
}
else
sdp_media_set_laddr_rtcp(m->sdpm, relay_addr);

Expand Down Expand Up @@ -238,7 +250,7 @@ static void tcp_estab_handler(void *arg)
err = turnc_alloc(&comp->turnc, NULL, IPPROTO_TCP, comp->tc, 0,
&m->sess->srv,
m->sess->user, m->sess->pass,
TURN_DEFAULT_LIFETIME, turn_handler, comp);
TURN_DEFAULT_LIFETIME, NULL, turn_handler, comp);
if (err) {
m->sess->estabh(err, 0, NULL, m->sess->arg);
}
Expand All @@ -259,7 +271,7 @@ static int media_start(struct mnat_sess *sess, struct mnat_media *m)
unsigned i;
int err = 0;

for (i=0; i<COMPC; i++) {
for (i=0; i<1; i++) {

struct comp *comp = &m->compv[i];

Expand All @@ -272,7 +284,7 @@ static int media_start(struct mnat_sess *sess, struct mnat_media *m)
err |= turnc_alloc(&comp->turnc, NULL,
IPPROTO_UDP, comp->sock, LAYER,
&sess->srv, sess->user, sess->pass,
TURN_DEFAULT_LIFETIME,
TURN_DEFAULT_LIFETIME, NULL,
turn_handler, comp);
break;

Expand Down
61 changes: 52 additions & 9 deletions modules/x11/x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ struct vidisp_st {
Atom XwinDeleted;
int button_is_down;
Time last_time;
char display[64];
struct geometry {
struct resolution {
int w;
int h;
} res;
struct position {
int x;
int y;
} pos;
} geom;
};


Expand Down Expand Up @@ -118,7 +129,8 @@ static int create_window(struct vidisp_st *st, const struct vidsz *sz)
XSetWindowAttributes attr;
#endif
st->win = XCreateSimpleWindow(st->disp, DefaultRootWindow(st->disp),
0, 0, sz->w, sz->h, 1, 0, 0);
st->geom.pos.x, st->geom.pos.y,
sz->w, sz->h, 0, 0, 0);
if (!st->win) {
warning("x11: failed to create X window\n");
return ENOMEM;
Expand Down Expand Up @@ -272,6 +284,9 @@ static int alloc(struct vidisp_st **stp, const struct vidisp *vd,
{
struct vidisp_st *st;
int err = 0;
char cfg_content[32] = "x11_";
char cfg_geometry[64];
struct pl x, y, w, h;
(void)vd;
(void)prm;
(void)dev;
Expand All @@ -284,7 +299,31 @@ static int alloc(struct vidisp_st **stp, const struct vidisp *vd,

st->shm.shmaddr = (char *)-1;

st->disp = XOpenDisplay(NULL);
str_ncpy(st->display, "", str_len(""));
st->geom.res.w = st->geom.res.h = 0;
st->geom.pos.x = st->geom.pos.y = 0;
str_ncpy(cfg_content + str_len(cfg_content),
prm->content, str_len(prm->content)+1);
/* Example of expected lines in configuration file:
x11_main :0,1280x720+0+0
x11_slides :0,1280x720+1280+0 */
err = conf_get_csv(conf_cur(), cfg_content,
st->display, sizeof(st->display),
cfg_geometry, sizeof(cfg_geometry));

err = err | re_regex(cfg_geometry,
str_len(cfg_geometry),
"[0-9]*x[0-9]*\+[0-9]*\+[0-9]*",
&w, &h, &x, &y );
if (!err) {
st->geom.res.w = pl_u32(&w);
st->geom.res.h = pl_u32(&h);
st->geom.pos.x = pl_u32(&x);
st->geom.pos.y = pl_u32(&y);
}
err = 0;
st->disp = XOpenDisplay(str_len(st->display)==0?
NULL:st->display);
if (!st->disp) {
warning("x11: could not open X display\n");
err = ENODEV;
Expand All @@ -307,12 +346,16 @@ static int display(struct vidisp_st *st, const char *title,
const struct vidframe *frame, uint64_t timestamp)
{
struct vidframe frame_rgb;
struct vidsz frame_size;
int err = 0;
(void)timestamp;

if (!st->disp)
return ENODEV;

frame_size.w = st->geom.res.w?st->geom.res.w:frame->size.w;
frame_size.h = st->geom.res.h?st->geom.res.h:frame->size.h;

/*
* check for window delete - without blocking
* the switch handles both the override redirect window
Expand Down Expand Up @@ -365,37 +408,37 @@ static int display(struct vidisp_st *st, const char *title,
}
}

if (!vidsz_cmp(&st->size, &frame->size)) {
if (!vidsz_cmp(&st->size, &frame_size)) {
char capt[256];

if (st->size.w && st->size.h) {
info("x11: reset: %u x %u ---> %u x %u\n",
st->size.w, st->size.h,
frame->size.w, frame->size.h);
frame_size.w, frame_size.h);
}

if (st->internal && !st->win)
err = create_window(st, &frame->size);
err = create_window(st, &frame_size);

err |= x11_reset(st, &frame->size);
err |= x11_reset(st, &frame_size);
if (err)
return err;

if (title) {
re_snprintf(capt, sizeof(capt), "%s - %u x %u",
title, frame->size.w, frame->size.h);
title, frame_size.w, frame_size.h);
}
else {
re_snprintf(capt, sizeof(capt), "%u x %u",
frame->size.w, frame->size.h);
frame_size.w, frame_size.h);
}

XStoreName(st->disp, st->win, capt);
}

/* Convert from YUV420P to RGB */

vidframe_init_buf(&frame_rgb, st->pixfmt, &frame->size,
vidframe_init_buf(&frame_rgb, st->pixfmt, &frame_size,
(uint8_t *)st->shm.shmaddr);

vidconv(&frame_rgb, frame, 0);
Expand Down
Loading

0 comments on commit 8b0de44

Please sign in to comment.