提交 d1e529ae authored 作者: Anthony Minessale's avatar Anthony Minessale

Add new hard_mute control to allow apps to request low level mute e.g. from the…

Add new hard_mute control to allow apps to request low level mute e.g. from the rtp stack level.  Its used in mod_conference to avoid reading audio while muted and possibly reduce some transcoding load
上级 0386db7d
......@@ -216,6 +216,7 @@ SWITCH_DECLARE(void) switch_core_media_set_udptl_image_sdp(switch_core_session_t
SWITCH_DECLARE(switch_core_media_params_t *) switch_core_media_get_mparams(switch_media_handle_t *smh);
SWITCH_DECLARE(void) switch_core_media_prepare_codecs(switch_core_session_t *session, switch_bool_t force);
SWITCH_DECLARE(void) switch_core_media_start_udptl(switch_core_session_t *session, switch_t38_options_t *t38_options);
SWITCH_DECLARE(void) switch_core_media_hard_mute(switch_core_session_t *session, switch_bool_t on);
SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg);
......
......@@ -727,6 +727,7 @@ typedef enum {
SWITCH_RTP_FLAG_FIR,
SWITCH_RTP_FLAG_PLI,
SWITCH_RTP_FLAG_RESET,
SWITCH_RTP_FLAG_MUTE,
SWITCH_RTP_FLAG_INVALID
} switch_rtp_flag_t;
......@@ -1039,6 +1040,7 @@ typedef enum {
SWITCH_MESSAGE_INDICATE_STUN_ERROR,
SWITCH_MESSAGE_INDICATE_MEDIA_RENEG,
SWITCH_MESSAGE_INDICATE_KEEPALIVE,
SWITCH_MESSAGE_INDICATE_HARD_MUTE,
SWITCH_MESSAGE_REFER_EVENT,
SWITCH_MESSAGE_ANSWER_EVENT,
SWITCH_MESSAGE_PROGRESS_EVENT,
......
......@@ -6139,6 +6139,10 @@ static switch_status_t conf_api_sub_mute(conference_member_t *member, switch_str
switch_clear_flag_locked(member, MFLAG_CAN_SPEAK);
switch_clear_flag_locked(member, MFLAG_TALKING);
if (member->session && !switch_test_flag(member, MFLAG_INDICATE_MUTE)) {
switch_core_media_hard_mute(member->session, SWITCH_TRUE);
}
if (!(data) || !strstr((char *) data, "quiet")) {
switch_set_flag(member, MFLAG_INDICATE_MUTE);
}
......@@ -6232,6 +6236,11 @@ static switch_status_t conf_api_sub_unmute(conference_member_t *member, switch_s
return SWITCH_STATUS_GENERR;
switch_set_flag_locked(member, MFLAG_CAN_SPEAK);
if (member->session && !switch_test_flag(member, MFLAG_INDICATE_MUTE)) {
switch_core_media_hard_mute(member->session, SWITCH_FALSE);
}
if (!(data) || !strstr((char *) data, "quiet")) {
switch_set_flag(member, MFLAG_INDICATE_UNMUTE);
}
......@@ -9264,6 +9273,11 @@ SWITCH_STANDARD_APP(conference_function)
/* no conference yet, so check for join-only flag */
if (flags_str) {
set_mflags(flags_str,&mflags);
if (!(mflags & MFLAG_CAN_SPEAK) && (mflags & MFLAG_INDICATE_MUTE)) {
switch_core_media_hard_mute(session, SWITCH_TRUE);
}
if (mflags & MFLAG_JOIN_ONLY) {
switch_event_t *event;
switch_xml_t jos_xml;
......
......@@ -7656,8 +7656,17 @@ SWITCH_DECLARE(void) switch_core_media_start_udptl(switch_core_session_t *sessio
}
}
//?
SWITCH_DECLARE(void) switch_core_media_hard_mute(switch_core_session_t *session, switch_bool_t on)
{
switch_core_session_message_t msg = { 0 };
msg.from = __FILE__;
msg.message_id = SWITCH_MESSAGE_INDICATE_HARD_MUTE;
msg.numeric_arg = on;
switch_core_session_receive_message(session, &msg);
}
//?
......@@ -7718,6 +7727,22 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se
}
}
break;
case SWITCH_MESSAGE_INDICATE_HARD_MUTE:
{
if (a_engine->rtp_session) {
if (msg->numeric_arg) {
switch_rtp_set_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_MUTE);
} else {
switch_rtp_clear_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_MUTE);
}
rtp_flush_read_buffer(a_engine->rtp_session, SWITCH_RTP_FLUSH_ONCE);
}
}
break;
case SWITCH_MESSAGE_INDICATE_DEBUG_MEDIA:
{
switch_rtp_t *rtp = a_engine->rtp_session;
......
......@@ -5915,6 +5915,10 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
result_continue:
timer_check:
if (rtp_session->flags[SWITCH_RTP_FLAG_MUTE]) {
do_cng++;
}
if (do_cng) {
uint8_t *data = (uint8_t *) RTP_BODY(rtp_session);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论