1 Star 0 Fork 1

waxl / janus-gateway-patch

forked from ubonass / janus-gateway-patch 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0001.janus-gateway-audiobrdige-using_data_channel_notify_audio_level-v0.9.5 4.26 KB
一键复制 编辑 Web IDE 原始数据 按行查看 历史
diff --git a/plugins/janus_audiobridge.c b/plugins/janus_audiobridge.c
old mode 100644
new mode 100755
index 92324d34..12ba0fb5
--- a/plugins/janus_audiobridge.c
+++ b/plugins/janus_audiobridge.c
@@ -2319,6 +2319,40 @@ static void janus_audiobridge_notify_participants(janus_audiobridge_participant
}
}
+//add by jeffrey
+typedef struct audio_level audio_level_t;
+struct audio_level {
+ gchar user_id[128];
+ //gchar room_id[128];
+ gboolean talking;
+ int dBov_level;
+};
+
+static void janus_audiobridge_audio_level_notify_participants(
+ janus_audiobridge_participant *participant, audio_level_t *audio_level)
+{
+ /* participant->room->participants_mutex has to be locked. */
+ GHashTableIter iter;
+ gpointer value;
+ g_hash_table_iter_init(&iter, participant->room->participants);
+
+ while(!participant->room->destroyed && g_hash_table_iter_next(&iter, NULL, &value)) {
+ janus_audiobridge_participant *p = value;
+ if(p && p->session && p != participant) {
+ JANUS_LOG(LOG_VERB, "Notifying participant %s (%s)\n", p->user_id_str, p->display ? p->display : "??");
+ //int ret = gateway->push_event(p->session->handle, &janus_audiobridge_plugin, NULL, msg, NULL);
+ /* Forward the packet to the peer */
+ janus_plugin_data r = {
+ .label = NULL,
+ .binary = TRUE,
+ .buffer = (char*)audio_level,
+ .length = sizeof(audio_level_t)
+ };
+ gateway->relay_data(p->session->handle, &r);
+ }
+ }
+}
+
json_t *janus_audiobridge_query_session(janus_plugin_session *handle) {
if(g_atomic_int_get(&stopping) || !g_atomic_int_get(&initialized)) {
return NULL;
@@ -4605,6 +4639,10 @@ void janus_audiobridge_incoming_rtp(janus_plugin_session *handle, janus_plugin_r
participant->audio_dBov_sum += level;
participant->audio_active_packets++;
participant->dBov_level = level;
+
+ //JANUS_LOG(LOG_ERR, "user_id_str = %s, participant->dBov_level = %d\n",
+ // participant->user_id_str,participant->dBov_level);
+
if(participant->audio_active_packets > 0 && participant->audio_active_packets == audio_active_packets) {
gboolean notify_talk_event = FALSE;
if((float) participant->audio_dBov_sum / (float) participant->audio_active_packets < audio_level_average) {
@@ -4620,8 +4658,10 @@ void janus_audiobridge_incoming_rtp(janus_plugin_session *handle, janus_plugin_r
}
participant->audio_active_packets = 0;
participant->audio_dBov_sum = 0;
+
/* Only notify in case of state changes */
if(participant->room && notify_talk_event) {
+ #if 0
janus_mutex_lock(&participant->room->mutex);
json_t *event = json_object();
json_object_set_new(event, "audiobridge", json_string(participant->talking ? "talking" : "stopped-talking"));
@@ -4644,6 +4684,19 @@ void janus_audiobridge_incoming_rtp(janus_plugin_session *handle, janus_plugin_r
string_ids ? json_string(participant->user_id_str) : json_integer(participant->user_id));
gateway->notify_event(&janus_audiobridge_plugin, session->handle, info);
}
+ #else
+ //add by jeffrey
+ janus_mutex_lock(&participant->room->mutex);
+ audio_level_t audio_level_info;
+ audio_level_info.dBov_level = participant->dBov_level;
+ audio_level_info.talking = participant->talking;
+ memcpy(audio_level_info.user_id, participant->user_id_str,strlen(participant->user_id_str));
+ audio_level_info.user_id[strlen(participant->user_id_str)] = '\n';
+ //memcpy(audio_level_info.room_id, participant->room->room_id_str,strlen(participant->room->room_id_str));
+ //audio_level_info.room_id[strlen(participant->room->room_id_str)] = '\n';
+ janus_mutex_unlock(&participant->room->mutex);
+ janus_audiobridge_audio_level_notify_participants(participant,&audio_level_info);
+ #endif
}
}
}
@@ -6104,7 +6157,7 @@ static void *janus_audiobridge_handler(void *data) {
/* Reject video and data channels, if offered */
JANUS_SDP_OA_AUDIO_CODEC, janus_audiocodec_name(participant->codec),
JANUS_SDP_OA_VIDEO, FALSE,
- JANUS_SDP_OA_DATA, FALSE,
+ JANUS_SDP_OA_DATA, TRUE,//modify by jeffrey
JANUS_SDP_OA_ACCEPT_EXTMAP, JANUS_RTP_EXTMAP_MID,
JANUS_SDP_OA_ACCEPT_EXTMAP, JANUS_RTP_EXTMAP_AUDIO_LEVEL,
JANUS_SDP_OA_DONE);
1
https://gitee.com/doibest/janus-gateway-patch.git
git@gitee.com:doibest/janus-gateway-patch.git
doibest
janus-gateway-patch
janus-gateway-patch
master

搜索帮助

14c37bed 8189591 565d56ea 8189591