...
|
...
|
@@ -31,9 +31,7 @@ import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; |
31
|
31
|
import org.thingsboard.server.common.data.yunteng.dto.DeviceDTO;
|
32
|
32
|
import org.thingsboard.server.common.data.yunteng.dto.sip.*;
|
33
|
33
|
import org.thingsboard.server.common.data.yunteng.dto.sip.hook.param.HookSubscribeForStreamChange;
|
34
|
|
-import org.thingsboard.server.common.data.yunteng.enums.PTZCommandEnum;
|
35
|
|
-import org.thingsboard.server.common.data.yunteng.enums.SessionTypeEnum;
|
36
|
|
-import org.thingsboard.server.common.data.yunteng.enums.VideoMethodEnum;
|
|
34
|
+import org.thingsboard.server.common.data.yunteng.enums.*;
|
37
|
35
|
import org.thingsboard.server.common.data.yunteng.utils.JacksonUtil;
|
38
|
36
|
import org.thingsboard.server.common.data.yunteng.utils.ZLMediaKitRestFulUtils;
|
39
|
37
|
import org.thingsboard.server.common.msg.rpc.FromDeviceRpcResponse;
|
...
|
...
|
@@ -63,7 +61,8 @@ public class TkVideoControlServiceImpl implements TkVideoControlService { |
63
|
61
|
|
64
|
62
|
@Override
|
65
|
63
|
public ListenableFuture<StreamContentDTO> startPlay(
|
66
|
|
- SecurityUser currentUser, String deviceId, String channelId, String tenantId) {
|
|
64
|
+ SecurityUser currentUser, String deviceId, String channelId) {
|
|
65
|
+ String tenantId = currentUser.getCurrentTenantId();
|
67
|
66
|
// 判断设备、通道是否存在
|
68
|
67
|
DeviceDTO deviceDTO = tkDeviceService.checkDeviceByTenantIdAndId(tenantId, deviceId, true);
|
69
|
68
|
SipDeviceDTO sipDeviceDTO =
|
...
|
...
|
@@ -74,7 +73,9 @@ public class TkVideoControlServiceImpl implements TkVideoControlService { |
74
|
73
|
if (null == sipDeviceDTO) {
|
75
|
74
|
throw new TkDataValidationException(ErrorMessage.FOUND_VIDEO_DEVICE_FAILED.getMessage());
|
76
|
75
|
}
|
77
|
|
- VideoChanelDTO videoChanelDTO = tkVideoChannelService.findVideoChannelById(sipDeviceDTO.getCameraCode(), channelId, tenantId);
|
|
76
|
+ VideoChanelDTO videoChanelDTO =
|
|
77
|
+ tkVideoChannelService.findVideoChannelById(
|
|
78
|
+ sipDeviceDTO.getCameraCode(), channelId, tenantId);
|
78
|
79
|
if (null == videoChanelDTO) {
|
79
|
80
|
throw new TkDataValidationException(ErrorMessage.VIDEO_CHANNEL_NOT_FOUND.getMessage());
|
80
|
81
|
}
|
...
|
...
|
@@ -114,6 +115,69 @@ public class TkVideoControlServiceImpl implements TkVideoControlService { |
114
|
115
|
}
|
115
|
116
|
|
116
|
117
|
@Override
|
|
118
|
+ public ListenableFuture<String> freshChannel(SecurityUser currentUser, String deviceId) {
|
|
119
|
+ String tenantId = currentUser.getCurrentTenantId();
|
|
120
|
+ // 判断设备、通道是否存在
|
|
121
|
+ Optional<DeviceDTO> device = Optional.ofNullable(tkDeviceService.checkDeviceByTenantIdAndId(tenantId, deviceId, true));
|
|
122
|
+ if(device.isEmpty()){
|
|
123
|
+ return Futures.immediateFuture(ErrorMessage.DEVICE_NOT_EXTIED.getMessage());
|
|
124
|
+ }
|
|
125
|
+ DeviceDTO deviceDTO = device.get();
|
|
126
|
+ if (!deviceDTO.getDeviceState().equals(DeviceState.ONLINE)) {
|
|
127
|
+ return Futures.immediateFuture(ErrorMessage.DEVICE_NOT_ONLINE.getMessage());
|
|
128
|
+ }
|
|
129
|
+ SipDeviceDTO sipDeviceDTO =
|
|
130
|
+ JacksonUtil.convertValue(
|
|
131
|
+ deviceDTO.getDeviceInfo().get(FastIotConstants.DeviceAdditional.SIP),
|
|
132
|
+ SipDeviceDTO.class);
|
|
133
|
+ // 获取设备的附加信息
|
|
134
|
+ if (null == sipDeviceDTO) {
|
|
135
|
+ throw new TkDataValidationException(ErrorMessage.FOUND_VIDEO_DEVICE_FAILED.getMessage());
|
|
136
|
+ }
|
|
137
|
+ CountDownLatch timeoutLatch = new CountDownLatch(1);
|
|
138
|
+ AtomicReference<String> result = new AtomicReference<>();
|
|
139
|
+ // 进行命令发送
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+ ObjectNode paramJson = JacksonUtil.newObjectNode();
|
|
143
|
+ paramJson.put(FastIotConstants.ZLMediaBody.MSG_TYPE, VideoXmlEnum.Query.name());
|
|
144
|
+ int sn = (int) ((Math.random() * 9 + 1) * 100000);
|
|
145
|
+ paramJson.put(FastIotConstants.ZLMediaBody.MSG_CONTEXT, sn);
|
|
146
|
+
|
|
147
|
+ try {
|
|
148
|
+ cameraCommonCmd(
|
|
149
|
+ currentUser.getCurrentTenantId(),
|
|
150
|
+ paramJson,
|
|
151
|
+ sipDeviceDTO.getCameraCode(),
|
|
152
|
+ VideoMethodEnum.MESSAGE,
|
|
153
|
+ false,
|
|
154
|
+ deviceId,
|
|
155
|
+ fromDeviceRpcResponse -> {
|
|
156
|
+ log.warn(
|
|
157
|
+ "【流媒体SIP】收到【视频点播】结果=异常【{}】+数据【{}】",
|
|
158
|
+ fromDeviceRpcResponse.getError(),
|
|
159
|
+ fromDeviceRpcResponse.getResponse());
|
|
160
|
+ fromDeviceRpcResponse
|
|
161
|
+ .getResponse()
|
|
162
|
+ .ifPresent(
|
|
163
|
+ jsonStr -> {
|
|
164
|
+ JsonNode responseJson = JacksonUtil.toJsonNode(jsonStr);
|
|
165
|
+ if (fromDeviceRpcResponse.getError().isEmpty()) {
|
|
166
|
+ result.set(jsonStr);
|
|
167
|
+ } else {
|
|
168
|
+ result.set(fromDeviceRpcResponse.getError().get().name());
|
|
169
|
+ }
|
|
170
|
+ });
|
|
171
|
+ timeoutLatch.countDown();
|
|
172
|
+ });
|
|
173
|
+ } catch (ThingsboardException e) {
|
|
174
|
+ Futures.immediateFailedFuture(e);
|
|
175
|
+ }
|
|
176
|
+ return Futures.immediateFuture(result.get());
|
|
177
|
+
|
|
178
|
+ }
|
|
179
|
+
|
|
180
|
+ @Override
|
117
|
181
|
public StreamInfoDTO onPublishHandlerForPlay(
|
118
|
182
|
MediaServerDTO mediaServerItem, JsonNode response, String deviceCode, String channelId) {
|
119
|
183
|
StreamInfoDTO streamInfo = onPublishHandler(mediaServerItem, response, deviceCode, channelId);
|
...
|
...
|
@@ -130,37 +194,41 @@ public class TkVideoControlServiceImpl implements TkVideoControlService { |
130
|
194
|
}
|
131
|
195
|
|
132
|
196
|
@Override
|
133
|
|
- public boolean stopPlay(SecurityUser currentUser, String tbDeviceId, String channelId) throws ThingsboardException {
|
134
|
|
- String tenantId = currentUser.getCurrentTenantId();
|
135
|
|
- DeviceDTO deviceDTO = tkDeviceService.findDeviceInfoByTbDeviceId(tenantId, tbDeviceId);
|
136
|
|
- if (null == deviceDTO
|
137
|
|
- || !deviceDTO.getDeviceInfo().has(FastIotConstants.DeviceAdditional.SIP)) {
|
138
|
|
- throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
|
139
|
|
- }
|
140
|
|
- String cameraCode =
|
141
|
|
- deviceDTO
|
142
|
|
- .getDeviceInfo()
|
143
|
|
- .get(FastIotConstants.DeviceAdditional.SIP)
|
144
|
|
- .get(FastIotConstants.ZLMediaBody.CAMERA_CODE)
|
145
|
|
- .asText();
|
146
|
|
-
|
147
|
|
- Optional<StreamInfoDTO> streamInfoDTO =
|
148
|
|
- tkCacheStorageService.queryPlayStreamByChannel(cameraCode, channelId);
|
149
|
|
- if (streamInfoDTO.isEmpty()) {
|
150
|
|
- throw new TkDataValidationException(
|
151
|
|
- ErrorMessage.STREAM_INFO_NOT_FOUND_FOR_PLAY.getMessage());
|
152
|
|
- }
|
153
|
|
- byeCmdInSsrcTransaction(
|
154
|
|
- currentUser.getCurrentTenantId(),
|
155
|
|
- false,
|
156
|
|
- tbDeviceId,
|
157
|
|
- cameraCode,channelId,streamInfoDTO.get().getStream(),
|
158
|
|
- fromDeviceRpcResponse->{
|
159
|
|
-
|
160
|
|
- });
|
|
197
|
+ public boolean stopPlay(SecurityUser currentUser, String tbDeviceId, String channelId)
|
|
198
|
+ throws ThingsboardException {
|
|
199
|
+ String tenantId = currentUser.getCurrentTenantId();
|
|
200
|
+ DeviceDTO deviceDTO = tkDeviceService.findDeviceInfoByTbDeviceId(tenantId, tbDeviceId);
|
|
201
|
+ if (null == deviceDTO
|
|
202
|
+ || !deviceDTO.getDeviceInfo().has(FastIotConstants.DeviceAdditional.SIP)) {
|
|
203
|
+ throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
|
|
204
|
+ }
|
|
205
|
+ String cameraCode =
|
|
206
|
+ deviceDTO
|
|
207
|
+ .getDeviceInfo()
|
|
208
|
+ .get(FastIotConstants.DeviceAdditional.SIP)
|
|
209
|
+ .get(FastIotConstants.ZLMediaBody.CAMERA_CODE)
|
|
210
|
+ .asText();
|
|
211
|
+
|
|
212
|
+ Optional<StreamInfoDTO> streamInfoDTO =
|
|
213
|
+ tkCacheStorageService.queryPlayStreamByChannel(cameraCode, channelId);
|
|
214
|
+ if (streamInfoDTO.isEmpty()) {
|
|
215
|
+ throw new TkDataValidationException(ErrorMessage.STREAM_INFO_NOT_FOUND_FOR_PLAY.getMessage());
|
|
216
|
+ }
|
|
217
|
+ byeCmdInSsrcTransaction(
|
|
218
|
+ currentUser.getCurrentTenantId(),
|
|
219
|
+ false,
|
|
220
|
+ tbDeviceId,
|
|
221
|
+ cameraCode,
|
|
222
|
+ channelId,
|
|
223
|
+ streamInfoDTO.get().getStream(),
|
|
224
|
+ fromDeviceRpcResponse -> {});
|
161
|
225
|
|
162
|
|
- tkCacheStorageService.deleteCacheStreamInfoByStopPlay(streamInfoDTO.get()); //redisCatchStorage.stopPlay(streamInfo);
|
163
|
|
- return tkVideoChannelService.updateVideoChannelStreamId(null, cameraCode, channelId);//storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
|
|
226
|
+ tkCacheStorageService.deleteCacheStreamInfoByStopPlay(
|
|
227
|
+ streamInfoDTO.get()); // redisCatchStorage.stopPlay(streamInfo);
|
|
228
|
+ return tkVideoChannelService.updateVideoChannelStreamId(
|
|
229
|
+ null,
|
|
230
|
+ cameraCode,
|
|
231
|
+ channelId); // storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
|
164
|
232
|
}
|
165
|
233
|
|
166
|
234
|
@Override
|
...
|
...
|
@@ -214,7 +282,8 @@ public class TkVideoControlServiceImpl implements TkVideoControlService { |
214
|
282
|
mediaServerDTO.getMediaServerId(), ssrcInfoDTO.getSsrc());
|
215
|
283
|
videoStreamSessionManager.remove(
|
216
|
284
|
sipDeviceDTO.getCameraCode(), channelId, ssrcInfoDTO.getStream());
|
217
|
|
- throw new TkDataValidationException(ErrorMessage.GET_PLAY_PORT_FAILED.getMessage());
|
|
285
|
+ throw new TkDataValidationException(
|
|
286
|
+ String.format(ErrorMessage.GET_PLAY_PORT_FAILED.getMessage(), mediaServerDTO.getIp()));
|
218
|
287
|
}
|
219
|
288
|
// 进行命令发送
|
220
|
289
|
AtomicReference<StreamInfoDTO> result = new AtomicReference<>();
|
...
|
...
|
@@ -263,9 +332,12 @@ public class TkVideoControlServiceImpl implements TkVideoControlService { |
263
|
332
|
sipDeviceDTO.getCameraCode(),
|
264
|
333
|
VideoMethodEnum.INVITE,
|
265
|
334
|
false,
|
266
|
|
- tbDeviceId,
|
|
335
|
+ tbDeviceId,
|
267
|
336
|
fromDeviceRpcResponse -> {
|
268
|
|
- log.warn("【流媒体SIP】收到【视频点播】结果=异常【{}】+数据【{}】",fromDeviceRpcResponse.getError(), fromDeviceRpcResponse.getResponse());
|
|
337
|
+ log.warn(
|
|
338
|
+ "【流媒体SIP】收到【视频点播】结果=异常【{}】+数据【{}】",
|
|
339
|
+ fromDeviceRpcResponse.getError(),
|
|
340
|
+ fromDeviceRpcResponse.getResponse());
|
269
|
341
|
fromDeviceRpcResponse
|
270
|
342
|
.getResponse()
|
271
|
343
|
.ifPresent(
|
...
|
...
|
@@ -298,7 +370,7 @@ public class TkVideoControlServiceImpl implements TkVideoControlService { |
298
|
370
|
} catch (Exception e) {
|
299
|
371
|
zlMediaKitTaskUtils.stop(timeOutTaskKey);
|
300
|
372
|
tkMediaServerNodeService.closeRTPServer(
|
301
|
|
- Optional.ofNullable(mediaServerDTO), ssrcInfoDTO.getStream());
|
|
373
|
+ Optional.of(mediaServerDTO), ssrcInfoDTO.getStream());
|
302
|
374
|
// 释放ssrc
|
303
|
375
|
tkMediaServerNodeService.releaseSsrc(mediaServerDTO.getId(), ssrcInfoDTO.getSsrc());
|
304
|
376
|
|
...
|
...
|
@@ -466,8 +538,15 @@ public class TkVideoControlServiceImpl implements TkVideoControlService { |
466
|
538
|
boolean persisted = false;
|
467
|
539
|
ToDeviceRpcRequest rpcRequest =
|
468
|
540
|
new ToDeviceRpcRequest(
|
469
|
|
- rpcRequestUUID, new TenantId(UUID.fromString(tenantId)),
|
470
|
|
- new DeviceId(UUID.fromString(deviceId)), oneWay, expTime, body, persisted, null, null);
|
|
541
|
+ rpcRequestUUID,
|
|
542
|
+ new TenantId(UUID.fromString(tenantId)),
|
|
543
|
+ new DeviceId(UUID.fromString(deviceId)),
|
|
544
|
+ oneWay,
|
|
545
|
+ expTime,
|
|
546
|
+ body,
|
|
547
|
+ persisted,
|
|
548
|
+ null,
|
|
549
|
+ null);
|
471
|
550
|
deviceRpcService.processRestApiRpcRequest(rpcRequest, responseConsumer, null);
|
472
|
551
|
} catch (IllegalArgumentException ioe) {
|
473
|
552
|
throw new ThingsboardException(
|
...
|
...
|
@@ -485,69 +564,90 @@ public class TkVideoControlServiceImpl implements TkVideoControlService { |
485
|
564
|
*/
|
486
|
565
|
@Override
|
487
|
566
|
public void byeCmdInSsrcTransaction(
|
488
|
|
- String tenantId,
|
489
|
|
- boolean oneWay,
|
490
|
|
- String tbDeviceId,
|
491
|
|
- String cameraCode,String channelId,String streamId,
|
492
|
|
- Consumer<FromDeviceRpcResponse> responseConsumer)
|
493
|
|
- throws ThingsboardException {
|
494
|
|
- Optional<SsrcTransactionDTO> transactionDTO = videoStreamSessionManager.getSsrcTransaction(cameraCode,channelId,streamId);
|
|
567
|
+ String tenantId,
|
|
568
|
+ boolean oneWay,
|
|
569
|
+ String tbDeviceId,
|
|
570
|
+ String cameraCode,
|
|
571
|
+ String channelId,
|
|
572
|
+ String streamId,
|
|
573
|
+ Consumer<FromDeviceRpcResponse> responseConsumer)
|
|
574
|
+ throws ThingsboardException {
|
|
575
|
+ Optional<SsrcTransactionDTO> transactionDTO =
|
|
576
|
+ videoStreamSessionManager.getSsrcTransaction(cameraCode, channelId, streamId);
|
495
|
577
|
if (transactionDTO.isEmpty()) {
|
496
|
|
- throw new TkDataValidationException(
|
497
|
|
- ErrorMessage.STREAM_INFO_NOT_FOUND_FOR_PLAY.getMessage());
|
|
578
|
+ throw new TkDataValidationException(ErrorMessage.STREAM_INFO_NOT_FOUND_FOR_PLAY.getMessage());
|
498
|
579
|
}
|
499
|
580
|
SsrcTransactionDTO ssrc = transactionDTO.get();
|
500
|
581
|
cameraByeCmd(
|
501
|
|
- tenantId,ssrc.getSipTransactionInfo(),oneWay,true,tbDeviceId,
|
502
|
|
- cameraCode,channelId,streamId,ssrc.getSsrc(),ssrc.getMediaServerId(),
|
503
|
|
- responseConsumer);
|
|
582
|
+ tenantId,
|
|
583
|
+ ssrc.getSipTransactionInfo(),
|
|
584
|
+ oneWay,
|
|
585
|
+ true,
|
|
586
|
+ tbDeviceId,
|
|
587
|
+ cameraCode,
|
|
588
|
+ channelId,
|
|
589
|
+ streamId,
|
|
590
|
+ ssrc.getSsrc(),
|
|
591
|
+ ssrc.getMediaServerId(),
|
|
592
|
+ responseConsumer);
|
504
|
593
|
}
|
505
|
594
|
|
506
|
595
|
public void byeCmdInSendRtp(
|
507
|
|
- SecurityUser currentUser,
|
508
|
|
- boolean oneWay,
|
509
|
|
- String tbDeviceId,
|
510
|
|
- String cameraCode,String channelId,String streamId,
|
511
|
|
- Consumer<FromDeviceRpcResponse> responseConsumer)
|
512
|
|
- throws ThingsboardException {
|
513
|
|
-
|
514
|
|
-// SendRtpItemDTO sendRtpItem =null;
|
515
|
|
-// SipMessageHeaderDTO sipTransactionInfo =
|
516
|
|
-// SipMessageHeaderDTO.builder()
|
517
|
|
-// .toTag(sendRtpItem.getToTag())
|
518
|
|
-// .fromTag(sendRtpItem.getFromTag())
|
519
|
|
-// .callId(sendRtpItem.getCallId())
|
520
|
|
-// .build();
|
521
|
|
-// MediaServerDTO mediaServer = tkMediaServerService.getMediaServerByMediaServerId(sendRtpItem.getMediaServerId());
|
522
|
|
-// cameraByeCmd(
|
523
|
|
-// currentUser,ssrc.getSipTransactionInfo(),oneWay,mediaServer != null,tbDeviceId,
|
524
|
|
-// cameraCode,sendRtpItem.getChannelId(),streamId,ssrc.getSsrc(),ssrc.getMediaServerId(),
|
525
|
|
-// responseConsumer);
|
526
|
|
- }
|
|
596
|
+ SecurityUser currentUser,
|
|
597
|
+ boolean oneWay,
|
|
598
|
+ String tbDeviceId,
|
|
599
|
+ String cameraCode,
|
|
600
|
+ String channelId,
|
|
601
|
+ String streamId,
|
|
602
|
+ Consumer<FromDeviceRpcResponse> responseConsumer)
|
|
603
|
+ throws ThingsboardException {
|
527
|
604
|
|
|
605
|
+ // SendRtpItemDTO sendRtpItem =null;
|
|
606
|
+ // SipMessageHeaderDTO sipTransactionInfo =
|
|
607
|
+ // SipMessageHeaderDTO.builder()
|
|
608
|
+ // .toTag(sendRtpItem.getToTag())
|
|
609
|
+ // .fromTag(sendRtpItem.getFromTag())
|
|
610
|
+ // .callId(sendRtpItem.getCallId())
|
|
611
|
+ // .build();
|
|
612
|
+ // MediaServerDTO mediaServer =
|
|
613
|
+ // tkMediaServerService.getMediaServerByMediaServerId(sendRtpItem.getMediaServerId());
|
|
614
|
+ // cameraByeCmd(
|
|
615
|
+ // currentUser,ssrc.getSipTransactionInfo(),oneWay,mediaServer != null,tbDeviceId,
|
|
616
|
+ //
|
|
617
|
+ // cameraCode,sendRtpItem.getChannelId(),streamId,ssrc.getSsrc(),ssrc.getMediaServerId(),
|
|
618
|
+ // responseConsumer);
|
|
619
|
+ }
|
528
|
620
|
|
529
|
621
|
public void cameraByeCmd(
|
530
|
|
- String currentUser,SipMessageHeaderDTO messageHeaderDTO,
|
531
|
|
- boolean oneWay,boolean mediaOnline,
|
532
|
|
- String tbDeviceId,
|
533
|
|
- String cameraCode,String channelId,String streamId,String ssrc,String mediaServerId,
|
534
|
|
- Consumer<FromDeviceRpcResponse> responseConsumer) throws ThingsboardException {
|
535
|
|
- if(mediaOnline){
|
536
|
|
- tkMediaServerNodeService.releaseSsrc(mediaServerId,ssrc);
|
537
|
|
- tkMediaServerNodeService.closeRTPServer(mediaServerId,streamId);
|
|
622
|
+ String currentUser,
|
|
623
|
+ SipMessageHeaderDTO messageHeaderDTO,
|
|
624
|
+ boolean oneWay,
|
|
625
|
+ boolean mediaOnline,
|
|
626
|
+ String tbDeviceId,
|
|
627
|
+ String cameraCode,
|
|
628
|
+ String channelId,
|
|
629
|
+ String streamId,
|
|
630
|
+ String ssrc,
|
|
631
|
+ String mediaServerId,
|
|
632
|
+ Consumer<FromDeviceRpcResponse> responseConsumer)
|
|
633
|
+ throws ThingsboardException {
|
|
634
|
+ if (mediaOnline) {
|
|
635
|
+ tkMediaServerNodeService.releaseSsrc(mediaServerId, ssrc);
|
|
636
|
+ tkMediaServerNodeService.closeRTPServer(mediaServerId, streamId);
|
538
|
637
|
}
|
539
|
|
- videoStreamSessionManager.remove(cameraCode,channelId,streamId);
|
|
638
|
+ videoStreamSessionManager.remove(cameraCode, channelId, streamId);
|
540
|
639
|
ObjectNode paramJson = JacksonUtil.newObjectNode();
|
541
|
640
|
paramJson.put(FastIotConstants.ZLMediaBody.CHANNEL_ID, channelId);
|
542
|
|
- paramJson.set(FastIotConstants.ZLMediaBody.MSG_HEADER, JacksonUtil.valueToTree(messageHeaderDTO));
|
|
641
|
+ paramJson.set(
|
|
642
|
+ FastIotConstants.ZLMediaBody.MSG_HEADER, JacksonUtil.valueToTree(messageHeaderDTO));
|
543
|
643
|
cameraCommonCmd(
|
544
|
|
- currentUser,
|
545
|
|
- paramJson,
|
546
|
|
- cameraCode,
|
547
|
|
- VideoMethodEnum.BYE,
|
548
|
|
- oneWay,
|
549
|
|
- tbDeviceId,
|
550
|
|
- responseConsumer);
|
|
644
|
+ currentUser,
|
|
645
|
+ paramJson,
|
|
646
|
+ cameraCode,
|
|
647
|
+ VideoMethodEnum.BYE,
|
|
648
|
+ oneWay,
|
|
649
|
+ tbDeviceId,
|
|
650
|
+ responseConsumer);
|
551
|
651
|
}
|
552
|
652
|
|
553
|
653
|
/**
|
...
|
...
|
@@ -687,11 +787,11 @@ public class TkVideoControlServiceImpl implements TkVideoControlService { |
687
|
787
|
byeCmdInSsrcTransaction(
|
688
|
788
|
currentUser.getCurrentTenantId(),
|
689
|
789
|
false,
|
690
|
|
- tbDeviceId,
|
691
|
|
- cameraCode,channelId,streamId,
|
692
|
|
- fromDeviceRpcResponse->{
|
693
|
|
-
|
694
|
|
- });
|
|
790
|
+ tbDeviceId,
|
|
791
|
+ cameraCode,
|
|
792
|
+ channelId,
|
|
793
|
+ streamId,
|
|
794
|
+ fromDeviceRpcResponse -> {});
|
695
|
795
|
} catch (Exception e) {
|
696
|
796
|
log.error("[命令发送失败] 停止点播, 发送BYE: {}", e.getMessage());
|
697
|
797
|
}
|
...
|
...
|
@@ -707,21 +807,31 @@ public class TkVideoControlServiceImpl implements TkVideoControlService { |
707
|
807
|
}
|
708
|
808
|
|
709
|
809
|
@Override
|
710
|
|
- public boolean control(SecurityUser currentUser, String tbDeviceId, String channelId, PTZCommandEnum command, int horizonSpeed, int verticalSpeed, int zoomSpeed) throws ThingsboardException {
|
|
810
|
+ public boolean control(
|
|
811
|
+ SecurityUser currentUser,
|
|
812
|
+ String tbDeviceId,
|
|
813
|
+ String channelId,
|
|
814
|
+ PTZCommandEnum command,
|
|
815
|
+ int horizonSpeed,
|
|
816
|
+ int verticalSpeed,
|
|
817
|
+ int zoomSpeed)
|
|
818
|
+ throws ThingsboardException {
|
711
|
819
|
|
712
|
820
|
if (PTZCommandEnum.STOP.equals(command)) {
|
713
|
821
|
horizonSpeed = 0;
|
714
|
822
|
verticalSpeed = 0;
|
715
|
823
|
zoomSpeed = 0;
|
716
|
824
|
}
|
717
|
|
- DeviceDTO deviceDTO = tkDeviceService.checkDeviceByTenantIdAndId(currentUser.getCurrentTenantId(), tbDeviceId, true);
|
|
825
|
+ DeviceDTO deviceDTO =
|
|
826
|
+ tkDeviceService.checkDeviceByTenantIdAndId(
|
|
827
|
+ currentUser.getCurrentTenantId(), tbDeviceId, true);
|
718
|
828
|
if (null == deviceDTO) {
|
719
|
829
|
throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
|
720
|
830
|
}
|
721
|
831
|
SipDeviceDTO sipDeviceDTO =
|
722
|
|
- JacksonUtil.convertValue(
|
723
|
|
- deviceDTO.getDeviceInfo().get(FastIotConstants.DeviceAdditional.SIP),
|
724
|
|
- SipDeviceDTO.class);
|
|
832
|
+ JacksonUtil.convertValue(
|
|
833
|
+ deviceDTO.getDeviceInfo().get(FastIotConstants.DeviceAdditional.SIP),
|
|
834
|
+ SipDeviceDTO.class);
|
725
|
835
|
if (null == sipDeviceDTO) {
|
726
|
836
|
throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
|
727
|
837
|
}
|
...
|
...
|
@@ -732,17 +842,17 @@ public class TkVideoControlServiceImpl implements TkVideoControlService { |
732
|
842
|
ptzCmdDTO.setZoomSpeed(zoomSpeed);
|
733
|
843
|
ObjectNode requestJson = JacksonUtil.newObjectNode();
|
734
|
844
|
requestJson.put(FastIotConstants.ZLMediaBody.CHANNEL_ID, channelId);
|
735
|
|
- requestJson.set(FastIotConstants.ZLMediaBody.CONTROL_CONTEXT, JacksonUtil.valueToTree(ptzCmdDTO));
|
|
845
|
+ requestJson.put(FastIotConstants.ZLMediaBody.MSG_TYPE, VideoXmlEnum.Control.name());
|
|
846
|
+ requestJson.set(
|
|
847
|
+ FastIotConstants.ZLMediaBody.MSG_CONTEXT, JacksonUtil.valueToTree(ptzCmdDTO));
|
736
|
848
|
cameraCommonCmd(
|
737
|
|
- currentUser.getCurrentTenantId(),
|
738
|
|
- requestJson,
|
739
|
|
- sipDeviceDTO.getCameraCode(),
|
740
|
|
- VideoMethodEnum.MESSAGE,
|
741
|
|
- false,
|
742
|
|
- tbDeviceId,
|
743
|
|
- fromDeviceRpcResponse->{
|
744
|
|
-
|
745
|
|
- });
|
|
849
|
+ currentUser.getCurrentTenantId(),
|
|
850
|
+ requestJson,
|
|
851
|
+ sipDeviceDTO.getCameraCode(),
|
|
852
|
+ VideoMethodEnum.MESSAGE,
|
|
853
|
+ false,
|
|
854
|
+ tbDeviceId,
|
|
855
|
+ fromDeviceRpcResponse -> {});
|
746
|
856
|
return false;
|
747
|
857
|
}
|
748
|
858
|
} |
...
|
...
|
|