优化点播体验, 优化tcp被动的sdp
parent
7f48246165
commit
d551c82d34
1
pom.xml
1
pom.xml
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
<groupId>com.genersoft</groupId>
|
<groupId>com.genersoft</groupId>
|
||||||
<artifactId>wvp</artifactId>
|
<artifactId>wvp</artifactId>
|
||||||
|
<version>2.0.0</version>
|
||||||
<name>web video platform</name>
|
<name>web video platform</name>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
|
|
@ -91,6 +91,9 @@ public class SIPCommander implements ISIPCommander {
|
||||||
@Value("${media.autoApplyPlay}")
|
@Value("${media.autoApplyPlay}")
|
||||||
private boolean autoApplyPlay;
|
private boolean autoApplyPlay;
|
||||||
|
|
||||||
|
@Value("${userSettings.waitTrack}")
|
||||||
|
private boolean waitTrack;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ZLMHttpHookSubscribe subscribe;
|
private ZLMHttpHookSubscribe subscribe;
|
||||||
|
|
||||||
|
@ -376,7 +379,7 @@ public class SIPCommander implements ISIPCommander {
|
||||||
subscribeKey.put("regist", true);
|
subscribeKey.put("regist", true);
|
||||||
|
|
||||||
subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey, json->{
|
subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey, json->{
|
||||||
if (json.getJSONArray("tracks") == null) return;
|
if (waitTrack && json.getJSONArray("tracks") == null) return;
|
||||||
event.response(json);
|
event.response(json);
|
||||||
subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey);
|
subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey);
|
||||||
});
|
});
|
||||||
|
@ -426,12 +429,6 @@ public class SIPCommander implements ISIPCommander {
|
||||||
content.append("a=rtpmap:96 PS/90000\r\n");
|
content.append("a=rtpmap:96 PS/90000\r\n");
|
||||||
content.append("a=rtpmap:98 H264/90000\r\n");
|
content.append("a=rtpmap:98 H264/90000\r\n");
|
||||||
content.append("a=rtpmap:97 MPEG4/90000\r\n");
|
content.append("a=rtpmap:97 MPEG4/90000\r\n");
|
||||||
if("TCP-PASSIVE".equals(streamMode)) { // tcp被动模式
|
|
||||||
content.append("a=setup:passive\r\n");
|
|
||||||
content.append("a=recvonly\r\n");
|
|
||||||
content.append("a=rtpmap:96 PS/90000\r\n");
|
|
||||||
content.append("a=rtpmap:98 H264/90000\r\n");
|
|
||||||
content.append("a=rtpmap:97 MPEG4/90000\r\n");
|
|
||||||
if ("TCP-PASSIVE".equals(streamMode)) { // tcp被动模式
|
if ("TCP-PASSIVE".equals(streamMode)) { // tcp被动模式
|
||||||
content.append("a=setup:passive\r\n");
|
content.append("a=setup:passive\r\n");
|
||||||
content.append("a=connection:new\r\n");
|
content.append("a=connection:new\r\n");
|
||||||
|
@ -440,7 +437,6 @@ public class SIPCommander implements ISIPCommander {
|
||||||
content.append("a=connection:new\r\n");
|
content.append("a=connection:new\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
content.append("y="+ssrc+"\r\n");//ssrc
|
content.append("y="+ssrc+"\r\n");//ssrc
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import gov.nist.javax.sip.stack.SIPDialog;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.context.request.async.DeferredResult;
|
import org.springframework.web.context.request.async.DeferredResult;
|
||||||
|
@ -58,6 +59,9 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private VideoStreamSessionManager streamSession;
|
private VideoStreamSessionManager streamSession;
|
||||||
|
|
||||||
|
@Value("${userSettings.playTimeout}")
|
||||||
|
private long playTimeout;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlayResult play(String deviceId, String channelId, ZLMHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent) {
|
public PlayResult play(String deviceId, String channelId, ZLMHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent) {
|
||||||
|
@ -67,7 +71,7 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
playResult.setDevice(device);
|
playResult.setDevice(device);
|
||||||
UUID uuid = UUID.randomUUID();
|
UUID uuid = UUID.randomUUID();
|
||||||
playResult.setUuid(uuid.toString());
|
playResult.setUuid(uuid.toString());
|
||||||
DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>();
|
DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(playTimeout);
|
||||||
playResult.setResult(result);
|
playResult.setResult(result);
|
||||||
// 录像查询以channelId作为deviceId查询
|
// 录像查询以channelId作为deviceId查询
|
||||||
resultHolder.put(DeferredResultHolder.CALLBACK_CMD_PlAY + uuid, result);
|
resultHolder.put(DeferredResultHolder.CALLBACK_CMD_PlAY + uuid, result);
|
||||||
|
|
|
@ -100,6 +100,10 @@ logging:
|
||||||
userSettings:
|
userSettings:
|
||||||
# 保存移动位置历史轨迹:true:保留历史数据,false:仅保留最后的位置(默认)
|
# 保存移动位置历史轨迹:true:保留历史数据,false:仅保留最后的位置(默认)
|
||||||
savePositionHistory: false
|
savePositionHistory: false
|
||||||
|
# 点播等待超时时间,单位:毫秒
|
||||||
|
playTimeout: 3000
|
||||||
|
# 等待音视频编码信息再返回, true: 可以根据编码选择合适的播放器,false: 可以更快点播
|
||||||
|
waitTrack: false
|
||||||
|
|
||||||
# 在线文档: swagger-ui(生产环境建议关闭)
|
# 在线文档: swagger-ui(生产环境建议关闭)
|
||||||
springfox:
|
springfox:
|
||||||
|
|
Loading…
Reference in New Issue