支持多WVP的推流播放
This commit is contained in:
@@ -13,8 +13,8 @@ import java.util.Set;
|
||||
@Repository
|
||||
public interface StreamPushMapper {
|
||||
|
||||
@Insert("INSERT INTO wvp_stream_push (app, stream, media_server_id, server_id, push_time, update_time, create_time, pushing) VALUES" +
|
||||
"(#{app}, #{stream}, #{mediaServerId} , #{serverId} , #{pushTime} ,#{updateTime}, #{createTime}, #{pushing})")
|
||||
@Insert("INSERT INTO wvp_stream_push (app, stream, media_server_id, server_id, push_time, update_time, create_time, pushing, start_offline_push) VALUES" +
|
||||
"(#{app}, #{stream}, #{mediaServerId} , #{serverId} , #{pushTime} ,#{updateTime}, #{createTime}, #{pushing}, #{startOfflinePush})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
int add(StreamPush streamPushItem);
|
||||
|
||||
@@ -28,6 +28,7 @@ public interface StreamPushMapper {
|
||||
"<if test=\"serverId != null\">, server_id=#{serverId}</if>" +
|
||||
"<if test=\"pushTime != null\">, push_time=#{pushTime}</if>" +
|
||||
"<if test=\"pushing != null\">, pushing=#{pushing}</if>" +
|
||||
"<if test=\"startOfflinePush != null\">, start_offline_push=#{startOfflinePush}</if>" +
|
||||
"WHERE id = #{id}"+
|
||||
" </script>"})
|
||||
int update(StreamPush streamPushItem);
|
||||
@@ -61,9 +62,9 @@ public interface StreamPushMapper {
|
||||
|
||||
@Insert("<script>" +
|
||||
"Insert INTO wvp_stream_push ( " +
|
||||
" app, stream, media_server_id, server_id, push_time, update_time, create_time, pushing) " +
|
||||
" app, stream, media_server_id, server_id, push_time, update_time, create_time, pushing, start_offline_push) " +
|
||||
" VALUES <foreach collection='streamPushItems' item='item' index='index' separator=','>" +
|
||||
" ( #{item.app}, #{item.stream}, #{item.mediaServerId},#{item.serverId} ,#{item.pushTime}, #{item.updateTime}, #{item.createTime}, #{item.pushing} )" +
|
||||
" ( #{item.app}, #{item.stream}, #{item.mediaServerId},#{item.serverId} ,#{item.pushTime}, #{item.updateTime}, #{item.createTime}, #{item.pushing}, #{item.startOfflinePush} )" +
|
||||
" </foreach>" +
|
||||
" </script>")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
@@ -136,4 +137,21 @@ public interface StreamPushMapper {
|
||||
")</script>")
|
||||
void batchDel(List<StreamPush> streamPushList);
|
||||
|
||||
|
||||
@Update({"<script>" +
|
||||
"<foreach collection='streamPushItemForUpdate' item='item' separator=';'>" +
|
||||
" UPDATE" +
|
||||
" wvp_stream_push" +
|
||||
" SET update_time=#{item.updateTime}" +
|
||||
", app=#{item.app}" +
|
||||
", stream=#{item.stream}" +
|
||||
", media_server_id=#{item.mediaServerId}" +
|
||||
", server_id=#{item.serverId}" +
|
||||
", push_time=#{item.pushTime}" +
|
||||
", pushing=#{item.pushing}" +
|
||||
", start_offline_push=#{item.startOfflinePush}" +
|
||||
" WHERE id=#{item.item.id}" +
|
||||
"</foreach>" +
|
||||
"</script>"})
|
||||
int batchUpdate(List<StreamPush> streamPushItemForUpdate);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public interface IStreamPushService {
|
||||
|
||||
void deleteByAppAndStream(String app, String stream);
|
||||
|
||||
void updatePushStatus(Integer streamPushId, boolean pushIng);
|
||||
void updatePushStatus(StreamPush streamPush, boolean pushIng);
|
||||
|
||||
void batchUpdate(List<StreamPush> streamPushItemForUpdate);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.conf.DynamicTask;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent;
|
||||
import com.genersoft.iot.vmp.media.bean.MediaInfo;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
|
||||
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
|
||||
@@ -53,14 +53,14 @@ public class StreamPushPlayServiceImpl implements IStreamPushPlayService {
|
||||
public void start(Integer id, ErrorCallback<StreamInfo> callback, String platformDeviceId, String platformName ) {
|
||||
StreamPush streamPush = streamPushMapper.queryOne(id);
|
||||
Assert.notNull(streamPush, "推流信息未找到");
|
||||
MediaArrivalEvent pushListItem = redisCatchStorage.getPushListItem(streamPush.getApp(), streamPush.getStream());
|
||||
if (pushListItem != null) {
|
||||
MediaInfo mediaInfo = redisCatchStorage.getPushListItem(streamPush.getApp(), streamPush.getStream());
|
||||
if (mediaInfo != null) {
|
||||
String callId = null;
|
||||
StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(streamPush.getApp(), streamPush.getStream());
|
||||
if (streamAuthorityInfo != null) {
|
||||
callId = streamAuthorityInfo.getCallId();
|
||||
}
|
||||
callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), mediaServerService.getStreamInfoByAppAndStream(pushListItem.getMediaServer(),
|
||||
callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), mediaServerService.getStreamInfoByAppAndStream(mediaInfo.getMediaServer(),
|
||||
streamPush.getApp(), streamPush.getStream(), null, callId));
|
||||
return;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class StreamPushPlayServiceImpl implements IStreamPushPlayService {
|
||||
long key = redisRpcService.onStreamOnlineEvent(streamPush.getApp(), streamPush.getStream(), (streamInfo) -> {
|
||||
dynamicTask.stop(timeOutTaskKey);
|
||||
if (streamInfo == null) {
|
||||
log.warn("[级联点播] 等待推流得到结果未空: {}/{}", streamPush.getApp(), streamPush.getStream());
|
||||
log.warn("等待推流得到结果未空: {}/{}", streamPush.getApp(), streamPush.getStream());
|
||||
callback.run(ErrorCode.ERROR100.getCode(), "fail", null);
|
||||
}else {
|
||||
callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo);
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.genersoft.iot.vmp.streamPush.service.IStreamPushService;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -99,14 +98,11 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
||||
streamPush.setPushTime(DateUtil.getNow());
|
||||
add(streamPush);
|
||||
}else {
|
||||
updatePushStatus(streamPushInDb.getId(), true);
|
||||
updatePushStatus(streamPushInDb, true);
|
||||
}
|
||||
// 冗余数据,自己系统中自用
|
||||
if (!"broadcast".equals(event.getApp()) && !"talk".equals(event.getApp())) {
|
||||
StreamInfo streamInfo = mediaServerService.getStreamInfoByAppAndStream(
|
||||
event.getMediaServer(), event.getApp(), event.getStream(), event.getMediaInfo(), event.getCallId());
|
||||
event.getHookParam().setStreamInfo(new StreamContent(streamInfo));
|
||||
redisCatchStorage.addPushListItem(event.getApp(), event.getStream(), event);
|
||||
redisCatchStorage.addPushListItem(event.getApp(), event.getStream(), event.getMediaInfo());
|
||||
}
|
||||
|
||||
// 发送流变化redis消息
|
||||
@@ -148,18 +144,12 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
||||
redisCatchStorage.sendStreamChangeMsg(type, jsonObject);
|
||||
}
|
||||
}
|
||||
StreamPush push = getPush(event.getApp(), event.getStream());
|
||||
if (push == null) {
|
||||
StreamPush streamPush = getPush(event.getApp(), event.getStream());
|
||||
if (streamPush == null) {
|
||||
return;
|
||||
}
|
||||
push.setPushing(false);
|
||||
if (push.getGbDeviceId() != null) {
|
||||
if (userSetting.isUsePushingAsStatus()) {
|
||||
push.setGbStatus("OFF");
|
||||
updateStatus(push);
|
||||
// streamPushMapper.updatePushStatus(event.getApp(), event.getStream(), false);
|
||||
// eventPublisher.catalogEventPublishForStream(null, gbStream, CatalogEvent.OFF);
|
||||
}
|
||||
if (streamPush.getGbDeviceId() != null) {
|
||||
updatePushStatus(streamPush, false);
|
||||
}else {
|
||||
deleteByAppAndStream(event.getApp(), event.getStream());
|
||||
}
|
||||
@@ -524,27 +514,28 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
||||
|
||||
@Override
|
||||
public void updateStatus(StreamPush push) {
|
||||
if (ObjectUtils.isEmpty(push.getGbDeviceId())) {
|
||||
return;
|
||||
}
|
||||
if ("ON".equalsIgnoreCase(push.getGbStatus())) {
|
||||
gbChannelService.online(push.buildCommonGBChannel());
|
||||
}else {
|
||||
gbChannelService.offline(push.buildCommonGBChannel());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void updatePushStatus(Integer streamPushId, boolean pushIng) {
|
||||
StreamPush streamPushInDb = streamPushMapper.queryOne(streamPushId);
|
||||
streamPushInDb.setPushing(pushIng);
|
||||
@Transactional
|
||||
public void updatePushStatus(StreamPush streamPush, boolean pushIng) {
|
||||
streamPush.setPushing(pushIng);
|
||||
if (userSetting.isUsePushingAsStatus()) {
|
||||
streamPushInDb.setGbStatus(pushIng?"ON":"OFF");
|
||||
streamPush.setGbStatus(pushIng?"ON":"OFF");
|
||||
}
|
||||
streamPush.setPushTime(DateUtil.getNow());
|
||||
streamPushMapper.updatePushStatus(streamPush.getId(), pushIng);
|
||||
if (ObjectUtils.isEmpty(streamPush.getGbDeviceId())) {
|
||||
return;
|
||||
}
|
||||
if ("ON".equalsIgnoreCase(streamPush.getGbStatus())) {
|
||||
gbChannelService.online(streamPush.buildCommonGBChannel());
|
||||
}else {
|
||||
gbChannelService.offline(streamPush.buildCommonGBChannel());
|
||||
}
|
||||
streamPushInDb.setPushTime(DateUtil.getNow());
|
||||
updateStatus(streamPushInDb);
|
||||
}
|
||||
|
||||
private List<StreamPush> handleJSON(List<StreamInfo> streamInfoList) {
|
||||
@@ -570,7 +561,16 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
||||
|
||||
@Override
|
||||
public void batchUpdate(List<StreamPush> streamPushItemForUpdate) {
|
||||
|
||||
int result = streamPushMapper.batchUpdate(streamPushItemForUpdate);
|
||||
if (result > 0) {
|
||||
List<CommonGBChannel> commonGBChannels = new ArrayList<>();
|
||||
for (StreamPush streamPush : streamPushItemForUpdate) {
|
||||
if (!ObjectUtils.isEmpty(streamPush.getGbDeviceId())) {
|
||||
commonGBChannels.add(streamPush.buildCommonGBChannel());
|
||||
}
|
||||
}
|
||||
gbChannelService.batchUpdate(commonGBChannels);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user