| | |
| | | import com.genersoft.iot.vmp.conf.DynamicTask; |
| | | import com.genersoft.iot.vmp.conf.UserSetting; |
| | | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| | | import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; |
| | | import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; |
| | | import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager; |
| | | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| | | import com.genersoft.iot.vmp.service.IMediaServerService; |
| | | import com.genersoft.iot.vmp.service.bean.*; |
| | |
| | | import org.springframework.data.redis.connection.MessageListener; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.sip.InvalidArgumentException; |
| | | import javax.sip.SipException; |
| | | import java.text.ParseException; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | |
| | | @Autowired |
| | | private UserSetting userSetting; |
| | | |
| | | @Autowired |
| | | private RedisUtil redis; |
| | | |
| | | @Autowired |
| | | private ZLMMediaListManager zlmMediaListManager; |
| | |
| | | private ZLMMediaListManager mediaListManager; |
| | | |
| | | @Autowired |
| | | private ZLMHttpHookSubscribe subscribe; |
| | | private ZlmHttpHookSubscribe subscribe; |
| | | |
| | | |
| | | public interface PlayMsgCallback{ |
| | |
| | | WvpRedisMsg response = WvpRedisMsg.getResponseInstance(userSetting.getServerId(), toId, |
| | | WvpRedisMsgCmd.REQUEST_PUSH_STREAM, serial, result); |
| | | JSONObject jsonObject = (JSONObject)JSON.toJSON(response); |
| | | redis.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); |
| | | RedisUtil.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); |
| | | } |
| | | |
| | | /** |
| | |
| | | WvpRedisMsgCmd.GET_SEND_ITEM, serial, result); |
| | | |
| | | JSONObject jsonObject = (JSONObject)JSON.toJSON(response); |
| | | redis.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); |
| | | RedisUtil.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); |
| | | return; |
| | | } |
| | | // 确定流是否在线 |
| | |
| | | userSetting.getServerId(), toId, WvpRedisMsgCmd.GET_SEND_ITEM, serial, result |
| | | ); |
| | | JSONObject jsonObject = (JSONObject)JSON.toJSON(response); |
| | | redis.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); |
| | | RedisUtil.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); |
| | | }, userSetting.getPlatformPlayTimeout()); |
| | | |
| | | // 添加订阅 |
| | | JSONObject subscribeKey = new JSONObject(); |
| | | subscribeKey.put("app", content.getApp()); |
| | | subscribeKey.put("stream", content.getStream()); |
| | | subscribeKey.put("regist", true); |
| | | subscribeKey.put("schema", "rtmp"); |
| | | subscribeKey.put("mediaServerId", mediaServerItem.getId()); |
| | | subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey, |
| | | (MediaServerItem mediaServerItemInUse, JSONObject json)->{ |
| | | HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed(content.getApp(), content.getStream(), true, "rtsp", mediaServerItem.getId()); |
| | | |
| | | subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json)->{ |
| | | dynamicTask.stop(taskKey); |
| | | responseSendItem(mediaServerItem, content, toId, serial); |
| | | }); |
| | |
| | | userSetting.getServerId(), toId, WvpRedisMsgCmd.GET_SEND_ITEM, serial, result |
| | | ); |
| | | JSONObject jsonObject = (JSONObject)JSON.toJSON(response); |
| | | redis.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); |
| | | RedisUtil.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); |
| | | } |
| | | |
| | | /** |
| | |
| | | wvpResult.setMsg("timeout"); |
| | | errorCallback.handler(wvpResult); |
| | | }, userSetting.getPlatformPlayTimeout()); |
| | | redis.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); |
| | | RedisUtil.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); |
| | | } |
| | | |
| | | /** |
| | |
| | | callbacksForStartSendRtpStream.remove(key); |
| | | callbacksForError.remove(key); |
| | | }); |
| | | redis.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); |
| | | RedisUtil.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); |
| | | } |
| | | } |