[+] Mediasoup
This commit is contained in:
34
taoyao-signal/taoyao-media/README.md
Normal file
34
taoyao-signal/taoyao-media/README.md
Normal 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:实时传输协议(音频视频)
|
||||
* RTCP:RTP传输控制协议(监控数据传输质量并给予数据发送方反馈)
|
||||
* SCTP:流控制传输协议(自定义的应用数据传输)
|
||||
* RTMP:实时消息传送协议
|
||||
* RTSP:可以控制媒体(点播)
|
||||
|
||||
### ICE/SDP/SIP
|
||||
|
||||
ICE信息的描述格式通常采用标准的SDP,其全称为Session Description Protocol,即会话描述协议。<br />
|
||||
SDP只是一种信息格式的描述标准,不属于传输协议,但是可以被其他传输协议用来交换必要的信息,例如:SIP、RTSP等等。
|
||||
26
taoyao-signal/taoyao-media/pom.xml
Normal file
26
taoyao-signal/taoyao-media/pom.xml
Normal 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>
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.acgist.taoyao.media.processor;
|
||||
|
||||
public class MediaAggregateProcessor {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.acgist.taoyao.media.processor;
|
||||
|
||||
/**
|
||||
* 并行媒体处理器
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
public class MediaParallelProcessor {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.acgist.taoyao.media.processor;
|
||||
|
||||
public class MediaRecordProcessor {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.acgist.taoyao.media.processor.audio;
|
||||
|
||||
/**
|
||||
* 降噪
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
public class MediaDenoiseProcessor {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.acgist.taoyao.media.processor.audio;
|
||||
|
||||
/**
|
||||
* 混音
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
public class MediaMixProcessor {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.acgist.taoyao.media.processor.audio;
|
||||
|
||||
/**
|
||||
* 变声器
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
public class MediaWhineProcessor {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.acgist.taoyao.media.processor.video;
|
||||
|
||||
/**
|
||||
* 美颜
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
public class MediaBeautyProcessor {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.acgist.taoyao.media.processor.video;
|
||||
|
||||
/**
|
||||
* AI识别
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
public class MediaMarkHandler {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.acgist.taoyao.media.processor.video;
|
||||
|
||||
/**
|
||||
* 水印
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
public class MediaWatermarkHandler {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user