| | |
| | | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
|
| | | import com.genersoft.iot.vmp.gb28181.bean.*;
|
| | | import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
| | | import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
|
| | | import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
| | | import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
|
| | | import com.genersoft.iot.vmp.gb28181.session.SSRCFactory;
|
| | | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
| | | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
| | | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
|
| | | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
| | | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
| | | import com.genersoft.iot.vmp.media.bean.Track;
|
| | | import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
| | | import com.genersoft.iot.vmp.media.zlm.dto.HookType;
|
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
|
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
| | | import com.genersoft.iot.vmp.media.zlm.dto.*;
|
| | | import com.genersoft.iot.vmp.media.zlm.dto.hook.*;
|
| | | import com.genersoft.iot.vmp.media.zlm.event.HookZlmServerKeepaliveEvent;
|
| | | import com.genersoft.iot.vmp.media.zlm.event.HookZlmServerStartEvent;
|
| | | import com.genersoft.iot.vmp.service.*;
|
| | | import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
|
| | | import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
| | |
| | | import com.genersoft.iot.vmp.vmanager.bean.OtherPsSendInfo;
|
| | | import com.genersoft.iot.vmp.vmanager.bean.OtherRtpSendInfo;
|
| | | import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
|
| | | import org.apache.poi.ss.formula.functions.T;
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.beans.factory.annotation.Qualifier;
|
| | | import org.springframework.context.ApplicationEventPublisher;
|
| | | import org.springframework.data.redis.core.RedisTemplate;
|
| | | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
| | | import org.springframework.util.ObjectUtils;
|
| | |
| | |
|
| | | @Autowired
|
| | | private AudioBroadcastManager audioBroadcastManager;
|
| | |
|
| | | @Autowired
|
| | | private ZLMServerFactory zlmServerFactory;
|
| | |
|
| | | @Autowired
|
| | | private IPlayService playService;
|
| | |
| | | private VideoStreamSessionManager sessionManager;
|
| | |
|
| | | @Autowired
|
| | | private AssistRESTfulUtils assistRESTfulUtils;
|
| | |
|
| | | @Autowired
|
| | | private SSRCFactory ssrcFactory;
|
| | |
|
| | | @Qualifier("taskExecutor")
|
| | |
| | | @Autowired
|
| | | private RedisTemplate<Object, Object> redisTemplate;
|
| | |
|
| | | @Autowired
|
| | | private ApplicationEventPublisher applicationEventPublisher;
|
| | |
|
| | | /**
|
| | | * 服务器定时上报时间,上报间隔可配置,默认10s上报一次
|
| | | */
|
| | |
| | |
|
| | | @PostMapping(value = "/on_server_keepalive", produces = "application/json;charset=UTF-8")
|
| | | public HookResult onServerKeepalive(@RequestBody OnServerKeepaliveHookParam param) {
|
| | |
|
| | |
|
| | | taskExecutor.execute(() -> {
|
| | | List<ZlmHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_keepalive);
|
| | | if (subscribes != null && subscribes.size() > 0) {
|
| | |
| | | }
|
| | | }
|
| | | });
|
| | | mediaServerService.updateMediaServerKeepalive(param.getMediaServerId(), param.getData());
|
| | |
|
| | | try {
|
| | | HookZlmServerKeepaliveEvent event = new HookZlmServerKeepaliveEvent(this);
|
| | | MediaServerItem mediaServerItem = mediaServerService.getOne(param.getMediaServerId());
|
| | | if (mediaServerItem != null) {
|
| | | event.setMediaServerItem(mediaServerItem);
|
| | | applicationEventPublisher.publishEvent(event);
|
| | | }
|
| | | }catch (Exception e) {
|
| | | logger.info("[ZLM-HOOK-心跳] 发送通知失败 ", e);
|
| | | }
|
| | | return HookResult.SUCCESS();
|
| | | }
|
| | |
|
| | |
| | | * 播放器鉴权事件,rtsp/rtmp/http-flv/ws-flv/hls的播放都将触发此鉴权事件。
|
| | | */
|
| | | @ResponseBody
|
| | |
|
| | | @PostMapping(value = "/on_play", produces = "application/json;charset=UTF-8")
|
| | | public HookResult onPlay(@RequestBody OnPlayHookParam param) {
|
| | | if (logger.isDebugEnabled()) {
|
| | |
| | | JSONObject json = (JSONObject) JSON.toJSON(param);
|
| | |
|
| | | logger.info("[ZLM HOOK]推流鉴权:{}->{}", param.getMediaServerId(), param);
|
| | | // TODO 加快处理速度
|
| | |
|
| | | String mediaServerId = json.getString("mediaServerId");
|
| | | MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
|
| | |
| | | }
|
| | |
|
| | | List<OnStreamChangedHookParam.MediaTrack> tracks = param.getTracks();
|
| | | Track track = new Track();
|
| | | track.setReaderCount(param.getTotalReaderCount());
|
| | | for (OnStreamChangedHookParam.MediaTrack mediaTrack : tracks) {
|
| | | switch (mediaTrack.getCodec_id()) {
|
| | | case 0:
|
| | | track.setVideoCodec("H264");
|
| | | break;
|
| | | case 1:
|
| | | track.setVideoCodec("H265");
|
| | | break;
|
| | | case 2:
|
| | | track.setAudioCodec("AAC");
|
| | | break;
|
| | | case 3:
|
| | | track.setAudioCodec("G711A");
|
| | | break;
|
| | | case 4:
|
| | | track.setAudioCodec("G711U");
|
| | | break;
|
| | | }
|
| | | if (mediaTrack.getSample_rate() > 0) {
|
| | | track.setAudioSampleRate(mediaTrack.getSample_rate());
|
| | | }
|
| | | if (mediaTrack.getChannels() > 0) {
|
| | | track.setAudioChannels(mediaTrack.getChannels());
|
| | | }
|
| | | if (mediaTrack.getHeight() > 0) {
|
| | | track.setHeight(mediaTrack.getHeight());
|
| | | }
|
| | | if (mediaTrack.getWidth() > 0) {
|
| | | track.setWidth(mediaTrack.getWidth());
|
| | | }
|
| | | }
|
| | | // TODO 重构此处逻辑
|
| | | if (param.isRegist()) {
|
| | | // 处理流注册的鉴权信息, 流注销这里不再删除鉴权信息,下次来了新的鉴权信息会对就的进行覆盖
|
| | |
| | | callId = streamAuthorityInfo.getCallId();
|
| | | }
|
| | | StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaInfo,
|
| | | param.getApp(), param.getStream(), tracks, callId);
|
| | | param.getApp(), param.getStream(), track, callId);
|
| | | param.setStreamInfo(new StreamContent(streamInfoByAppAndStream));
|
| | | redisCatchStorage.addStream(mediaInfo, type, param.getApp(), param.getStream(), param);
|
| | | if (param.getOriginType() == OriginType.RTSP_PUSH.ordinal()
|
| | |
| | | subscribe.response(null, zlmServerConfig);
|
| | | }
|
| | | }
|
| | | mediaServerService.zlmServerOnline(zlmServerConfig);
|
| | | });
|
| | | try {
|
| | | HookZlmServerStartEvent event = new HookZlmServerStartEvent(this);
|
| | | MediaServerItem mediaServerItem = mediaServerService.getOne(zlmServerConfig.getMediaServerId());
|
| | | if (mediaServerItem != null) {
|
| | | event.setMediaServerItem(mediaServerItem);
|
| | | applicationEventPublisher.publishEvent(event);
|
| | | }
|
| | | }catch (Exception e) {
|
| | | logger.info("[ZLM-HOOK-ZLM启动] 发送通知失败 ", e);
|
| | | }
|
| | |
|
| | | return HookResult.SUCCESS();
|
| | | }
|