[*] 日常优化
This commit is contained in:
@@ -783,6 +783,7 @@ public final class Taoyao implements ITaoyao {
|
|||||||
private void controlConfigAudio(Message message, Map<String, Object> body) {
|
private void controlConfigAudio(Message message, Map<String, Object> body) {
|
||||||
final MediaAudioProperties mediaAudioProperties = JSONUtils.toJava(JSONUtils.toJSON(body), MediaAudioProperties.class);
|
final MediaAudioProperties mediaAudioProperties = JSONUtils.toJava(JSONUtils.toJSON(body), MediaAudioProperties.class);
|
||||||
this.mediaManager.updateAudioConfig(mediaAudioProperties);
|
this.mediaManager.updateAudioConfig(mediaAudioProperties);
|
||||||
|
this.push(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -794,6 +795,7 @@ public final class Taoyao implements ITaoyao {
|
|||||||
private void controlConfigVideo(Message message, Map<String, Object> body) {
|
private void controlConfigVideo(Message message, Map<String, Object> body) {
|
||||||
final MediaVideoProperties mediaVideoProperties = JSONUtils.toJava(JSONUtils.toJSON(body), MediaVideoProperties.class);
|
final MediaVideoProperties mediaVideoProperties = JSONUtils.toJava(JSONUtils.toJSON(body), MediaVideoProperties.class);
|
||||||
this.mediaManager.updateVideoConfig(mediaVideoProperties);
|
this.mediaManager.updateVideoConfig(mediaVideoProperties);
|
||||||
|
this.push(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -274,11 +274,9 @@ class Room {
|
|||||||
const me = this;
|
const me = this;
|
||||||
// 静音监控
|
// 静音监控
|
||||||
me.audioLevelObserver.on("silence", () => {
|
me.audioLevelObserver.on("silence", () => {
|
||||||
signalChannel.push(
|
signalChannel.push(protocol.buildMessage("media::audio::volume", {
|
||||||
protocol.buildMessage("media::audio::volume", {
|
|
||||||
roomId: me.roomId,
|
roomId: me.roomId,
|
||||||
})
|
}));
|
||||||
);
|
|
||||||
});
|
});
|
||||||
// me.audioLevelObserver.observer.on("silence", () => {});
|
// me.audioLevelObserver.observer.on("silence", () => {});
|
||||||
// 音量监控
|
// 音量监控
|
||||||
@@ -291,12 +289,10 @@ class Room {
|
|||||||
clientId: producer.clientId
|
clientId: producer.clientId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
signalChannel.push(
|
signalChannel.push(protocol.buildMessage("media::audio::volume", {
|
||||||
protocol.buildMessage("media::audio::volume", {
|
|
||||||
roomId : me.roomId,
|
roomId : me.roomId,
|
||||||
volumes: notifyVolumes
|
volumes: notifyVolumes
|
||||||
})
|
}));
|
||||||
);
|
|
||||||
});
|
});
|
||||||
// me.audioLevelObserver.observer.on("volumes", (volumes) => {});
|
// me.audioLevelObserver.observer.on("volumes", (volumes) => {});
|
||||||
}
|
}
|
||||||
@@ -702,8 +698,9 @@ class Taoyao {
|
|||||||
}
|
}
|
||||||
if(videoConsumer) {
|
if(videoConsumer) {
|
||||||
await videoConsumer.resume();
|
await videoConsumer.resume();
|
||||||
|
// 请求录像关键帧
|
||||||
|
me.requestKeyFrameForRecord(0, filepath, videoConsumer);
|
||||||
}
|
}
|
||||||
this.requestKeyFrameForRecord(0, filepath, videoConsumer);
|
|
||||||
message.body = {
|
message.body = {
|
||||||
roomId : roomId,
|
roomId : roomId,
|
||||||
audioConsumerId : audioConsumerId,
|
audioConsumerId : audioConsumerId,
|
||||||
@@ -725,9 +722,6 @@ class Taoyao {
|
|||||||
* @param {*} videoConsumer 视频消费者
|
* @param {*} videoConsumer 视频消费者
|
||||||
*/
|
*/
|
||||||
requestKeyFrameForRecord(index, filepath, videoConsumer) {
|
requestKeyFrameForRecord(index, filepath, videoConsumer) {
|
||||||
if(!filepath || !videoConsumer) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const {
|
const {
|
||||||
requestKeyFrameMaxIndex,
|
requestKeyFrameMaxIndex,
|
||||||
requestKeyFrameFileSize
|
requestKeyFrameFileSize
|
||||||
@@ -1715,7 +1709,7 @@ class Taoyao {
|
|||||||
const mediasoupRouter = await mediasoupWorker.createRouter({ mediaCodecs });
|
const mediasoupRouter = await mediasoupWorker.createRouter({ mediaCodecs });
|
||||||
// 音量监控
|
// 音量监控
|
||||||
const audioLevelObserver = await mediasoupRouter.createAudioLevelObserver({
|
const audioLevelObserver = await mediasoupRouter.createAudioLevelObserver({
|
||||||
interval : 2000,
|
interval : 500,
|
||||||
// 范围:-127~0
|
// 范围:-127~0
|
||||||
threshold : -80,
|
threshold : -80,
|
||||||
// 监控数量
|
// 监控数量
|
||||||
|
|||||||
@@ -817,10 +817,10 @@ class Taoyao extends RemoteClient {
|
|||||||
me.defaultMediaConsumerClose(message);
|
me.defaultMediaConsumerClose(message);
|
||||||
break;
|
break;
|
||||||
case "media::consumer::pause":
|
case "media::consumer::pause":
|
||||||
this.defaultMediaConsumerPause(message);
|
me.defaultMediaConsumerPause(message);
|
||||||
break;
|
break;
|
||||||
case "media::consumer::resume":
|
case "media::consumer::resume":
|
||||||
this.defaultMediaConsumerResume(message);
|
me.defaultMediaConsumerResume(message);
|
||||||
break;
|
break;
|
||||||
case "media::data::consumer::close":
|
case "media::data::consumer::close":
|
||||||
me.defaultMediaDataConsumerClose(message);
|
me.defaultMediaDataConsumerClose(message);
|
||||||
@@ -1392,18 +1392,17 @@ class Taoyao extends RemoteClient {
|
|||||||
*/
|
*/
|
||||||
defaultMediaAudioVolume(message) {
|
defaultMediaAudioVolume(message) {
|
||||||
const me = this;
|
const me = this;
|
||||||
const { roomId, volumes } = message.body;
|
const {
|
||||||
// 静音
|
roomId,
|
||||||
if (!volumes || volumes.length <= 0) {
|
volumes
|
||||||
me.volume = 0;
|
} = message.body;
|
||||||
me.remoteClients.forEach(v => {
|
if (volumes && volumes.length > 0) {
|
||||||
v.volume = 0;
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 声音
|
// 声音
|
||||||
volumes.forEach(v => {
|
volumes.forEach(v => {
|
||||||
const { volume, clientId } = v;
|
const {
|
||||||
|
volume,
|
||||||
|
clientId
|
||||||
|
} = v;
|
||||||
if (me.clientId === clientId) {
|
if (me.clientId === clientId) {
|
||||||
me.setVolume(volume);
|
me.setVolume(volume);
|
||||||
} else {
|
} else {
|
||||||
@@ -1411,6 +1410,13 @@ class Taoyao extends RemoteClient {
|
|||||||
remoteClient?.setVolume(volume);
|
remoteClient?.setVolume(volume);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// 静音
|
||||||
|
me.volume = 0;
|
||||||
|
me.remoteClients.forEach(v => {
|
||||||
|
v.volume = 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1900,7 +1906,10 @@ class Taoyao extends RemoteClient {
|
|||||||
console.debug("消费者关闭(无效)", consumer.id, streamId);
|
console.debug("消费者关闭(无效)", consumer.id, streamId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const { spatialLayers, temporalLayers } = mediasoupClient.parseScalabilityMode(
|
const {
|
||||||
|
spatialLayers,
|
||||||
|
temporalLayers
|
||||||
|
} = mediasoupClient.parseScalabilityMode(
|
||||||
consumer.rtpParameters.encodings[0].scalabilityMode
|
consumer.rtpParameters.encodings[0].scalabilityMode
|
||||||
);
|
);
|
||||||
console.debug("时间层空间层", spatialLayers, temporalLayers);
|
console.debug("时间层空间层", spatialLayers, temporalLayers);
|
||||||
|
|||||||
@@ -19,17 +19,17 @@ import com.acgist.taoyao.signal.protocol.ProtocolRoomAdapter;
|
|||||||
@Description(
|
@Description(
|
||||||
body = """
|
body = """
|
||||||
{
|
{
|
||||||
"roomId": "房间ID",
|
"roomId" : "房间ID",
|
||||||
"volumes" : [
|
"volumes" : [
|
||||||
{
|
{
|
||||||
"volume": 音量,
|
"volume" : 音量,
|
||||||
"clientId": "终端ID"
|
"clientId": "终端ID"
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
""",
|
""",
|
||||||
flow = "媒体服务->信令服务->终端"
|
flow = "媒体服务->信令服务-)终端"
|
||||||
)
|
)
|
||||||
public class MediaAudioVolumeProtocol extends ProtocolRoomAdapter {
|
public class MediaAudioVolumeProtocol extends ProtocolRoomAdapter {
|
||||||
|
|
||||||
|
|||||||
@@ -39,14 +39,14 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
""",
|
""",
|
||||||
body = """
|
body = """
|
||||||
{
|
{
|
||||||
"roomId": "房间ID"
|
"roomId" : "房间ID"
|
||||||
"producerId": "生产者ID"
|
"producerId": "生产者ID"
|
||||||
}
|
}
|
||||||
""",
|
""",
|
||||||
flow = {
|
flow = {
|
||||||
"终端-[生产媒体]>信令服务-[其他终端消费])信令服务",
|
"终端-[生产媒体]>信令服务-[消费媒体])信令服务=>信令服务->终端",
|
||||||
"终端-[创建WebRTC消费通道]>信令服务-[消费其他终端])信令服务",
|
"终端-[创建WebRTC通道]>信令服务-[消费媒体])信令服务=>信令服务->终端",
|
||||||
"终端->信令服务->媒体服务=>信令服务->终端->信令服务->媒体服务"
|
"终端->信令服务->媒体服务=>信令服务->终端"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
public class MediaConsumeProtocol extends ProtocolRoomAdapter implements ApplicationListener<MediaConsumeEvent> {
|
public class MediaConsumeProtocol extends ProtocolRoomAdapter implements ApplicationListener<MediaConsumeEvent> {
|
||||||
|
|||||||
Reference in New Issue
Block a user