mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-05-24 22:17:49 +08:00
临时提交
This commit is contained in:
parent
d96faa2459
commit
5c83bf2a41
@ -11,6 +11,7 @@ import com.genersoft.iot.vmp.gb28181.bean.SendRtpInfo;
|
|||||||
import com.genersoft.iot.vmp.media.bean.MediaInfo;
|
import com.genersoft.iot.vmp.media.bean.MediaInfo;
|
||||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||||
import com.genersoft.iot.vmp.media.service.IMediaNodeServerService;
|
import com.genersoft.iot.vmp.media.service.IMediaNodeServerService;
|
||||||
|
import com.genersoft.iot.vmp.media.zlm.dto.ZLMResult;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.ZLMServerConfig;
|
import com.genersoft.iot.vmp.media.zlm.dto.ZLMServerConfig;
|
||||||
import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy;
|
import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||||
@ -71,9 +72,10 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
|
|||||||
if (mediaServer == null) {
|
if (mediaServer == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
JSONObject responseJSON = zlmresTfulUtils.getMediaServerConfig(mediaServer);
|
ZLMResult zlmResult = zlmresTfulUtils.getMediaServerConfig(mediaServer);
|
||||||
if (responseJSON != null) {
|
if (zlmResult != null) {
|
||||||
JSONArray data = responseJSON.getJSONArray("data");
|
zlmResult.getData()
|
||||||
|
JSONArray data = zlmResult.getJSONArray("data");
|
||||||
if (data != null && !data.isEmpty()) {
|
if (data != null && !data.isEmpty()) {
|
||||||
ZLMServerConfig zlmServerConfig= JSON.parseObject(JSON.toJSONString(data.get(0)), ZLMServerConfig.class);
|
ZLMServerConfig zlmServerConfig= JSON.parseObject(JSON.toJSONString(data.get(0)), ZLMServerConfig.class);
|
||||||
return zlmServerConfig.getGeneralMediaServerId().equals(mediaServer.getId());
|
return zlmServerConfig.getGeneralMediaServerId().equals(mediaServer.getId());
|
||||||
@ -181,15 +183,15 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
|
|||||||
@Override
|
@Override
|
||||||
public List<StreamInfo> getMediaList(MediaServer mediaServer, String app, String stream, String callId) {
|
public List<StreamInfo> getMediaList(MediaServer mediaServer, String app, String stream, String callId) {
|
||||||
List<StreamInfo> streamInfoList = new ArrayList<>();
|
List<StreamInfo> streamInfoList = new ArrayList<>();
|
||||||
JSONObject mediaList = zlmresTfulUtils.getMediaList(mediaServer, app, stream);
|
ZLMResult<?> zlmResult = zlmresTfulUtils.getMediaList(mediaServer, app, stream);
|
||||||
if (mediaList != null) {
|
if (zlmResult != null) {
|
||||||
if (mediaList.getInteger("code") == 0) {
|
if (zlmResult.getCode() == 0) {
|
||||||
JSONArray dataArray = mediaList.getJSONArray("data");
|
ZLMResult<JSONArray> result = (ZLMResult<JSONArray>)zlmResult;
|
||||||
if (dataArray == null) {
|
if (result.getData() == null) {
|
||||||
return streamInfoList;
|
return streamInfoList;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < dataArray.size(); i++) {
|
for (int i = 0; i < result.getData().size(); i++) {
|
||||||
JSONObject mediaJSON = dataArray.getJSONObject(0);
|
JSONObject mediaJSON = result.getData().getJSONObject(0);
|
||||||
MediaInfo mediaInfo = MediaInfo.getInstance(mediaJSON, mediaServer, userSetting.getServerId());
|
MediaInfo mediaInfo = MediaInfo.getInstance(mediaJSON, mediaServer, userSetting.getServerId());
|
||||||
StreamInfo streamInfo = getStreamInfoByAppAndStream(mediaServer, mediaInfo.getApp(), mediaInfo.getStream(), mediaInfo, callId, true);
|
StreamInfo streamInfo = getStreamInfoByAppAndStream(mediaServer, mediaInfo.getApp(), mediaInfo.getStream(), mediaInfo, callId, true);
|
||||||
if (streamInfo != null) {
|
if (streamInfo != null) {
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
package com.genersoft.iot.vmp.media.zlm;
|
package com.genersoft.iot.vmp.media.zlm;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.TypeReference;
|
||||||
|
import com.genersoft.iot.vmp.media.bean.MediaInfo;
|
||||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||||
|
import com.genersoft.iot.vmp.media.zlm.dto.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import okhttp3.*;
|
import okhttp3.*;
|
||||||
import okhttp3.logging.HttpLoggingInterceptor;
|
import okhttp3.logging.HttpLoggingInterceptor;
|
||||||
@ -16,6 +19,7 @@ import java.math.BigDecimal;
|
|||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -28,7 +32,10 @@ public class ZLMRESTfulUtils {
|
|||||||
|
|
||||||
|
|
||||||
public interface RequestCallback{
|
public interface RequestCallback{
|
||||||
void run(JSONObject response);
|
void run(String response);
|
||||||
|
}
|
||||||
|
public interface ResultCallback{
|
||||||
|
void run(ZLMResult<?> response);
|
||||||
}
|
}
|
||||||
|
|
||||||
private OkHttpClient getClient(){
|
private OkHttpClient getClient(){
|
||||||
@ -62,26 +69,22 @@ public class ZLMRESTfulUtils {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject sendPost(MediaServer mediaServerItem, String api, Map<String, Object> param, RequestCallback callback) {
|
public String sendPost(MediaServer mediaServer, String api, Map<String, Object> param, RequestCallback callback) {
|
||||||
return sendPost(mediaServerItem, api, param, callback, null);
|
return sendPost(mediaServer, api, param, callback, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public JSONObject sendPost(MediaServer mediaServerItem, String api, Map<String, Object> param, RequestCallback callback, Integer readTimeOut) {
|
public String sendPost(MediaServer mediaServer, String api, Map<String, Object> param, RequestCallback callback, Integer readTimeOut) {
|
||||||
OkHttpClient client = getClient(readTimeOut);
|
OkHttpClient client = getClient(readTimeOut);
|
||||||
|
|
||||||
if (mediaServerItem == null) {
|
if (mediaServer == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String url = String.format("http://%s:%s/index/api/%s", mediaServerItem.getIp(), mediaServerItem.getHttpPort(), api);
|
String url = String.format("http://%s:%s/index/api/%s", mediaServer.getIp(), mediaServer.getHttpPort(), api);
|
||||||
JSONObject responseJSON = new JSONObject();
|
String result = null;
|
||||||
//-2自定义流媒体 调用错误码
|
|
||||||
responseJSON.put("code",-2);
|
|
||||||
responseJSON.put("msg","流媒体调用失败");
|
|
||||||
|
|
||||||
FormBody.Builder builder = new FormBody.Builder();
|
FormBody.Builder builder = new FormBody.Builder();
|
||||||
builder.add("secret",mediaServerItem.getSecret());
|
builder.add("secret",mediaServer.getSecret());
|
||||||
if (param != null && param.keySet().size() > 0) {
|
if (param != null && !param.isEmpty()) {
|
||||||
for (String key : param.keySet()){
|
for (String key : param.keySet()){
|
||||||
if (param.get(key) != null) {
|
if (param.get(key) != null) {
|
||||||
builder.add(key, param.get(key).toString());
|
builder.add(key, param.get(key).toString());
|
||||||
@ -101,8 +104,7 @@ public class ZLMRESTfulUtils {
|
|||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
ResponseBody responseBody = response.body();
|
ResponseBody responseBody = response.body();
|
||||||
if (responseBody != null) {
|
if (responseBody != null) {
|
||||||
String responseStr = responseBody.string();
|
result = responseBody.string();
|
||||||
responseJSON = JSON.parseObject(responseStr);
|
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
response.close();
|
response.close();
|
||||||
@ -131,7 +133,7 @@ public class ZLMRESTfulUtils {
|
|||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
try {
|
try {
|
||||||
String responseStr = Objects.requireNonNull(response.body()).string();
|
String responseStr = Objects.requireNonNull(response.body()).string();
|
||||||
callback.run(JSON.parseObject(responseStr));
|
callback.run(responseStr);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error(String.format("[ %s ]请求失败: %s", url, e.getMessage()));
|
log.error(String.format("[ %s ]请求失败: %s", url, e.getMessage()));
|
||||||
}
|
}
|
||||||
@ -158,20 +160,18 @@ public class ZLMRESTfulUtils {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
return responseJSON;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendGetForImg(MediaServer mediaServerItem, String api, Map<String, Object> params, String targetPath, String fileName) {
|
public void sendGetForImg(MediaServer mediaServer, String api, Map<String, Object> params, String targetPath, String fileName) {
|
||||||
String url = String.format("http://%s:%s/index/api/%s", mediaServerItem.getIp(), mediaServerItem.getHttpPort(), api);
|
String url = String.format("http://%s:%s/index/api/%s", mediaServer.getIp(), mediaServer.getHttpPort(), api);
|
||||||
HttpUrl parseUrl = HttpUrl.parse(url);
|
HttpUrl parseUrl = HttpUrl.parse(url);
|
||||||
if (parseUrl == null) {
|
if (parseUrl == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HttpUrl.Builder httpBuilder = parseUrl.newBuilder();
|
HttpUrl.Builder httpBuilder = parseUrl.newBuilder();
|
||||||
|
|
||||||
httpBuilder.addQueryParameter("secret", mediaServerItem.getSecret());
|
httpBuilder.addQueryParameter("secret", mediaServer.getSecret());
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
for (Map.Entry<String, Object> param : params.entrySet()) {
|
for (Map.Entry<String, Object> param : params.entrySet()) {
|
||||||
httpBuilder.addQueryParameter(param.getKey(), param.getValue().toString());
|
httpBuilder.addQueryParameter(param.getKey(), param.getValue().toString());
|
||||||
@ -217,7 +217,7 @@ public class ZLMRESTfulUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject isMediaOnline(MediaServer mediaServerItem, String app, String stream, String schema){
|
public ZLMResult<?> isMediaOnline(MediaServer mediaServer, String app, String stream, String schema){
|
||||||
Map<String, Object> param = new HashMap<>();
|
Map<String, Object> param = new HashMap<>();
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
param.put("app",app);
|
param.put("app",app);
|
||||||
@ -229,10 +229,15 @@ public class ZLMRESTfulUtils {
|
|||||||
param.put("schema",schema);
|
param.put("schema",schema);
|
||||||
}
|
}
|
||||||
param.put("vhost","__defaultVhost__");
|
param.put("vhost","__defaultVhost__");
|
||||||
return sendPost(mediaServerItem, "isMediaOnline", param, null);
|
String response = sendPost(mediaServer, "isMediaOnline", param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, ZLMResult.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject getMediaList(MediaServer mediaServerItem, String app, String stream, String schema, RequestCallback callback){
|
public ZLMResult<?> getMediaList(MediaServer mediaServer, String app, String stream, String schema, RequestCallback callback){
|
||||||
Map<String, Object> param = new HashMap<>();
|
Map<String, Object> param = new HashMap<>();
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
param.put("app",app);
|
param.put("app",app);
|
||||||
@ -244,106 +249,202 @@ public class ZLMRESTfulUtils {
|
|||||||
param.put("schema",schema);
|
param.put("schema",schema);
|
||||||
}
|
}
|
||||||
param.put("vhost","__defaultVhost__");
|
param.put("vhost","__defaultVhost__");
|
||||||
return sendPost(mediaServerItem, "getMediaList",param, callback);
|
String response = sendPost(mediaServer, "getMediaList",param, callback);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, new TypeReference<ZLMResult<JSONArray>>() {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject getMediaList(MediaServer mediaServerItem, String app, String stream){
|
public ZLMResult<?> getMediaList(MediaServer mediaServer, String app, String stream){
|
||||||
return getMediaList(mediaServerItem, app, stream,null, null);
|
return getMediaList(mediaServer, app, stream,null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject getMediaList(MediaServer mediaServerItem, RequestCallback callback){
|
public ZLMResult<?> getMediaInfo(MediaServer mediaServer, String app, String schema, String stream){
|
||||||
return sendPost(mediaServerItem, "getMediaList",null, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
public JSONObject getMediaInfo(MediaServer mediaServerItem, String app, String schema, String stream){
|
|
||||||
Map<String, Object> param = new HashMap<>();
|
Map<String, Object> param = new HashMap<>();
|
||||||
param.put("app",app);
|
param.put("app",app);
|
||||||
param.put("schema",schema);
|
param.put("schema",schema);
|
||||||
param.put("stream",stream);
|
param.put("stream",stream);
|
||||||
param.put("vhost","__defaultVhost__");
|
param.put("vhost","__defaultVhost__");
|
||||||
return sendPost(mediaServerItem, "getMediaInfo",param, null);
|
|
||||||
|
String response = sendPost(mediaServer, "getMediaInfo",param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, new TypeReference<ZLMResult<MediaInfo>>() {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject getRtpInfo(MediaServer mediaServerItem, String stream_id){
|
public ZLMResult<?> getRtpInfo(MediaServer mediaServer, String stream_id){
|
||||||
Map<String, Object> param = new HashMap<>();
|
Map<String, Object> param = new HashMap<>();
|
||||||
param.put("stream_id",stream_id);
|
param.put("stream_id",stream_id);
|
||||||
return sendPost(mediaServerItem, "getRtpInfo",param, null);
|
String response = sendPost(mediaServer, "getRtpInfo",param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, ZLMResult.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject addFFmpegSource(MediaServer mediaServerItem, String src_url, String dst_url, Integer timeout_sec,
|
public ZLMResult<?> addFFmpegSource(MediaServer mediaServer, String src_url, String dst_url, Integer timeout_sec,
|
||||||
boolean enable_audio, boolean enable_mp4, String ffmpeg_cmd_key){
|
boolean enable_audio, boolean enable_mp4, String ffmpeg_cmd_key){
|
||||||
log.info(src_url);
|
|
||||||
log.info(dst_url);
|
|
||||||
Map<String, Object> param = new HashMap<>();
|
Map<String, Object> param = new HashMap<>();
|
||||||
param.put("src_url", src_url);
|
param.put("src_url", src_url);
|
||||||
param.put("dst_url", dst_url);
|
param.put("dst_url", dst_url);
|
||||||
param.put("timeout_ms", timeout_sec*1000);
|
param.put("timeout_ms", timeout_sec*1000);
|
||||||
param.put("enable_mp4", enable_mp4);
|
param.put("enable_mp4", enable_mp4);
|
||||||
param.put("ffmpeg_cmd_key", ffmpeg_cmd_key);
|
param.put("ffmpeg_cmd_key", ffmpeg_cmd_key);
|
||||||
return sendPost(mediaServerItem, "addFFmpegSource",param, null);
|
|
||||||
|
String response = sendPost(mediaServer, "addFFmpegSource",param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, new TypeReference<ZLMResult<StreamProxyResult>>() {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject delFFmpegSource(MediaServer mediaServerItem, String key){
|
public ZLMResult<?> delFFmpegSource(MediaServer mediaServer, String key){
|
||||||
Map<String, Object> param = new HashMap<>();
|
Map<String, Object> param = new HashMap<>();
|
||||||
param.put("key", key);
|
param.put("key", key);
|
||||||
return sendPost(mediaServerItem, "delFFmpegSource",param, null);
|
|
||||||
|
String response = sendPost(mediaServer, "delFFmpegSource",param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, new TypeReference<ZLMResult<FlagData>>() {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject delStreamProxy(MediaServer mediaServerItem, String key){
|
public ZLMResult<?> delStreamProxy(MediaServer mediaServer, String key){
|
||||||
Map<String, Object> param = new HashMap<>();
|
Map<String, Object> param = new HashMap<>();
|
||||||
param.put("key", key);
|
param.put("key", key);
|
||||||
return sendPost(mediaServerItem, "delStreamProxy",param, null);
|
String response = sendPost(mediaServer, "delStreamProxy",param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, new TypeReference<ZLMResult<FlagData>>() {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject getMediaServerConfig(MediaServer mediaServerItem){
|
public ZLMResult<?> getMediaServerConfig(MediaServer mediaServer ){
|
||||||
return sendPost(mediaServerItem, "getServerConfig",null, null);
|
|
||||||
|
String response = sendPost(mediaServer, "getServerConfig",null, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, new TypeReference<ZLMResult<List<ZLMServerConfig>>>() {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject setServerConfig(MediaServer mediaServerItem, Map<String, Object> param){
|
public ZLMResult<?> setServerConfig(MediaServer mediaServer, Map<String, Object> param){
|
||||||
return sendPost(mediaServerItem,"setServerConfig",param, null);
|
String response = sendPost(mediaServer, "setServerConfig",param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, ZLMResult.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject openRtpServer(MediaServer mediaServerItem, Map<String, Object> param){
|
public ZLMResult<?> openRtpServer(MediaServer mediaServer, Map<String, Object> param){
|
||||||
return sendPost(mediaServerItem, "openRtpServer",param, null);
|
String response = sendPost(mediaServer, "openRtpServer",param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, ZLMResult.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject closeRtpServer(MediaServer mediaServerItem, Map<String, Object> param) {
|
public ZLMResult<?> closeRtpServer(MediaServer mediaServer, Map<String, Object> param) {
|
||||||
return sendPost(mediaServerItem, "closeRtpServer",param, null);
|
String response = sendPost(mediaServer, "closeRtpServer",param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, ZLMResult.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeRtpServer(MediaServer mediaServerItem, Map<String, Object> param, RequestCallback callback) {
|
public void closeRtpServer(MediaServer mediaServer, Map<String, Object> param, ResultCallback callback) {
|
||||||
sendPost(mediaServerItem, "closeRtpServer",param, callback);
|
sendPost(mediaServer, "closeRtpServer",param, (response -> {
|
||||||
|
if (response == null) {
|
||||||
|
callback.run(ZLMResult.getFailForMediaServer());
|
||||||
|
}else {
|
||||||
|
callback.run(JSON.parseObject(response, ZLMResult.class));
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject listRtpServer(MediaServer mediaServerItem) {
|
public ZLMResult<?> listRtpServer(MediaServer mediaServer) {
|
||||||
return sendPost(mediaServerItem, "listRtpServer",null, null);
|
String response = sendPost(mediaServer, "listRtpServer",null, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, new TypeReference<ZLMResult<List<RtpServerResult>>>() {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject startSendRtp(MediaServer mediaServerItem, Map<String, Object> param) {
|
public ZLMResult<?> startSendRtp(MediaServer mediaServer, Map<String, Object> param) {
|
||||||
return sendPost(mediaServerItem, "startSendRtp",param, null);
|
String response = sendPost(mediaServer, "startSendRtp",param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, ZLMResult.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject startSendRtpPassive(MediaServer mediaServerItem, Map<String, Object> param) {
|
public ZLMResult<?> startSendRtpPassive(MediaServer mediaServer, Map<String, Object> param) {
|
||||||
return sendPost(mediaServerItem, "startSendRtpPassive",param, null);
|
String response = sendPost(mediaServer, "startSendRtpPassive",param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, ZLMResult.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject startSendRtpPassive(MediaServer mediaServerItem, Map<String, Object> param, RequestCallback callback) {
|
public ZLMResult<?> startSendRtpPassive(MediaServer mediaServer, Map<String, Object> param, ResultCallback callback) {
|
||||||
return sendPost(mediaServerItem, "startSendRtpPassive",param, callback);
|
String response = sendPost(mediaServer, "startSendRtpPassive",param, (responseStr -> {
|
||||||
|
if (responseStr == null) {
|
||||||
|
callback.run(ZLMResult.getFailForMediaServer());
|
||||||
|
}else {
|
||||||
|
callback.run(JSON.parseObject(responseStr, ZLMResult.class));
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, ZLMResult.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject startSendRtpTalk(MediaServer mediaServerItem, Map<String, Object> param, RequestCallback callback) {
|
public ZLMResult<?> startSendRtpTalk(MediaServer mediaServer, Map<String, Object> param, RequestCallback callback) {
|
||||||
return sendPost(mediaServerItem, "startSendRtpTalk",param, callback);
|
String response = sendPost(mediaServer, "startSendRtpTalk",param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, ZLMResult.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject stopSendRtp(MediaServer mediaServerItem, Map<String, Object> param) {
|
public ZLMResult<?> stopSendRtp(MediaServer mediaServer, Map<String, Object> param) {
|
||||||
return sendPost(mediaServerItem, "stopSendRtp",param, null);
|
String response = sendPost(mediaServer, "stopSendRtp",param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, ZLMResult.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject restartServer(MediaServer mediaServerItem) {
|
public ZLMResult<?> restartServer(MediaServer mediaServer) {
|
||||||
return sendPost(mediaServerItem, "restartServer",null, null);
|
String response = sendPost(mediaServer, "restartServer",null, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, ZLMResult.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject addStreamProxy(MediaServer mediaServerItem, String app, String stream, String url, boolean enable_audio, boolean enable_mp4, String rtp_type, Integer timeOut) {
|
public ZLMResult<?> addStreamProxy(MediaServer mediaServer, String app, String stream, String url, boolean enable_audio, boolean enable_mp4, String rtp_type, Integer timeOut) {
|
||||||
Map<String, Object> param = new HashMap<>();
|
Map<String, Object> param = new HashMap<>();
|
||||||
param.put("vhost", "__defaultVhost__");
|
param.put("vhost", "__defaultVhost__");
|
||||||
param.put("app", app);
|
param.put("app", app);
|
||||||
@ -355,95 +456,148 @@ public class ZLMRESTfulUtils {
|
|||||||
param.put("timeout_sec", timeOut);
|
param.put("timeout_sec", timeOut);
|
||||||
// 拉流重试次数,默认为3
|
// 拉流重试次数,默认为3
|
||||||
param.put("retry_count", 3);
|
param.put("retry_count", 3);
|
||||||
return sendPost(mediaServerItem, "addStreamProxy",param, null, 20);
|
|
||||||
|
String response = sendPost(mediaServer, "addStreamProxy",param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, new TypeReference<ZLMResult<StreamProxyResult>>() {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject closeStreams(MediaServer mediaServerItem, String app, String stream) {
|
public ZLMResult<?> closeStreams(MediaServer mediaServer, String app, String stream) {
|
||||||
Map<String, Object> param = new HashMap<>();
|
Map<String, Object> param = new HashMap<>();
|
||||||
param.put("vhost", "__defaultVhost__");
|
param.put("vhost", "__defaultVhost__");
|
||||||
param.put("app", app);
|
param.put("app", app);
|
||||||
param.put("stream", stream);
|
param.put("stream", stream);
|
||||||
param.put("force", 1);
|
param.put("force", 1);
|
||||||
return sendPost(mediaServerItem, "close_streams",param, null);
|
|
||||||
|
String response = sendPost(mediaServer, "close_streams",param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, new TypeReference<ZLMResult<FlagData>>() {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject getAllSession(MediaServer mediaServerItem) {
|
public ZLMResult<?> getAllSession(MediaServer mediaServer) {
|
||||||
return sendPost(mediaServerItem, "getAllSession",null, null);
|
String response = sendPost(mediaServer, "getAllSession",null, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, new TypeReference<ZLMResult<SessionData>>() {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void kickSessions(MediaServer mediaServerItem, String localPortSStr) {
|
public void kickSessions(MediaServer mediaServer, String localPortSStr) {
|
||||||
Map<String, Object> param = new HashMap<>();
|
Map<String, Object> param = new HashMap<>();
|
||||||
param.put("local_port", localPortSStr);
|
param.put("local_port", localPortSStr);
|
||||||
sendPost(mediaServerItem, "kick_sessions",param, null);
|
sendPost(mediaServer, "kick_sessions",param, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getSnap(MediaServer mediaServerItem, String streamUrl, int timeout_sec, int expire_sec, String targetPath, String fileName) {
|
public void getSnap(MediaServer mediaServer, String streamUrl, int timeout_sec, int expire_sec, String targetPath, String fileName) {
|
||||||
Map<String, Object> param = new HashMap<>(3);
|
Map<String, Object> param = new HashMap<>(3);
|
||||||
param.put("url", streamUrl);
|
param.put("url", streamUrl);
|
||||||
param.put("timeout_sec", timeout_sec);
|
param.put("timeout_sec", timeout_sec);
|
||||||
param.put("expire_sec", expire_sec);
|
param.put("expire_sec", expire_sec);
|
||||||
param.put("async", 1);
|
param.put("async", 1);
|
||||||
sendGetForImg(mediaServerItem, "getSnap", param, targetPath, fileName);
|
sendGetForImg(mediaServer, "getSnap", param, targetPath, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject pauseRtpCheck(MediaServer mediaServerItem, String streamId) {
|
public ZLMResult<?> pauseRtpCheck(MediaServer mediaServer, String streamId) {
|
||||||
Map<String, Object> param = new HashMap<>(1);
|
Map<String, Object> param = new HashMap<>(1);
|
||||||
param.put("stream_id", streamId);
|
param.put("stream_id", streamId);
|
||||||
return sendPost(mediaServerItem, "pauseRtpCheck",param, null);
|
String response = sendPost(mediaServer, "pauseRtpCheck", param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, ZLMResult.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject resumeRtpCheck(MediaServer mediaServerItem, String streamId) {
|
public ZLMResult<?> resumeRtpCheck(MediaServer mediaServer, String streamId) {
|
||||||
Map<String, Object> param = new HashMap<>(1);
|
Map<String, Object> param = new HashMap<>(1);
|
||||||
param.put("stream_id", streamId);
|
param.put("stream_id", streamId);
|
||||||
return sendPost(mediaServerItem, "resumeRtpCheck",param, null);
|
String response = sendPost(mediaServer, "resumeRtpCheck", param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, ZLMResult.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject connectRtpServer(MediaServer mediaServerItem, String dst_url, int dst_port, String stream_id) {
|
public ZLMResult<?> connectRtpServer(MediaServer mediaServer, String dst_url, int dst_port, String stream_id) {
|
||||||
Map<String, Object> param = new HashMap<>(1);
|
Map<String, Object> param = new HashMap<>(1);
|
||||||
param.put("dst_url", dst_url);
|
param.put("dst_url", dst_url);
|
||||||
param.put("dst_port", dst_port);
|
param.put("dst_port", dst_port);
|
||||||
param.put("stream_id", stream_id);
|
param.put("stream_id", stream_id);
|
||||||
return sendPost(mediaServerItem, "connectRtpServer",param, null);
|
String response = sendPost(mediaServer, "connectRtpServer", param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, ZLMResult.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject updateRtpServerSSRC(MediaServer mediaServerItem, String streamId, String ssrc) {
|
public ZLMResult<?> updateRtpServerSSRC(MediaServer mediaServer, String streamId, String ssrc) {
|
||||||
Map<String, Object> param = new HashMap<>(1);
|
Map<String, Object> param = new HashMap<>(1);
|
||||||
param.put("ssrc", ssrc);
|
param.put("ssrc", ssrc);
|
||||||
param.put("stream_id", streamId);
|
param.put("stream_id", streamId);
|
||||||
return sendPost(mediaServerItem, "updateRtpServerSSRC",param, null);
|
|
||||||
|
String response = sendPost(mediaServer, "updateRtpServerSSRC", param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, ZLMResult.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject deleteRecordDirectory(MediaServer mediaServerItem, String app, String stream, String date, String fileName) {
|
public ZLMResult<?> deleteRecordDirectory(MediaServer mediaServer, String app, String stream, String date, String fileName) {
|
||||||
Map<String, Object> param = new HashMap<>(1);
|
Map<String, Object> param = new HashMap<>(1);
|
||||||
param.put("vhost", "__defaultVhost__");
|
param.put("vhost", "__defaultVhost__");
|
||||||
param.put("app", app);
|
param.put("app", app);
|
||||||
param.put("stream", stream);
|
param.put("stream", stream);
|
||||||
param.put("period", date);
|
param.put("period", date);
|
||||||
param.put("name", fileName);
|
param.put("name", fileName);
|
||||||
return sendPost(mediaServerItem, "deleteRecordDirectory",param, null);
|
String response = sendPost(mediaServer, "deleteRecordDirectory", param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, ZLMResult.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject loadMP4File(MediaServer mediaServer, String app, String stream, String datePath) {
|
public ZLMResult<?> loadMP4File(MediaServer mediaServer, String app, String stream, String datePath) {
|
||||||
Map<String, Object> param = new HashMap<>(1);
|
Map<String, Object> param = new HashMap<>(1);
|
||||||
param.put("vhost", "__defaultVhost__");
|
param.put("vhost", "__defaultVhost__");
|
||||||
param.put("app", app);
|
param.put("app", app);
|
||||||
param.put("stream", stream);
|
param.put("stream", stream);
|
||||||
param.put("file_path", datePath);
|
param.put("file_path", datePath);
|
||||||
param.put("file_repeat", "0");
|
param.put("file_repeat", "0");
|
||||||
return sendPost(mediaServer, "loadMP4File",param, null);
|
String response = sendPost(mediaServer, "loadMP4File", param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, ZLMResult.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject setRecordSpeed(MediaServer mediaServer, String app, String stream, int speed, String schema) {
|
public ZLMResult<?> setRecordSpeed(MediaServer mediaServer, String app, String stream, int speed, String schema) {
|
||||||
Map<String, Object> param = new HashMap<>(1);
|
Map<String, Object> param = new HashMap<>(1);
|
||||||
param.put("vhost", "__defaultVhost__");
|
param.put("vhost", "__defaultVhost__");
|
||||||
param.put("app", app);
|
param.put("app", app);
|
||||||
param.put("stream", stream);
|
param.put("stream", stream);
|
||||||
param.put("speed", speed);
|
param.put("speed", speed);
|
||||||
param.put("schema", schema);
|
param.put("schema", schema);
|
||||||
return sendPost(mediaServer, "setRecordSpeed",param, null);
|
String response = sendPost(mediaServer, "setRecordSpeed", param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, ZLMResult.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject seekRecordStamp(MediaServer mediaServer, String app, String stream, Double stamp, String schema) {
|
public ZLMResult<?> seekRecordStamp(MediaServer mediaServer, String app, String stream, Double stamp, String schema) {
|
||||||
Map<String, Object> param = new HashMap<>(1);
|
Map<String, Object> param = new HashMap<>(1);
|
||||||
param.put("vhost", "__defaultVhost__");
|
param.put("vhost", "__defaultVhost__");
|
||||||
param.put("app", app);
|
param.put("app", app);
|
||||||
@ -451,6 +605,12 @@ public class ZLMRESTfulUtils {
|
|||||||
BigDecimal bigDecimal = new BigDecimal(stamp);
|
BigDecimal bigDecimal = new BigDecimal(stamp);
|
||||||
param.put("stamp", bigDecimal);
|
param.put("stamp", bigDecimal);
|
||||||
param.put("schema", schema);
|
param.put("schema", schema);
|
||||||
return sendPost(mediaServer, "seekRecordStamp",param, null);
|
|
||||||
|
String response = sendPost(mediaServer, "seekRecordStamp", param, null);
|
||||||
|
if (response == null) {
|
||||||
|
return ZLMResult.getFailForMediaServer();
|
||||||
|
}else {
|
||||||
|
return JSON.parseObject(response, ZLMResult.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
package com.genersoft.iot.vmp.media.zlm;
|
package com.genersoft.iot.vmp.media.zlm;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.genersoft.iot.vmp.common.CommonCallback;
|
import com.genersoft.iot.vmp.common.CommonCallback;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.SendRtpInfo;
|
import com.genersoft.iot.vmp.gb28181.bean.SendRtpInfo;
|
||||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||||
|
import com.genersoft.iot.vmp.media.zlm.dto.ZLMResult;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -31,18 +33,18 @@ public class ZLMServerFactory {
|
|||||||
public int createRTPServer(MediaServer mediaServerItem, String app, String streamId, long ssrc, Integer port, Boolean onlyAuto, Boolean disableAudio, Boolean reUsePort, Integer tcpMode) {
|
public int createRTPServer(MediaServer mediaServerItem, String app, String streamId, long ssrc, Integer port, Boolean onlyAuto, Boolean disableAudio, Boolean reUsePort, Integer tcpMode) {
|
||||||
int result = -1;
|
int result = -1;
|
||||||
// 查询此rtp server 是否已经存在
|
// 查询此rtp server 是否已经存在
|
||||||
JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaServerItem, streamId);
|
ZLMResult<?> rtpInfoResult = zlmresTfulUtils.getRtpInfo(mediaServerItem, streamId);
|
||||||
if(rtpInfo.getInteger("code") == 0){
|
if(rtpInfoResult.getCode() == 0){
|
||||||
if (rtpInfo.getBoolean("exist")) {
|
if (rtpInfoResult.getExist() != null && rtpInfoResult.getExist()) {
|
||||||
result = rtpInfo.getInteger("local_port");
|
result = rtpInfoResult.getLocal_port();
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
// 此时说明rtpServer已经创建但是流还没有推上来
|
// 此时说明rtpServer已经创建但是流还没有推上来
|
||||||
// 此时重新打开rtpServer
|
// 此时重新打开rtpServer
|
||||||
Map<String, Object> param = new HashMap<>();
|
Map<String, Object> param = new HashMap<>();
|
||||||
param.put("stream_id", streamId);
|
param.put("stream_id", streamId);
|
||||||
JSONObject jsonObject = zlmresTfulUtils.closeRtpServer(mediaServerItem, param);
|
ZLMResult<?> zlmResult = zlmresTfulUtils.closeRtpServer(mediaServerItem, param);
|
||||||
if (jsonObject != null ) {
|
if (zlmResult != null ) {
|
||||||
if (jsonObject.getInteger("code") == 0) {
|
if (zlmResult.getCode() == 0) {
|
||||||
return createRTPServer(mediaServerItem, streamId, app, ssrc, port,onlyAuto, reUsePort,disableAudio, tcpMode);
|
return createRTPServer(mediaServerItem, streamId, app, ssrc, port,onlyAuto, reUsePort,disableAudio, tcpMode);
|
||||||
}else {
|
}else {
|
||||||
log.warn("[开启rtpServer], 重启RtpServer错误");
|
log.warn("[开启rtpServer], 重启RtpServer错误");
|
||||||
@ -51,7 +53,7 @@ public class ZLMServerFactory {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}else if(rtpInfo.getInteger("code") == -2){
|
}else if(rtpInfoResult.getCode() == -2){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,13 +176,14 @@ public class ZLMServerFactory {
|
|||||||
* 查询待转推的流是否就绪
|
* 查询待转推的流是否就绪
|
||||||
*/
|
*/
|
||||||
public Boolean isStreamReady(MediaServer mediaServerItem, String app, String streamId) {
|
public Boolean isStreamReady(MediaServer mediaServerItem, String app, String streamId) {
|
||||||
JSONObject mediaInfo = zlmresTfulUtils.getMediaList(mediaServerItem, app, streamId);
|
ZLMResult<?> zlmResult = zlmresTfulUtils.getMediaList(mediaServerItem, app, streamId);
|
||||||
if (mediaInfo == null || (mediaInfo.getInteger("code") == -2)) {
|
if (zlmResult == null || zlmResult.getCode() == -2) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return (mediaInfo.getInteger("code") == 0
|
ZLMResult<JSONArray> result = (ZLMResult<JSONArray>) zlmResult;
|
||||||
&& mediaInfo.getJSONArray("data") != null
|
return (result.getCode() == 0
|
||||||
&& mediaInfo.getJSONArray("data").size() > 0);
|
&& result.getData() != null
|
||||||
|
&& !result.getData().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -0,0 +1,8 @@
|
|||||||
|
package com.genersoft.iot.vmp.media.zlm.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FlagData {
|
||||||
|
private boolean flag;
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
package com.genersoft.iot.vmp.media.zlm.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class RtpServerResult {
|
||||||
|
private Integer port;
|
||||||
|
private String stream_id;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
package com.genersoft.iot.vmp.media.zlm.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SessionData {
|
||||||
|
private String id;
|
||||||
|
private String local_ip;
|
||||||
|
private Integer local_port;
|
||||||
|
private String peer_ip;
|
||||||
|
private Integer peer_port;
|
||||||
|
private String typeid;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.genersoft.iot.vmp.media.zlm.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class StreamProxyResult {
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
package com.genersoft.iot.vmp.media.zlm.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ZLMResult<T> {
|
||||||
|
private int code;
|
||||||
|
private String msg;
|
||||||
|
private T data;
|
||||||
|
|
||||||
|
|
||||||
|
private Boolean online;
|
||||||
|
private Boolean exist;
|
||||||
|
private String peer_ip;
|
||||||
|
private Integer peer_port;
|
||||||
|
private String local_ip;
|
||||||
|
private Integer local_port;
|
||||||
|
private Integer changed;
|
||||||
|
private Integer port;
|
||||||
|
private Integer hit;
|
||||||
|
|
||||||
|
public static ZLMResult<?> getFailForMediaServer() {
|
||||||
|
ZLMResult<?> zlmResult = new ZLMResult<>();
|
||||||
|
zlmResult.setCode(-2);
|
||||||
|
zlmResult.setMsg("流媒体调用失败");
|
||||||
|
return zlmResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ZLMResult<?> getMediaServer(int code, String msg) {
|
||||||
|
return getMediaServer(code, msg, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ZLMResult<?> getMediaServer(int code, String msg, Object data) {
|
||||||
|
ZLMResult<Object> zlmResult = new ZLMResult<>();
|
||||||
|
zlmResult.setCode(code);
|
||||||
|
zlmResult.setMsg(msg);
|
||||||
|
zlmResult.setData(data);
|
||||||
|
return zlmResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user