static int module_init(void) { struct list *vidcodecl = baresip_vidcodecl(); char h264enc[64]; char h264dec[64]; #ifdef USE_X264 debug("avcodec: x264 build %d\n", X264_BUILD); #else debug("avcodec: using libavcodec H.264 encoder\n"); #endif #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 10, 0) avcodec_init(); #endif #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100) avcodec_register_all(); #endif if (0 == conf_get_str(conf_cur(), "avcodec_h264dec", h264dec, sizeof(h264dec))) { info("avcodec: using h264 decoder by name (%s)\n", h264dec); avcodec_h264dec = avcodec_find_decoder_by_name(h264dec); if (!avcodec_h264dec) { warning("avcodec: h264 decoder not found (%s)\n", h264dec); return ENOENT; } vidcodec_register(vidcodecl, &h264); } else { if (avcodec_find_decoder(AV_CODEC_ID_H264)) vidcodec_register(vidcodecl, &h264); } if (avcodec_find_decoder(AV_CODEC_ID_H263)) vidcodec_register(vidcodecl, &h263); if (avcodec_find_decoder(AV_CODEC_ID_MPEG4)) vidcodec_register(vidcodecl, &mpg4); if (0 == conf_get_str(conf_cur(), "avcodec_h264enc", h264enc, sizeof(h264enc))) { info("avcodec: using h264 encoder by name (%s)\n", h264enc); avcodec_h264enc = avcodec_find_encoder_by_name(h264enc); if (!avcodec_h264enc) { warning("avcodec: h264 encoder not found (%s)\n", h264enc); return ENOENT; } } return 0; }
static int module_init(void) { int err = 0; #ifdef MODULE_CONF struct pl pl; if (!conf_get(conf_cur(), "opus_application", &pl)) { if (!pl_strcasecmp(&pl, "voip")) opus.app = OPUS_APPLICATION_VOIP; else if (!pl_strcasecmp(&pl, "audio")) opus.app = OPUS_APPLICATION_AUDIO; else { DEBUG_WARNING("unknown application: %r\n", &pl); } } if (!conf_get(conf_cur(), "opus_bandwidth", &pl)) { if (!pl_strcasecmp(&pl, "narrowband")) opus.bandwidth = OPUS_BANDWIDTH_NARROWBAND; else if (!pl_strcasecmp(&pl, "mediumband")) opus.bandwidth = OPUS_BANDWIDTH_MEDIUMBAND; else if (!pl_strcasecmp(&pl, "wideband")) opus.bandwidth = OPUS_BANDWIDTH_WIDEBAND; else if (!pl_strcasecmp(&pl, "superwideband")) opus.bandwidth = OPUS_BANDWIDTH_SUPERWIDEBAND; else if (!pl_strcasecmp(&pl, "fullband")) opus.bandwidth = OPUS_BANDWIDTH_FULLBAND; else { DEBUG_WARNING("unknown bandwidth: %r\n", &pl); } } conf_get_u32(conf_cur(), "opus_complexity", &opus.complex); conf_get_u32(conf_cur(), "opus_bitrate", &opus.bitrate); conf_get_bool(conf_cur(), "opus_vbr", &opus.vbr); #endif err |= aucodec_register(&codecv[0], NULL, "opus", 48000, 2, NULL, alloc, encode, decode, NULL); err |= aucodec_register(&codecv[1], NULL, "opus", 48000, 1, NULL, alloc, encode, decode, NULL); #if 0 err |= aucodec_register(&codecv[2], NULL, "opus", 32000, 1, NULL, alloc, encode, decode, NULL); #endif return err; }
static int module_init(void) { struct pl pl = PL("pip"); (void)conf_get(conf_cur(), "video_selfview", &pl); if (0 == pl_strcasecmp(&pl, "window")) vidfilt_register(&selfview_win); else if (0 == pl_strcasecmp(&pl, "pip")) vidfilt_register(&selfview_pip); (void)conf_get_vidsz(conf_cur(), "selfview_size", &selfview_size); return 0; }
static int module_init(void) { struct pl pl; int err; if (0 == conf_get(conf_cur(), "pcp_server", &pl)) { err = sa_decode(&pcp_srv, pl.p, pl.l); if (err) return err; } else { err = net_default_gateway_get(net_af(baresip_network()), &pcp_srv); if (err) return err; sa_set_port(&pcp_srv, PCP_PORT_SRV); } info("pcp: using PCP server at %J\n", &pcp_srv); #if 1 /* todo: if multiple applications are listening on port 5350 then this will not work */ err = pcp_listen(&lsnr, &pcp_srv, pcp_msg_handler, 0); if (err) { info("pcp: could not enable listener: %m\n", err); err = 0; } #endif return mnat_register(&mnat, "pcp", NULL, session_alloc, media_alloc, NULL); }
static int module_init(void) { struct conf *conf = conf_cur(); uint32_t value; char *p = fmtp + str_len(fmtp); bool b; int n = 0; if (0 == conf_get_u32(conf, "opus_bitrate", &value)) { n = re_snprintf(p, sizeof(fmtp) - str_len(p), ";maxaveragebitrate=%d", value); if (n <= 0) return ENOMEM; p += n; } if (0 == conf_get_bool(conf, "opus_cbr", &b)) { n = re_snprintf(p, sizeof(fmtp) - str_len(p), ";cbr=%d", b); if (n <= 0) return ENOMEM; p += n; } if (0 == conf_get_bool(conf, "opus_inbandfec", &b)) { n = re_snprintf(p, sizeof(fmtp) - str_len(p), ";useinbandfec=%d", b); if (n <= 0) return ENOMEM; p += n; } if (0 == conf_get_bool(conf, "opus_dtx", &b)) { n = re_snprintf(p, sizeof(fmtp) - str_len(p), ";usedtx=%d", b); if (n <= 0) return ENOMEM; p += n; } (void)conf_get_bool(conf, "opus_mirror", &opus_mirror); debug("opus: fmtp=\"%s\"\n", fmtp); aucodec_register(&opus); return 0; }
static int module_init(void) { aufilt_register(baresip_aufiltl(), &sndfile); conf_get_str(conf_cur(), "snd_path", file_path, sizeof(file_path)); info("sndfile: saving files in %s\n", file_path); return 0; }
static int module_init(void) { struct pl pl; if (conf_get(conf_cur(), "video_selfview", &pl)) return 0; if (0 == pl_strcasecmp(&pl, "window")) vidfilt_register(&selfview_win); else if (0 == pl_strcasecmp(&pl, "pip")) vidfilt_register(&selfview_pip); return 0; }
static int speex_init(void) { size_t i; config_parse(conf_cur()); (void)re_snprintf(speex_fmtp, sizeof(speex_fmtp), "mode=\"7\";vbr=%s;cng=on", sconf.vad ? "vad" : (sconf.vbr ? "on" : "off")); for (i=0; i<ARRAY_SIZE(speexv); i++) aucodec_register(&speexv[i]); return 0; }
static int cons_init(void) { struct sa laddr; int err; if (conf_get_sa(conf_cur(), "cons_listen", &laddr)) { sa_set_str(&laddr, "0.0.0.0", CONS_PORT); } err = cons_alloc(&cons, &laddr); if (err) return err; ui_register(&ui_cons); return 0; }
static int module_init(void) { struct conf *conf = conf_cur(); uint32_t value; static char fmtp[128]; if (0 == conf_get_u32(conf, "opus_bitrate", &value)) { (void)re_snprintf(fmtp, sizeof(fmtp), "stereo=1;sprop-stereo=1;maxaveragebitrate=%d", value); opus.fmtp = fmtp; } aucodec_register(&opus); return 0; }
static int module_init(void) { struct sa laddr; int err; if (conf_get_sa(conf_cur(), "http_listen", &laddr)) { sa_set_str(&laddr, "0.0.0.0", 8000); } err = http_listen(&httpsock, &laddr, http_req_handler, NULL); if (err) return err; ui_register(&ui_http); info("httpd: listening on %J\n", &laddr); return 0; }
/** * Load a module by name or by filename * * @param name Module name incl/excl extension, excluding module path * * @return 0 if success, otherwise errorcode * * example: "foo" * example: "foo.so" */ int module_load(const char *name) { char filename[256]; struct pl path, pl_name; int err; if (!str_isset(name)) return EINVAL; append_extension(filename, sizeof(filename), name); pl_set_str(&pl_name, filename); if (conf_get(conf_cur(), "module_path", &path)) pl_set_str(&path, "."); err = load_module(NULL, &path, &pl_name); return err; }
static int module_init(void) { int err; sa_init(&natpmp_srv, AF_INET); sa_set_port(&natpmp_srv, NATPMP_PORT); net_rt_list(net_rt_handler, NULL); conf_get_sa(conf_cur(), "natpmp_server", &natpmp_srv); info("natpmp: using NAT-PMP server at %J\n", &natpmp_srv); err = natpmp_external_request(&natpmp_ext, &natpmp_srv, extaddr_handler, NULL); if (err) return err; return mnat_register(&mnat, "natpmp", NULL, session_alloc, media_alloc, NULL); }
static int module_init(void) { config_parse(conf_cur()); aufilt_register(&preproc); return 0; }
static int module_init(void) { struct conf *conf = conf_cur(); uint32_t value; char *p = fmtp + str_len(fmtp); bool b, stereo = true, sprop_stereo = true; struct pl pl; int n = 0; conf_get_bool(conf, "opus_stereo", &stereo); conf_get_bool(conf, "opus_sprop_stereo", &sprop_stereo); /* always set stereo parameter first */ n = re_snprintf(p, sizeof(fmtp) - str_len(p), "stereo=%d;sprop-stereo=%d", stereo, sprop_stereo); if (n <= 0) return ENOMEM; p += n; if (0 == conf_get_u32(conf, "opus_bitrate", &value)) { n = re_snprintf(p, sizeof(fmtp) - str_len(p), ";maxaveragebitrate=%d", value); if (n <= 0) return ENOMEM; p += n; } if (0 == conf_get_bool(conf, "opus_cbr", &b)) { n = re_snprintf(p, sizeof(fmtp) - str_len(p), ";cbr=%d", b); if (n <= 0) return ENOMEM; p += n; } if (0 == conf_get_bool(conf, "opus_inbandfec", &b)) { n = re_snprintf(p, sizeof(fmtp) - str_len(p), ";useinbandfec=%d", b); if (n <= 0) return ENOMEM; p += n; } if (0 == conf_get_bool(conf, "opus_dtx", &b)) { n = re_snprintf(p, sizeof(fmtp) - str_len(p), ";usedtx=%d", b); if (n <= 0) return ENOMEM; p += n; } (void)conf_get_bool(conf, "opus_mirror", &opus_mirror); if (opus_mirror) { opus.fmtp = NULL; opus.fmtp_ench = opus_fmtp_enc; } (void)conf_get_u32(conf, "opus_complexity", &opus_complexity); if (opus_complexity > 10) opus_complexity = 10; if (!conf_get(conf, "opus_application", &pl)) { if (!pl_strcasecmp(&pl, "audio")) opus_application = OPUS_APPLICATION_AUDIO; else if (!pl_strcasecmp(&pl, "voip")) opus_application = OPUS_APPLICATION_VOIP; else { warning("opus: unknown encoder application: %r\n", &pl); return EINVAL; } } debug("opus: fmtp=\"%s\"\n", fmtp); aucodec_register(baresip_aucodecl(), &opus); return 0; }
static int module_init(void) { zrtp_status_t s; char config_path[256] = ""; char zrtp_zid_path[256] = ""; FILE *f; int ret, err; (void)conf_get_bool(conf_cur(), "zrtp_hash", &use_sig_hash); zrtp_log_set_log_engine(zrtp_log); zrtp_config_defaults(&zrtp_config); str_ncpy(zrtp_config.client_id, "baresip/zrtp", sizeof(zrtp_config.client_id)); zrtp_config.lic_mode = ZRTP_LICENSE_MODE_UNLIMITED; zrtp_config.cb.misc_cb.on_send_packet = on_send_packet; zrtp_config.cb.event_cb.on_zrtp_secure = on_zrtp_secure; zrtp_config.cb.event_cb.on_zrtp_security_event = on_zrtp_security_event; err = conf_path_get(config_path, sizeof(config_path)); if (err) { warning("zrtp: could not get config path: %m\n", err); return err; } ret = re_snprintf(zrtp_config.def_cache_path.buffer, zrtp_config.def_cache_path.max_length, "%s/zrtp_cache.dat", config_path); if (ret < 0) { warning("zrtp: could not write cache path\n"); return ENOMEM; } zrtp_config.def_cache_path.length = ret; if (re_snprintf(zrtp_zid_path, sizeof(zrtp_zid_path), "%s/zrtp_zid", config_path) < 0) return ENOMEM; if ((f = fopen(zrtp_zid_path, "rb")) != NULL) { if (fread(zid, sizeof(zid), 1, f) != 1) { if (feof(f) || ferror(f)) { warning("zrtp: invalid zrtp_zid file\n"); } } } else if ((f = fopen(zrtp_zid_path, "wb")) != NULL) { rand_bytes(zid, sizeof(zid)); if (fwrite(zid, sizeof(zid), 1, f) != 1) { warning("zrtp: zrtp_zid file write failed\n"); } info("zrtp: generated new persistent ZID (%s)\n", zrtp_zid_path); } else { err = errno; warning("zrtp: fopen() %s (%m)\n", zrtp_zid_path, err); } if (f) (void) fclose(f); s = zrtp_init(&zrtp_config, &zrtp_global); if (zrtp_status_ok != s) { warning("zrtp: zrtp_init() failed (status = %d)\n", s); return ENOSYS; } menc_register(baresip_mencl(), &menc_zrtp); debug("zrtp: cache_file: %s\n", zrtp_config.def_cache_path.buffer); debug(" zid_file: %s\n", zrtp_zid_path); debug(" zid: %w\n", zid, sizeof(zid)); return cmd_register(baresip_commands(), cmdv, ARRAY_SIZE(cmdv)); }
static int module_init(void) { conf_get_str(conf_cur(), "auloop_codec", aucodec, sizeof(aucodec)); return cmd_register(cmdv, ARRAY_SIZE(cmdv)); }
static int module_init(void) { struct conf *conf = conf_cur(); uint32_t value; char *p = fmtp + str_len(fmtp); bool b, stereo = true, sprop_stereo = true; int n = 0; conf_get_bool(conf, "opus_stereo", &stereo); conf_get_bool(conf, "opus_sprop_stereo", &sprop_stereo); /* always set stereo parameter first */ n = re_snprintf(p, sizeof(fmtp) - str_len(p), "stereo=%d;sprop-stereo=%d", stereo, sprop_stereo); if (n <= 0) return ENOMEM; p += n; if (0 == conf_get_u32(conf, "opus_bitrate", &value)) { n = re_snprintf(p, sizeof(fmtp) - str_len(p), ";maxaveragebitrate=%d", value); if (n <= 0) return ENOMEM; p += n; } if (0 == conf_get_bool(conf, "opus_cbr", &b)) { n = re_snprintf(p, sizeof(fmtp) - str_len(p), ";cbr=%d", b); if (n <= 0) return ENOMEM; p += n; } if (0 == conf_get_bool(conf, "opus_inbandfec", &b)) { n = re_snprintf(p, sizeof(fmtp) - str_len(p), ";useinbandfec=%d", b); if (n <= 0) return ENOMEM; p += n; } if (0 == conf_get_bool(conf, "opus_dtx", &b)) { n = re_snprintf(p, sizeof(fmtp) - str_len(p), ";usedtx=%d", b); if (n <= 0) return ENOMEM; p += n; } (void)conf_get_bool(conf, "opus_mirror", &opus_mirror); if (opus_mirror) { opus.fmtp = NULL; opus.fmtp_ench = opus_fmtp_enc; } debug("opus: fmtp=\"%s\"\n", fmtp); aucodec_register(baresip_aucodecl(), &opus); return 0; }