26个文件已修改
5个文件已添加
10 文件已重命名
1个文件已删除
| | |
| | | private double longitude; |
| | | private double latitude; |
| | | private String streamType; |
| | | private boolean status; |
| | | |
| | | public String getApp() { |
| | | return app; |
| | |
| | | public void setStreamType(String streamType) { |
| | | this.streamType = streamType; |
| | | } |
| | | |
| | | public boolean isStatus() { |
| | | return status; |
| | | } |
| | | |
| | | public void setStatus(boolean status) { |
| | | this.status = status; |
| | | } |
| | | } |
| | |
| | | public void setPlatformId(String platformId) { |
| | | this.platformId = platformId; |
| | | } |
| | | |
| | | } |
| | |
| | | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
|
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
| | | import com.genersoft.iot.vmp.gb28181.transmit.response.impl.*;
|
| | | import com.genersoft.iot.vmp.vmanager.service.IPlayService;
|
| | | import com.genersoft.iot.vmp.service.IPlayService;
|
| | | // import org.slf4j.Logger;
|
| | | // import org.slf4j.LoggerFactory;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | |
|
| | | import com.genersoft.iot.vmp.conf.MediaServerConfig;
|
| | | import com.genersoft.iot.vmp.gb28181.bean.*;
|
| | | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
| | | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
| | | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
|
| | | import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor;
|
| | | import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
|
| | | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
|
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
| | | import com.genersoft.iot.vmp.vmanager.play.bean.PlayResult;
|
| | | import com.genersoft.iot.vmp.vmanager.service.IPlayService;
|
| | | import com.genersoft.iot.vmp.service.IPlayService;
|
| | | import gov.nist.javax.sip.address.AddressImpl;
|
| | | import gov.nist.javax.sip.address.SipUri;
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | |
|
| | | import java.text.ParseException;
|
| | | import java.util.HashMap;
|
| | | import java.util.Map;
|
| | | import java.util.Vector;
|
| | |
|
| | | /**
|
| | |
| | | deviceChannel.setLatitude(gbStream.getLatitude());
|
| | | deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
|
| | | deviceChannel.setManufacture("wvp-pro");
|
| | | deviceChannel.setStatus(1);
|
| | | deviceChannel.setStatus(gbStream.isStatus()?1:0);
|
| | | // deviceChannel.setParentId(parentPlatform.getDeviceGBId());
|
| | | deviceChannel.setRegisterWay(1);
|
| | | deviceChannel.setCivilCode(cmder.getSipConfig().getSipDomain());
|
| | |
| | | import com.genersoft.iot.vmp.gb28181.bean.Device;
|
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
| | | import com.genersoft.iot.vmp.vmanager.service.IPlayService;
|
| | | import com.genersoft.iot.vmp.service.IPlayService;
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
| | | String streamId = json.getString("stream");
|
| | | String schema = json.getString("schema");
|
| | | boolean regist = json.getBoolean("regist");
|
| | | StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
|
| | |
|
| | | if ("rtp".equals(app) && !regist ) {
|
| | | StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
|
| | | if (streamInfo!=null){
|
| | | redisCatchStorage.stopPlay(streamInfo);
|
| | | storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
|
| | |
| | | redisCatchStorage.stopPlayback(streamInfo);
|
| | | }
|
| | | }else {
|
| | | if (!"rtp".equals(app) && "rtsp".equals(schema)){
|
| | | zlmMediaListManager.updateMediaList();
|
| | | if (!"rtp".equals(app) && "rtmp".equals(schema)){
|
| | | if (regist) {
|
| | | zlmMediaListManager.addMedia(app, streamId);
|
| | | }else {
|
| | | zlmMediaListManager.removeMedia(app, streamId);
|
| | | }
|
| | | }
|
| | | }
|
| | | JSONObject ret = new JSONObject();
|
| | |
| | | return event; |
| | | } |
| | | |
| | | /** |
| | | * 获取某个类型的所有的订阅 |
| | | * @param type |
| | | * @return |
| | | */ |
| | | public List<ZLMHttpHookSubscribe.Event> getSubscribes(HookType type) { |
| | | ZLMHttpHookSubscribe.Event event= null; |
| | | Map<JSONObject, Event> eventMap = allSubscribes.get(type); |
| | |
| | | package com.genersoft.iot.vmp.media.zlm; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.genersoft.iot.vmp.common.RealVideo; |
| | | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| | | import com.genersoft.iot.vmp.gb28181.session.SsrcUtil; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| | | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; |
| | | import com.genersoft.iot.vmp.service.IStreamPushService; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.storager.impl.RedisCatchStorageImpl; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; |
| | | import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.*; |
| | |
| | | @Autowired |
| | | private IRedisCatchStorage redisCatchStorage; |
| | | |
| | | @Autowired |
| | | private IVideoManagerStorager storager; |
| | | |
| | | @Autowired |
| | | private GbStreamMapper gbStreamMapper; |
| | | |
| | | @Autowired |
| | | private PlatformGbStreamMapper platformGbStreamMapper; |
| | | |
| | | @Autowired |
| | | private IStreamPushService streamPushService; |
| | | |
| | | |
| | | public void updateMediaList() { |
| | | JSONObject mediaList = zlmresTfulUtils.getMediaList(); |
| | | if (mediaList == null) return; |
| | | String dataStr = mediaList.getString("data"); |
| | | storager.clearMediaList(); |
| | | |
| | | Integer code = mediaList.getInteger("code"); |
| | | Map<String, RealVideo> result = new HashMap<>(); |
| | | if (code == 0 ) { |
| | | if (dataStr != null) { |
| | | List<MediaItem> mediaItems = JSON.parseObject(dataStr, new TypeReference<List<MediaItem>>() {}); |
| | | for (MediaItem item : mediaItems) { |
| | | if ("rtp".equals(item.getApp())) { |
| | | continue; |
| | | } |
| | | String key = item.getApp() + "_" + item.getStream(); |
| | | RealVideo realVideo = result.get(key); |
| | | if (realVideo == null) { |
| | | realVideo = new RealVideo(); |
| | | realVideo.setApp(item.getApp()); |
| | | realVideo.setStream(item.getStream()); |
| | | realVideo.setAliveSecond(item.getAliveSecond()); |
| | | realVideo.setCreateStamp(item.getCreateStamp()); |
| | | realVideo.setOriginSock(item.getOriginSock()); |
| | | realVideo.setTotalReaderCount(item.getTotalReaderCount()); |
| | | realVideo.setOriginType(item.getOriginType()); |
| | | realVideo.setOriginTypeStr(item.getOriginTypeStr()); |
| | | realVideo.setOriginUrl(item.getOriginUrl()); |
| | | realVideo.setCreateStamp(item.getCreateStamp()); |
| | | realVideo.setAliveSecond(item.getAliveSecond()); |
| | | // 使用异步的当时更新媒体流列表 |
| | | zlmresTfulUtils.getMediaList((mediaList ->{ |
| | | if (mediaList == null) return; |
| | | String dataStr = mediaList.getString("data"); |
| | | |
| | | ArrayList<RealVideo.MediaSchema> mediaSchemas = new ArrayList<>(); |
| | | realVideo.setSchemas(mediaSchemas); |
| | | realVideo.setTracks(item.getTracks()); |
| | | realVideo.setVhost(item.getVhost()); |
| | | result.put(key, realVideo); |
| | | } |
| | | |
| | | RealVideo.MediaSchema mediaSchema = new RealVideo.MediaSchema(); |
| | | mediaSchema.setSchema(item.getSchema()); |
| | | mediaSchema.setBytesSpeed(item.getBytesSpeed()); |
| | | realVideo.getSchemas().add(mediaSchema); |
| | | Integer code = mediaList.getInteger("code"); |
| | | Map<String, StreamPushItem> result = new HashMap<>(); |
| | | List<StreamPushItem> streamPushItems = null; |
| | | // 获取所有的国标关联 |
| | | List<GbStream> gbStreams = gbStreamMapper.selectAll(); |
| | | if (code == 0 ) { |
| | | if (dataStr != null) { |
| | | streamPushItems = streamPushService.handleJSON(dataStr); |
| | | } |
| | | |
| | | }else { |
| | | logger.warn("更新视频流失败,错误code: " + code); |
| | | } |
| | | }else { |
| | | logger.warn("更新视频流失败,错误code: " + code); |
| | | } |
| | | |
| | | List<RealVideo> realVideos = new ArrayList<>(result.values()); |
| | | Collections.sort(realVideos); |
| | | redisCatchStorage.updateMediaList(realVideos); |
| | | if (streamPushItems != null) { |
| | | storager.updateMediaList(streamPushItems); |
| | | } |
| | | })); |
| | | |
| | | } |
| | | |
| | | public void addMedia(String app, String streamId) { |
| | | //使用异步更新推流 |
| | | zlmresTfulUtils.getMediaList(app, streamId, "rtmp", json->{ |
| | | |
| | | if (json == null) return; |
| | | String dataStr = json.getString("data"); |
| | | |
| | | Integer code = json.getInteger("code"); |
| | | Map<String, StreamPushItem> result = new HashMap<>(); |
| | | List<StreamPushItem> streamPushItems = null; |
| | | if (code == 0 ) { |
| | | if (dataStr != null) { |
| | | streamPushItems = streamPushService.handleJSON(dataStr); |
| | | } |
| | | }else { |
| | | logger.warn("更新视频流失败,错误code: " + code); |
| | | } |
| | | |
| | | if (streamPushItems != null && streamPushItems.size() == 1) { |
| | | storager.updateMedia(streamPushItems.get(0)); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | public void removeMedia(String app, String streamId) { |
| | | // 查找是否关联了国标, 关联了不删除, 置为离线 |
| | | StreamProxyItem streamProxyItem = gbStreamMapper.selectOne(app, streamId); |
| | | if (streamProxyItem == null) { |
| | | storager.removeMedia(app, streamId); |
| | | }else { |
| | | storager.mediaOutline(app, streamId); |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import okhttp3.*; |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | @Value("${media.secret}") |
| | | private String mediaSecret; |
| | | |
| | | public JSONObject sendPost(String api, Map<String, Object> param) { |
| | | public interface RequestCallback{ |
| | | void run(JSONObject response); |
| | | } |
| | | |
| | | public JSONObject sendPost(String api, Map<String, Object> param, RequestCallback callback) { |
| | | OkHttpClient client = new OkHttpClient(); |
| | | String url = String.format("http://%s:%s/index/api/%s", mediaIp, mediaPort, api); |
| | | JSONObject responseJSON = null; |
| | |
| | | .post(body) |
| | | .url(url) |
| | | .build(); |
| | | try { |
| | | Response response = client.newCall(request).execute(); |
| | | if (response.isSuccessful()) { |
| | | String responseStr = response.body().string(); |
| | | if (responseStr != null) { |
| | | responseJSON = JSON.parseObject(responseStr); |
| | | if (callback == null) { |
| | | try { |
| | | Response response = client.newCall(request).execute(); |
| | | if (response.isSuccessful()) { |
| | | String responseStr = response.body().string(); |
| | | if (responseStr != null) { |
| | | responseJSON = JSON.parseObject(responseStr); |
| | | } |
| | | } |
| | | } catch (ConnectException e) { |
| | | logger.error(String.format("连接ZLM失败: %s, %s", e.getCause().getMessage(), e.getMessage())); |
| | | logger.info("请检查media配置并确认ZLM已启动..."); |
| | | }catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }else { |
| | | client.newCall(request).enqueue(new Callback(){ |
| | | |
| | | @Override |
| | | public void onResponse(@NotNull Call call, @NotNull Response response){ |
| | | if (response.isSuccessful()) { |
| | | try { |
| | | String responseStr = response.body().string(); |
| | | if (responseStr != null) { |
| | | callback.run(JSON.parseObject(responseStr)); |
| | | }else { |
| | | callback.run(null); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(@NotNull Call call, @NotNull IOException e) { |
| | | logger.error(String.format("连接ZLM失败: %s, %s", e.getCause().getMessage(), e.getMessage())); |
| | | logger.info("请检查media配置并确认ZLM已启动..."); |
| | | } |
| | | }); |
| | | } |
| | | } catch (ConnectException e) { |
| | | logger.error(String.format("连接ZLM失败: %s, %s", e.getCause().getMessage(), e.getMessage())); |
| | | logger.info("请检查media配置并确认ZLM已启动..."); |
| | | }catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | |
| | | return responseJSON; |
| | | } |
| | | |
| | | public JSONObject getMediaList(String app, String schema){ |
| | | public JSONObject getMediaList(String app, String stream, String schema, RequestCallback callback){ |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("app",app); |
| | | param.put("schema",schema); |
| | | if (app != null) param.put("app",app); |
| | | if (stream != null) param.put("stream",stream); |
| | | if (schema != null) param.put("schema",schema); |
| | | param.put("vhost","__defaultVhost__"); |
| | | return sendPost("getMediaList",param); |
| | | return sendPost("getMediaList",param, callback); |
| | | } |
| | | |
| | | public JSONObject getMediaList(){ |
| | | return sendPost("getMediaList",null); |
| | | public JSONObject getMediaList(String app, String stream){ |
| | | return getMediaList(app, stream,null, null); |
| | | } |
| | | |
| | | public JSONObject getMediaList(RequestCallback callback){ |
| | | return sendPost("getMediaList",null, callback); |
| | | } |
| | | |
| | | public JSONObject getMediaInfo(String app, String schema, String stream){ |
| | |
| | | param.put("schema",schema); |
| | | param.put("stream",stream); |
| | | param.put("vhost","__defaultVhost__"); |
| | | return sendPost("getMediaInfo",param); |
| | | return sendPost("getMediaInfo",param, null); |
| | | } |
| | | |
| | | public JSONObject getRtpInfo(String stream_id){ |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("stream_id",stream_id); |
| | | return sendPost("getRtpInfo",param); |
| | | return sendPost("getRtpInfo",param, null); |
| | | } |
| | | |
| | | public JSONObject addFFmpegSource(String src_url, String dst_url, String timeout_ms){ |
| | |
| | | param.put("src_url", src_url); |
| | | param.put("dst_url", dst_url); |
| | | param.put("timeout_ms", timeout_ms); |
| | | return sendPost("addFFmpegSource",param); |
| | | return sendPost("addFFmpegSource",param, null); |
| | | } |
| | | |
| | | public JSONObject delFFmpegSource(String key){ |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("key", key); |
| | | return sendPost("delFFmpegSource",param); |
| | | return sendPost("delFFmpegSource",param, null); |
| | | } |
| | | |
| | | public JSONObject getMediaServerConfig(){ |
| | | return sendPost("getServerConfig",null); |
| | | return sendPost("getServerConfig",null, null); |
| | | } |
| | | |
| | | public JSONObject setServerConfig(Map<String, Object> param){ |
| | | return sendPost("setServerConfig",param); |
| | | return sendPost("setServerConfig",param, null); |
| | | } |
| | | |
| | | public JSONObject openRtpServer(Map<String, Object> param){ |
| | | return sendPost("openRtpServer",param); |
| | | return sendPost("openRtpServer",param, null); |
| | | } |
| | | |
| | | public JSONObject closeRtpServer(Map<String, Object> param) { |
| | | return sendPost("closeRtpServer",param); |
| | | return sendPost("closeRtpServer",param, null); |
| | | } |
| | | |
| | | public JSONObject startSendRtp(Map<String, Object> param) { |
| | | return sendPost("startSendRtp",param); |
| | | return sendPost("startSendRtp",param, null); |
| | | } |
| | | |
| | | public JSONObject stopSendRtp(Map<String, Object> param) { |
| | | return sendPost("stopSendRtp",param); |
| | | return sendPost("stopSendRtp",param, null); |
| | | } |
| | | |
| | | public JSONObject addStreamProxy(String app, String stream, String url, boolean enable_hls, boolean enable_mp4, String rtp_type) { |
| | |
| | | param.put("enable_hls", enable_hls?1:0); |
| | | param.put("enable_mp4", enable_mp4?1:0); |
| | | param.put("rtp_type", rtp_type); |
| | | return sendPost("addStreamProxy",param); |
| | | return sendPost("addStreamProxy",param, null); |
| | | } |
| | | |
| | | public JSONObject closeStreams(String app, String stream) { |
| | |
| | | param.put("app", app); |
| | | param.put("stream", stream); |
| | | param.put("force", 1); |
| | | return sendPost("close_streams",param); |
| | | return sendPost("close_streams",param, null); |
| | | } |
| | | } |
| | |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | //import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import com.genersoft.iot.vmp.vmanager.service.IStreamProxyService; |
| | | import com.genersoft.iot.vmp.service.IStreamProxyService; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @Override |
| | | public void run(String... strings) throws Exception { |
| | | JSONObject subscribeKey = new JSONObject(); |
| | | // 订阅 zlm启动事件 |
| | | hookSubscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_server_started,subscribeKey,(response)->{ |
| | | hookSubscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_server_started,null,(response)->{ |
| | | MediaServerConfig mediaServerConfig = JSONObject.toJavaObject(response, MediaServerConfig.class); |
| | | zLmRunning(mediaServerConfig); |
| | | }); |
| | |
| | | logger.info("zlm接入成功..."); |
| | | if (autoConfig) saveZLMConfig(); |
| | | MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); |
| | | if (System.currentTimeMillis() - mediaInfo.getUpdateTime() < 50){ |
| | | if (mediaInfo != null && System.currentTimeMillis() - mediaInfo.getUpdateTime() < 50){ |
| | | logger.info("zlm刚刚更新,忽略这次更新"); |
| | | return; |
| | | } |
File was renamed from src/main/java/com/genersoft/iot/vmp/common/RealVideo.java |
| | |
| | | package com.genersoft.iot.vmp.common; |
| | | package com.genersoft.iot.vmp.media.zlm.dto; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; |
| | | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| | | import org.jetbrains.annotations.NotNull; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | public class RealVideo implements Comparable<RealVideo>{ |
| | | public class StreamPushItem extends GbStream implements Comparable<StreamPushItem>{ |
| | | |
| | | /** |
| | | * 应用名 |
| | |
| | | this.vhost = vhost; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int compareTo(@NotNull RealVideo realVideo) { |
| | | return new Long(this.createStamp - realVideo.getCreateStamp().intValue()).intValue(); |
| | | public int compareTo(@NotNull StreamPushItem streamPushItem) { |
| | | return new Long(this.createStamp - streamPushItem.getCreateStamp().intValue()).intValue(); |
| | | } |
| | | |
| | | public static class MediaSchema { |
File was renamed from src/main/java/com/genersoft/iot/vmp/vmanager/service/IGbStreamService.java |
| | |
| | | package com.genersoft.iot.vmp.vmanager.service; |
| | | package com.genersoft.iot.vmp.service; |
| | | |
| | | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| | | import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream; |
| | | import com.github.pagehelper.PageInfo; |
| | | |
| | | import java.util.List; |
File was renamed from src/main/java/com/genersoft/iot/vmp/vmanager/service/IMediaService.java |
| | |
| | | package com.genersoft.iot.vmp.vmanager.service; |
| | | package com.genersoft.iot.vmp.service; |
| | | |
| | | import com.genersoft.iot.vmp.common.StreamInfo; |
| | | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| | | import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream; |
| | | |
| | | /** |
| | | * 媒体信息业务 |
| | |
| | | * @return |
| | | */ |
| | | StreamInfo getStreamInfoByAppAndStream(String app, String stream); |
| | | |
| | | } |
File was renamed from src/main/java/com/genersoft/iot/vmp/vmanager/service/IPlayService.java |
| | |
| | | package com.genersoft.iot.vmp.vmanager.service; |
| | | package com.genersoft.iot.vmp.service; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
File was renamed from src/main/java/com/genersoft/iot/vmp/vmanager/service/IStreamProxyService.java |
| | |
| | | package com.genersoft.iot.vmp.vmanager.service; |
| | | package com.genersoft.iot.vmp.service; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
New file |
| | |
| | | package com.genersoft.iot.vmp.service; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| | | import com.github.pagehelper.PageInfo; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface IStreamPushService { |
| | | |
| | | List<StreamPushItem> handleJSON(String json); |
| | | |
| | | /** |
| | | * 将应用名和流ID加入国标关联 |
| | | * @param stream |
| | | * @return |
| | | */ |
| | | boolean saveToGB(GbStream stream); |
| | | |
| | | /** |
| | | * 将应用名和流ID移出国标关联 |
| | | * @param stream |
| | | * @return |
| | | */ |
| | | boolean removeFromGB(GbStream stream); |
| | | |
| | | /** |
| | | * 获取 |
| | | * @param page |
| | | * @param count |
| | | * @return |
| | | */ |
| | | PageInfo<StreamPushItem> getPushList(Integer page, Integer count); |
| | | } |
File was renamed from src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/GbStreamServiceImpl.java |
| | |
| | | package com.genersoft.iot.vmp.vmanager.service.impl; |
| | | package com.genersoft.iot.vmp.service.impl; |
| | | |
| | | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| | | import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| | | import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; |
| | | import com.genersoft.iot.vmp.storager.dao.PlarfotmGbStreamMapper; |
| | | import com.genersoft.iot.vmp.vmanager.platform.PlatformController; |
| | | import com.genersoft.iot.vmp.vmanager.service.IGbStreamService; |
| | | import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; |
| | | import com.genersoft.iot.vmp.service.IGbStreamService; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import org.slf4j.Logger; |
| | |
| | | private GbStreamMapper gbStreamMapper; |
| | | |
| | | @Autowired |
| | | private PlarfotmGbStreamMapper plarfotmGbStreamMapper; |
| | | private PlatformGbStreamMapper platformGbStreamMapper; |
| | | |
| | | @Override |
| | | public PageInfo<GbStream> getAll(Integer page, Integer count) { |
| | |
| | | try { |
| | | for (GbStream gbStream : gbStreams) { |
| | | gbStream.setPlatformId(platformId); |
| | | plarfotmGbStreamMapper.add(gbStream); |
| | | platformGbStreamMapper.add(gbStream); |
| | | } |
| | | dataSourceTransactionManager.commit(transactionStatus); //手动提交 |
| | | result = true; |
| | |
| | | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| | | try { |
| | | for (GbStream gbStream : gbStreams) { |
| | | plarfotmGbStreamMapper.delByAppAndStream(gbStream.getApp(), gbStream.getStream()); |
| | | platformGbStreamMapper.delByAppAndStream(gbStream.getApp(), gbStream.getStream()); |
| | | } |
| | | dataSourceTransactionManager.commit(transactionStatus); //手动提交 |
| | | result = true; |
File was renamed from src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/MediaServiceImpl.java |
| | |
| | | package com.genersoft.iot.vmp.vmanager.service.impl; |
| | | package com.genersoft.iot.vmp.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.common.StreamInfo; |
| | | import com.genersoft.iot.vmp.conf.MediaServerConfig; |
| | | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| | | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import com.genersoft.iot.vmp.vmanager.service.IMediaService; |
| | | import com.genersoft.iot.vmp.vmanager.service.IStreamProxyService; |
| | | import com.genersoft.iot.vmp.service.IMediaService; |
| | | import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private ZLMRESTfulUtils zlmresTfulUtils; |
| | | |
| | | |
| | | |
| | | @Override |
| | | public StreamInfo getStreamInfoByAppAndStream(String app, String stream) { |
| | |
| | | } |
| | | return streamInfo; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
File was renamed from src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/PlayServiceImpl.java |
| | |
| | | package com.genersoft.iot.vmp.vmanager.service.impl; |
| | | package com.genersoft.iot.vmp.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.common.StreamInfo; |
| | | import com.genersoft.iot.vmp.conf.MediaServerConfig; |
| | | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| | | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| | | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| | |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import com.genersoft.iot.vmp.vmanager.play.bean.PlayResult; |
| | | import com.genersoft.iot.vmp.vmanager.service.IMediaService; |
| | | import com.genersoft.iot.vmp.vmanager.service.IPlayService; |
| | | import com.genersoft.iot.vmp.service.IMediaService; |
| | | import com.genersoft.iot.vmp.service.IPlayService; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
File was renamed from src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/StreamProxyServiceImpl.java |
| | |
| | | package com.genersoft.iot.vmp.vmanager.service.impl; |
| | | package com.genersoft.iot.vmp.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.conf.MediaServerConfig; |
| | |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; |
| | | import com.genersoft.iot.vmp.storager.dao.PlarfotmGbStreamMapper; |
| | | import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; |
| | | import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper; |
| | | import com.genersoft.iot.vmp.vmanager.service.IStreamProxyService; |
| | | import com.genersoft.iot.vmp.service.IStreamProxyService; |
| | | import com.github.pagehelper.PageInfo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private GbStreamMapper gbStreamMapper; |
| | | |
| | | @Autowired |
| | | private PlarfotmGbStreamMapper plarfotmGbStreamMapper; |
| | | private PlatformGbStreamMapper platformGbStreamMapper; |
| | | |
| | | |
| | | @Override |
| | |
| | | videoManagerStorager.deleteStreamProxy(app, stream); |
| | | // 如果关联了国标那么移除关联 |
| | | gbStreamMapper.del(app, stream); |
| | | plarfotmGbStreamMapper.delByAppAndStream(app, stream); |
| | | platformGbStreamMapper.delByAppAndStream(app, stream); |
| | | // TODO 如果关联的推流, 那么状态设置为离线 |
| | | } |
| | | } |
New file |
| | |
| | | package com.genersoft.iot.vmp.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| | | import com.genersoft.iot.vmp.service.IStreamPushService; |
| | | import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; |
| | | import com.genersoft.iot.vmp.storager.dao.StreamPushMapper; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | public class StreamPushServiceImpl implements IStreamPushService { |
| | | |
| | | @Autowired |
| | | private GbStreamMapper gbStreamMapper; |
| | | |
| | | @Autowired |
| | | private StreamPushMapper streamPushMapper; |
| | | |
| | | @Override |
| | | public List<StreamPushItem> handleJSON(String jsonData) { |
| | | if (jsonData == null) return null; |
| | | |
| | | Map<String, StreamPushItem> result = new HashMap<>(); |
| | | |
| | | List<MediaItem> mediaItems = JSON.parseObject(jsonData, new TypeReference<List<MediaItem>>() {}); |
| | | for (MediaItem item : mediaItems) { |
| | | |
| | | // 不保存国标推理以及拉流代理的流 |
| | | if (item.getOriginType() == 3 || item.getOriginType() == 4 || item.getOriginType() == 5) { |
| | | continue; |
| | | } |
| | | String key = item.getApp() + "_" + item.getStream(); |
| | | StreamPushItem streamPushItem = result.get(key); |
| | | if (streamPushItem == null) { |
| | | streamPushItem = new StreamPushItem(); |
| | | streamPushItem.setApp(item.getApp()); |
| | | streamPushItem.setStream(item.getStream()); |
| | | streamPushItem.setAliveSecond(item.getAliveSecond()); |
| | | streamPushItem.setCreateStamp(item.getCreateStamp()); |
| | | streamPushItem.setOriginSock(item.getOriginSock()); |
| | | streamPushItem.setTotalReaderCount(item.getTotalReaderCount()); |
| | | streamPushItem.setOriginType(item.getOriginType()); |
| | | streamPushItem.setOriginTypeStr(item.getOriginTypeStr()); |
| | | streamPushItem.setOriginUrl(item.getOriginUrl()); |
| | | streamPushItem.setCreateStamp(item.getCreateStamp()); |
| | | streamPushItem.setAliveSecond(item.getAliveSecond()); |
| | | streamPushItem.setStatus(true); |
| | | streamPushItem.setVhost(item.getVhost()); |
| | | result.put(key, streamPushItem); |
| | | } |
| | | } |
| | | |
| | | return new ArrayList<>(result.values()); |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<StreamPushItem> getPushList(Integer page, Integer count) { |
| | | PageHelper.startPage(page, count); |
| | | List<StreamPushItem> all = streamPushMapper.selectAll(); |
| | | return new PageInfo<>(all); |
| | | } |
| | | |
| | | @Override |
| | | public boolean saveToGB(GbStream stream) { |
| | | stream.setStreamType("push"); |
| | | stream.setStatus(true); |
| | | int add = gbStreamMapper.add(stream); |
| | | return add > 0; |
| | | } |
| | | |
| | | @Override |
| | | public boolean removeFromGB(GbStream stream) { |
| | | int del = gbStreamMapper.del(stream.getApp(), stream.getStream()); |
| | | return del > 0; |
| | | } |
| | | } |
| | |
| | | package com.genersoft.iot.vmp.storager; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.common.RealVideo; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| | | import com.genersoft.iot.vmp.common.StreamInfo; |
| | | import com.genersoft.iot.vmp.conf.MediaServerConfig; |
| | | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| | |
| | | */ |
| | | boolean isChannelSendingRTP(String channelId); |
| | | |
| | | /** |
| | | * 更新媒体流列表 |
| | | * @param mediaList |
| | | */ |
| | | void updateMediaList(List<RealVideo> mediaList); |
| | | |
| | | /** |
| | | * 获取当前媒体流列表 |
| | | * @return List<RealVideo> |
| | | */ |
| | | JSONObject getMediaList(int start, int end); |
| | | } |
| | |
| | |
|
| | | import com.genersoft.iot.vmp.gb28181.bean.*;
|
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
|
| | | import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce;
|
| | | import com.github.pagehelper.PageInfo;
|
| | |
|
| | |
| | | * @return
|
| | | */
|
| | | List<GbStream> queryGbStreamListInPlatform(String platformId);
|
| | |
|
| | | /**
|
| | | * 批量更新推流列表
|
| | | * @param streamPushItems
|
| | | */
|
| | | void updateMediaList(List<StreamPushItem> streamPushItems);
|
| | |
|
| | | /**
|
| | | * 更新单个推流
|
| | | * @param streamPushItem
|
| | | */
|
| | | void updateMedia(StreamPushItem streamPushItem);
|
| | |
|
| | | /**
|
| | | * 移除单个推流
|
| | | * @param app
|
| | | * @param stream
|
| | | */
|
| | | void removeMedia(String app, String stream);
|
| | |
|
| | |
|
| | | /**
|
| | | * 清空推流列表
|
| | | */
|
| | | void clearMediaList();
|
| | |
|
| | | /**
|
| | | * 设置流离线
|
| | | * @param app
|
| | | * @param streamId
|
| | | */
|
| | | void mediaOutline(String app, String streamId);
|
| | | }
|
| | |
| | | public interface GbStreamMapper { |
| | | |
| | | @Insert("INSERT INTO gb_stream (app, stream, gbId, name, " + |
| | | "longitude, latitude, streamType) VALUES" + |
| | | "longitude, latitude, streamType, status) VALUES" + |
| | | "('${app}', '${stream}', '${gbId}', '${name}', " + |
| | | "'${longitude}', '${latitude}', '${streamType}')") |
| | | "'${longitude}', '${latitude}', '${streamType}', ${status})") |
| | | int add(GbStream gbStream); |
| | | |
| | | @Update("UPDATE gb_stream " + |
| | |
| | | "name=#{name}," + |
| | | "streamType=#{streamType}," + |
| | | "longitude=#{longitude}, " + |
| | | "latitude=#{latitude}, " + |
| | | "latitude=#{latitude} " + |
| | | "status=${status} " + |
| | | "WHERE app=#{app} AND stream=#{stream} AND gbId=#{gbId}") |
| | | int update(GbStream gbStream); |
| | | |
| | |
| | | "LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream " + |
| | | "WHERE pgs.platformId = '${platformId}'") |
| | | List<GbStream> queryGbStreamListInPlatform(String platformId); |
| | | |
| | | @Update("UPDATE gb_stream " + |
| | | "SET status=${status} " + |
| | | "WHERE app=#{app} AND stream=#{stream}") |
| | | void setStatus(String app, String stream, boolean status); |
| | | } |
File was renamed from src/main/java/com/genersoft/iot/vmp/storager/dao/PlarfotmGbStreamMapper.java |
| | |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface PlarfotmGbStreamMapper { |
| | | public interface PlatformGbStreamMapper { |
| | | |
| | | @Insert("INSERT INTO platform_gb_stream (app, stream, platformId) VALUES" + |
| | | "('${app}', '${stream}', '${platformId}')") |
| | |
| | | @Delete("DELETE FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream}") |
| | | int delByAppAndStream(String app, String stream); |
| | | |
| | | @Delete("DELETE FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream}") |
| | | @Delete("DELETE FROM platform_gb_stream WHERE platformId=#{platformId}") |
| | | int delByPlatformId(String platformId); |
| | | |
| | | @Select("SELECT * FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream} AND platformId=#{platformId}") |
| | | StreamProxyItem selectOne(String app, String stream, String platformId); |
| | | @Select("SELECT * FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream}") |
| | | List<StreamProxyItem> selectByAppAndStream(String app, String stream); |
| | | } |
New file |
| | |
| | | package com.genersoft.iot.vmp.storager.dao; |
| | | |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| | | import org.apache.ibatis.annotations.*; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface StreamPushMapper { |
| | | |
| | | @Insert("INSERT INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " + |
| | | "createStamp, aliveSecond) VALUES" + |
| | | "('${app}', '${stream}', '${totalReaderCount}', '${originType}', '${originTypeStr}', " + |
| | | "'${createStamp}', '${aliveSecond}' )") |
| | | int add(StreamPushItem streamPushItem); |
| | | |
| | | @Update("UPDATE stream_push " + |
| | | "SET app=#{app}," + |
| | | "stream=#{stream}," + |
| | | "totalReaderCount=#{totalReaderCount}, " + |
| | | "originType=#{originType}," + |
| | | "originTypeStr=#{originTypeStr}, " + |
| | | "createStamp=#{createStamp}, " + |
| | | "aliveSecond=#{aliveSecond} " + |
| | | "WHERE app=#{app} AND stream=#{stream}") |
| | | int update(StreamPushItem streamPushItem); |
| | | |
| | | @Delete("DELETE FROM stream_push WHERE app=#{app} AND stream=#{stream}") |
| | | int del(String app, String stream); |
| | | |
| | | @Select("SELECT st.*, pgs.gbId, pgs.status, pgs.name, pgs.longitude, pgs.latitude FROM stream_push st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream") |
| | | List<StreamPushItem> selectAll(); |
| | | |
| | | @Select("SELECT st.*, pgs.gbId, pgs.status, pgs.name, pgs.longitude, pgs.latitude FROM stream_push st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.enable=${enable}") |
| | | List<StreamPushItem> selectForEnable(boolean enable); |
| | | |
| | | @Select("SELECT st.*, pgs.gbId, pgs.status, pgs.name, pgs.longitude, pgs.latitude FROM stream_push st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.app=#{app} AND st.stream=#{stream}") |
| | | StreamPushItem selectOne(String app, String stream); |
| | | |
| | | @Insert("<script>" + |
| | | "INSERT INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " + |
| | | "createStamp, aliveSecond) " + |
| | | "VALUES <foreach collection='streamPushItems' item='item' index='index' >" + |
| | | "( '${item.app}', '${item.stream}', '${item.totalReaderCount}', '${item.originType}', " + |
| | | "'${item.originTypeStr}','${item.createStamp}', '${item.aliveSecond}' )" + |
| | | " </foreach>" + |
| | | "</script>") |
| | | void addAll(List<StreamPushItem> streamPushItems); |
| | | |
| | | @Delete("DELETE FROM stream_push") |
| | | void clear(); |
| | | |
| | | } |
| | |
| | | package com.genersoft.iot.vmp.storager.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.common.RealVideo; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| | | import com.genersoft.iot.vmp.common.StreamInfo; |
| | | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| | | import com.genersoft.iot.vmp.conf.MediaServerConfig; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 更新媒体流列表 |
| | | * @param mediaList |
| | | */ |
| | | @Override |
| | | public void updateMediaList(List<RealVideo> mediaList) { |
| | | String key = VideoManagerConstants.MEDIA_STREAM_PREFIX; |
| | | redis.del(key); |
| | | for (int i = 0; i < mediaList.size(); i++) { |
| | | RealVideo realVideo = mediaList.get(i); |
| | | redis.zAdd(key, realVideo, realVideo.getCreateStamp()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取当前媒体流列表 |
| | | * @return List<RealVideo> |
| | | */ |
| | | @Override |
| | | public JSONObject getMediaList(int start, int end) { |
| | | String key = VideoManagerConstants.MEDIA_STREAM_PREFIX; |
| | | Set<Object> realVideos = redis.ZRange(key, start, end); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("list", new ArrayList(realVideos)); |
| | | jsonObject.put("total", redis.zSize(key)); |
| | | |
| | | return jsonObject; |
| | | } |
| | | } |
| | |
| | | |
| | | import com.genersoft.iot.vmp.gb28181.bean.*; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.storager.dao.*; |
| | | import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce; |
| | |
| | | |
| | | @Autowired |
| | | private StreamProxyMapper streamProxyMapper; |
| | | |
| | | @Autowired |
| | | private StreamPushMapper streamPushMapper; |
| | | |
| | | @Autowired |
| | | private GbStreamMapper gbStreamMapper; |
| | |
| | | */ |
| | | @Override |
| | | public synchronized boolean outline(String deviceId) { |
| | | System.out.println("更新设备离线: " + deviceId); |
| | | Device device = deviceMapper.getDeviceByDeviceId(deviceId); |
| | | if (device == null) return false; |
| | | device.setOnline(0); |
| | | System.out.println("更新设备离线"); |
| | | return deviceMapper.update(device) > 0; |
| | | } |
| | | |
| | |
| | | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| | | boolean result = false; |
| | | streamProxyItem.setStreamType("proxy"); |
| | | streamProxyItem.setStatus(true); |
| | | try { |
| | | if (gbStreamMapper.add(streamProxyItem)<0 || streamProxyMapper.add(streamProxyItem) < 0) { |
| | | //事务回滚 |
| | |
| | | public StreamProxyItem queryStreamProxy(String app, String stream){ |
| | | return streamProxyMapper.selectOne(app, stream); |
| | | } |
| | | |
| | | @Override |
| | | public void updateMediaList(List<StreamPushItem> streamPushItems) { |
| | | if (streamPushItems == null || streamPushItems.size() == 0) return; |
| | | System.out.printf("updateMediaList: " + streamPushItems.size()); |
| | | streamPushMapper.addAll(streamPushItems); |
| | | // TODO 待优化 |
| | | for (int i = 0; i < streamPushItems.size(); i++) { |
| | | gbStreamMapper.setStatus(streamPushItems.get(i).getApp(), streamPushItems.get(i).getStream(), true); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void updateMedia(StreamPushItem streamPushItem) { |
| | | streamPushMapper.del(streamPushItem.getApp(), streamPushItem.getStream()); |
| | | streamPushMapper.add(streamPushItem); |
| | | gbStreamMapper.setStatus(streamPushItem.getApp(), streamPushItem.getStream(), true); |
| | | } |
| | | |
| | | @Override |
| | | public void removeMedia(String app, String stream) { |
| | | streamPushMapper.del(app, stream); |
| | | } |
| | | |
| | | @Override |
| | | public void clearMediaList() { |
| | | streamPushMapper.clear(); |
| | | } |
| | | |
| | | @Override |
| | | public void mediaOutline(String app, String streamId) { |
| | | gbStreamMapper.setStatus(app, streamId, false); |
| | | } |
| | | } |
| | |
| | | package com.genersoft.iot.vmp.vmanager.gbStream; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import com.genersoft.iot.vmp.vmanager.gbStream.bean.GbStreamParam; |
| | | import com.genersoft.iot.vmp.vmanager.platform.bean.UpdateChannelParam; |
| | | import com.genersoft.iot.vmp.vmanager.service.IGbStreamService; |
| | | import com.genersoft.iot.vmp.service.IGbStreamService; |
| | | import com.github.pagehelper.PageInfo; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | @CrossOrigin |
| | | @RestController |
| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.common.StreamInfo; |
| | | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| | | import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream; |
| | | import com.genersoft.iot.vmp.service.IStreamPushService; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.vmanager.service.IMediaService; |
| | | import com.genersoft.iot.vmp.vmanager.service.IStreamProxyService; |
| | | import com.genersoft.iot.vmp.service.IMediaService; |
| | | import com.genersoft.iot.vmp.service.IStreamProxyService; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private final static Logger logger = LoggerFactory.getLogger(MediaController.class); |
| | | |
| | | @Autowired |
| | | private IRedisCatchStorage redisCatchStorage; |
| | | private IVideoManagerStorager storager; |
| | | |
| | | @Autowired |
| | | private IStreamProxyService streamProxyService; |
| | | private IStreamPushService streamPushService; |
| | | |
| | | @Autowired |
| | | private IMediaService mediaService; |
| | | |
| | | |
| | | @RequestMapping(value = "/list") |
| | | @ResponseBody |
| | | public JSONObject list( @RequestParam(required = false)Integer page, |
| | | @RequestParam(required = false)Integer count, |
| | | @RequestParam(required = false)String q, |
| | | @RequestParam(required = false)Boolean online ){ |
| | | |
| | | JSONObject jsonObject = redisCatchStorage.getMediaList(page - 1, page - 1 + count); |
| | | return jsonObject; |
| | | } |
| | | |
| | | @RequestMapping(value = "/getStreamInfoByAppAndStream") |
| | | @ResponseBody |
| | |
| | | return mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | package com.genersoft.iot.vmp.vmanager.platformGbStream; |
| | | |
| | | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| | | import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import com.genersoft.iot.vmp.vmanager.service.IGbStreamService; |
| | | import com.genersoft.iot.vmp.service.IGbStreamService; |
| | | import com.github.pagehelper.PageInfo; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.vmanager.play.bean.PlayResult; |
| | | import com.genersoft.iot.vmp.vmanager.service.IMediaService; |
| | | import com.genersoft.iot.vmp.vmanager.service.IPlayService; |
| | | import com.genersoft.iot.vmp.service.IMediaService; |
| | | import com.genersoft.iot.vmp.service.IPlayService; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; |
| | | //import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.vmanager.service.IPlayService; |
| | | import com.genersoft.iot.vmp.service.IPlayService; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.vmanager.service.IStreamProxyService; |
| | | import com.genersoft.iot.vmp.service.IStreamProxyService; |
| | | import com.github.pagehelper.PageInfo; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
New file |
| | |
| | | package com.genersoft.iot.vmp.vmanager.streamPush; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| | | import com.genersoft.iot.vmp.service.IStreamPushService; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import com.genersoft.iot.vmp.vmanager.media.MediaController; |
| | | import com.github.pagehelper.PageInfo; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | @Controller |
| | | @CrossOrigin |
| | | @RequestMapping(value = "/api/push") |
| | | public class StreamPushController { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(StreamPushController.class); |
| | | |
| | | @Autowired |
| | | private IStreamPushService streamPushService; |
| | | |
| | | @RequestMapping(value = "/list") |
| | | @ResponseBody |
| | | public PageInfo<StreamPushItem> list(@RequestParam(required = false)Integer page, |
| | | @RequestParam(required = false)Integer count, |
| | | @RequestParam(required = false)String q, |
| | | @RequestParam(required = false)Boolean online ){ |
| | | |
| | | PageInfo<StreamPushItem> pushList = streamPushService.getPushList(page - 1, page - 1 + count); |
| | | return pushList; |
| | | } |
| | | |
| | | @RequestMapping(value = "/saveToGB") |
| | | @ResponseBody |
| | | public Object saveToGB(@RequestBody GbStream stream){ |
| | | if (streamPushService.saveToGB(stream)){ |
| | | return "success"; |
| | | }else { |
| | | return "fail"; |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/removeFormGB") |
| | | @ResponseBody |
| | | public Object removeFormGB(@RequestBody GbStream stream){ |
| | | if (streamPushService.removeFromGB(stream)){ |
| | | return "success"; |
| | | }else { |
| | | return "fail"; |
| | | } |
| | | } |
| | | } |
| | |
| | | <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;"> |
| | | <span style="font-size: 1rem; font-weight: bold;">推流列表</span> |
| | | </div> |
| | | <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;font-size: 14px;"> |
| | | <el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary" @click="addStreamProxy">添加代理</el-button> |
| | | </div> |
| | | <devicePlayer ref="devicePlayer"></devicePlayer> |
| | | <addStreamTOGB ref="addStreamTOGB"></addStreamTOGB> |
| | | <el-table :data="pushList" border style="width: 100%" :height="winHeight"> |
| | | <el-table-column prop="app" label="APP" width="180" align="center"> |
| | | </el-table-column> |
| | | <el-table-column prop="stream" label="流ID" width="240" align="center"> |
| | | </el-table-column> |
| | | <el-table-column prop="totalReaderCount" label="在线人数" width="240" align="center"> |
| | | </el-table-column> |
| | | <el-table-column prop="gbId" label="国标编码" width="150" align="center"> |
| | | </el-table-column> |
| | | <el-table-column label="开始时间" align="center" > |
| | | <template slot-scope="scope"> |
| | |
| | | </el-button-group> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="正在推流" align="center" > |
| | | <template slot-scope="scope"> |
| | | {{!!scope.row.status?'是':'否'}} |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column label="操作" width="360" align="center" fixed="right"> |
| | | <template slot-scope="scope"> |
| | | <el-button-group> |
| | | <el-button size="mini" icon="el-icon-video-play" @click="playPuhsh(scope.row)">播放</el-button> |
| | | <el-button size="mini" icon="el-icon-switch-button" type="danger" v-if="!!scope.row.streamId" @click="stopPuhsh(scope.row)">停止</el-button> |
| | | <el-button size="mini" icon="el-icon-position" type="primary" v-if="!!!scope.row.gbId" @click="addToGB(scope.row)">加入国标</el-button> |
| | | <el-button size="mini" icon="el-icon-position" type="primary" v-if="!!scope.row.gbId" @click="removeFromGB(scope.row)">移出国标</el-button> |
| | | </el-button-group> |
| | | </template> |
| | | </el-table-column> |
| | |
| | | <script> |
| | | import streamProxyEdit from './dialog/StreamProxyEdit.vue' |
| | | import devicePlayer from './dialog/devicePlayer.vue' |
| | | import addStreamTOGB from './dialog/addStreamTOGB.vue' |
| | | import uiHeader from './UiHeader.vue' |
| | | export default { |
| | | name: 'pushVideoList', |
| | | components: { |
| | | devicePlayer, |
| | | addStreamTOGB, |
| | | streamProxyEdit, |
| | | uiHeader |
| | | }, |
| | |
| | | }, |
| | | mounted() { |
| | | this.initData(); |
| | | // this.updateLooper = setInterval(this.initData, 10000); |
| | | this.updateLooper = setInterval(this.initData, 2000); |
| | | }, |
| | | destroyed() { |
| | | this.$destroy('videojs'); |
| | | clearTimeout(this.updateLooper); |
| | | }, |
| | | methods: { |
| | |
| | | getPushList: function() { |
| | | let that = this; |
| | | this.getDeviceListLoading = true; |
| | | this.$axios.get(`/api/media/list`,{ |
| | | this.$axios.get(`/api/push/list`,{ |
| | | params: { |
| | | page: that.currentPage, |
| | | count: that.count |
| | |
| | | that.getDeviceListLoading = false; |
| | | }); |
| | | }, |
| | | addStreamProxy: function(){ |
| | | console.log(2222) |
| | | this.$refs.streamProxyEdit.openDialog(null, this.initData) |
| | | }, |
| | | saveStreamProxy: function(){ |
| | | }, |
| | | |
| | | playPuhsh: function(row){ |
| | | let that = this; |
| | | this.getListLoading = true; |
| | |
| | | stopPuhsh: function(row){ |
| | | console.log(row) |
| | | }, |
| | | addToGB: function(row){ |
| | | this.$refs.addStreamTOGB.openDialog({app: row.app, stream: row.stream}, this.initData); |
| | | }, |
| | | removeFromGB: function(row){ |
| | | var that = this; |
| | | that.$axios.post(`/api/push/removeFormGB`, row) |
| | | .then(function (res) { |
| | | console.log(res); |
| | | console.log(res.data == "success"); |
| | | if (res.data == "success") { |
| | | that.initData() |
| | | } |
| | | }) |
| | | .catch(function (error) { |
| | | console.log(error); |
| | | }); |
| | | }, |
| | | dateFormat: function(/** timestamp=0 **/) { |
| | | var ts = arguments[0] || 0; |
| | | var t,y,m,d,h,i,s; |
| | |
| | | <el-button size="mini" icon="el-icon-close" type="success" v-if="scope.row.enable" @click="stop(scope.row)">停用</el-button> |
| | | <el-button size="mini" icon="el-icon-check" type="primary" v-if="!scope.row.enable" @click="start(scope.row)">启用</el-button> |
| | | <el-button size="mini" icon="el-icon-delete" type="danger" @click="deleteStreamProxy(scope.row)">删除</el-button> |
| | | <!-- <el-button size="mini" icon="el-icon-position" type="primary" >加入国标</el-button> --> |
| | | </el-button-group> |
| | | </template> |
| | | </el-table-column> |
New file |
| | |
| | | <template> |
| | | <div id="addStreamProxy" v-loading="isLoging"> |
| | | <el-dialog |
| | | title=" 加入" |
| | | width="40%" |
| | | top="2rem" |
| | | :close-on-click-modal="false" |
| | | :visible.sync="showDialog" |
| | | :destroy-on-close="true" |
| | | @close="close()" |
| | | > |
| | | <div id="shared" style="margin-top: 1rem;margin-right: 100px;"> |
| | | <el-form ref="streamProxy" :rules="rules" :model="proxyParam" label-width="140px"> |
| | | <el-form-item label="名称" prop="name"> |
| | | <el-input v-model="proxyParam.name" clearable></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="流应用名" prop="app"> |
| | | <el-input v-model="proxyParam.app" clearable :disabled="true"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="流ID" prop="stream"> |
| | | <el-input v-model="proxyParam.stream" clearable :disabled="true"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="国标编码" prop="gbId"> |
| | | <el-input v-model="proxyParam.gbId" placeholder="设置国标编码可推送到国标" clearable></el-input> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <div style="float: right;"> |
| | | <el-button type="primary" @click="onSubmit">保存</el-button> |
| | | <el-button @click="close">取消</el-button> |
| | | </div> |
| | | |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | name: "streamProxyEdit", |
| | | props: {}, |
| | | computed: {}, |
| | | created() {}, |
| | | data() { |
| | | // var deviceGBIdRules = async (rule, value, callback) => { |
| | | // console.log(value); |
| | | // if (value === "") { |
| | | // callback(new Error("请输入设备国标编号")); |
| | | // } else { |
| | | // var exit = await this.deviceGBIdExit(value); |
| | | // console.log(exit); |
| | | // console.log(exit == "true"); |
| | | // console.log(exit === "true"); |
| | | // if (exit) { |
| | | // callback(new Error("设备国标编号已存在")); |
| | | // } else { |
| | | // callback(); |
| | | // } |
| | | // } |
| | | // }; |
| | | return { |
| | | listChangeCallback: null, |
| | | showDialog: false, |
| | | isLoging: false, |
| | | proxyParam: { |
| | | name: null, |
| | | app: null, |
| | | stream: null, |
| | | gbId: null, |
| | | }, |
| | | |
| | | rules: { |
| | | name: [{ required: true, message: "请输入名称", trigger: "blur" }], |
| | | app: [{ required: true, message: "请输入应用名", trigger: "blur" }], |
| | | stream: [{ required: true, message: "请输入流ID", trigger: "blur" }], |
| | | gbId: [{ required: true, message: "请输入国标编码", trigger: "blur" }], |
| | | }, |
| | | }; |
| | | }, |
| | | methods: { |
| | | openDialog: function (proxyParam, callback) { |
| | | this.showDialog = true; |
| | | this.listChangeCallback = callback; |
| | | if (proxyParam != null) { |
| | | this.proxyParam = proxyParam; |
| | | } |
| | | }, |
| | | onSubmit: function () { |
| | | console.log("onSubmit"); |
| | | var that = this; |
| | | that.$axios |
| | | .post(`/api/push/saveToGB`, that.proxyParam) |
| | | .then(function (res) { |
| | | console.log(res); |
| | | console.log(res.data == "success"); |
| | | if (res.data == "success") { |
| | | that.$message({ |
| | | showClose: true, |
| | | message: "保存成功", |
| | | type: "success", |
| | | }); |
| | | that.showDialog = false; |
| | | if (that.listChangeCallback != null) { |
| | | that.listChangeCallback(); |
| | | } |
| | | } |
| | | }) |
| | | .catch(function (error) { |
| | | console.log(error); |
| | | }); |
| | | }, |
| | | close: function () { |
| | | console.log("关闭加入GB"); |
| | | this.showDialog = false; |
| | | this.$refs.streamProxy.resetFields(); |
| | | }, |
| | | deviceGBIdExit: async function (deviceGbId) { |
| | | var result = false; |
| | | var that = this; |
| | | await that.$axios |
| | | .post(`/api/platforms/exit/${deviceGbId}`) |
| | | .then(function (res) { |
| | | result = res.data; |
| | | }) |
| | | .catch(function (error) { |
| | | console.log(error); |
| | | }); |
| | | return result; |
| | | }, |
| | | checkExpires: function() { |
| | | if (this.platform.enable && this.platform.expires == "0") { |
| | | this.platform.expires = "300"; |
| | | } |
| | | } |
| | | }, |
| | | }; |
| | | </script> |
| | |
| | | </el-table-column> |
| | | <el-table-column prop="gbId" label="国标编码" show-overflow-tooltip> |
| | | </el-table-column> |
| | | <el-table-column prop="streamType" label="流来源" align="center" show-overflow-tooltip> |
| | | </el-table-column> |
| | | <el-table-column label="流来源" width="100" align="center"> |
| | | <template slot-scope="scope"> |
| | | <div slot="reference" class="name-wrapper"> |
| | |
| | | import channelList from '../components/channelList.vue' |
| | | import pushVideoList from '../components/PushVideoList.vue' |
| | | import streamProxyList from '../components/StreamProxyList.vue' |
| | | import pLatformStreamList from '../components/PLatformStreamList.vue' |
| | | import devicePosition from '../components/devicePosition.vue' |
| | | import login from '../components/Login.vue' |
| | | import parentPlatformList from '../components/ParentPlatformList.vue' |
| | |
| | | { |
| | | path: '/pushVideoList', |
| | | component: pushVideoList, |
| | | }, |
| | | { |
| | | path: '/pLatformStreamList', |
| | | component: pLatformStreamList, |
| | | }, |
| | | { |
| | | path: '/streamProxyList', |