集成rtc播放器

This commit is contained in:
panlinlin
2021-04-11 14:44:27 +08:00
parent 2b1e56973e
commit a4ab9a0a6c
7 changed files with 7691 additions and 19 deletions

View File

@@ -18,6 +18,7 @@ public class StreamInfo {
private String ws_ts;
private String rtmp;
private String rtsp;
private String rtc;
private JSONArray tracks;
public String getApp() {
@@ -139,4 +140,12 @@ public class StreamInfo {
public void setStreamId(String streamId) {
this.streamId = streamId;
}
public String getRtc() {
return rtc;
}
public void setRtc(String rtc) {
this.rtc = rtc;
}
}

View File

@@ -4,6 +4,7 @@ import java.util.List;
import java.util.UUID;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.gb28181.bean.Device;
@@ -239,26 +240,33 @@ public class ZLMHttpHookListener {
String app = json.getString("app");
String streamId = json.getString("stream");
String schema = json.getString("schema");
boolean regist = json.getBoolean("regist");
JSONArray tracks = json.getJSONArray("tracks");
String regist = json.getString("regist");
if (tracks != null) {
System.out.println("222222" + schema);
}
if ("rtmp".equals(schema)){
if ("rtp".equals(app) && !regist ) {
StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
if (streamInfo!=null){
redisCatchStorage.stopPlay(streamInfo);
storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
}else{
streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId);
redisCatchStorage.stopPlayback(streamInfo);
}
}else {
if (!"rtp".equals(app) && "rtmp".equals(schema)){
if (regist) {
zlmMediaListManager.addMedia(app, streamId);
}else {
zlmMediaListManager.removeMedia(app, streamId);
if ("rtp".equals(app) && regist != null ) {
StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
if (streamInfo!=null){
redisCatchStorage.stopPlay(streamInfo);
storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
}else{
streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId);
redisCatchStorage.stopPlayback(streamInfo);
}
}else {
if (!"rtp".equals(app) ){
if (regist == null) {
zlmMediaListManager.addMedia(app, streamId);
}else {
zlmMediaListManager.removeMedia(app, streamId);
}
}
}
}
JSONObject ret = new JSONObject();
ret.put("code", 0);
ret.put("msg", "success");

View File

@@ -42,6 +42,8 @@ public class MediaServiceImpl implements IMediaService {
streamInfoResult.setWs_fmp4(String.format("ws://%s:%s/%s/%s.live.mp4", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), app, stream));
streamInfoResult.setTs(String.format("http://%s:%s/%s/%s.live.ts", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), app, stream));
streamInfoResult.setWs_ts(String.format("ws://%s:%s/%s/%s.live.ts", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), app, stream));
streamInfoResult.setRtc(String.format("http://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), app, stream));
return streamInfoResult;
}