From 150d0f9afac8add18bb90b02d4759c91fc9d0e9a Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 18 May 2014 11:20:14 +0200 Subject: fix call mute-state for multiple calls added audio_ismuted() and remove static state from menu.c thanks to Remik who reported the issue and suggested a nice solution :) --- include/baresip.h | 1 + modules/menu/menu.c | 6 +++--- src/audio.c | 18 +++++++++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/include/baresip.h b/include/baresip.h index 6f0deae..8ccdee1 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -813,6 +813,7 @@ int vidfilt_dec_append(struct list *filtl, void **ctx, struct audio; void audio_mute(struct audio *a, bool muted); +bool audio_ismuted(const struct audio *a); void audio_set_devicename(struct audio *a, const char *src, const char *play); void audio_encoder_cycle(struct audio *audio); int audio_debug(struct re_printf *pf, const struct audio *a); diff --git a/modules/menu/menu.c b/modules/menu/menu.c index 583fb69..e0e6e22 100644 --- a/modules/menu/menu.c +++ b/modules/menu/menu.c @@ -340,12 +340,12 @@ static int call_reinvite(struct re_printf *pf, void *unused) static int call_mute(struct re_printf *pf, void *unused) { - static bool muted = false; + struct audio *audio = call_audio(ua_call(uag_cur())); + bool muted = !audio_ismuted(audio); (void)unused; - muted = !muted; (void)re_hprintf(pf, "\ncall %smuted\n", muted ? "" : "un-"); - audio_mute(call_audio(ua_call(uag_cur())), muted); + audio_mute(audio, muted); return 0; } diff --git a/src/audio.c b/src/audio.c index d8bb689..4f03591 100644 --- a/src/audio.c +++ b/src/audio.c @@ -1278,7 +1278,7 @@ int audio_send_digit(struct audio *a, char key) /** - * Mute the audio stream + * Mute the audio stream source (i.e. Microphone) * * @param a Audio stream * @param muted True to mute, false to un-mute @@ -1292,6 +1292,22 @@ void audio_mute(struct audio *a, bool muted) } +/** + * Get the mute state of an audio source + * + * @param a Audio stream + * + * @return True if muted, otherwise false + */ +bool audio_ismuted(const struct audio *a) +{ + if (!a) + return false; + + return a->tx.muted; +} + + void audio_sdp_attr_decode(struct audio *a) { const char *attr; -- cgit v1.2.3 From ef0646cdc165477212ad4826ee26f0fed0455a3a Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 18 May 2014 15:08:58 +0200 Subject: call: cancel local timer on call_progress() for incoming calls, we start a local timer of 120 seconds. this timer is stopped when the call is answered with 200 or 183. issue was reported by Victor Sergienko, thanks! --- src/call.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/call.c b/src/call.c index 0cf4358..e07d0c0 100644 --- a/src/call.c +++ b/src/call.c @@ -656,6 +656,8 @@ int call_progress(struct call *call) if (!call) return EINVAL; + tmr_cancel(&call->tmr_inv); + err = call_sdp_get(call, &desc, false); if (err) return err; -- cgit v1.2.3 From dd2e332a65af6dce2e540f27fdb2b815f4358574 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 18 May 2014 15:42:37 +0200 Subject: move struct stream to core.h --- src/core.h | 29 ++++++++++++++++++++++++++++- src/stream.c | 37 ------------------------------------- 2 files changed, 28 insertions(+), 38 deletions(-) diff --git a/src/core.h b/src/core.h index 2f8784b..3d4bf9a 100644 --- a/src/core.h +++ b/src/core.h @@ -291,7 +291,6 @@ const struct sdp_format *sdp_media_format_cycle(struct sdp_media *m); * Stream */ -struct stream; struct rtp_header; enum {STREAM_PRESZ = 4+12}; /* same as RTP_HEADER_SIZE */ @@ -300,6 +299,34 @@ typedef void (stream_rtp_h)(const struct rtp_header *hdr, struct mbuf *mb, void *arg); typedef void (stream_rtcp_h)(struct rtcp_msg *msg, void *arg); +/** Defines a generic media stream */ +struct stream { + struct le le; /**< Linked list element */ + struct config_avt cfg; /**< Stream configuration */ + struct call *call; /**< Ref. to call object */ + struct sdp_media *sdp; /**< SDP Media line */ + struct rtp_sock *rtp; /**< RTP Socket */ + struct rtpkeep *rtpkeep; /**< RTP Keepalive */ + struct rtcp_stats rtcp_stats;/**< RTCP statistics */ + struct jbuf *jbuf; /**< Jitter Buffer for incoming RTP */ + struct mnat_media *mns; /**< Media NAT traversal state */ + const struct menc *menc; /**< Media encryption module */ + struct menc_sess *mencs; /**< Media encryption session state */ + struct menc_media *mes; /**< Media Encryption media state */ + struct metric metric_tx; /**< Metrics for transmit */ + struct metric metric_rx; /**< Metrics for receiving */ + char *cname; /**< RTCP Canonical end-point identifier */ + uint32_t ssrc_rx; /**< Incoming syncronizing source */ + uint32_t pseq; /**< Sequence number for incoming RTP */ + int pt_enc; /**< Payload type for encoding */ + bool rtcp; /**< Enable RTCP */ + bool rtcp_mux; /**< RTP/RTCP multiplex supported by peer */ + bool jbuf_started; /**< True if jitter-buffer was started */ + stream_rtp_h *rtph; /**< Stream RTP handler */ + stream_rtcp_h *rtcph; /**< Stream RTCP handler */ + void *arg; /**< Handler argument */ +}; + int stream_alloc(struct stream **sp, const struct config_avt *cfg, struct call *call, struct sdp_session *sdp_sess, const char *name, int label, diff --git a/src/stream.c b/src/stream.c index 0825fe9..fcd4da4 100644 --- a/src/stream.c +++ b/src/stream.c @@ -10,46 +10,11 @@ #include "core.h" -#define MAGIC 0x00814ea5 -#include "magic.h" - - enum { RTP_RECV_SIZE = 8192, }; -/** Defines a generic media stream */ -struct stream { - MAGIC_DECL - - struct le le; /**< Linked list element */ - struct config_avt cfg; /**< Stream configuration */ - struct call *call; /**< Ref. to call object */ - struct sdp_media *sdp; /**< SDP Media line */ - struct rtp_sock *rtp; /**< RTP Socket */ - struct rtpkeep *rtpkeep; /**< RTP Keepalive */ - struct rtcp_stats rtcp_stats;/**< RTCP statistics */ - struct jbuf *jbuf; /**< Jitter Buffer for incoming RTP */ - struct mnat_media *mns; /**< Media NAT traversal state */ - const struct menc *menc; /**< Media encryption module */ - struct menc_sess *mencs; /**< Media encryption session state */ - struct menc_media *mes; /**< Media Encryption media state */ - struct metric metric_tx; /**< Metrics for transmit */ - struct metric metric_rx; /**< Metrics for receiving */ - char *cname; /**< RTCP Canonical end-point identifier */ - uint32_t ssrc_rx; /**< Incoming syncronizing source */ - uint32_t pseq; /**< Sequence number for incoming RTP */ - int pt_enc; /**< Payload type for encoding */ - bool rtcp; /**< Enable RTCP */ - bool rtcp_mux; /**< RTP/RTCP multiplex supported by peer */ - bool jbuf_started; /**< True if jitter-buffer was started */ - stream_rtp_h *rtph; /**< Stream RTP handler */ - stream_rtcp_h *rtcph; /**< Stream RTCP handler */ - void *arg; /**< Handler argument */ -}; - - static inline int lostcalc(struct stream *s, uint16_t seq) { const uint16_t delta = seq - s->pseq; @@ -259,8 +224,6 @@ int stream_alloc(struct stream **sp, const struct config_avt *cfg, if (!s) return ENOMEM; - MAGIC_INIT(s); - s->cfg = *cfg; s->call = call; s->rtph = rtph; -- cgit v1.2.3