Fix uqmi and up version of baresip (#793)

pull/794/head
Igor Zalatov 2023-05-13 18:41:25 +03:00 committed by GitHub
parent 03e5708074
commit 5496b82e9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 1409 additions and 63 deletions

View File

@ -0,0 +1,884 @@
diff -ruN a/modules/h264passcodec/avcodec.c b/modules/h264passcodec/avcodec.c
--- a/modules/h264passcodec/avcodec.c 1970-01-01 03:00:00.000000000 +0300
+++ b/modules/h264passcodec/avcodec.c 2023-01-30 12:10:57.054035500 +0300
@@ -0,0 +1,119 @@
+/**
+ * @file avcodec.c Video codecs using libavcodec
+ *
+ * Copyright (C) 2010 - 2016 Alfred E. Heggestad
+ */
+#include <re.h>
+#include <rem.h>
+#include <baresip.h>
+#include "h26x.h"
+#include "avcodec.h"
+#include "defines.h"
+
+/**
+ * @defgroup avcodec avcodec
+ *
+ * Video codecs using libavcodec
+ *
+ * This module implements H.263, H.264 and H.265 video codecs
+ * using libavcodec from FFmpeg or libav projects.
+ *
+ *
+ * Config options:
+ *
+ \verbatim
+ avcodec_h264enc <NAME> ; e.g. h264_nvenc, h264_videotoolbox
+ avcodec_h264dec <NAME> ; e.g. h264_cuvid, h264_vda, h264_qsv
+ \endverbatim
+ *
+ * References:
+ *
+ * http://ffmpeg.org
+ *
+ * https://libav.org
+ *
+ * RTP Payload Format for H.264 Video
+ * https://tools.ietf.org/html/rfc6184
+ */
+
+
+//const AVCodec *avcodec_h264enc; /* optional; specified H.264 encoder */
+//const AVCodec *avcodec_h264dec; /* optional; specified H.264 decoder */
+
+
+
+int avcodec_resolve_codecid(const char *s)
+{
+ if (0 == str_casecmp(s, "H264"))
+ return AV_CODEC_ID_H264;
+ else
+ return AV_CODEC_ID_NONE;
+}
+
+
+static struct vidcodec h264 = {
+ .name = "H264",
+ .variant = "packetization-mode=0",
+ .encupdh = avcodec_encode_update,
+ .ench = avcodec_encode,
+ .decupdh = NULL,
+ .dech = NULL,
+ .fmtp_ench = avcodec_h264_fmtp_enc,
+ .fmtp_cmph = avcodec_h264_fmtp_cmp,
+ .packetizeh= avcodec_packetize,
+};
+
+static struct vidcodec h264_1 = {
+ .name = "H264",
+ .variant = "packetization-mode=1",
+ .encupdh = avcodec_encode_update,
+ .ench = avcodec_encode,
+ .decupdh = NULL,
+ .dech = NULL,
+ .fmtp_ench = avcodec_h264_fmtp_enc,
+ .fmtp_cmph = avcodec_h264_fmtp_cmp,
+ .packetizeh= avcodec_packetize,
+};
+
+static int module_init(void)
+{
+ struct list *vidcodecl = baresip_vidcodecl();
+ char h264enc[64] = "h264";
+ char h264dec[64] = "h264";
+
+ conf_get_str(conf_cur(), "avcodec_h264enc", h264enc, sizeof(h264enc));
+ conf_get_str(conf_cur(), "avcodec_h264dec", h264dec, sizeof(h264dec));
+
+ printf(">>>>>>>>>init h264passcodec\n");
+ //register
+ vidcodec_register(vidcodecl, &h264);
+ vidcodec_register(vidcodecl, &h264_1);
+
+/*
+ if (avcodec_h264enc) {
+ info("avcodec: using H.264 encoder '%s' -- %s\n",
+ avcodec_h264enc->name, avcodec_h264enc->long_name);
+ }
+ if (avcodec_h264dec) {
+ info("avcodec: using H.264 decoder '%s' -- %s\n",
+ avcodec_h264dec->name, avcodec_h264dec->long_name);
+ }
+*/
+ return 0;
+}
+
+
+static int module_close(void)
+{
+ vidcodec_unregister(&h264);
+
+ return 0;
+}
+
+
+EXPORT_SYM const struct mod_export DECL_EXPORTS(h264passcodec) = {
+ "h264passcodec",
+ "codec",
+ module_init,
+ module_close
+};
diff -ruN a/modules/h264passcodec/avcodec.h b/modules/h264passcodec/avcodec.h
--- a/modules/h264passcodec/avcodec.h 1970-01-01 03:00:00.000000000 +0300
+++ b/modules/h264passcodec/avcodec.h 2023-01-27 21:19:26.141734000 +0300
@@ -0,0 +1,43 @@
+/**
+ * @file avcodec.h Video codecs using libavcodec -- internal API
+ *
+ * Copyright (C) 2010 Alfred E. Heggestad
+ */
+
+
+/*
+ * Encode
+ */
+
+struct videnc_state;
+
+int avcodec_encode_update(struct videnc_state **vesp,
+ const struct vidcodec *vc,
+ struct videnc_param *prm, const char *fmtp,
+ videnc_packet_h *pkth, void *arg);
+int avcodec_encode(struct videnc_state *st, bool update,
+ const struct vidframe *frame, uint64_t timestamp);
+int avcodec_packetize(struct videnc_state *st, const struct vidpacket *packet);
+
+
+int avcodec_decode_update(struct viddec_state **vdsp,
+ const struct vidcodec *vc, const char *fmtp);
+int avcodec_decode_h263(struct viddec_state *st, struct vidframe *frame,
+ bool *intra, bool eof, uint16_t seq, struct mbuf *src);
+int avcodec_decode_h264(struct viddec_state *st, struct vidframe *frame,
+ bool *intra, bool eof, uint16_t seq, struct mbuf *src);
+int avcodec_decode_h265(struct viddec_state *st, struct vidframe *frame,
+ bool *intra, bool eof, uint16_t seq, struct mbuf *src);
+
+
+int avcodec_resolve_codecid(const char *s);
+
+
+/*
+ * SDP
+ */
+
+uint32_t h264_packetization_mode(const char *fmtp);
+int avcodec_h264_fmtp_enc(struct mbuf *mb, const struct sdp_format *fmt,
+ bool offer, void *arg);
+bool avcodec_h264_fmtp_cmp(const char *lfmtp, const char *rfmtp, void *data);
diff -ruN a/modules/h264passcodec/defines.h b/modules/h264passcodec/defines.h
--- a/modules/h264passcodec/defines.h 1970-01-01 03:00:00.000000000 +0300
+++ b/modules/h264passcodec/defines.h 2023-01-28 20:25:39.609698100 +0300
@@ -0,0 +1,14 @@
+#ifndef __DEFINES_H
+#define __DEFINES_H
+
+//some defines from ffmpeg
+
+
+//only used items have declared
+enum AVCodecID {
+ AV_CODEC_ID_NONE,
+ AV_CODEC_ID_H264
+};
+
+
+#endif
diff -ruN a/modules/h264passcodec/encode.c b/modules/h264passcodec/encode.c
--- a/modules/h264passcodec/encode.c 1970-01-01 03:00:00.000000000 +0300
+++ b/modules/h264passcodec/encode.c 2023-01-30 12:10:13.244035500 +0300
@@ -0,0 +1,318 @@
+/**
+ * @file avcodec/encode.c Video codecs using libavcodec -- encoder
+ *
+ * Copyright (C) 2010 - 2013 Alfred E. Heggestad
+ * Copyright (C) 2021 by:
+ * Media Magic Technologies <developer@mediamagictechnologies.com>
+ * and Divus GmbH <developer@divus.eu>
+ */
+#include <re.h>
+#include <rem.h>
+#include <baresip.h>
+#include "h26x.h"
+#include "avcodec.h"
+#include "defines.h"
+
+
+enum {
+ KEYFRAME_INTERVAL = 10 /* Keyframes per second */
+};
+
+
+struct picsz {
+ enum h263_fmt fmt; /**< Picture size */
+ uint8_t mpi; /**< Minimum Picture Interval (1-32) */
+};
+
+
+struct videnc_state {
+// const AVCodec *codec;
+// AVCodecContext *ctx;
+ struct mbuf *mb_frag;
+ struct videnc_param encprm;
+ struct vidsz encsize;
+ enum vidfmt fmt;
+ enum AVCodecID codec_id;
+ videnc_packet_h *pkth;
+ void *arg;
+
+ union {
+ struct {
+ struct picsz picszv[8];
+ uint32_t picszn;
+ } h263;
+
+ struct {
+ uint32_t packetization_mode;
+ uint32_t profile_idc;
+ uint32_t profile_iop;
+ uint32_t level_idc;
+ uint32_t max_fs;
+ uint32_t max_smbps;
+ } h264;
+ } u;
+};
+
+
+static void destructor(void *arg)
+{
+ struct videnc_state *st = arg;
+
+ mem_deref(st->mb_frag);
+
+// if (st->ctx)
+// avcodec_free_context(&st->ctx);
+}
+
+
+static int init_encoder(struct videnc_state *st, const char *name)
+{
+ /*
+ * Special handling of H.264 encoder
+ */
+
+ printf(">>>>>init encoder\n");
+/*
+ if (st->codec_id == AV_CODEC_ID_H264 && avcodec_h264enc) {
+
+ st->codec = avcodec_h264enc;
+
+ info("avcodec: h264 encoder activated\n");
+
+ return 0;
+ }
+
+ st->codec = avcodec_find_encoder(st->codec_id);
+ if (!st->codec)
+ return ENOENT;
+*/
+ return 0;
+}
+
+
+static int open_encoder(struct videnc_state *st,
+ const struct videnc_param *prm,
+ const struct vidsz *size,
+ int pix_fmt)
+{
+ int err = 0;
+
+ printf(">>>>>open encoder\n");
+// if (st->ctx)
+// avcodec_free_context(&st->ctx);
+
+// st->ctx = avcodec_alloc_context3(st->codec);
+// if (!st->ctx) {
+// err = ENOMEM;
+// goto out;
+// }
+
+// av_opt_set_defaults(st->ctx);
+
+/* st->ctx->bit_rate = prm->bitrate;
+ st->ctx->width = size->w;
+ st->ctx->height = size->h;
+
+ st->ctx->pix_fmt = pix_fmt;
+
+ st->ctx->time_base.num = 1;
+ st->ctx->time_base.den = prm->fps;
+ st->ctx->gop_size = KEYFRAME_INTERVAL * prm->fps;
+
+ if (0 == str_cmp(st->codec->name, "h264")) {
+
+ av_opt_set(st->ctx->priv_data, "profile", "baseline", 0);
+ av_opt_set(st->ctx->priv_data, "preset", "ultrafast", 0);
+ av_opt_set(st->ctx->priv_data, "tune", "zerolatency", 0);
+
+ if (st->u.h264.packetization_mode == 0) {
+ av_opt_set_int(st->ctx->priv_data,
+ "slice-max-size", prm->pktsize, 0);
+ }
+ }
+*/
+
+ /* params to avoid libavcodec/x264 default preset error */
+/* if (st->codec_id == AV_CODEC_ID_H264) {
+
+ av_opt_set(st->ctx->priv_data, "profile", "baseline", 0);
+ }
+
+ st->ctx->me_range = 16;
+ st->ctx->qmin = 10;
+ st->ctx->qmax = 51;
+ st->ctx->max_qdiff = 4;
+
+ if (avcodec_open2(st->ctx, st->codec, NULL) < 0) {
+ err = ENOENT;
+ goto out;
+ }
+*/
+ st->encsize = *size;
+
+ out:
+ if (err) {
+/*
+ if (st->ctx)
+ avcodec_free_context(&st->ctx);
+*/
+ }
+
+ return err;
+}
+
+
+static int decode_sdpparam_h264(struct videnc_state *st, const struct pl *name,
+ const struct pl *val)
+{
+ if (0 == pl_strcasecmp(name, "packetization-mode")) {
+ st->u.h264.packetization_mode = pl_u32(val);
+
+ if (st->u.h264.packetization_mode != 0 &&
+ st->u.h264.packetization_mode != 1 ) {
+ warning("avcodec: illegal packetization-mode %u\n",
+ st->u.h264.packetization_mode);
+ return EPROTO;
+ }
+ }
+ else if (0 == pl_strcasecmp(name, "profile-level-id")) {
+ struct pl prof = *val;
+ if (prof.l != 6) {
+ warning("avcodec: invalid profile-level-id (%r)\n",
+ val);
+ return EPROTO;
+ }
+
+ prof.l = 2;
+ st->u.h264.profile_idc = pl_x32(&prof); prof.p += 2;
+ st->u.h264.profile_iop = pl_x32(&prof); prof.p += 2;
+ st->u.h264.level_idc = pl_x32(&prof);
+ }
+ else if (0 == pl_strcasecmp(name, "max-fs")) {
+ st->u.h264.max_fs = pl_u32(val);
+ }
+ else if (0 == pl_strcasecmp(name, "max-smbps")) {
+ st->u.h264.max_smbps = pl_u32(val);
+ }
+
+ return 0;
+}
+
+static void param_handler(const struct pl *name, const struct pl *val,
+ void *arg)
+{
+ struct videnc_state *st = arg;
+
+ if (st->codec_id == AV_CODEC_ID_H264)
+ (void)decode_sdpparam_h264(st, name, val);
+}
+
+int avcodec_encode_update(struct videnc_state **vesp,
+ const struct vidcodec *vc,
+ struct videnc_param *prm, const char *fmtp,
+ videnc_packet_h *pkth, void *arg)
+{
+ struct videnc_state *st;
+ int err = 0;
+
+ if (!vesp || !vc || !prm || !pkth)
+ return EINVAL;
+
+ if (*vesp)
+ return 0;
+
+ st = mem_zalloc(sizeof(*st), destructor);
+ if (!st)
+ return ENOMEM;
+
+ st->encprm = *prm;
+ st->pkth = pkth;
+ st->arg = arg;
+
+ st->codec_id = avcodec_resolve_codecid(vc->name);
+ if (st->codec_id == AV_CODEC_ID_NONE) {
+ warning("avcodec: unknown encoder (%s)\n", vc->name);
+ err = EINVAL;
+ goto out;
+ }
+
+ st->mb_frag = mbuf_alloc(1024);
+ if (!st->mb_frag) {
+ err = ENOMEM;
+ goto out;
+ }
+
+ st->fmt = -1;
+
+ err = init_encoder(st, vc->name);
+ if (err) {
+ warning("avcodec: %s: could not init encoder\n", vc->name);
+ goto out;
+ }
+
+ if (str_isset(fmtp)) {
+ struct pl sdp_fmtp;
+
+ pl_set_str(&sdp_fmtp, fmtp);
+
+ fmt_param_apply(&sdp_fmtp, param_handler, st);
+ }
+
+ debug("avcodec: video encoder %s: %.2f fps, %d bit/s, pktsize=%u\n",
+ vc->name, prm->fps, prm->bitrate, prm->pktsize);
+
+ out:
+ if (err)
+ mem_deref(st);
+ else
+ *vesp = st;
+
+ return err;
+}
+
+int avcodec_encode(struct videnc_state *st, bool update,
+ const struct vidframe *frame, uint64_t timestamp)
+{
+ printf("avcodec_encode\n");
+ return 0;
+}
+
+int avcodec_packetize(struct videnc_state *st, const struct vidpacket *packet)
+{
+ int err = 0;
+ uint64_t ts;
+ struct mbuf mb;
+
+ printf("packetize\n");
+
+ if (!st || !packet)
+ return EINVAL;
+
+ printf("packetize1\n");
+
+ mb.buf = packet->buf;
+ mb.pos = 0;
+ mb.end = packet->size;
+ mb.size = packet->size;
+
+ ts = video_calc_rtp_timestamp_fix(packet->timestamp);
+
+
+ switch (st->codec_id) {
+
+ case AV_CODEC_ID_H264:
+ {
+ err = h264_packetize(ts, packet->buf, packet->size,
+ st->encprm.pktsize,
+ st->pkth, st->arg);
+ printf("h264_packetize size=%d encpktsize=%d, res=%d\n",packet->size, st->encprm.pktsize, err);
+ }
+ break;
+
+ default:
+ err = EPROTO;
+ break;
+ }
+
+ return err;
+}
diff -ruN a/modules/h264passcodec/h26x.h b/modules/h264passcodec/h26x.h
--- a/modules/h264passcodec/h26x.h 1970-01-01 03:00:00.000000000 +0300
+++ b/modules/h264passcodec/h26x.h 2022-03-27 11:22:42.000000000 +0300
@@ -0,0 +1,96 @@
+/**
+ * @file h26x.h Interface to H.26x video codecs
+ *
+ * Copyright (C) 2010 Alfred E. Heggestad
+ */
+
+
+/*
+ * H.263
+ */
+
+
+enum h263_mode {
+ H263_MODE_A,
+ H263_MODE_B,
+ H263_MODE_C
+};
+
+enum {
+ H263_HDR_SIZE_MODEA = 4,
+ H263_HDR_SIZE_MODEB = 8,
+ H263_HDR_SIZE_MODEC = 12
+};
+
+/** H.263 picture size format */
+enum h263_fmt {
+ H263_FMT_SQCIF = 1, /**< 128 x 96 */
+ H263_FMT_QCIF = 2, /**< 176 x 144 */
+ H263_FMT_CIF = 3, /**< 352 x 288 */
+ H263_FMT_4CIF = 4, /**< 704 x 576 */
+ H263_FMT_16CIF = 5, /**< 1408 x 1152 */
+ H263_FMT_OTHER = 7,
+};
+
+/**
+ * H.263 Header defined in RFC 2190
+ */
+struct h263_hdr {
+
+ /* common */
+ unsigned f:1; /**< 1 bit - Flag; 0=mode A, 1=mode B/C */
+ unsigned p:1; /**< 1 bit - PB-frames, 0=mode B, 1=mode C */
+ unsigned sbit:3; /**< 3 bits - Start Bit Position (SBIT) */
+ unsigned ebit:3; /**< 3 bits - End Bit Position (EBIT) */
+ unsigned src:3; /**< 3 bits - Source format */
+
+ /* mode A */
+ unsigned i:1; /**< 1 bit - 0=intra-coded, 1=inter-coded */
+ unsigned u:1; /**< 1 bit - Unrestricted Motion Vector */
+ unsigned s:1; /**< 1 bit - Syntax-based Arithmetic Coding */
+ unsigned a:1; /**< 1 bit - Advanced Prediction option */
+ unsigned r:4; /**< 4 bits - Reserved (zero) */
+ unsigned dbq:2; /**< 2 bits - DBQUANT */
+ unsigned trb:3; /**< 3 bits - Temporal Reference for B-frame */
+ unsigned tr:8; /**< 8 bits - Temporal Reference for P-frame */
+
+ /* mode B */
+ unsigned quant:5; //=0 for GOB header
+ unsigned gobn:5; // gob number
+ unsigned mba:9; // address
+ unsigned hmv1:7; // horizontal motion vector
+ unsigned vmv1:7; // vertical motion vector
+ unsigned hmv2:7;
+ unsigned vmv2:7;
+
+
+};
+
+enum {I_FRAME=0, P_FRAME=1};
+
+/** H.263 bit-stream header */
+struct h263_strm {
+ uint8_t psc[2]; /**< Picture Start Code (PSC) */
+
+ uint8_t temp_ref; /**< Temporal Reference */
+ unsigned split_scr:1; /**< Split Screen Indicator */
+ unsigned doc_camera:1; /**< Document Camera Indicator */
+ unsigned pic_frz_rel:1; /**< Full Picture Freeze Release */
+ unsigned src_fmt:3; /**< Source Format. 3=CIF */
+ unsigned pic_type:1; /**< Picture Coding Type. 0=I, 1=P */
+ unsigned umv:1; /**< Unrestricted Motion Vector mode */
+ unsigned sac:1; /**< Syntax-based Arithmetic Coding */
+ unsigned apm:1; /**< Advanced Prediction mode */
+ unsigned pb:1; /**< PB-frames mode */
+ unsigned pquant:5; /**< Quantizer Information */
+ unsigned cpm:1; /**< Continuous Presence Multipoint */
+ unsigned pei:1; /**< Extra Insertion Information */
+ /* H.263 bit-stream ... */
+};
+
+int h263_hdr_encode(const struct h263_hdr *hdr, struct mbuf *mb);
+int h263_hdr_decode(struct h263_hdr *hdr, struct mbuf *mb);
+enum h263_mode h263_hdr_mode(const struct h263_hdr *hdr);
+
+int h263_strm_decode(struct h263_strm *s, struct mbuf *mb);
+void h263_hdr_copy_strm(struct h263_hdr *hdr, const struct h263_strm *s);
diff -ruN a/modules/h264passcodec/module.mk b/modules/h264passcodec/module.mk
--- a/modules/h264passcodec/module.mk 1970-01-01 03:00:00.000000000 +0300
+++ b/modules/h264passcodec/module.mk 2023-01-27 21:27:00.501734000 +0300
@@ -0,0 +1,14 @@
+#
+# module.mk
+#
+# Copyright (C) 2010 Alfred E. Heggestad
+#
+
+MOD := h264passcodec
+$(MOD)_SRCS += avcodec.c
+$(MOD)_SRCS += encode.c
+$(MOD)_SRCS += sdp.c
+$(MOD)_CFLAGS +=
+$(MOD)_LFLAGS +=
+
+include mk/mod.mk
diff -ruN a/modules/h264passcodec/sdp.c b/modules/h264passcodec/sdp.c
--- a/modules/h264passcodec/sdp.c 1970-01-01 03:00:00.000000000 +0300
+++ b/modules/h264passcodec/sdp.c 2023-01-27 21:27:19.881734000 +0300
@@ -0,0 +1,86 @@
+/**
+ * @file avcodec/sdp.c Video codecs using libavcodec -- SDP functions
+ *
+ * Copyright (C) 2010 Alfred E. Heggestad
+ * Copyright (C) 2021 by:
+ * Media Magic Technologies <developer@mediamagictechnologies.com>
+ * and Divus GmbH <developer@divus.eu>
+ */
+
+#include <re.h>
+#include <baresip.h>
+#include "avcodec.h"
+
+
+static char profile_level_id[256] = "";
+
+
+uint32_t h264_packetization_mode(const char *fmtp)
+{
+ struct pl pl, mode;
+
+ if (!fmtp)
+ return 0;
+
+ pl_set_str(&pl, fmtp);
+
+ if (fmt_param_get(&pl, "packetization-mode", &mode))
+ return pl_u32(&mode);
+
+ return 0;
+}
+
+
+int avcodec_h264_fmtp_enc(struct mbuf *mb, const struct sdp_format *fmt,
+ bool offer, void *arg)
+{
+ struct vidcodec *vc = arg;
+ uint8_t profile_idc = 0x42; /* baseline profile */
+ uint8_t profile_iop = 0xe0;
+ uint8_t h264_level_idc = 0x1f;
+ (void)offer;
+
+ if (!mb || !fmt || !vc)
+ return 0;
+
+ conf_get_str(conf_cur(), "avcodec_profile_level_id",
+ profile_level_id, sizeof(profile_level_id));
+
+ if (str_isset(profile_level_id)) {
+ struct pl prof;
+
+ pl_set_str(&prof, profile_level_id);
+ if (prof.l != 6) {
+ warning("avcodec: invalid profile_level_id"
+ " (%r) using default\n",
+ profile_level_id);
+ goto out;
+ }
+
+ prof.l = 2;
+ profile_idc = pl_x32(&prof); prof.p += 2;
+ profile_iop = pl_x32(&prof); prof.p += 2;
+ h264_level_idc = pl_x32(&prof);
+ }
+
+ out:
+ return mbuf_printf(mb, "a=fmtp:%s"
+ " %s"
+ ";profile-level-id=%02x%02x%02x"
+ "\r\n",
+ fmt->id, vc->variant,
+ profile_idc, profile_iop, h264_level_idc);
+}
+
+
+bool avcodec_h264_fmtp_cmp(const char *lfmtp, const char *rfmtp, void *arg)
+{
+ const struct vidcodec *vc = arg;
+ (void)lfmtp;
+
+ if (!vc)
+ return false;
+
+ return h264_packetization_mode(vc->variant) ==
+ h264_packetization_mode(rfmtp);
+}
diff -ruN a/modules/menu/dynamic_menu.c b/modules/menu/dynamic_menu.c
--- a/modules/menu/dynamic_menu.c 2022-03-27 11:22:42.000000000 +0300
+++ b/modules/menu/dynamic_menu.c 2023-01-26 19:14:52.915866100 +0300
@@ -355,8 +355,8 @@
if (!pl_isset(&argdir[1]))
argdir[1] = argdir[0];
- adir = sdp_dir_decode(&argdir[0]);
- vdir = sdp_dir_decode(&argdir[1]);
+ adir = decode_sdp_enum(&argdir[0]);
+ vdir = decode_sdp_enum(&argdir[1]);
if (adir == SDP_INACTIVE && vdir == SDP_INACTIVE) {
(void) re_hprintf(pf, "%s", usage);
return EINVAL;
diff -ruN a/modules/menu/menu.c b/modules/menu/menu.c
--- a/modules/menu/menu.c 2022-03-27 11:22:42.000000000 +0300
+++ b/modules/menu/menu.c 2023-01-26 19:17:29.575866100 +0300
@@ -928,6 +928,20 @@
return 0;
}
+enum sdp_dir decode_sdp_enum(const struct pl *pl)
+{
+ if (!pl_strcmp(pl, "inactive")) {
+ return SDP_INACTIVE;
+ }
+ else if (!pl_strcmp(pl, "sendonly")) {
+ return SDP_SENDONLY;
+ }
+ else if (!pl_strcmp(pl, "recvonly")) {
+ return SDP_RECVONLY;
+ }
+
+ return SDP_SENDRECV;
+}
static int module_init(void)
{
diff -ruN a/modules/menu/static_menu.c b/modules/menu/static_menu.c
--- a/modules/menu/static_menu.c 2022-03-27 11:22:42.000000000 +0300
+++ b/modules/menu/static_menu.c 2023-01-26 19:15:56.745866100 +0300
@@ -136,8 +136,8 @@
if (!pl_isset(&argdir[1]))
argdir[1] = argdir[0];
- adir = sdp_dir_decode(&argdir[0]);
- vdir = sdp_dir_decode(&argdir[1]);
+ adir = decode_sdp_enum(&argdir[0]);
+ vdir = decode_sdp_enum(&argdir[1]);
if (adir == SDP_INACTIVE && vdir == SDP_INACTIVE) {
(void) re_hprintf(pf, "%s", usage);
@@ -541,8 +541,8 @@
if (!pl_isset(&argdir[1]))
argdir[1] = argdir[0];
- adir = sdp_dir_decode(&argdir[0]);
- vdir = sdp_dir_decode(&argdir[1]);
+ adir = decode_sdp_enum(&argdir[0]);
+ vdir = decode_sdp_enum(&argdir[1]);
if (adir == SDP_INACTIVE && vdir == SDP_INACTIVE) {
(void)re_hprintf(pf, "%s", usage);
diff -ruN a/src/audio.c b/src/audio.c
--- a/src/audio.c 2022-03-27 11:22:42.000000000 +0300
+++ b/src/audio.c 2023-01-26 16:16:07.045866100 +0300
@@ -1,3 +1,4 @@
+#define _POSIX_C_SOURCE 200809L
/**
* @file src/audio.c Audio stream
*
diff -ruN a/src/main.c b/src/main.c
--- a/src/main.c 2022-03-27 11:22:42.000000000 +0300
+++ b/src/main.c 2023-01-26 18:49:09.115866100 +0300
@@ -13,6 +13,7 @@
#include <re.h>
#include <baresip.h>
+int verbose=0;
static void signal_handler(int sig)
{
diff -ruN a/src/sdp.c b/src/sdp.c
--- a/src/sdp.c 2022-03-27 11:22:42.000000000 +0300
+++ b/src/sdp.c 2023-01-28 18:44:16.019698100 +0300
@@ -63,8 +63,18 @@
bool has;
has = sdp_media_rformat(m, NULL) != NULL;
+
+ if( !has )
+ info("has_media: no codecs\n");
+
if (has)
- return sdp_media_rport(m) != 0;
+ {
+ has = sdp_media_rport(m);
+ if( !has )
+ info("has_media: no rport\n");
+ return has != 0 ;
+ }
+
return false;
}
diff -ruN a/src/stream.c b/src/stream.c
--- a/src/stream.c 2022-03-27 11:22:42.000000000 +0300
+++ b/src/stream.c 2023-01-28 18:25:24.999698100 +0300
@@ -1029,6 +1029,7 @@
s->tx.pt_enc = fmt ? fmt->pt : -1;
if (sdp_media_has_media(s->sdp)) {
+ info("stream: has media\n");
if (bundle_state(s->bundle) == BUNDLE_MUX) {
@@ -1043,6 +1044,10 @@
bundle_handle_extmap(s->bundle, s->sdp);
}
}
+ else
+ {
+ info("stream: has no media\n");
+ }
if (s->mencs && mnat_ready(s)) {
diff -ruN a/src/video.c b/src/video.c
--- a/src/video.c 2022-03-27 11:22:42.000000000 +0300
+++ b/src/video.c 2023-01-28 20:42:26.409698100 +0300
@@ -1169,12 +1169,18 @@
if (sc) {
if (dir & SDP_SENDONLY)
+ {
err = video_encoder_set(v, sc->data, sc->pt,
sc->params);
+ debug("video: sendonly\n");
+ }
if (dir & SDP_RECVONLY)
+ {
err |= video_decoder_set(v, sc->data, sc->pt,
sc->rparams);
+ debug("video: recvonly\n");
+ }
/* Stop / Start source & display*/
if (dir & SDP_SENDONLY)
@@ -1220,10 +1226,16 @@
int err;
if (!v)
+ {
+ printf("video_start_source EINVAL");
return EINVAL;
+ }
if (v->vtx.vsrc)
+ {
+ printf("vsrc is set, return\n");
return 0;
+ }
debug("video: start source\n");

View File

@ -1,12 +1,13 @@
config BR2_PACKAGE_BARESIP_OPENIPC config BR2_PACKAGE_BARESIP_OPENIPC
bool "baresip-openipc" bool "baresip-openipc"
select BR2_PACKAGE_LIBRE_OPENIPC default n
select BR2_PACKAGE_LIBREM_OPENIPC depends on BR2_PACKAGE_LIBRE_OPENIPC
default n depends on BR2_PACKAGE_LIBREM_OPENIPC
help select BR2_PACKAGE_LIBRE_OPENIPC
Baresip is a portable and modular SIP User-Agent with audio select BR2_PACKAGE_LIBREM_OPENIPC
and video support. Copyright (c) 2010 - 2022 Alfred E. Heggestad help
and Contributors Distributed under BSD license. Baresip is a portable and modular SIP User-Agent with audio
and video support. Copyright (c) 2010 - 2022 Alfred E. Heggestad
https://github.com/baresip/baresip and Contributors Distributed under BSD license.
https://github.com/baresip/baresip

View File

@ -4,7 +4,7 @@
# #
############################################################# #############################################################
BARESIP_OPENIPC_VERSION = 1.0.0 BARESIP_OPENIPC_VERSION = 2.0.1
BARESIP_OPENIPC_SOURCE = v$(BARESIP_OPENIPC_VERSION).tar.gz BARESIP_OPENIPC_SOURCE = v$(BARESIP_OPENIPC_VERSION).tar.gz
BARESIP_OPENIPC_SITE = https://github.com/baresip/baresip/archive BARESIP_OPENIPC_SITE = https://github.com/baresip/baresip/archive
BARESIP_OPENIPC_DEPENDENCIES = libre-openipc librem-openipc zlib BARESIP_OPENIPC_DEPENDENCIES = libre-openipc librem-openipc zlib

View File

@ -0,0 +1,460 @@
diff -ruN a/include/re_sha.h b/include/re_sha.h
--- a/include/re_sha.h 2022-03-12 09:42:35.000000000 +0300
+++ b/include/re_sha.h 2023-01-26 15:39:59.205866100 +0300
@@ -4,12 +4,31 @@
* Copyright (C) 2010 Creytiv.com
*/
+
+#ifdef USE_OPENSSL
+#include <openssl/sha.h>
+#else
+
+/* public api for steve reid's public domain SHA-1 implementation */
+/* this file is in the public domain */
+
+/** SHA-1 Context */
+typedef struct {
+ uint32_t state[5]; /**< Context state */
+ uint32_t count[2]; /**< Counter */
+ uint8_t buffer[64]; /**< SHA-1 buffer */
+} SHA1_CTX;
+
+/** SHA-1 Context (OpenSSL compat) */
+typedef SHA1_CTX SHA_CTX;
+
/** SHA-1 Digest size in bytes */
#define SHA1_DIGEST_SIZE 20
-
-#ifndef SHA_DIGEST_LENGTH
/** SHA-1 Digest size in bytes (OpenSSL compat) */
#define SHA_DIGEST_LENGTH SHA1_DIGEST_SIZE
-#endif
-void sha1(const uint8_t *d, size_t n, uint8_t *md);
+void SHA1_Init(SHA1_CTX* context);
+void SHA1_Update(SHA1_CTX* context, const void *p, size_t len);
+void SHA1_Final(uint8_t digest[SHA1_DIGEST_SIZE], SHA1_CTX* context);
+
+#endif
diff -ruN a/src/hmac/hmac_sha1.c b/src/hmac/hmac_sha1.c
--- a/src/hmac/hmac_sha1.c 2022-03-12 09:42:35.000000000 +0300
+++ b/src/hmac/hmac_sha1.c 2023-01-26 15:41:07.255866100 +0300
@@ -9,8 +9,8 @@
#include <openssl/sha.h>
#include <openssl/hmac.h>
#include <openssl/err.h>
-#elif defined (__APPLE__)
-#include <CommonCrypto/CommonHMAC.h>
+#else
+#include <re_sha.h>
#endif
#include <re_hmac.h>
@@ -32,31 +32,68 @@
* @param t Size of digest output
*/
void hmac_sha1(const uint8_t *k, /* secret key */
- size_t lk, /* length of the key in bytes */
- const uint8_t *d, /* data */
- size_t ld, /* length of data in bytes */
- uint8_t *out, /* output buffer, at least "t" bytes */
- size_t t)
+ size_t lk, /* length of the key in bytes */
+ const uint8_t *d, /* data */
+ size_t ld, /* length of data in bytes */
+ uint8_t *out, /* output buffer, at least "t" bytes */
+ size_t t)
{
#ifdef USE_OPENSSL
- (void)t;
-
- if (!HMAC(EVP_sha1(), k, (int)lk, d, ld, out, NULL))
- ERR_clear_error();
-#elif defined (__APPLE__)
- (void)t;
+ (void)t;
- CCHmac(kCCHmacAlgSHA1, k, lk, d, ld, out);
+ if (!HMAC(EVP_sha1(), k, (int)lk, d, ld, out, NULL))
+ ERR_clear_error();
#else
- (void)k;
- (void)lk;
- (void)d;
- (void)ld;
- (void)out;
- (void)t;
+ SHA_CTX ictx, octx;
+ uint8_t isha[SHA_DIGEST_LENGTH], osha[SHA_DIGEST_LENGTH];
+ uint8_t key[SHA_DIGEST_LENGTH];
+ uint8_t buf[SHA_BLOCKSIZE];
+ size_t i;
+
+ if (lk > SHA_BLOCKSIZE) {
+ SHA_CTX tctx;
+
+ SHA1_Init(&tctx);
+ SHA1_Update(&tctx, k, lk);
+ SHA1_Final(key, &tctx);
+
+ k = key;
+ lk = SHA_DIGEST_LENGTH;
+ }
+
+ /**** Inner Digest ****/
+
+ SHA1_Init(&ictx);
+
+ /* Pad the key for inner digest */
+ for (i = 0 ; i < lk ; ++i)
+ buf[i] = k[i] ^ 0x36;
+ for (i = lk ; i < SHA_BLOCKSIZE ; ++i)
+ buf[i] = 0x36;
+
+ SHA1_Update(&ictx, buf, SHA_BLOCKSIZE);
+ SHA1_Update(&ictx, d, ld);
+
+ SHA1_Final(isha, &ictx);
+
+ /**** Outer Digest ****/
+
+ SHA1_Init(&octx);
+
+ /* Pad the key for outter digest */
+
+ for (i = 0 ; i < lk ; ++i)
+ buf[i] = k[i] ^ 0x5c;
+ for (i = lk ; i < SHA_BLOCKSIZE ; ++i)
+ buf[i] = 0x5c;
-#error missing HMAC-SHA1 backend
+ SHA1_Update(&octx, buf, SHA_BLOCKSIZE);
+ SHA1_Update(&octx, isha, SHA_DIGEST_LENGTH);
+ SHA1_Final(osha, &octx);
+ /* truncate and print the results */
+ t = t > SHA_DIGEST_LENGTH ? SHA_DIGEST_LENGTH : t;
+ memcpy(out, osha, t);
#endif
}
diff -ruN a/src/sha/mod.mk b/src/sha/mod.mk
--- a/src/sha/mod.mk 2022-03-12 09:42:35.000000000 +0300
+++ b/src/sha/mod.mk 2023-01-26 15:38:20.695866100 +0300
@@ -4,4 +4,4 @@
# Copyright (C) 2010 Creytiv.com
#
-SRCS += sha/wrap.c
+SRCS += sha/sha1.c
diff -ruN a/src/sha/sha1.c b/src/sha/sha1.c
--- a/src/sha/sha1.c 1970-01-01 03:00:00.000000000 +0300
+++ b/src/sha/sha1.c 2023-01-26 15:38:37.045866100 +0300
@@ -0,0 +1,270 @@
+/**
+ * @file sha1.c SHA-1 in C
+ */
+
+/*
+By Steve Reid <sreid@sea-to-sky.net>
+100% Public Domain
+
+-----------------
+Modified 7/98
+By James H. Brown <jbrown@burgoyne.com>
+Still 100% Public Domain
+
+Corrected a problem which generated improper hash values on 16 bit machines
+Routine SHA1Update changed from
+ void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int
+len)
+to
+ void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned
+long len)
+
+The 'len' parameter was declared an int which works fine on 32 bit machines.
+However, on 16 bit machines an int is too small for the shifts being done
+against
+it. This caused the hash function to generate incorrect values if len was
+greater than 8191 (8K - 1) due to the 'len << 3' on line 3 of SHA1Update().
+
+Since the file IO in main() reads 16K at a time, any file 8K or larger would
+be guaranteed to generate the wrong hash (e.g. Test Vector #3, a million
+"a"s).
+
+I also changed the declaration of variables i & j in SHA1Update to
+unsigned long from unsigned int for the same reason.
+
+These changes should make no difference to any 32 bit implementations since
+an
+int and a long are the same size in those environments.
+
+--
+I also corrected a few compiler warnings generated by Borland C.
+1. Added #include <process.h> for exit() prototype
+2. Removed unused variable 'j' in SHA1Final
+3. Changed exit(0) to return(0) at end of main.
+
+ALL changes I made can be located by searching for comments containing 'JHB'
+-----------------
+Modified 8/98
+By Steve Reid <sreid@sea-to-sky.net>
+Still 100% public domain
+
+1- Removed #include <process.h> and used return() instead of exit()
+2- Fixed overwriting of finalcount in SHA1Final() (discovered by Chris Hall)
+3- Changed email address from steve@edmweb.com to sreid@sea-to-sky.net
+
+-----------------
+Modified 4/01
+By Saul Kravitz <Saul.Kravitz@celera.com>
+Still 100% PD
+Modified to run on Compaq Alpha hardware.
+
+-----------------
+Modified 07/2002
+By Ralph Giles <giles@artofcode.com>
+Still 100% public domain
+modified for use with stdint types, autoconf
+code cleanup, removed attribution comments
+switched SHA1Final() argument order for consistency
+use SHA1_ prefix for public api
+move public api to sha1.h
+*/
+
+/*
+Test Vectors (from FIPS PUB 180-1)
+"abc"
+ A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
+"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
+A million repetitions of "a"
+ 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
+*/
+
+#define SHA1HANDSOFF 1
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <re_types.h>
+#include <re_sha.h>
+
+void SHA1_Transform(uint32_t state[5], const uint8_t buffer[64]);
+
+#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
+
+#if defined (BYTE_ORDER) && defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN)
+#define WORDS_BIGENDIAN 1
+#endif
+#ifdef _BIG_ENDIAN
+#define WORDS_BIGENDIAN 1
+#endif
+
+
+/* blk0() and blk() perform the initial expand. */
+/* I got the idea of expanding during the round function from SSLeay */
+/* FIXME: can we do this in an endian-proof way? */
+#ifdef WORDS_BIGENDIAN
+#define blk0(i) block->l[i]
+#else
+#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xff00ff00) \
+ |(rol(block->l[i],8)&0x00ff00ff))
+#endif
+#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
+ ^block->l[(i+2)&15]^block->l[i&15],1))
+
+/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
+#define R0(v,w,x,y,z,i) \
+ z+=((w&(x^y))^y)+blk0(i)+0x5a827999+rol(v,5);w=rol(w,30);
+#define R1(v,w,x,y,z,i) \
+ z+=((w&(x^y))^y)+blk(i)+0x5a827999+rol(v,5);w=rol(w,30);
+#define R2(v,w,x,y,z,i) \
+ z+=(w^x^y)+blk(i)+0x6ed9eba1+rol(v,5);w=rol(w,30);
+#define R3(v,w,x,y,z,i) \
+ z+=(((w|x)&y)|(w&x))+blk(i)+0x8f1bbcdc+rol(v,5);w=rol(w,30);
+#define R4(v,w,x,y,z,i) \
+ z+=(w^x^y)+blk(i)+0xca62c1d6+rol(v,5);w=rol(w,30);
+
+
+/* Hash a single 512-bit block. This is the core of the algorithm. */
+void SHA1_Transform(uint32_t state[5], const uint8_t buffer[64])
+{
+ uint32_t a, b, c, d, e;
+ typedef union {
+ uint8_t c[64];
+ uint32_t l[16];
+ } CHAR64LONG16;
+ CHAR64LONG16* block;
+
+#ifdef SHA1HANDSOFF
+ CHAR64LONG16 workspace;
+ block = &workspace;
+ memcpy(block, buffer, 64);
+#else
+ block = (CHAR64LONG16*)buffer;
+#endif
+
+ /* Copy context->state[] to working vars */
+ a = state[0];
+ b = state[1];
+ c = state[2];
+ d = state[3];
+ e = state[4];
+
+ /* 4 rounds of 20 operations each. Loop unrolled. */
+ R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2);R0(c,d,e,a,b, 3);
+ R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6);R0(d,e,a,b,c, 7);
+ R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10);R0(e,a,b,c,d,11);
+ R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14);R0(a,b,c,d,e,15);
+ R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18);R1(b,c,d,e,a,19);
+ R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22);R2(c,d,e,a,b,23);
+ R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26);R2(d,e,a,b,c,27);
+ R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30);R2(e,a,b,c,d,31);
+ R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34);R2(a,b,c,d,e,35);
+ R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38);R2(b,c,d,e,a,39);
+ R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42);R3(c,d,e,a,b,43);
+ R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46);R3(d,e,a,b,c,47);
+ R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50);R3(e,a,b,c,d,51);
+ R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54);R3(a,b,c,d,e,55);
+ R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58);R3(b,c,d,e,a,59);
+ R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62);R4(c,d,e,a,b,63);
+ R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66);R4(d,e,a,b,c,67);
+ R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70);R4(e,a,b,c,d,71);
+ R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74);R4(a,b,c,d,e,75);
+ R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78);R4(b,c,d,e,a,79);
+
+ /* Add the working vars back into context.state[] */
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+ state[4] += e;
+
+ /* Wipe variables */
+ a = b = c = d = e = 0;
+}
+
+
+/**
+ * Initialize new context
+ *
+ * @param context SHA1-Context
+ */
+void SHA1_Init(SHA1_CTX* context)
+{
+ /* SHA1 initialization constants */
+ context->state[0] = 0x67452301;
+ context->state[1] = 0xefcdab89;
+ context->state[2] = 0x98badcfe;
+ context->state[3] = 0x10325476;
+ context->state[4] = 0xc3d2e1f0;
+ context->count[0] = context->count[1] = 0;
+}
+
+
+/**
+ * Run your data through this
+ *
+ * @param context SHA1-Context
+ * @param p Buffer to run SHA1 on
+ * @param len Number of bytes
+ */
+void SHA1_Update(SHA1_CTX* context, const void *p, size_t len)
+{
+ const uint8_t* data = p;
+ size_t i, j;
+
+ j = (context->count[0] >> 3) & 63;
+ if ((context->count[0] += (uint32_t)(len << 3)) < (len << 3))
+ context->count[1]++;
+ context->count[1] += (uint32_t)(len >> 29);
+ if ((j + len) > 63) {
+ memcpy(&context->buffer[j], data, (i = 64-j));
+ SHA1_Transform(context->state, context->buffer);
+ for ( ; i + 63 < len; i += 64) {
+ SHA1_Transform(context->state, data + i);
+ }
+ j = 0;
+ }
+ else i = 0;
+ memcpy(&context->buffer[j], &data[i], len - i);
+}
+
+
+/**
+ * Add padding and return the message digest
+ *
+ * @param digest Generated message digest
+ * @param context SHA1-Context
+ */
+void SHA1_Final(uint8_t digest[SHA1_DIGEST_SIZE], SHA1_CTX* context)
+{
+ uint32_t i;
+ uint8_t finalcount[8];
+
+ for (i = 0; i < 8; i++) {
+ finalcount[i] = (uint8_t)((context->count[(i >= 4 ? 0 : 1)]
+ >> ((3-(i & 3)) * 8) ) & 255);
+ }
+ SHA1_Update(context, (uint8_t *)"\200", 1);
+ while ((context->count[0] & 504) != 448) {
+ SHA1_Update(context, (uint8_t *)"\0", 1);
+ }
+ SHA1_Update(context, finalcount, 8); /* Should cause SHA1_Transform */
+ for (i = 0; i < SHA1_DIGEST_SIZE; i++) {
+ digest[i] = (uint8_t)
+ ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
+ }
+
+ /* Wipe variables */
+ i = 0;
+ memset(context->buffer, 0, 64);
+ memset(context->state, 0, 20);
+ memset(context->count, 0, 8);
+ memset(finalcount, 0, 8); /* SWR */
+
+#ifdef SHA1HANDSOFF /* make SHA1Transform overwrite its own static vars */
+ SHA1_Transform(context->state, context->buffer);
+#endif
+}
diff -ruN a/src/websock/websock.c b/src/websock/websock.c
--- a/src/websock/websock.c 2022-03-12 09:42:35.000000000 +0300
+++ b/src/websock/websock.c 2023-01-26 17:15:14.905866100 +0300
@@ -369,24 +369,19 @@
static int accept_print(struct re_printf *pf, const struct pl *key)
{
- uint8_t digest[SHA_DIGEST_LENGTH];
- uint8_t *data;
- size_t len = key->l + sizeof(magic)-1;
+ uint8_t digest[SHA_DIGEST_LENGTH];
+ SHA_CTX ctx;
- data = mem_zalloc(len, NULL);
- if (!data)
- return ENOMEM;
+ SHA1_Init(&ctx);
+ SHA1_Update(&ctx, key->p, key->l);
+ SHA1_Update(&ctx, magic, sizeof(magic)-1);
+ SHA1_Final(digest, &ctx);
- memcpy(data, key->p, key->l);
- memcpy(data + key->l, magic, sizeof(magic)-1);
-
- sha1(data, len, digest);
- mem_deref(data);
-
- return base64_print(pf, digest, sizeof(digest));
+ return base64_print(pf, digest, sizeof(digest));
}
+
static void http_resp_handler(int err, const struct http_msg *msg, void *arg)
{
struct websock_conn *conn = arg;

View File

@ -1,9 +1,8 @@
config BR2_PACKAGE_LIBRE_OPENIPC config BR2_PACKAGE_LIBRE_OPENIPC
bool "libre-openipc" bool "libre-openipc"
default n default n
help help
libre is a Generic library for real-time communications libre is a Generic library for real-time communications
with async IO support. with async IO support.
https://github.com/baresip/re
https://github.com/baresip/re

View File

@ -4,7 +4,7 @@
# #
########################################################################### ###########################################################################
LIBRE_OPENIPC_VERSION = 1.1.0 LIBRE_OPENIPC_VERSION = 2.1.1
LIBRE_OPENIPC_SOURCE = v$(LIBRE_OPENIPC_VERSION).tar.gz LIBRE_OPENIPC_SOURCE = v$(LIBRE_OPENIPC_VERSION).tar.gz
LIBRE_OPENIPC_SITE = https://github.com/baresip/re/archive LIBRE_OPENIPC_SITE = https://github.com/baresip/re/archive
LIBRE_OPENIPC_INSTALL_STAGING = YES LIBRE_OPENIPC_INSTALL_STAGING = YES
@ -18,20 +18,20 @@ endif
define LIBRE_OPENIPC_BUILD_CMDS define LIBRE_OPENIPC_BUILD_CMDS
$(TARGET_MAKE_ENV) \ $(TARGET_MAKE_ENV) \
$(MAKE) -C $(@D) \ $(MAKE) -C $(@D) \
LIBRE_MK=$(STAGING_DIR)/usr/share/re/re.mk \ LIBRE_MK=$(STAGING_DIR)/usr/share/re/re.mk \
LIBRE_INC=$(STAGING_DIR)/usr/include/re \ LIBRE_INC=$(STAGING_DIR)/usr/include/re \
LIBRE_SO=$(STAGING_DIR)/usr/lib \ LIBRE_SO=$(STAGING_DIR)/usr/lib \
CC="$(TARGET_CC)" \ CC="$(TARGET_CC)" \
EXTRA_CFLAGS="$(TARGET_CFLAGS) -D_GNU_SOURCE" \ EXTRA_CFLAGS="$(TARGET_CFLAGS) -D_GNU_SOURCE" \
EXTRA_LFLAGS="-lm" \ EXTRA_LFLAGS="-lm" \
DESTDIR="$(STAGING_DIR)" \ DESTDIR="$(STAGING_DIR)" \
SYSROOT="$(STAGING_DIR)/usr" \ SYSROOT="$(STAGING_DIR)/usr" \
SYSROOT_ALT="$(STAGING_DIR)/usr" \ SYSROOT_ALT="$(STAGING_DIR)/usr" \
RELEASE=1 \ RELEASE=1 \
CROSS_COMPILE="$(TARGET_CROSS)" \ CROSS_COMPILE="$(TARGET_CROSS)" \
OS=linux \ OS=linux \
all install all install
endef endef

View File

@ -1,9 +1,9 @@
config BR2_PACKAGE_LIBREM_OPENIPC config BR2_PACKAGE_LIBREM_OPENIPC
bool "librem-openipc" bool "librem-openipc"
select BR2_PACKAGE_LIBRE_OPENIPC default n
default n depends on BR2_PACKAGE_LIBRE_OPENIPC
help select BR2_PACKAGE_LIBRE_OPENIPC
librem is a Audio and video processing media library. help
librem is a Audio and video processing media library.
https://github.com/baresip/rem
https://github.com/baresip/rem

View File

@ -4,7 +4,7 @@
# #
############################################################# #############################################################
LIBREM_OPENIPC_VERSION = 0.6.0 LIBREM_OPENIPC_VERSION = 2.0.1
LIBREM_OPENIPC_SOURCE = v$(LIBREM_OPENIPC_VERSION).tar.gz LIBREM_OPENIPC_SOURCE = v$(LIBREM_OPENIPC_VERSION).tar.gz
LIBREM_OPENIPC_SITE = https://github.com/baresip/rem/archive LIBREM_OPENIPC_SITE = https://github.com/baresip/rem/archive
LIBREM_OPENIPC_INSTALL_STAGING = YES LIBREM_OPENIPC_INSTALL_STAGING = YES
@ -15,21 +15,21 @@ endif
define LIBREM_OPENIPC_BUILD_CMDS define LIBREM_OPENIPC_BUILD_CMDS
$(TARGET_MAKE_ENV) \ $(TARGET_MAKE_ENV) \
$(MAKE) -C $(@D) \ $(MAKE) -C $(@D) \
LIBRE_MK=$(STAGING_DIR)/usr/share/re/re.mk \ LIBRE_MK=$(STAGING_DIR)/usr/share/re/re.mk \
LIBRE_INC=$(STAGING_DIR)/usr/include/re \ LIBRE_INC=$(STAGING_DIR)/usr/include/re \
LIBRE_SO=$(STAGING_DIR)/usr/lib \ LIBRE_SO=$(STAGING_DIR)/usr/lib \
HAVE_LIBRESOLV= \ HAVE_LIBRESOLV= \
CC="$(TARGET_CC)" \ CC="$(TARGET_CC)" \
EXTRA_CFLAGS="$(TARGET_CFLAGS) -D_GNU_SOURCE" \ EXTRA_CFLAGS="$(TARGET_CFLAGS) -D_GNU_SOURCE" \
EXTRA_LFLAGS="-lm" \ EXTRA_LFLAGS="-lm" \
DESTDIR="$(STAGING_DIR)" \ DESTDIR="$(STAGING_DIR)" \
SYSROOT="$(STAGING_DIR)/usr" \ SYSROOT="$(STAGING_DIR)/usr" \
SYSROOT_ALT="$(STAGING_DIR)/usr" \ SYSROOT_ALT="$(STAGING_DIR)/usr" \
RELEASE=1 \ RELEASE=1 \
CROSS_COMPILE="$(TARGET_CROSS)" \ CROSS_COMPILE="$(TARGET_CROSS)" \
OS=linux \ OS=linux \
all install all install
endef endef
define LIBREM_OPENIPC_INSTALL_TARGET_CMDS define LIBREM_OPENIPC_INSTALL_TARGET_CMDS

View File

@ -1,5 +1,7 @@
config BR2_PACKAGE_UQMI_OPENIPC config BR2_PACKAGE_UQMI_OPENIPC
bool "uqmi-openipc" bool "uqmi-openipc"
select BR2_PACKAGE_JSON_C_OPENIPC
select BR2_PACKAGE_LIBUBOX
help help
This command line tool originates from the OpenWrt project This command line tool originates from the OpenWrt project
to configure LTE modem in QMI mode for WAN connection. to configure LTE modem in QMI mode for WAN connection.

View File

@ -4,10 +4,10 @@
# #
################################################################################ ################################################################################
UQMI_VERSION = f254fc59c710d781eca3ec36e0bff2d8970370fa UQMI_OPENIPC_VERSION = f254fc59c710d781eca3ec36e0bff2d8970370fa
UQMI_SITE = git://git.openwrt.org/project/uqmi.git UQMI_OPENIPC_SITE = git://git.openwrt.org/project/uqmi.git
UQMI_DEPENDENCIES = json-c-openipc libubox UQMI_OPENIPC_DEPENDENCIES = json-c-openipc libubox
UQMI_LICENSE = LGPL-2.0+ UQMI_OPENIPC_LICENSE = LGPL-2.0+
UQMI_LICENSE_FILES = COPYING UQMI_OPENIPC_LICENSE_FILES = COPYING
$(eval $(cmake-package)) $(eval $(cmake-package))