sdp 测试
This commit is contained in:
parent
39feebece9
commit
60df3e396f
@ -0,0 +1,24 @@
|
||||
package cn.skcks.docking.gb28181.core.sip.gb28181.sdp;
|
||||
|
||||
import javax.sdp.SessionDescription;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MediaSdpHelper {
|
||||
public static final Map<String, String> RTPMAP = new HashMap<>() {{
|
||||
put("96", "PS/90000");
|
||||
put("126", "H264/90000");
|
||||
put("125", "H264S/90000");
|
||||
put("99", "H265/90000");
|
||||
put("98", "H264/90000");
|
||||
put("97", "MPEG4/90000");
|
||||
}};
|
||||
public static final Map<String, String> FMTP = new HashMap<>() {{
|
||||
put("126", "profile-level-id=42e01e");
|
||||
put("125", "profile-level-id=42e01e");
|
||||
}};
|
||||
|
||||
public SessionDescription build(String deviceId, String channelId, String rtpIp, int rtpPort, String streamMode){
|
||||
return null;
|
||||
}
|
||||
}
|
@ -12,6 +12,10 @@ import cn.skcks.docking.gb28181.media.proxy.ZlmMediaService;
|
||||
import cn.skcks.docking.gb28181.orm.mybatis.dynamic.model.DockingDevice;
|
||||
import cn.skcks.docking.gb28181.service.docking.device.DockingDeviceService;
|
||||
import cn.skcks.docking.gb28181.service.ssrc.SsrcService;
|
||||
import gov.nist.javax.sdp.fields.SDPField;
|
||||
import gov.nist.javax.sdp.fields.SDPFormat;
|
||||
import gov.nist.javax.sdp.fields.SDPObject;
|
||||
import gov.nist.javax.sdp.parser.SDPParser;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -75,6 +79,8 @@ public class PlayService {
|
||||
sb.append("v=0\r\n");
|
||||
sb.append("o=").append(channelId).append(" 0 0 IN IP4 ").append(ip).append("\r\n");
|
||||
|
||||
// new SDPField();
|
||||
|
||||
return result;
|
||||
// zlmMediaService.getRtpInfo();
|
||||
// GetMediaList getMediaList = new GetMediaList();
|
||||
|
@ -1,9 +1,18 @@
|
||||
package cn.skcks.docking.gb28181.core.sip.message.event;
|
||||
|
||||
import cn.skcks.docking.gb28181.core.sip.gb28181.sdp.MediaSdpHelper;
|
||||
import gov.nist.core.NameValue;
|
||||
import gov.nist.core.Separators;
|
||||
import gov.nist.javax.sdp.MediaDescriptionImpl;
|
||||
import gov.nist.javax.sdp.SessionDescriptionImpl;
|
||||
import gov.nist.javax.sdp.fields.*;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.sdp.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@ -23,6 +32,7 @@ public class SipEventTest {
|
||||
List<String> list = new ArrayList<>();
|
||||
Flow.Subscriber<String> subscriber = new Flow.Subscriber<>() {
|
||||
Flow.Subscription subscription;
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Flow.Subscription subscription) {
|
||||
this.subscription = subscription;
|
||||
@ -52,7 +62,7 @@ public class SipEventTest {
|
||||
|
||||
AtomicInteger finalI = new AtomicInteger(1);
|
||||
|
||||
new Thread(()->{
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
@ -77,6 +87,7 @@ public class SipEventTest {
|
||||
CountDownLatch countDownLatch2 = new CountDownLatch(1);
|
||||
submissionPublisher.subscribe(new Flow.Subscriber<>() {
|
||||
Flow.Subscription subscription;
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Flow.Subscription subscription) {
|
||||
this.subscription = subscription;
|
||||
@ -104,4 +115,46 @@ public class SipEventTest {
|
||||
countDownLatch2.await();
|
||||
executor.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
public void sdpTest() {
|
||||
SessionDescription sessionDescription = SdpFactory.getInstance().createSessionDescription("Play");
|
||||
Version version = SdpFactory.getInstance().createVersion(0);
|
||||
sessionDescription.setVersion(version);
|
||||
|
||||
Connection connectionField = SdpFactory.getInstance().createConnection(ConnectionField.IN, Connection.IP4, "10.10.10.20");
|
||||
sessionDescription.setConnection(connectionField);
|
||||
|
||||
MediaDescription mediaDescription = SdpFactory.getInstance().createMediaDescription("video", 6666, 0, SdpConstants.RTP_AVP, MediaSdpHelper.RTPMAP.keySet().toArray(new String[0]));
|
||||
mediaDescription.addAttribute((AttributeField)SdpFactory.getInstance().createAttribute("recvonly",null));
|
||||
MediaSdpHelper.RTPMAP.forEach((k, v)->{
|
||||
Optional.ofNullable(MediaSdpHelper.FMTP.get(k)).ifPresent((f)->{
|
||||
mediaDescription.addAttribute((AttributeField) SdpFactory.getInstance().createAttribute(SdpConstants.FMTP.toLowerCase(), StringUtils.joinWith(Separators.SP,k,f)));
|
||||
});
|
||||
mediaDescription.addAttribute((AttributeField) SdpFactory.getInstance().createAttribute(SdpConstants.RTPMAP, StringUtils.joinWith(Separators.SP,k,v)));
|
||||
});
|
||||
|
||||
// TCP-PASSIVE
|
||||
mediaDescription.addAttribute((AttributeField)SdpFactory.getInstance().createAttribute("setup","passive"));
|
||||
mediaDescription.addAttribute((AttributeField)SdpFactory.getInstance().createAttribute("connection","new"));
|
||||
|
||||
// TCP-ACTIVE
|
||||
mediaDescription.addAttribute((AttributeField)SdpFactory.getInstance().createAttribute("setup","active"));
|
||||
mediaDescription.addAttribute((AttributeField)SdpFactory.getInstance().createAttribute("connection","new"));
|
||||
|
||||
sessionDescription.setMediaDescriptions(new Vector<>() {{
|
||||
add(mediaDescription);
|
||||
}});
|
||||
|
||||
TimeDescription timeDescription = SdpFactory.getInstance().createTimeDescription();
|
||||
sessionDescription.setTimeDescriptions(new Vector<>(){{add(timeDescription);}});
|
||||
|
||||
// channelId
|
||||
Origin origin = SdpFactory.getInstance().createOrigin("44050100001310000006", 0, 0, ConnectionField.IN, Connection.IP4, "10.10.10.20");
|
||||
sessionDescription.setOrigin(origin);
|
||||
// mediaDescription.setPreconditionFields();
|
||||
|
||||
log.info("\n{}", sessionDescription);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user