Commit d551c82d34618ca31e2a15b5bc0c51f727084466
1 parent
7f482461
优化点播体验, 优化tcp被动的sdp
Showing
4 changed files
with
19 additions
and
14 deletions
pom.xml
| @@ -11,6 +11,7 @@ | @@ -11,6 +11,7 @@ | ||
| 11 | 11 | ||
| 12 | <groupId>com.genersoft</groupId> | 12 | <groupId>com.genersoft</groupId> |
| 13 | <artifactId>wvp</artifactId> | 13 | <artifactId>wvp</artifactId> |
| 14 | + <version>2.0.0</version> | ||
| 14 | <name>web video platform</name> | 15 | <name>web video platform</name> |
| 15 | 16 | ||
| 16 | <repositories> | 17 | <repositories> |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| @@ -91,6 +91,9 @@ public class SIPCommander implements ISIPCommander { | @@ -91,6 +91,9 @@ public class SIPCommander implements ISIPCommander { | ||
| 91 | @Value("${media.autoApplyPlay}") | 91 | @Value("${media.autoApplyPlay}") |
| 92 | private boolean autoApplyPlay; | 92 | private boolean autoApplyPlay; |
| 93 | 93 | ||
| 94 | + @Value("${userSettings.waitTrack}") | ||
| 95 | + private boolean waitTrack; | ||
| 96 | + | ||
| 94 | @Autowired | 97 | @Autowired |
| 95 | private ZLMHttpHookSubscribe subscribe; | 98 | private ZLMHttpHookSubscribe subscribe; |
| 96 | 99 | ||
| @@ -376,7 +379,7 @@ public class SIPCommander implements ISIPCommander { | @@ -376,7 +379,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 376 | subscribeKey.put("regist", true); | 379 | subscribeKey.put("regist", true); |
| 377 | 380 | ||
| 378 | subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey, json->{ | 381 | subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey, json->{ |
| 379 | - if (json.getJSONArray("tracks") == null) return; | 382 | + if (waitTrack && json.getJSONArray("tracks") == null) return; |
| 380 | event.response(json); | 383 | event.response(json); |
| 381 | subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey); | 384 | subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey); |
| 382 | }); | 385 | }); |
| @@ -426,19 +429,12 @@ public class SIPCommander implements ISIPCommander { | @@ -426,19 +429,12 @@ public class SIPCommander implements ISIPCommander { | ||
| 426 | content.append("a=rtpmap:96 PS/90000\r\n"); | 429 | content.append("a=rtpmap:96 PS/90000\r\n"); |
| 427 | content.append("a=rtpmap:98 H264/90000\r\n"); | 430 | content.append("a=rtpmap:98 H264/90000\r\n"); |
| 428 | content.append("a=rtpmap:97 MPEG4/90000\r\n"); | 431 | content.append("a=rtpmap:97 MPEG4/90000\r\n"); |
| 429 | - if("TCP-PASSIVE".equals(streamMode)) { // tcp被动模式 | 432 | + if ("TCP-PASSIVE".equals(streamMode)) { // tcp被动模式 |
| 430 | content.append("a=setup:passive\r\n"); | 433 | content.append("a=setup:passive\r\n"); |
| 431 | - content.append("a=recvonly\r\n"); | ||
| 432 | - content.append("a=rtpmap:96 PS/90000\r\n"); | ||
| 433 | - content.append("a=rtpmap:98 H264/90000\r\n"); | ||
| 434 | - content.append("a=rtpmap:97 MPEG4/90000\r\n"); | ||
| 435 | - if ("TCP-PASSIVE".equals(streamMode)) { // tcp被动模式 | ||
| 436 | - content.append("a=setup:passive\r\n"); | ||
| 437 | - content.append("a=connection:new\r\n"); | ||
| 438 | - } else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式 | ||
| 439 | - content.append("a=setup:active\r\n"); | ||
| 440 | - content.append("a=connection:new\r\n"); | ||
| 441 | - } | 434 | + content.append("a=connection:new\r\n"); |
| 435 | + } else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式 | ||
| 436 | + content.append("a=setup:active\r\n"); | ||
| 437 | + content.append("a=connection:new\r\n"); | ||
| 442 | } | 438 | } |
| 443 | } | 439 | } |
| 444 | 440 |
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| @@ -22,6 +22,7 @@ import gov.nist.javax.sip.stack.SIPDialog; | @@ -22,6 +22,7 @@ import gov.nist.javax.sip.stack.SIPDialog; | ||
| 22 | import org.slf4j.Logger; | 22 | import org.slf4j.Logger; |
| 23 | import org.slf4j.LoggerFactory; | 23 | import org.slf4j.LoggerFactory; |
| 24 | import org.springframework.beans.factory.annotation.Autowired; | 24 | import org.springframework.beans.factory.annotation.Autowired; |
| 25 | +import org.springframework.beans.factory.annotation.Value; | ||
| 25 | import org.springframework.http.ResponseEntity; | 26 | import org.springframework.http.ResponseEntity; |
| 26 | import org.springframework.stereotype.Service; | 27 | import org.springframework.stereotype.Service; |
| 27 | import org.springframework.web.context.request.async.DeferredResult; | 28 | import org.springframework.web.context.request.async.DeferredResult; |
| @@ -58,6 +59,9 @@ public class PlayServiceImpl implements IPlayService { | @@ -58,6 +59,9 @@ public class PlayServiceImpl implements IPlayService { | ||
| 58 | @Autowired | 59 | @Autowired |
| 59 | private VideoStreamSessionManager streamSession; | 60 | private VideoStreamSessionManager streamSession; |
| 60 | 61 | ||
| 62 | + @Value("${userSettings.playTimeout}") | ||
| 63 | + private long playTimeout; | ||
| 64 | + | ||
| 61 | 65 | ||
| 62 | @Override | 66 | @Override |
| 63 | public PlayResult play(String deviceId, String channelId, ZLMHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent) { | 67 | public PlayResult play(String deviceId, String channelId, ZLMHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent) { |
| @@ -67,7 +71,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -67,7 +71,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 67 | playResult.setDevice(device); | 71 | playResult.setDevice(device); |
| 68 | UUID uuid = UUID.randomUUID(); | 72 | UUID uuid = UUID.randomUUID(); |
| 69 | playResult.setUuid(uuid.toString()); | 73 | playResult.setUuid(uuid.toString()); |
| 70 | - DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(); | 74 | + DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(playTimeout); |
| 71 | playResult.setResult(result); | 75 | playResult.setResult(result); |
| 72 | // 录像查询以channelId作为deviceId查询 | 76 | // 录像查询以channelId作为deviceId查询 |
| 73 | resultHolder.put(DeferredResultHolder.CALLBACK_CMD_PlAY + uuid, result); | 77 | resultHolder.put(DeferredResultHolder.CALLBACK_CMD_PlAY + uuid, result); |
src/main/resources/application-dev.yml
| @@ -100,6 +100,10 @@ logging: | @@ -100,6 +100,10 @@ logging: | ||
| 100 | userSettings: | 100 | userSettings: |
| 101 | # 保存移动位置历史轨迹:true:保留历史数据,false:仅保留最后的位置(默认) | 101 | # 保存移动位置历史轨迹:true:保留历史数据,false:仅保留最后的位置(默认) |
| 102 | savePositionHistory: false | 102 | savePositionHistory: false |
| 103 | + # 点播等待超时时间,单位:毫秒 | ||
| 104 | + playTimeout: 3000 | ||
| 105 | + # 等待音视频编码信息再返回, true: 可以根据编码选择合适的播放器,false: 可以更快点播 | ||
| 106 | + waitTrack: false | ||
| 103 | 107 | ||
| 104 | # 在线文档: swagger-ui(生产环境建议关闭) | 108 | # 在线文档: swagger-ui(生产环境建议关闭) |
| 105 | springfox: | 109 | springfox: |