Selaa lähdekoodia

Merge branch 'refs/heads/master' into dev/master-通道结构重构

# Conflicts:
#	src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
#	src/main/resources/application.yml
648540858 1 vuosi sitten
vanhempi
commit
fe921b860a

+ 2 - 6
doc/_content/introduction/compile.md

@@ -2,12 +2,8 @@
 # 编译
 WVP-PRO不只是实现了国标28181的协议,本身也是一个完整的视频平台。所以对于新手来说,你可能需要一些耐心来完成。遇到问题不要焦躁,你可以
 1. 百度
-2. 如果身边有熟悉java的朋友,可以咨询下朋友;
-3. 来群里(901799015)咨询群友;
-4. 向作者发送邮件648540858@qq.com;
-5. 作者远程支持(有偿)。   
-   如果这些仍不能解决你的问题,那么你可能需要与作者我一起合作完成这个项目,解决你遇到的问题。
-
+2. 加入星球体提问;[知识星球](https://t.zsxq.com/0d8VAD3Dm)
+3. 向作者发送邮件648540858@qq.com,寻求技术支持(有偿);
 
 WVP-PRO使用Spring boot开发,maven管理依赖。对于熟悉spring开发的朋友是很容易进行编译部署以及运行的。  
 下面将提供一种通用方法方便大家运行项目。

+ 15 - 2
src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java

@@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.common.InviteInfo;
 import com.genersoft.iot.vmp.common.InviteSessionStatus;
 import com.genersoft.iot.vmp.common.InviteSessionType;
 import com.genersoft.iot.vmp.common.VideoManagerConstants;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent;
 import com.genersoft.iot.vmp.media.event.media.MediaDepartureEvent;
 import com.genersoft.iot.vmp.service.IInviteStreamService;
@@ -38,6 +39,9 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
     @Autowired
     private IVideoManagerStorage storage;
 
+    @Autowired
+    private UserSetting userSetting;
+
     /**
      * 流到来的处理
      */
@@ -65,7 +69,11 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
     }
     @Override
     public void updateInviteInfo(InviteInfo inviteInfo) {
-        updateInviteInfo(inviteInfo, null);
+        if (InviteSessionStatus.ready == inviteInfo.getStatus()) {
+            updateInviteInfo(inviteInfo, Long.valueOf(userSetting.getPlayTimeout()) * 2);
+        }else {
+            updateInviteInfo(inviteInfo, null);
+        }
     }
 
     @Override
@@ -146,7 +154,12 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
         if (inviteInfoInDb.getSsrcInfo() != null) {
             inviteInfoInDb.getSsrcInfo().setStream(stream);
         }
-        redisTemplate.opsForValue().set(key, inviteInfoInDb);
+        if (InviteSessionStatus.ready == inviteInfo.getStatus()) {
+            redisTemplate.opsForValue().set(key, inviteInfoInDb, userSetting.getPlayTimeout() * 2, TimeUnit.SECONDS);
+        }else {
+            redisTemplate.opsForValue().set(key, inviteInfoInDb);
+        }
+
         return inviteInfoInDb;
     }
 

+ 27 - 16
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java

@@ -461,9 +461,11 @@ public class PlayServiceImpl implements IPlayService {
                      ErrorCallback<Object> callback) {
 
         if (mediaServerItem == null || ssrcInfo == null) {
-            callback.run(InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getCode(),
-                    InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getMsg(),
-                    null);
+            if (callback != null) {
+                callback.run(InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getCode(),
+                        InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getMsg(),
+                        null);
+            }
             return;
         }
         log.info("[点播开始] deviceId: {}, channelId: {},码流类型:{}, 收流端口: {}, 码流:{}, 收流模式:{}, SSRC: {}, SSRC校验:{}",
@@ -475,8 +477,9 @@ public class PlayServiceImpl implements IPlayService {
             // 释放ssrc
             mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
             streamSession.remove(device.getDeviceId(), channel.getDeviceId(), ssrcInfo.getStream());
-
-            callback.run(InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getCode(), "点播端口分配异常", null);
+            if (callback != null) {
+                callback.run(InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getCode(), "点播端口分配异常", null);
+            }
             inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getDeviceId(), null,
                     InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getCode(), "点播端口分配异常", null);
             return;
@@ -496,8 +499,9 @@ public class PlayServiceImpl implements IPlayService {
                 log.info("[点播超时] 收流超时 deviceId: {}, channelId: {},码流:{},端口:{}, SSRC: {}",
                         device.getDeviceId(), channel.getDeviceId(), channel.getStreamIdentification(),
                         ssrcInfo.getPort(), ssrcInfo.getSsrc());
-
-                callback.run(InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode(), InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getMsg(), null);
+                if (callback != null) {
+                    callback.run(InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode(), InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getMsg(), null);
+                }
                 inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getDeviceId(), null,
                         InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode(), InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getMsg(), null);
                 inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channel.getDeviceId());
@@ -533,14 +537,19 @@ public class PlayServiceImpl implements IPlayService {
                 // hook响应
                 StreamInfo streamInfo = onPublishHandlerForPlay(hookData.getMediaServer(), hookData.getMediaInfo(), device.getDeviceId(), channel.getDeviceId());
                 if (streamInfo == null){
-                    callback.run(InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getCode(),
-                            InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getMsg(), null);
+                    if (callback != null) {
+                        callback.run(InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getCode(),
+                                InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getMsg(), null);
+                    }
+
                     inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getDeviceId(), null,
                             InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getCode(),
                             InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getMsg(), null);
                     return;
                 }
-                callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo);
+                if (callback != null) {
+                    callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo);
+                }
                 inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getDeviceId(), null,
                         InviteErrorCode.SUCCESS.getCode(),
                         InviteErrorCode.SUCCESS.getMsg(),
@@ -560,8 +569,9 @@ public class PlayServiceImpl implements IPlayService {
                 mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
 
                 streamSession.remove(device.getDeviceId(), channel.getDeviceId(), ssrcInfo.getStream());
-
-                callback.run(event.statusCode, event.msg, null);
+                if (callback != null) {
+                    callback.run(event.statusCode, event.msg, null);
+                }
                 inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getDeviceId(), null,
                         InviteErrorCode.ERROR_FOR_RESET_SSRC.getCode(),
                         String.format("点播失败, 错误码: %s, %s", event.statusCode, event.msg), null);
@@ -577,10 +587,11 @@ public class PlayServiceImpl implements IPlayService {
             mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
 
             streamSession.remove(device.getDeviceId(), channel.getDeviceId(), ssrcInfo.getStream());
-
-            callback.run(InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getCode(),
-                    InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getMsg(), null);
-            inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getDeviceId(), null,
+            if (callback != null) {
+                callback.run(InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getCode(),
+                        InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getMsg(), null);
+            }
+            inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId(), null,
                     InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getCode(),
                     InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getMsg(), null);