[+] Mediasoup

This commit is contained in:
acgist
2023-02-02 17:03:01 +08:00
parent 03f34ca888
commit de7e15f6e5
233 changed files with 1860 additions and 985 deletions

View File

@@ -0,0 +1,34 @@
# 媒体
# WebRTC
## WebRTC协议栈
```
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| HTTPS / WSS | | SCTP | SRTP / SRTCP |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ICE / SDP / SIP +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| TLS | | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ DTLS +-+-+-+-+-+-+-+-+-+
| HTTP / WS | NAT / STUN / TURN | | RTP / RTCP |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| TCP | UDP |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| IPv4 / IPv6 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
```
## 协议简介
* 会话通道ICE/SIP/SDP
* 媒体通道RTP/RTCP/SRTP/SRTCP
* RTP实时传输协议音频视频
* RTCPRTP传输控制协议监控数据传输质量并给予数据发送方反馈
* SCTP流控制传输协议自定义的应用数据传输
* RTMP实时消息传送协议
* RTSP可以控制媒体点播
### ICE/SDP/SIP
ICE信息的描述格式通常采用标准的SDP其全称为Session Description Protocol即会话描述协议。<br />
SDP只是一种信息格式的描述标准不属于传输协议但是可以被其他传输协议用来交换必要的信息例如SIP、RTSP等等。

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.acgist</groupId>
<artifactId>taoyao</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>taoyao-media</artifactId>
<packaging>jar</packaging>
<name>taoyao-media</name>
<description>媒体录制、音频降噪、混音、变声、视频水印、美颜、AI识别</description>
<dependencies>
<dependency>
<groupId>com.acgist</groupId>
<artifactId>taoyao-signal</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,35 @@
package com.acgist.taoyao.media.listener;
import java.util.Map;
import com.acgist.taoyao.boot.annotation.EventListener;
import com.acgist.taoyao.boot.model.Message;
import com.acgist.taoyao.signal.event.media.MediaAnswerEvent;
import com.acgist.taoyao.signal.listener.MediaListenerAdapter;
import lombok.extern.slf4j.Slf4j;
/**
* Answer监听
*
* @author acgist
*/
@Slf4j
@EventListener
public class MediaAnswerListener extends MediaListenerAdapter<MediaAnswerEvent> {
@Override
public void onApplicationEvent(MediaAnswerEvent event) {
final String sn = event.getSn();
final String to = event.getTo();
if(sn.equals(to)) {
log.debug("忽略Answer消息相同终端{}-{}", sn, to);
return;
}
final Message message = event.getMessage();
final Map<String, Object> mergeBody = event.mergeBody();
mergeBody.put("from", sn);
this.clientSessionManager.unicast(to, message);
}
}

View File

@@ -0,0 +1,35 @@
package com.acgist.taoyao.media.listener;
import java.util.Map;
import com.acgist.taoyao.boot.annotation.EventListener;
import com.acgist.taoyao.boot.model.Message;
import com.acgist.taoyao.signal.event.media.MediaCandidateEvent;
import com.acgist.taoyao.signal.listener.MediaListenerAdapter;
import lombok.extern.slf4j.Slf4j;
/**
* 候选监听
*
* @author acgist
*/
@Slf4j
@EventListener
public class MediaCandidateListener extends MediaListenerAdapter<MediaCandidateEvent> {
@Override
public void onApplicationEvent(MediaCandidateEvent event) {
final String sn = event.getSn();
final String to = event.getTo();
if(sn.equals(to)) {
log.debug("忽略候选消息(相同终端):{}-{}", sn, to);
return;
}
final Message message = event.getMessage();
final Map<String, Object> mergeBody = event.mergeBody();
mergeBody.put("from", sn);
this.clientSessionManager.unicast(to, message);
}
}

View File

@@ -0,0 +1,35 @@
package com.acgist.taoyao.media.listener;
import java.util.Map;
import com.acgist.taoyao.boot.annotation.EventListener;
import com.acgist.taoyao.boot.model.Message;
import com.acgist.taoyao.signal.event.media.MediaOfferEvent;
import com.acgist.taoyao.signal.listener.MediaListenerAdapter;
import lombok.extern.slf4j.Slf4j;
/**
* Offer监听
*
* @author acgist
*/
@Slf4j
@EventListener
public class MediaOfferListener extends MediaListenerAdapter<MediaOfferEvent> {
@Override
public void onApplicationEvent(MediaOfferEvent event) {
final String sn = event.getSn();
final String to = event.getTo();
if(sn.equals(to)) {
log.debug("忽略Offer消息相同终端{}-{}", sn, to);
return;
}
final Message message = event.getMessage();
final Map<String, Object> mergeBody = event.mergeBody();
mergeBody.put("from", sn);
this.clientSessionManager.unicast(to, message);
}
}

View File

@@ -0,0 +1,35 @@
package com.acgist.taoyao.media.listener;
import java.util.Map;
import com.acgist.taoyao.boot.annotation.EventListener;
import com.acgist.taoyao.boot.model.Message;
import com.acgist.taoyao.signal.event.media.MediaPublishEvent;
import com.acgist.taoyao.signal.listener.MediaListenerAdapter;
import lombok.extern.slf4j.Slf4j;
/**
* 发布监听
*
* @author acgist
*/
@Slf4j
@EventListener
public class MediaPublishListener extends MediaListenerAdapter<MediaPublishEvent> {
@Override
public void onApplicationEvent(MediaPublishEvent event) {
final String sn = event.getSn();
final String to = event.getTo();
if(sn.equals(to)) {
log.debug("忽略发布消息(相同终端):{}-{}", sn, to);
return;
}
final Message message = event.getMessage();
final Map<String, Object> mergeBody = event.mergeBody();
mergeBody.put("from", sn);
this.clientSessionManager.unicast(to, message);
}
}

View File

@@ -0,0 +1,35 @@
package com.acgist.taoyao.media.listener;
import java.util.Map;
import com.acgist.taoyao.boot.annotation.EventListener;
import com.acgist.taoyao.boot.model.Message;
import com.acgist.taoyao.signal.event.media.MediaSubscribeEvent;
import com.acgist.taoyao.signal.listener.MediaListenerAdapter;
import lombok.extern.slf4j.Slf4j;
/**
* 订阅监听
*
* @author acgist
*/
@Slf4j
@EventListener
public class MediaSubscribeListener extends MediaListenerAdapter<MediaSubscribeEvent> {
@Override
public void onApplicationEvent(MediaSubscribeEvent event) {
final String sn = event.getSn();
final String to = event.getTo();
if(sn.equals(to)) {
log.debug("忽略订阅消息(相同终端):{}-{}", sn, to);
return;
}
final Message message = event.getMessage();
final Map<String, Object> mergeBody = event.mergeBody();
mergeBody.put("from", sn);
this.clientSessionManager.unicast(to, message);
}
}

View File

@@ -0,0 +1,5 @@
package com.acgist.taoyao.media.processor;
public class MediaAggregateProcessor {
}

View File

@@ -0,0 +1,10 @@
package com.acgist.taoyao.media.processor;
/**
* 并行媒体处理器
*
* @author acgist
*/
public class MediaParallelProcessor {
}

View File

@@ -0,0 +1,5 @@
package com.acgist.taoyao.media.processor;
public class MediaRecordProcessor {
}

View File

@@ -0,0 +1,10 @@
package com.acgist.taoyao.media.processor.audio;
/**
* 降噪
*
* @author acgist
*/
public class MediaDenoiseProcessor {
}

View File

@@ -0,0 +1,10 @@
package com.acgist.taoyao.media.processor.audio;
/**
* 混音
*
* @author acgist
*/
public class MediaMixProcessor {
}

View File

@@ -0,0 +1,10 @@
package com.acgist.taoyao.media.processor.audio;
/**
* 变声器
*
* @author acgist
*/
public class MediaWhineProcessor {
}

View File

@@ -0,0 +1,10 @@
package com.acgist.taoyao.media.processor.video;
/**
* 美颜
*
* @author acgist
*/
public class MediaBeautyProcessor {
}

View File

@@ -0,0 +1,10 @@
package com.acgist.taoyao.media.processor.video;
/**
* AI识别
*
* @author acgist
*/
public class MediaMarkHandler {
}

View File

@@ -0,0 +1,10 @@
package com.acgist.taoyao.media.processor.video;
/**
* 水印
*
* @author acgist
*/
public class MediaWatermarkHandler {
}