Commit f223aad70516049577c261d5e6cd876abed07cb4
Merge branch 'wvp-28181-2.0'
# Conflicts: # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java # src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java # src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java # src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeFactory.java # src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java # src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java # src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java # src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java # src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java # web_src/src/components/dialog/devicePlayer.vue
Showing
45 changed files
with
1512 additions
and
1040 deletions
Too many changes to show.
To preserve performance only 45 of 188 files are displayed.
README.md
| ... | ... | @@ -101,6 +101,7 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git |
| 101 | 101 | - [X] 敶恥 |
| 102 | 102 | - [X] 敶 |
| 103 | 103 | - [X] GPS霈a嚗瘚 |
| 104 | +- [X] 瘛餃挽憭挽憭挽蝵桀 | |
| 104 | 105 | - [X] 瘛餃TSP閫 |
| 105 | 106 | - [X] 瘛餃 |
| 106 | 107 | - [X] 瘛餃TMP閫 |
| ... | ... | @@ -155,7 +156,6 @@ QQ蝘縑銝銝, 蝎曉.甈Z之摰嗅蝢日悄霈.閫★撖嫣 |
| 155 | 156 | |
| 156 | 157 | # 悅 |
| 157 | 158 | 憿寧誨蝙摰賣IT悅嚗靽縑銝隞亥摨鈭★ 雿憿寧銋蝣蝙鈭鈭隞皞誨銝窈銵隞嚗 鈭蝙憿寧漣熒噩蛹銝璁憿寧嚗窈銵 雿輻憿寧隞嚗砲悅銝剖銵冽憿寧靘洵銝摨悅 |
| 158 | - | |
| 159 | 159 | # 靚 |
| 160 | 160 | 陝雿憭(https://github.com/xia-chu) 皞獢,撟嗅撘葉蝏葬 |
| 161 | 161 | 陝雿dexter langhuihui](https://github.com/langhuihui) 撘皞末EB |
| ... | ... | @@ -165,7 +165,7 @@ QQ蝘縑銝銝, 蝎曉.甈Z之摰嗅蝢日悄霈.閫★撖嫣 |
| 165 | 165 | [hotcoffie](https://github.com/hotcoffie) [xiaomu](https://github.com/nikmu) [TristingChen](https://github.com/TristingChen) |
| 166 | 166 | [chenparty](https://github.com/chenparty) [Hotleave](https://github.com/hotleave) [ydwxb](https://github.com/ydwxb) |
| 167 | 167 | [ydpd](https://github.com/ydpd) [szy833](https://github.com/szy833) [ydwxb](https://github.com/ydwxb) [Albertzhu666](https://github.com/Albertzhu666) |
| 168 | -[mk1990](https://github.com/mk1990) | |
| 168 | +[mk1990](https://github.com/mk1990) [SaltFish001](https://github.com/SaltFish001) | |
| 169 | 169 | |
| 170 | 170 | ps: 葵摰鈭之雿穿洽餈之雿祈頂溶 |
| 171 | 171 | ... | ... |
doc/_content/qa/play_error.md
pom.xml
| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | |
| 12 | 12 | <groupId>com.genersoft</groupId> |
| 13 | 13 | <artifactId>wvp-pro</artifactId> |
| 14 | - <version>2.3.2</version> | |
| 14 | + <version>2.6.6</version> | |
| 15 | 15 | <name>web video platform</name> |
| 16 | 16 | <description>国标28181视频平台</description> |
| 17 | 17 | |
| ... | ... | @@ -153,13 +153,17 @@ |
| 153 | 153 | <version>2.1.3</version> |
| 154 | 154 | </dependency> |
| 155 | 155 | |
| 156 | - <!-- json解析库fastjson --> | |
| 156 | + <!-- json解析库fastjson2 --> | |
| 157 | 157 | <dependency> |
| 158 | - <groupId>com.alibaba</groupId> | |
| 159 | - <artifactId>fastjson</artifactId> | |
| 160 | - <version>1.2.83</version> | |
| 158 | + <groupId>com.alibaba.fastjson2</groupId> | |
| 159 | + <artifactId>fastjson2</artifactId> | |
| 160 | + <version>2.0.17</version> | |
| 161 | + </dependency> | |
| 162 | + <dependency> | |
| 163 | + <groupId>com.alibaba.fastjson2</groupId> | |
| 164 | + <artifactId>fastjson2-extension</artifactId> | |
| 165 | + <version>2.0.17</version> | |
| 161 | 166 | </dependency> |
| 162 | - | |
| 163 | 167 | |
| 164 | 168 | <!-- okhttp --> |
| 165 | 169 | <dependency> | ... | ... |
sql/mysql.sql
| 1 | --- MySQL dump 10.13 Distrib 8.0.29, for Linux (x86_64) | |
| 1 | +-- MySQL dump 10.13 Distrib 8.0.30, for Linux (x86_64) | |
| 2 | 2 | -- |
| 3 | --- Host: 127.0.0.1 Database: 242wvp | |
| 3 | +-- Host: 127.0.0.1 Database: wvp | |
| 4 | 4 | -- ------------------------------------------------------ |
| 5 | --- Server version 8.0.29-0ubuntu0.22.04.3 | |
| 5 | +-- Server version 8.0.30 | |
| 6 | 6 | |
| 7 | 7 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; |
| 8 | 8 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; |
| ... | ... | @@ -34,13 +34,13 @@ CREATE TABLE `device` ( |
| 34 | 34 | `online` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, |
| 35 | 35 | `registerTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, |
| 36 | 36 | `keepaliveTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, |
| 37 | - `ip` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, | |
| 37 | + `ip` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 38 | 38 | `createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 39 | 39 | `updateTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 40 | - `port` int NOT NULL, | |
| 41 | - `expires` int NOT NULL, | |
| 42 | - `subscribeCycleForCatalog` int NOT NULL, | |
| 43 | - `hostAddress` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, | |
| 40 | + `port` int DEFAULT NULL, | |
| 41 | + `expires` int DEFAULT NULL, | |
| 42 | + `subscribeCycleForCatalog` int DEFAULT NULL, | |
| 43 | + `hostAddress` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 44 | 44 | `charset` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 45 | 45 | `subscribeCycleForMobilePosition` int DEFAULT NULL, |
| 46 | 46 | `mobilePositionSubmissionInterval` int DEFAULT '5', |
| ... | ... | @@ -49,9 +49,11 @@ CREATE TABLE `device` ( |
| 49 | 49 | `geoCoordSys` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 50 | 50 | `treeType` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 51 | 51 | `mediaServerId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'auto', |
| 52 | + `custom_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 53 | + `password` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 52 | 54 | PRIMARY KEY (`id`), |
| 53 | 55 | UNIQUE KEY `device_deviceId_uindex` (`deviceId`) |
| 54 | -) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; | |
| 56 | +) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; | |
| 55 | 57 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 56 | 58 | |
| 57 | 59 | -- |
| ... | ... | @@ -143,7 +145,7 @@ CREATE TABLE `device_channel` ( |
| 143 | 145 | PRIMARY KEY (`id`), |
| 144 | 146 | UNIQUE KEY `device_channel_id_uindex` (`id`), |
| 145 | 147 | UNIQUE KEY `device_channel_pk` (`channelId`,`deviceId`) |
| 146 | -) ENGINE=InnoDB AUTO_INCREMENT=60163 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; | |
| 148 | +) ENGINE=InnoDB AUTO_INCREMENT=60301 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; | |
| 147 | 149 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 148 | 150 | |
| 149 | 151 | -- |
| ... | ... | @@ -213,7 +215,7 @@ CREATE TABLE `gb_stream` ( |
| 213 | 215 | PRIMARY KEY (`gbStreamId`) USING BTREE, |
| 214 | 216 | UNIQUE KEY `app` (`app`,`stream`) USING BTREE, |
| 215 | 217 | UNIQUE KEY `gbId` (`gbId`) USING BTREE |
| 216 | -) ENGINE=InnoDB AUTO_INCREMENT=301057 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 218 | +) ENGINE=InnoDB AUTO_INCREMENT=301059 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 217 | 219 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 218 | 220 | |
| 219 | 221 | -- |
| ... | ... | @@ -243,7 +245,7 @@ CREATE TABLE `log` ( |
| 243 | 245 | `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 244 | 246 | `createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 245 | 247 | PRIMARY KEY (`id`) USING BTREE |
| 246 | -) ENGINE=InnoDB AUTO_INCREMENT=727574 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 248 | +) ENGINE=InnoDB AUTO_INCREMENT=733627 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 247 | 249 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 248 | 250 | |
| 249 | 251 | -- |
| ... | ... | @@ -279,7 +281,6 @@ CREATE TABLE `media_server` ( |
| 279 | 281 | `secret` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 280 | 282 | `rtpEnable` int NOT NULL, |
| 281 | 283 | `rtpPortRange` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 282 | - `sendRtpPortRange` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, | |
| 283 | 284 | `recordAssistPort` int NOT NULL, |
| 284 | 285 | `defaultServer` int NOT NULL, |
| 285 | 286 | `createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| ... | ... | @@ -336,7 +337,7 @@ CREATE TABLE `parent_platform` ( |
| 336 | 337 | PRIMARY KEY (`id`), |
| 337 | 338 | UNIQUE KEY `parent_platform_id_uindex` (`id`), |
| 338 | 339 | UNIQUE KEY `parent_platform_pk` (`serverGBId`) |
| 339 | -) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 340 | +) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 340 | 341 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 341 | 342 | |
| 342 | 343 | -- |
| ... | ... | @@ -388,7 +389,7 @@ CREATE TABLE `platform_gb_channel` ( |
| 388 | 389 | `catalogId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 389 | 390 | `deviceChannelId` int NOT NULL, |
| 390 | 391 | PRIMARY KEY (`id`) |
| 391 | -) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; | |
| 392 | +) ENGINE=InnoDB AUTO_INCREMENT=102 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; | |
| 392 | 393 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 393 | 394 | |
| 394 | 395 | -- |
| ... | ... | @@ -414,7 +415,7 @@ CREATE TABLE `platform_gb_stream` ( |
| 414 | 415 | `id` int NOT NULL AUTO_INCREMENT, |
| 415 | 416 | PRIMARY KEY (`id`), |
| 416 | 417 | UNIQUE KEY `platform_gb_stream_pk` (`platformId`,`catalogId`,`gbStreamId`) |
| 417 | -) ENGINE=InnoDB AUTO_INCREMENT=301759 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 418 | +) ENGINE=InnoDB AUTO_INCREMENT=301766 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 418 | 419 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 419 | 420 | |
| 420 | 421 | -- |
| ... | ... | @@ -453,9 +454,10 @@ CREATE TABLE `stream_proxy` ( |
| 453 | 454 | `createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 454 | 455 | `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, |
| 455 | 456 | `updateTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, |
| 457 | + `enable_disable_none_reader` bit(1) DEFAULT NULL, | |
| 456 | 458 | PRIMARY KEY (`id`), |
| 457 | 459 | UNIQUE KEY `stream_proxy_pk` (`app`,`stream`) |
| 458 | -) ENGINE=InnoDB AUTO_INCREMENT=545 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; | |
| 460 | +) ENGINE=InnoDB AUTO_INCREMENT=548 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; | |
| 459 | 461 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 460 | 462 | |
| 461 | 463 | -- |
| ... | ... | @@ -492,7 +494,7 @@ CREATE TABLE `stream_push` ( |
| 492 | 494 | `self` int DEFAULT NULL, |
| 493 | 495 | PRIMARY KEY (`id`), |
| 494 | 496 | UNIQUE KEY `stream_push_pk` (`app`,`stream`) |
| 495 | -) ENGINE=InnoDB AUTO_INCREMENT=310546 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; | |
| 497 | +) ENGINE=InnoDB AUTO_INCREMENT=310558 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; | |
| 496 | 498 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 497 | 499 | |
| 498 | 500 | -- |
| ... | ... | @@ -521,7 +523,7 @@ CREATE TABLE `user` ( |
| 521 | 523 | `pushKey` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, |
| 522 | 524 | PRIMARY KEY (`id`) USING BTREE, |
| 523 | 525 | UNIQUE KEY `user_username_uindex` (`username`) USING BTREE |
| 524 | -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 526 | +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 525 | 527 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 526 | 528 | |
| 527 | 529 | -- |
| ... | ... | @@ -570,4 +572,4 @@ UNLOCK TABLES; |
| 570 | 572 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; |
| 571 | 573 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; |
| 572 | 574 | |
| 573 | --- Dump completed on 2022-09-08 16:46:27 | |
| 575 | +-- Dump completed on 2022-10-18 17:00:02 | ... | ... |
sql/update.sql
| 1 | 1 | alter table media_server |
| 2 | 2 | drop column streamNoneReaderDelayMS; |
| 3 | 3 | |
| 4 | +alter table media_server | |
| 5 | + drop column sendRtpPortRange; | |
| 6 | + | |
| 4 | 7 | alter table stream_proxy |
| 5 | 8 | add enable_disable_none_reader bit(1) default null; |
| 9 | + | |
| 10 | +alter table device | |
| 11 | + add mediaServerId varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'auto'; | |
| 12 | + | |
| 13 | +alter table device | |
| 14 | + add custom_name varchar(255) default null; | |
| 15 | + | |
| 16 | +alter table device | |
| 17 | + add sdpIp varchar(50) default null; | |
| 18 | + | |
| 19 | +alter table device | |
| 20 | + add localIp varchar(50) default null; | |
| 21 | + | |
| 22 | +alter table device | |
| 23 | + add password varchar(255) default null; | |
| 24 | + | |
| 25 | +alter table device | |
| 26 | + modify ip varchar(50) null; | |
| 27 | + | |
| 28 | +alter table device | |
| 29 | + modify port int null; | |
| 30 | + | |
| 31 | +alter table device | |
| 32 | + modify expires int null; | |
| 33 | + | |
| 34 | +alter table device | |
| 35 | + modify subscribeCycleForCatalog int null; | |
| 36 | + | |
| 37 | +alter table device | |
| 38 | + modify hostAddress varchar(50) null; | ... | ... |
src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java
| ... | ... | @@ -2,8 +2,10 @@ package com.genersoft.iot.vmp.common; |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | |
| 5 | +import java.io.Serializable; | |
| 6 | + | |
| 5 | 7 | @Schema(description = "流信息") |
| 6 | -public class StreamInfo { | |
| 8 | +public class StreamInfo implements Serializable, Cloneable{ | |
| 7 | 9 | |
| 8 | 10 | @Schema(description = "应用名") |
| 9 | 11 | private String app; |
| ... | ... | @@ -13,54 +15,56 @@ public class StreamInfo { |
| 13 | 15 | private String deviceID; |
| 14 | 16 | @Schema(description = "通道编号") |
| 15 | 17 | private String channelId; |
| 16 | - @Schema(description = "HTTP-FLV流地址") | |
| 17 | - private String flv; | |
| 18 | 18 | |
| 19 | 19 | @Schema(description = "IP") |
| 20 | 20 | private String ip; |
| 21 | + | |
| 22 | + @Schema(description = "HTTP-FLV流地址") | |
| 23 | + private StreamURL flv; | |
| 24 | + | |
| 21 | 25 | @Schema(description = "HTTPS-FLV流地址") |
| 22 | - private String https_flv; | |
| 26 | + private StreamURL https_flv; | |
| 23 | 27 | @Schema(description = "Websocket-FLV流地址") |
| 24 | - private String ws_flv; | |
| 28 | + private StreamURL ws_flv; | |
| 25 | 29 | @Schema(description = "Websockets-FLV流地址") |
| 26 | - private String wss_flv; | |
| 30 | + private StreamURL wss_flv; | |
| 27 | 31 | @Schema(description = "HTTP-FMP4流地址") |
| 28 | - private String fmp4; | |
| 32 | + private StreamURL fmp4; | |
| 29 | 33 | @Schema(description = "HTTPS-FMP4流地址") |
| 30 | - private String https_fmp4; | |
| 34 | + private StreamURL https_fmp4; | |
| 31 | 35 | @Schema(description = "Websocket-FMP4流地址") |
| 32 | - private String ws_fmp4; | |
| 36 | + private StreamURL ws_fmp4; | |
| 33 | 37 | @Schema(description = "Websockets-FMP4流地址") |
| 34 | - private String wss_fmp4; | |
| 38 | + private StreamURL wss_fmp4; | |
| 35 | 39 | @Schema(description = "HLS流地址") |
| 36 | - private String hls; | |
| 40 | + private StreamURL hls; | |
| 37 | 41 | @Schema(description = "HTTPS-HLS流地址") |
| 38 | - private String https_hls; | |
| 42 | + private StreamURL https_hls; | |
| 39 | 43 | @Schema(description = "Websocket-HLS流地址") |
| 40 | - private String ws_hls; | |
| 44 | + private StreamURL ws_hls; | |
| 41 | 45 | @Schema(description = "Websockets-HLS流地址") |
| 42 | - private String wss_hls; | |
| 46 | + private StreamURL wss_hls; | |
| 43 | 47 | @Schema(description = "HTTP-TS流地址") |
| 44 | - private String ts; | |
| 48 | + private StreamURL ts; | |
| 45 | 49 | @Schema(description = "HTTPS-TS流地址") |
| 46 | - private String https_ts; | |
| 50 | + private StreamURL https_ts; | |
| 47 | 51 | @Schema(description = "Websocket-TS流地址") |
| 48 | - private String ws_ts; | |
| 52 | + private StreamURL ws_ts; | |
| 49 | 53 | @Schema(description = "Websockets-TS流地址") |
| 50 | - private String wss_ts; | |
| 54 | + private StreamURL wss_ts; | |
| 51 | 55 | @Schema(description = "RTMP流地址") |
| 52 | - private String rtmp; | |
| 56 | + private StreamURL rtmp; | |
| 53 | 57 | @Schema(description = "RTMPS流地址") |
| 54 | - private String rtmps; | |
| 58 | + private StreamURL rtmps; | |
| 55 | 59 | @Schema(description = "RTSP流地址") |
| 56 | - private String rtsp; | |
| 60 | + private StreamURL rtsp; | |
| 57 | 61 | @Schema(description = "RTSPS流地址") |
| 58 | - private String rtsps; | |
| 62 | + private StreamURL rtsps; | |
| 59 | 63 | @Schema(description = "RTC流地址") |
| 60 | - private String rtc; | |
| 64 | + private StreamURL rtc; | |
| 61 | 65 | |
| 62 | 66 | @Schema(description = "RTCS流地址") |
| 63 | - private String rtcs; | |
| 67 | + private StreamURL rtcs; | |
| 64 | 68 | @Schema(description = "流媒体ID") |
| 65 | 69 | private String mediaServerId; |
| 66 | 70 | @Schema(description = "流编码信息") |
| ... | ... | @@ -75,125 +79,221 @@ public class StreamInfo { |
| 75 | 79 | @Schema(description = "是否暂停(录像回放使用)") |
| 76 | 80 | private boolean pause; |
| 77 | 81 | |
| 78 | - public static class TransactionInfo{ | |
| 79 | - public String callId; | |
| 80 | - public String localTag; | |
| 81 | - public String remoteTag; | |
| 82 | - public String branch; | |
| 82 | + public void setFlv(StreamURL flv) { | |
| 83 | + this.flv = flv; | |
| 83 | 84 | } |
| 84 | 85 | |
| 85 | - private TransactionInfo transactionInfo; | |
| 86 | + public void setHttps_flv(StreamURL https_flv) { | |
| 87 | + this.https_flv = https_flv; | |
| 88 | + } | |
| 86 | 89 | |
| 87 | - public String getApp() { | |
| 88 | - return app; | |
| 90 | + public void setWs_flv(StreamURL ws_flv) { | |
| 91 | + this.ws_flv = ws_flv; | |
| 89 | 92 | } |
| 90 | 93 | |
| 91 | - public void setApp(String app) { | |
| 92 | - this.app = app; | |
| 94 | + public void setWss_flv(StreamURL wss_flv) { | |
| 95 | + this.wss_flv = wss_flv; | |
| 93 | 96 | } |
| 94 | 97 | |
| 95 | - public String getDeviceID() { | |
| 96 | - return deviceID; | |
| 98 | + public void setFmp4(StreamURL fmp4) { | |
| 99 | + this.fmp4 = fmp4; | |
| 97 | 100 | } |
| 98 | 101 | |
| 99 | - public void setDeviceID(String deviceID) { | |
| 100 | - this.deviceID = deviceID; | |
| 102 | + public void setHttps_fmp4(StreamURL https_fmp4) { | |
| 103 | + this.https_fmp4 = https_fmp4; | |
| 101 | 104 | } |
| 102 | 105 | |
| 103 | - public String getChannelId() { | |
| 104 | - return channelId; | |
| 106 | + public void setWs_fmp4(StreamURL ws_fmp4) { | |
| 107 | + this.ws_fmp4 = ws_fmp4; | |
| 105 | 108 | } |
| 106 | 109 | |
| 107 | - public void setChannelId(String channelId) { | |
| 108 | - this.channelId = channelId; | |
| 110 | + public void setWss_fmp4(StreamURL wss_fmp4) { | |
| 111 | + this.wss_fmp4 = wss_fmp4; | |
| 109 | 112 | } |
| 110 | 113 | |
| 111 | - public String getFlv() { | |
| 112 | - return flv; | |
| 114 | + public void setHls(StreamURL hls) { | |
| 115 | + this.hls = hls; | |
| 113 | 116 | } |
| 114 | 117 | |
| 115 | - public void setFlv(String flv) { | |
| 116 | - this.flv = flv; | |
| 118 | + public void setHttps_hls(StreamURL https_hls) { | |
| 119 | + this.https_hls = https_hls; | |
| 117 | 120 | } |
| 118 | 121 | |
| 119 | - public String getWs_flv() { | |
| 120 | - return ws_flv; | |
| 122 | + public void setWs_hls(StreamURL ws_hls) { | |
| 123 | + this.ws_hls = ws_hls; | |
| 121 | 124 | } |
| 122 | 125 | |
| 123 | - public void setWs_flv(String ws_flv) { | |
| 124 | - this.ws_flv = ws_flv; | |
| 126 | + public void setWss_hls(StreamURL wss_hls) { | |
| 127 | + this.wss_hls = wss_hls; | |
| 125 | 128 | } |
| 126 | 129 | |
| 127 | - public String getRtmp() { | |
| 128 | - return rtmp; | |
| 130 | + public void setTs(StreamURL ts) { | |
| 131 | + this.ts = ts; | |
| 129 | 132 | } |
| 130 | 133 | |
| 131 | - public void setRtmp(String rtmp) { | |
| 132 | - this.rtmp = rtmp; | |
| 134 | + public void setHttps_ts(StreamURL https_ts) { | |
| 135 | + this.https_ts = https_ts; | |
| 133 | 136 | } |
| 134 | 137 | |
| 135 | - public String getHls() { | |
| 136 | - return hls; | |
| 138 | + public void setWs_ts(StreamURL ws_ts) { | |
| 139 | + this.ws_ts = ws_ts; | |
| 137 | 140 | } |
| 138 | 141 | |
| 139 | - public void setHls(String hls) { | |
| 140 | - this.hls = hls; | |
| 142 | + public void setWss_ts(StreamURL wss_ts) { | |
| 143 | + this.wss_ts = wss_ts; | |
| 141 | 144 | } |
| 142 | 145 | |
| 143 | - public String getRtsp() { | |
| 144 | - return rtsp; | |
| 146 | + public void setRtmp(StreamURL rtmp) { | |
| 147 | + this.rtmp = rtmp; | |
| 145 | 148 | } |
| 146 | 149 | |
| 147 | - public void setRtsp(String rtsp) { | |
| 148 | - this.rtsp = rtsp; | |
| 150 | + public void setRtmps(StreamURL rtmps) { | |
| 151 | + this.rtmps = rtmps; | |
| 149 | 152 | } |
| 150 | 153 | |
| 151 | - public Object getTracks() { | |
| 152 | - return tracks; | |
| 154 | + public void setRtsp(StreamURL rtsp) { | |
| 155 | + this.rtsp = rtsp; | |
| 153 | 156 | } |
| 154 | 157 | |
| 155 | - public void setTracks(Object tracks) { | |
| 156 | - this.tracks = tracks; | |
| 158 | + public void setRtsps(StreamURL rtsps) { | |
| 159 | + this.rtsps = rtsps; | |
| 157 | 160 | } |
| 158 | 161 | |
| 159 | - public String getFmp4() { | |
| 160 | - return fmp4; | |
| 162 | + public void setRtc(StreamURL rtc) { | |
| 163 | + this.rtc = rtc; | |
| 161 | 164 | } |
| 162 | 165 | |
| 163 | - public void setFmp4(String fmp4) { | |
| 164 | - this.fmp4 = fmp4; | |
| 166 | + public void setRtcs(StreamURL rtcs) { | |
| 167 | + this.rtcs = rtcs; | |
| 165 | 168 | } |
| 166 | 169 | |
| 167 | - public String getWs_fmp4() { | |
| 168 | - return ws_fmp4; | |
| 170 | + public void setRtmp(String host, int port, int sslPort, String app, String stream, String callIdParam) { | |
| 171 | + String file = String.format("%s/%s/%s", app, stream, callIdParam); | |
| 172 | + this.rtmp = new StreamURL("rtmp", host, port, file); | |
| 173 | + if (sslPort != 0) { | |
| 174 | + this.rtmps = new StreamURL("rtmps", host, sslPort, file); | |
| 175 | + } | |
| 176 | + } | |
| 177 | + | |
| 178 | + public void setRtsp(String host, int port, int sslPort, String app, String stream, String callIdParam) { | |
| 179 | + String file = String.format("%s/%s/%s", app, stream, callIdParam); | |
| 180 | + this.rtsp = new StreamURL("rtsp", host, port, file); | |
| 181 | + if (sslPort != 0) { | |
| 182 | + this.rtsps = new StreamURL("rtsps", host, sslPort, file); | |
| 183 | + } | |
| 184 | + } | |
| 185 | + | |
| 186 | + public void setFlv(String host, int port, int sslPort, String app, String stream, String callIdParam) { | |
| 187 | + String file = String.format("%s/%s.live.flv%s", app, stream, callIdParam); | |
| 188 | + this.flv = new StreamURL("http", host, port, file); | |
| 189 | + this.ws_flv = new StreamURL("ws", host, port, file); | |
| 190 | + if (sslPort != 0) { | |
| 191 | + this.https_flv = new StreamURL("https", host, sslPort, file); | |
| 192 | + this.wss_flv = new StreamURL("wss", host, sslPort, file); | |
| 193 | + } | |
| 194 | + } | |
| 195 | + | |
| 196 | + public void setFmp4(String host, int port, int sslPort, String app, String stream, String callIdParam) { | |
| 197 | + String file = String.format("%s/%s.live.mp4%s", app, stream, callIdParam); | |
| 198 | + this.fmp4 = new StreamURL("http", host, port, file); | |
| 199 | + this.ws_fmp4 = new StreamURL("ws", host, port, file); | |
| 200 | + if (sslPort != 0) { | |
| 201 | + this.https_fmp4 = new StreamURL("https", host, sslPort, file); | |
| 202 | + this.wss_fmp4 = new StreamURL("wss", host, sslPort, file); | |
| 203 | + } | |
| 204 | + } | |
| 205 | + | |
| 206 | + public void setHls(String host, int port, int sslPort, String app, String stream, String callIdParam) { | |
| 207 | + String file = String.format("%s/%s/hls.m3u8%s", app, stream, callIdParam); | |
| 208 | + this.hls = new StreamURL("http", host, port, file); | |
| 209 | + this.ws_hls = new StreamURL("ws", host, port, file); | |
| 210 | + if (sslPort != 0) { | |
| 211 | + this.https_hls = new StreamURL("https", host, sslPort, file); | |
| 212 | + this.wss_hls = new StreamURL("wss", host, sslPort, file); | |
| 213 | + } | |
| 214 | + } | |
| 215 | + | |
| 216 | + public void setTs(String host, int port, int sslPort, String app, String stream, String callIdParam) { | |
| 217 | + String file = String.format("%s/%s.live.ts%s", app, stream, callIdParam); | |
| 218 | + this.ts = new StreamURL("http", host, port, file); | |
| 219 | + this.ws_ts = new StreamURL("ws", host, port, file); | |
| 220 | + if (sslPort != 0) { | |
| 221 | + this.https_ts = new StreamURL("https", host, sslPort, file); | |
| 222 | + this.wss_ts = new StreamURL("wss", host, sslPort, file); | |
| 223 | + } | |
| 224 | + } | |
| 225 | + | |
| 226 | + public void setRtc(String host, int port, int sslPort, String app, String stream, String callIdParam) { | |
| 227 | + String file = String.format("index/api/webrtc?app=%s&stream=%s&type=play%s", app, stream, callIdParam); | |
| 228 | + this.rtc = new StreamURL("http", host, port, file); | |
| 229 | + if (sslPort != 0) { | |
| 230 | + this.rtcs = new StreamURL("https", host, sslPort, file); | |
| 231 | + } | |
| 232 | + } | |
| 233 | + | |
| 234 | + public void channgeStreamIp(String localAddr) { | |
| 235 | + this.flv.setHost(localAddr); | |
| 236 | + this.ws_flv.setHost(localAddr); | |
| 237 | + this.hls.setHost(localAddr); | |
| 238 | + this.ws_hls.setHost(localAddr); | |
| 239 | + this.ts.setHost(localAddr); | |
| 240 | + this.ws_ts.setHost(localAddr); | |
| 241 | + this.fmp4.setHost(localAddr); | |
| 242 | + this.ws_fmp4.setHost(localAddr); | |
| 243 | + this.rtc.setHost(localAddr); | |
| 244 | + if (this.https_flv != null) { | |
| 245 | + this.https_flv.setHost(localAddr); | |
| 246 | + this.wss_flv.setHost(localAddr); | |
| 247 | + this.https_hls.setHost(localAddr); | |
| 248 | + this.wss_hls.setHost(localAddr); | |
| 249 | + this.wss_ts.setHost(localAddr); | |
| 250 | + this.https_fmp4.setHost(localAddr); | |
| 251 | + this.wss_fmp4.setHost(localAddr); | |
| 252 | + this.rtcs.setHost(localAddr); | |
| 253 | + } | |
| 254 | + this.rtsp.setHost(localAddr); | |
| 255 | + if (this.rtsps != null) { | |
| 256 | + this.rtsps.setHost(localAddr); | |
| 257 | + } | |
| 258 | + this.rtmp.setHost(localAddr); | |
| 259 | + if (this.rtmps != null) { | |
| 260 | + this.rtmps.setHost(localAddr); | |
| 261 | + } | |
| 262 | + | |
| 169 | 263 | } |
| 170 | 264 | |
| 171 | - public void setWs_fmp4(String ws_fmp4) { | |
| 172 | - this.ws_fmp4 = ws_fmp4; | |
| 265 | + | |
| 266 | + public static class TransactionInfo{ | |
| 267 | + public String callId; | |
| 268 | + public String localTag; | |
| 269 | + public String remoteTag; | |
| 270 | + public String branch; | |
| 173 | 271 | } |
| 174 | 272 | |
| 175 | - public String getWs_hls() { | |
| 176 | - return ws_hls; | |
| 273 | + private TransactionInfo transactionInfo; | |
| 274 | + | |
| 275 | + public String getApp() { | |
| 276 | + return app; | |
| 177 | 277 | } |
| 178 | 278 | |
| 179 | - public void setWs_hls(String ws_hls) { | |
| 180 | - this.ws_hls = ws_hls; | |
| 279 | + public void setApp(String app) { | |
| 280 | + this.app = app; | |
| 181 | 281 | } |
| 182 | 282 | |
| 183 | - public String getTs() { | |
| 184 | - return ts; | |
| 283 | + public String getDeviceID() { | |
| 284 | + return deviceID; | |
| 185 | 285 | } |
| 186 | 286 | |
| 187 | - public void setTs(String ts) { | |
| 188 | - this.ts = ts; | |
| 287 | + public void setDeviceID(String deviceID) { | |
| 288 | + this.deviceID = deviceID; | |
| 189 | 289 | } |
| 190 | 290 | |
| 191 | - public String getWs_ts() { | |
| 192 | - return ws_ts; | |
| 291 | + public String getChannelId() { | |
| 292 | + return channelId; | |
| 193 | 293 | } |
| 194 | 294 | |
| 195 | - public void setWs_ts(String ws_ts) { | |
| 196 | - this.ws_ts = ws_ts; | |
| 295 | + public void setChannelId(String channelId) { | |
| 296 | + this.channelId = channelId; | |
| 197 | 297 | } |
| 198 | 298 | |
| 199 | 299 | public String getStream() { |
| ... | ... | @@ -204,110 +304,125 @@ public class StreamInfo { |
| 204 | 304 | this.stream = stream; |
| 205 | 305 | } |
| 206 | 306 | |
| 207 | - public String getRtc() { | |
| 208 | - return rtc; | |
| 307 | + public String getIp() { | |
| 308 | + return ip; | |
| 209 | 309 | } |
| 210 | 310 | |
| 211 | - public void setRtc(String rtc) { | |
| 212 | - this.rtc = rtc; | |
| 311 | + public void setIp(String ip) { | |
| 312 | + this.ip = ip; | |
| 213 | 313 | } |
| 214 | 314 | |
| 215 | - public TransactionInfo getTransactionInfo() { | |
| 216 | - return transactionInfo; | |
| 315 | + public StreamURL getFlv() { | |
| 316 | + return flv; | |
| 217 | 317 | } |
| 218 | 318 | |
| 219 | - public void setTransactionInfo(TransactionInfo transactionInfo) { | |
| 220 | - this.transactionInfo = transactionInfo; | |
| 319 | + public StreamURL getHttps_flv() { | |
| 320 | + return https_flv; | |
| 221 | 321 | } |
| 222 | 322 | |
| 223 | - public String getMediaServerId() { | |
| 224 | - return mediaServerId; | |
| 323 | + public StreamURL getWs_flv() { | |
| 324 | + return ws_flv; | |
| 225 | 325 | } |
| 226 | 326 | |
| 227 | - public void setMediaServerId(String mediaServerId) { | |
| 228 | - this.mediaServerId = mediaServerId; | |
| 229 | - } | |
| 230 | 327 | |
| 231 | - public String getHttps_flv() { | |
| 232 | - return https_flv; | |
| 328 | + public StreamURL getWss_flv() { | |
| 329 | + return wss_flv; | |
| 233 | 330 | } |
| 234 | 331 | |
| 235 | - public void setHttps_flv(String https_flv) { | |
| 236 | - this.https_flv = https_flv; | |
| 332 | + public StreamURL getFmp4() { | |
| 333 | + return fmp4; | |
| 237 | 334 | } |
| 238 | 335 | |
| 239 | - public String getWss_flv() { | |
| 240 | - return wss_flv; | |
| 336 | + | |
| 337 | + | |
| 338 | + public StreamURL getHttps_fmp4() { | |
| 339 | + return https_fmp4; | |
| 241 | 340 | } |
| 242 | 341 | |
| 243 | - public void setWss_flv(String wss_flv) { | |
| 244 | - this.wss_flv = wss_flv; | |
| 342 | + public StreamURL getWs_fmp4() { | |
| 343 | + return ws_fmp4; | |
| 245 | 344 | } |
| 246 | 345 | |
| 247 | - public String getWss_fmp4() { | |
| 346 | + public StreamURL getWss_fmp4() { | |
| 248 | 347 | return wss_fmp4; |
| 249 | 348 | } |
| 250 | 349 | |
| 251 | - public void setWss_fmp4(String wss_fmp4) { | |
| 252 | - this.wss_fmp4 = wss_fmp4; | |
| 350 | + public StreamURL getHls() { | |
| 351 | + return hls; | |
| 253 | 352 | } |
| 254 | 353 | |
| 255 | - public String getWss_hls() { | |
| 354 | + | |
| 355 | + public StreamURL getHttps_hls() { | |
| 356 | + return https_hls; | |
| 357 | + } | |
| 358 | + | |
| 359 | + public StreamURL getWs_hls() { | |
| 360 | + return ws_hls; | |
| 361 | + } | |
| 362 | + | |
| 363 | + public StreamURL getWss_hls() { | |
| 256 | 364 | return wss_hls; |
| 257 | 365 | } |
| 258 | 366 | |
| 259 | - public void setWss_hls(String wss_hls) { | |
| 260 | - this.wss_hls = wss_hls; | |
| 367 | + public StreamURL getTs() { | |
| 368 | + return ts; | |
| 261 | 369 | } |
| 262 | 370 | |
| 263 | - public String getWss_ts() { | |
| 264 | - return wss_ts; | |
| 371 | + | |
| 372 | + public StreamURL getHttps_ts() { | |
| 373 | + return https_ts; | |
| 265 | 374 | } |
| 266 | 375 | |
| 267 | - public void setWss_ts(String wss_ts) { | |
| 268 | - this.wss_ts = wss_ts; | |
| 376 | + | |
| 377 | + public StreamURL getWs_ts() { | |
| 378 | + return ws_ts; | |
| 269 | 379 | } |
| 270 | 380 | |
| 271 | - public String getRtmps() { | |
| 272 | - return rtmps; | |
| 381 | + | |
| 382 | + public StreamURL getWss_ts() { | |
| 383 | + return wss_ts; | |
| 273 | 384 | } |
| 274 | 385 | |
| 275 | - public void setRtmps(String rtmps) { | |
| 276 | - this.rtmps = rtmps; | |
| 386 | + | |
| 387 | + public StreamURL getRtmp() { | |
| 388 | + return rtmp; | |
| 277 | 389 | } |
| 278 | 390 | |
| 279 | - public String getRtsps() { | |
| 280 | - return rtsps; | |
| 391 | + public StreamURL getRtmps() { | |
| 392 | + return rtmps; | |
| 281 | 393 | } |
| 282 | 394 | |
| 283 | - public void setRtsps(String rtsps) { | |
| 284 | - this.rtsps = rtsps; | |
| 395 | + public StreamURL getRtsp() { | |
| 396 | + return rtsp; | |
| 285 | 397 | } |
| 286 | 398 | |
| 287 | - public String getHttps_hls() { | |
| 288 | - return https_hls; | |
| 399 | + public StreamURL getRtsps() { | |
| 400 | + return rtsps; | |
| 289 | 401 | } |
| 290 | 402 | |
| 291 | - public void setHttps_hls(String https_hls) { | |
| 292 | - this.https_hls = https_hls; | |
| 403 | + public StreamURL getRtc() { | |
| 404 | + return rtc; | |
| 293 | 405 | } |
| 294 | 406 | |
| 295 | - public String getHttps_fmp4() { | |
| 296 | - return https_fmp4; | |
| 407 | + public StreamURL getRtcs() { | |
| 408 | + return rtcs; | |
| 297 | 409 | } |
| 298 | 410 | |
| 299 | - public void setHttps_fmp4(String https_fmp4) { | |
| 300 | - this.https_fmp4 = https_fmp4; | |
| 411 | + public String getMediaServerId() { | |
| 412 | + return mediaServerId; | |
| 301 | 413 | } |
| 302 | 414 | |
| 303 | - public String getHttps_ts() { | |
| 304 | - return https_ts; | |
| 415 | + public void setMediaServerId(String mediaServerId) { | |
| 416 | + this.mediaServerId = mediaServerId; | |
| 305 | 417 | } |
| 306 | 418 | |
| 307 | - public void setHttps_ts(String https_ts) { | |
| 308 | - this.https_ts = https_ts; | |
| 419 | + public Object getTracks() { | |
| 420 | + return tracks; | |
| 309 | 421 | } |
| 310 | 422 | |
| 423 | + public void setTracks(Object tracks) { | |
| 424 | + this.tracks = tracks; | |
| 425 | + } | |
| 311 | 426 | |
| 312 | 427 | public String getStartTime() { |
| 313 | 428 | return startTime; |
| ... | ... | @@ -333,27 +448,30 @@ public class StreamInfo { |
| 333 | 448 | this.progress = progress; |
| 334 | 449 | } |
| 335 | 450 | |
| 336 | - public String getIp() { | |
| 337 | - return ip; | |
| 338 | - } | |
| 339 | - | |
| 340 | - public void setIp(String ip) { | |
| 341 | - this.ip = ip; | |
| 451 | + public boolean isPause() { | |
| 452 | + return pause; | |
| 342 | 453 | } |
| 343 | 454 | |
| 344 | - public String getRtcs() { | |
| 345 | - return rtcs; | |
| 455 | + public void setPause(boolean pause) { | |
| 456 | + this.pause = pause; | |
| 346 | 457 | } |
| 347 | 458 | |
| 348 | - public void setRtcs(String rtcs) { | |
| 349 | - this.rtcs = rtcs; | |
| 459 | + public TransactionInfo getTransactionInfo() { | |
| 460 | + return transactionInfo; | |
| 350 | 461 | } |
| 351 | 462 | |
| 352 | - public boolean isPause() { | |
| 353 | - return pause; | |
| 463 | + public void setTransactionInfo(TransactionInfo transactionInfo) { | |
| 464 | + this.transactionInfo = transactionInfo; | |
| 354 | 465 | } |
| 355 | 466 | |
| 356 | - public void setPause(boolean pause) { | |
| 357 | - this.pause = pause; | |
| 467 | + @Override | |
| 468 | + public StreamInfo clone() { | |
| 469 | + StreamInfo instance = null; | |
| 470 | + try{ | |
| 471 | + instance = (StreamInfo)super.clone(); | |
| 472 | + }catch(CloneNotSupportedException e) { | |
| 473 | + e.printStackTrace(); | |
| 474 | + } | |
| 475 | + return instance; | |
| 358 | 476 | } |
| 359 | 477 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/common/StreamURL.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.common; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | + | |
| 5 | +import java.io.Serializable; | |
| 6 | + | |
| 7 | + | |
| 8 | +@Schema(description = "流地址信息") | |
| 9 | +public class StreamURL implements Serializable { | |
| 10 | + | |
| 11 | + @Schema(description = "协议") | |
| 12 | + private String protocol; | |
| 13 | + | |
| 14 | + @Schema(description = "主机地址") | |
| 15 | + private String host; | |
| 16 | + | |
| 17 | + @Schema(description = "端口") | |
| 18 | + private int port = -1; | |
| 19 | + | |
| 20 | + @Schema(description = "定位位置") | |
| 21 | + private String file; | |
| 22 | + | |
| 23 | + @Schema(description = "拼接后的地址") | |
| 24 | + private String url; | |
| 25 | + | |
| 26 | + public StreamURL() { | |
| 27 | + } | |
| 28 | + | |
| 29 | + public StreamURL(String protocol, String host, int port, String file) { | |
| 30 | + this.protocol = protocol; | |
| 31 | + this.host = host; | |
| 32 | + this.port = port; | |
| 33 | + this.file = file; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public String getProtocol() { | |
| 37 | + return protocol; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public void setProtocol(String protocol) { | |
| 41 | + this.protocol = protocol; | |
| 42 | + } | |
| 43 | + | |
| 44 | + public String getHost() { | |
| 45 | + return host; | |
| 46 | + } | |
| 47 | + | |
| 48 | + public void setHost(String host) { | |
| 49 | + this.host = host; | |
| 50 | + } | |
| 51 | + | |
| 52 | + public int getPort() { | |
| 53 | + return port; | |
| 54 | + } | |
| 55 | + | |
| 56 | + public void setPort(int port) { | |
| 57 | + this.port = port; | |
| 58 | + } | |
| 59 | + | |
| 60 | + public String getFile() { | |
| 61 | + return file; | |
| 62 | + } | |
| 63 | + | |
| 64 | + public void setFile(String file) { | |
| 65 | + this.file = file; | |
| 66 | + } | |
| 67 | + | |
| 68 | + public String getUrl() { | |
| 69 | + return this.toString(); | |
| 70 | + } | |
| 71 | + | |
| 72 | + @Override | |
| 73 | + public String toString() { | |
| 74 | + if (protocol != null && host != null && port != -1 ) { | |
| 75 | + return String.format("%s://%s:%s/%s", protocol, host, port, file); | |
| 76 | + }else { | |
| 77 | + return null; | |
| 78 | + } | |
| 79 | + } | |
| 80 | +} | ... | ... |
src/main/java/com/genersoft/iot/vmp/common/SystemAllInfo.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.common; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +public class SystemAllInfo { | |
| 6 | + | |
| 7 | + private List<Object> cpu; | |
| 8 | + private List<Object> mem; | |
| 9 | + private List<Object> net; | |
| 10 | + | |
| 11 | + private long netTotal; | |
| 12 | + | |
| 13 | + private Object disk; | |
| 14 | + | |
| 15 | + public List<Object> getCpu() { | |
| 16 | + return cpu; | |
| 17 | + } | |
| 18 | + | |
| 19 | + public void setCpu(List<Object> cpu) { | |
| 20 | + this.cpu = cpu; | |
| 21 | + } | |
| 22 | + | |
| 23 | + public List<Object> getMem() { | |
| 24 | + return mem; | |
| 25 | + } | |
| 26 | + | |
| 27 | + public void setMem(List<Object> mem) { | |
| 28 | + this.mem = mem; | |
| 29 | + } | |
| 30 | + | |
| 31 | + public List<Object> getNet() { | |
| 32 | + return net; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public void setNet(List<Object> net) { | |
| 36 | + this.net = net; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public Object getDisk() { | |
| 40 | + return disk; | |
| 41 | + } | |
| 42 | + | |
| 43 | + public void setDisk(Object disk) { | |
| 44 | + this.disk = disk; | |
| 45 | + } | |
| 46 | + | |
| 47 | + public long getNetTotal() { | |
| 48 | + return netTotal; | |
| 49 | + } | |
| 50 | + | |
| 51 | + public void setNetTotal(long netTotal) { | |
| 52 | + this.netTotal = netTotal; | |
| 53 | + } | |
| 54 | +} | ... | ... |
src/main/java/com/genersoft/iot/vmp/common/SystemInfoDto.java deleted
100644 → 0
| 1 | -package com.genersoft.iot.vmp.common; | |
| 2 | - | |
| 3 | -public class SystemInfoDto<T> { | |
| 4 | - private String time; | |
| 5 | - private T data; | |
| 6 | - | |
| 7 | - public String getTime() { | |
| 8 | - return time; | |
| 9 | - } | |
| 10 | - | |
| 11 | - public void setTime(String time) { | |
| 12 | - this.time = time; | |
| 13 | - } | |
| 14 | - | |
| 15 | - public T getData() { | |
| 16 | - return data; | |
| 17 | - } | |
| 18 | - | |
| 19 | - public void setData(T data) { | |
| 20 | - this.data = data; | |
| 21 | - } | |
| 22 | -} |
src/main/java/com/genersoft/iot/vmp/common/VersionPo.java
| 1 | 1 | package com.genersoft.iot.vmp.common; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.annotation.JSONField; | |
| 3 | +import com.alibaba.fastjson2.annotation.JSONField; | |
| 4 | 4 | |
| 5 | 5 | public class VersionPo { |
| 6 | 6 | /** |
| 7 | 7 | * git的全版本号 |
| 8 | 8 | */ |
| 9 | - @JSONField(name="GIT-Revision") | |
| 9 | + @JSONField(name="GIT_Revision") | |
| 10 | 10 | private String GIT_Revision; |
| 11 | 11 | /** |
| 12 | 12 | * maven版本 |
| 13 | 13 | */ |
| 14 | - @JSONField(name = "Create-By") | |
| 14 | + @JSONField(name = "Create_By") | |
| 15 | 15 | private String Create_By; |
| 16 | 16 | /** |
| 17 | 17 | * git的分支 |
| 18 | 18 | */ |
| 19 | - @JSONField(name = "GIT-BRANCH") | |
| 19 | + @JSONField(name = "GIT_BRANCH") | |
| 20 | 20 | private String GIT_BRANCH; |
| 21 | 21 | /** |
| 22 | 22 | * git的url |
| 23 | 23 | */ |
| 24 | - @JSONField(name = "GIT-URL") | |
| 24 | + @JSONField(name = "GIT_URL") | |
| 25 | 25 | private String GIT_URL; |
| 26 | 26 | /** |
| 27 | 27 | * 构建日期 |
| 28 | 28 | */ |
| 29 | - @JSONField(name = "BUILD-DATE") | |
| 29 | + @JSONField(name = "BUILD_DATE") | |
| 30 | 30 | private String BUILD_DATE; |
| 31 | 31 | /** |
| 32 | + * 构建日期 | |
| 33 | + */ | |
| 34 | + @JSONField(name = "GIT_DATE") | |
| 35 | + private String GIT_DATE; | |
| 36 | + /** | |
| 32 | 37 | * 项目名称 配合pom使用 |
| 33 | 38 | */ |
| 34 | 39 | @JSONField(name = "artifactId") |
| ... | ... | @@ -36,7 +41,7 @@ public class VersionPo { |
| 36 | 41 | /** |
| 37 | 42 | * git局部版本号 |
| 38 | 43 | */ |
| 39 | - @JSONField(name = "GIT-Revision-SHORT") | |
| 44 | + @JSONField(name = "GIT_Revision_SHORT") | |
| 40 | 45 | private String GIT_Revision_SHORT; |
| 41 | 46 | /** |
| 42 | 47 | * 项目的版本如2.0.1.0 配合pom使用 |
| ... | ... | @@ -133,4 +138,12 @@ public class VersionPo { |
| 133 | 138 | public String getBuild_Jdk() { |
| 134 | 139 | return Build_Jdk; |
| 135 | 140 | } |
| 141 | + | |
| 142 | + public String getGIT_DATE() { | |
| 143 | + return GIT_DATE; | |
| 144 | + } | |
| 145 | + | |
| 146 | + public void setGIT_DATE(String GIT_DATE) { | |
| 147 | + this.GIT_DATE = GIT_DATE; | |
| 148 | + } | |
| 136 | 149 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
| ... | ... | @@ -27,11 +27,9 @@ public class VideoManagerConstants { |
| 27 | 27 | |
| 28 | 28 | public static final String KEEPLIVEKEY_PREFIX = "VMP_KEEPALIVE_"; |
| 29 | 29 | |
| 30 | - // 此处多了一个_,暂不修改 | |
| 30 | + // TODO 此处多了一个_,暂不修改 | |
| 31 | 31 | public static final String PLAYER_PREFIX = "VMP_PLAYER_"; |
| 32 | 32 | public static final String PLAY_BLACK_PREFIX = "VMP_PLAYBACK_"; |
| 33 | - public static final String PLAY_INFO_PREFIX = "VMP_PLAY_INFO_"; | |
| 34 | - | |
| 35 | 33 | public static final String DOWNLOAD_PREFIX = "VMP_DOWNLOAD_"; |
| 36 | 34 | |
| 37 | 35 | public static final String PLATFORM_KEEPALIVE_PREFIX = "VMP_PLATFORM_KEEPALIVE_"; |
| ... | ... | @@ -70,6 +68,8 @@ public class VideoManagerConstants { |
| 70 | 68 | |
| 71 | 69 | public static final String SYSTEM_INFO_NET_PREFIX = "VMP_SYSTEM_INFO_NET_"; |
| 72 | 70 | |
| 71 | + public static final String SYSTEM_INFO_DISK_PREFIX = "VMP_SYSTEM_INFO_DISK_"; | |
| 72 | + | |
| 73 | 73 | |
| 74 | 74 | |
| 75 | 75 | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java
| 1 | 1 | package com.genersoft.iot.vmp.conf; |
| 2 | 2 | |
| 3 | -import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; | |
| 4 | 3 | import org.slf4j.Logger; |
| 5 | 4 | import org.slf4j.LoggerFactory; |
| 6 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | -import org.springframework.context.annotation.Bean; | |
| 8 | 5 | import org.springframework.scheduling.annotation.Scheduled; |
| 9 | 6 | import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; |
| 10 | 7 | import org.springframework.stereotype.Component; |
| ... | ... | @@ -101,12 +98,14 @@ public class DynamicTask { |
| 101 | 98 | } |
| 102 | 99 | } |
| 103 | 100 | |
| 104 | - public void stop(String key) { | |
| 105 | - if (futureMap.get(key) != null && !futureMap.get(key).isCancelled()) { | |
| 106 | - futureMap.get(key).cancel(false); | |
| 101 | + public boolean stop(String key) { | |
| 102 | + boolean result = false; | |
| 103 | + if (futureMap.get(key) != null && !futureMap.get(key).isCancelled() && !futureMap.get(key).isDone()) { | |
| 104 | + result = futureMap.get(key).cancel(false); | |
| 107 | 105 | futureMap.remove(key); |
| 108 | 106 | runnableMap.remove(key); |
| 109 | 107 | } |
| 108 | + return result; | |
| 110 | 109 | } |
| 111 | 110 | |
| 112 | 111 | public boolean contains(String key) { |
| ... | ... | @@ -128,11 +127,15 @@ public class DynamicTask { |
| 128 | 127 | public void execute(){ |
| 129 | 128 | if (futureMap.size() > 0) { |
| 130 | 129 | for (String key : futureMap.keySet()) { |
| 131 | - if (futureMap.get(key).isDone()) { | |
| 130 | + if (futureMap.get(key).isDone() || futureMap.get(key).isCancelled()) { | |
| 132 | 131 | futureMap.remove(key); |
| 133 | 132 | runnableMap.remove(key); |
| 134 | 133 | } |
| 135 | 134 | } |
| 136 | 135 | } |
| 137 | 136 | } |
| 137 | + | |
| 138 | + public boolean isAlive(String key) { | |
| 139 | + return futureMap.get(key) != null && !futureMap.get(key).isDone() && !futureMap.get(key).isCancelled(); | |
| 140 | + } | |
| 138 | 141 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/GlobalResponseAdvice.java
| 1 | 1 | package com.genersoft.iot.vmp.conf; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | +import com.alibaba.fastjson2.support.spring.http.converter.FastJsonHttpMessageConverter; | |
| 5 | 5 | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| 6 | 6 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| 7 | 7 | import org.jetbrains.annotations.NotNull; | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java
| ... | ... | @@ -2,13 +2,11 @@ package com.genersoft.iot.vmp.conf; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 4 | 4 | import com.genersoft.iot.vmp.utils.DateUtil; |
| 5 | -import com.genersoft.iot.vmp.vmanager.gb28181.device.DeviceQuery; | |
| 6 | 5 | import org.slf4j.Logger; |
| 7 | 6 | import org.slf4j.LoggerFactory; |
| 8 | 7 | import org.springframework.beans.factory.annotation.Value; |
| 9 | 8 | import org.springframework.context.annotation.Configuration; |
| 10 | 9 | import org.springframework.util.ObjectUtils; |
| 11 | -import org.springframework.util.StringUtils; | |
| 12 | 10 | |
| 13 | 11 | import java.net.InetAddress; |
| 14 | 12 | import java.net.UnknownHostException; |
| ... | ... | @@ -27,7 +25,7 @@ public class MediaConfig{ |
| 27 | 25 | @Value("${media.ip}") |
| 28 | 26 | private String ip; |
| 29 | 27 | |
| 30 | - @Value("${media.hook-ip:${sip.ip}}") | |
| 28 | + @Value("${media.hook-ip:}") | |
| 31 | 29 | private String hookIp; |
| 32 | 30 | |
| 33 | 31 | @Value("${sip.ip}") |
| ... | ... | @@ -75,10 +73,6 @@ public class MediaConfig{ |
| 75 | 73 | @Value("${media.rtp.port-range}") |
| 76 | 74 | private String rtpPortRange; |
| 77 | 75 | |
| 78 | - | |
| 79 | - @Value("${media.rtp.send-port-range}") | |
| 80 | - private String sendRtpPortRange; | |
| 81 | - | |
| 82 | 76 | @Value("${media.record-assist-port:0}") |
| 83 | 77 | private Integer recordAssistPort = 0; |
| 84 | 78 | |
| ... | ... | @@ -92,7 +86,7 @@ public class MediaConfig{ |
| 92 | 86 | |
| 93 | 87 | public String getHookIp() { |
| 94 | 88 | if (ObjectUtils.isEmpty(hookIp)){ |
| 95 | - return sipIp; | |
| 89 | + return sipIp.split(",")[0]; | |
| 96 | 90 | }else { |
| 97 | 91 | return hookIp; |
| 98 | 92 | } |
| ... | ... | @@ -191,10 +185,6 @@ public class MediaConfig{ |
| 191 | 185 | return sipDomain; |
| 192 | 186 | } |
| 193 | 187 | |
| 194 | - public String getSendRtpPortRange() { | |
| 195 | - return sendRtpPortRange; | |
| 196 | - } | |
| 197 | - | |
| 198 | 188 | public MediaServerItem getMediaSerItem(){ |
| 199 | 189 | MediaServerItem mediaServerItem = new MediaServerItem(); |
| 200 | 190 | mediaServerItem.setId(id); |
| ... | ... | @@ -214,9 +204,8 @@ public class MediaConfig{ |
| 214 | 204 | mediaServerItem.setSecret(secret); |
| 215 | 205 | mediaServerItem.setRtpEnable(rtpEnable); |
| 216 | 206 | mediaServerItem.setRtpPortRange(rtpPortRange); |
| 217 | - mediaServerItem.setSendRtpPortRange(sendRtpPortRange); | |
| 218 | 207 | mediaServerItem.setRecordAssistPort(recordAssistPort); |
| 219 | - mediaServerItem.setHookAliveInterval(120); | |
| 208 | + mediaServerItem.setHookAliveInterval(30.00f); | |
| 220 | 209 | |
| 221 | 210 | mediaServerItem.setCreateTime(DateUtil.getNow()); |
| 222 | 211 | mediaServerItem.setUpdateTime(DateUtil.getNow()); | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/MediaStatusTimerTask.java
src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java
| ... | ... | @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.conf; |
| 3 | 3 | |
| 4 | 4 | import org.springframework.boot.context.properties.ConfigurationProperties; |
| 5 | 5 | import org.springframework.stereotype.Component; |
| 6 | +import org.springframework.util.ObjectUtils; | |
| 6 | 7 | |
| 7 | 8 | @Component |
| 8 | 9 | @ConfigurationProperties(prefix = "sip", ignoreInvalidFields = true) |
| ... | ... | @@ -10,11 +11,6 @@ public class SipConfig { |
| 10 | 11 | |
| 11 | 12 | private String ip; |
| 12 | 13 | |
| 13 | - /** | |
| 14 | - * 默认使用 0.0.0.0 | |
| 15 | - */ | |
| 16 | - private String monitorIp = "0.0.0.0"; | |
| 17 | - | |
| 18 | 14 | private Integer port; |
| 19 | 15 | |
| 20 | 16 | private String domain; |
| ... | ... | @@ -25,8 +21,6 @@ public class SipConfig { |
| 25 | 21 | |
| 26 | 22 | Integer ptzSpeed = 50; |
| 27 | 23 | |
| 28 | - Integer keepaliveTimeOut = 255; | |
| 29 | - | |
| 30 | 24 | Integer registerTimeInterval = 120; |
| 31 | 25 | |
| 32 | 26 | private boolean alarm; |
| ... | ... | @@ -35,10 +29,6 @@ public class SipConfig { |
| 35 | 29 | this.ip = ip; |
| 36 | 30 | } |
| 37 | 31 | |
| 38 | - public void setMonitorIp(String monitorIp) { | |
| 39 | - this.monitorIp = monitorIp; | |
| 40 | - } | |
| 41 | - | |
| 42 | 32 | public void setPort(Integer port) { |
| 43 | 33 | this.port = port; |
| 44 | 34 | } |
| ... | ... | @@ -59,18 +49,11 @@ public class SipConfig { |
| 59 | 49 | this.ptzSpeed = ptzSpeed; |
| 60 | 50 | } |
| 61 | 51 | |
| 62 | - public void setKeepaliveTimeOut(Integer keepaliveTimeOut) { | |
| 63 | - this.keepaliveTimeOut = keepaliveTimeOut; | |
| 64 | - } | |
| 65 | 52 | |
| 66 | 53 | public void setRegisterTimeInterval(Integer registerTimeInterval) { |
| 67 | 54 | this.registerTimeInterval = registerTimeInterval; |
| 68 | 55 | } |
| 69 | 56 | |
| 70 | - public String getMonitorIp() { | |
| 71 | - return monitorIp; | |
| 72 | - } | |
| 73 | - | |
| 74 | 57 | public String getIp() { |
| 75 | 58 | return ip; |
| 76 | 59 | } |
| ... | ... | @@ -99,10 +82,6 @@ public class SipConfig { |
| 99 | 82 | return ptzSpeed; |
| 100 | 83 | } |
| 101 | 84 | |
| 102 | - public Integer getKeepaliveTimeOut() { | |
| 103 | - return keepaliveTimeOut; | |
| 104 | - } | |
| 105 | - | |
| 106 | 85 | public Integer getRegisterTimeInterval() { |
| 107 | 86 | return registerTimeInterval; |
| 108 | 87 | } |
| ... | ... | @@ -114,4 +93,10 @@ public class SipConfig { |
| 114 | 93 | public void setAlarm(boolean alarm) { |
| 115 | 94 | this.alarm = alarm; |
| 116 | 95 | } |
| 96 | + | |
| 97 | + public void getLocalIp(String deviceLocalIp) { | |
| 98 | + if (ObjectUtils.isEmpty(deviceLocalIp)) { | |
| 99 | + | |
| 100 | + } | |
| 101 | + } | |
| 117 | 102 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java
| ... | ... | @@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.conf; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 4 | 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; |
| 5 | -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; | |
| 6 | 5 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| 7 | 6 | import com.genersoft.iot.vmp.service.IPlatformService; |
| 8 | 7 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| ... | ... | @@ -47,7 +46,7 @@ public class SipPlatformRunner implements CommandLineRunner { |
| 47 | 46 | parentPlatformCatch.setId(parentPlatform.getServerGBId()); |
| 48 | 47 | redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); |
| 49 | 48 | // 设置所有平台离线 |
| 50 | - platformService.offline(parentPlatform); | |
| 49 | + platformService.offline(parentPlatform, true); | |
| 51 | 50 | // 取消订阅 |
| 52 | 51 | sipCommanderForPlatform.unregister(parentPlatform, null, (eventResult)->{ |
| 53 | 52 | platformService.login(parentPlatform); | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/SystemInfoTimerTask.java
| ... | ... | @@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
| 9 | 9 | import org.springframework.scheduling.annotation.Scheduled; |
| 10 | 10 | import org.springframework.stereotype.Component; |
| 11 | 11 | |
| 12 | +import java.util.List; | |
| 12 | 13 | import java.util.Map; |
| 13 | 14 | |
| 14 | 15 | /** |
| ... | ... | @@ -22,15 +23,17 @@ public class SystemInfoTimerTask { |
| 22 | 23 | @Autowired |
| 23 | 24 | private IRedisCatchStorage redisCatchStorage; |
| 24 | 25 | |
| 25 | - @Scheduled(fixedRate = 1000) //每1秒执行一次 | |
| 26 | + @Scheduled(fixedRate = 2000) //每1秒执行一次 | |
| 26 | 27 | public void execute(){ |
| 27 | 28 | try { |
| 28 | 29 | double cpuInfo = SystemInfoUtils.getCpuInfo(); |
| 29 | 30 | redisCatchStorage.addCpuInfo(cpuInfo); |
| 30 | 31 | double memInfo = SystemInfoUtils.getMemInfo(); |
| 31 | 32 | redisCatchStorage.addMemInfo(memInfo); |
| 32 | - Map<String, String> networkInterfaces = SystemInfoUtils.getNetworkInterfaces(); | |
| 33 | + Map<String, Double> networkInterfaces = SystemInfoUtils.getNetworkInterfaces(); | |
| 33 | 34 | redisCatchStorage.addNetInfo(networkInterfaces); |
| 35 | + List<Map<String, Object>> diskInfo =SystemInfoUtils.getDiskInfo(); | |
| 36 | + redisCatchStorage.addDiskInfo(diskInfo); | |
| 34 | 37 | } catch (InterruptedException e) { |
| 35 | 38 | logger.error("[获取系统信息失败] {}", e.getMessage()); |
| 36 | 39 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
| ... | ... | @@ -33,8 +33,14 @@ public class UserSetting { |
| 33 | 33 | |
| 34 | 34 | private Boolean usePushingAsStatus = Boolean.TRUE; |
| 35 | 35 | |
| 36 | + private Boolean useSourceIpAsStreamIp = Boolean.FALSE; | |
| 37 | + | |
| 36 | 38 | private Boolean streamOnDemand = Boolean.TRUE; |
| 37 | 39 | |
| 40 | + private Boolean pushAuthority = Boolean.TRUE; | |
| 41 | + | |
| 42 | + private Boolean gbSendStreamStrict = Boolean.FALSE; | |
| 43 | + | |
| 38 | 44 | private String serverId = "000000"; |
| 39 | 45 | |
| 40 | 46 | private String thirdPartyGBIdReg = "[\\s\\S]*"; |
| ... | ... | @@ -156,4 +162,28 @@ public class UserSetting { |
| 156 | 162 | public void setStreamOnDemand(Boolean streamOnDemand) { |
| 157 | 163 | this.streamOnDemand = streamOnDemand; |
| 158 | 164 | } |
| 165 | + | |
| 166 | + public Boolean getUseSourceIpAsStreamIp() { | |
| 167 | + return useSourceIpAsStreamIp; | |
| 168 | + } | |
| 169 | + | |
| 170 | + public void setUseSourceIpAsStreamIp(Boolean useSourceIpAsStreamIp) { | |
| 171 | + this.useSourceIpAsStreamIp = useSourceIpAsStreamIp; | |
| 172 | + } | |
| 173 | + | |
| 174 | + public Boolean getPushAuthority() { | |
| 175 | + return pushAuthority; | |
| 176 | + } | |
| 177 | + | |
| 178 | + public void setPushAuthority(Boolean pushAuthority) { | |
| 179 | + this.pushAuthority = pushAuthority; | |
| 180 | + } | |
| 181 | + | |
| 182 | + public Boolean getGbSendStreamStrict() { | |
| 183 | + return gbSendStreamStrict; | |
| 184 | + } | |
| 185 | + | |
| 186 | + public void setGbSendStreamStrict(Boolean gbSendStreamStrict) { | |
| 187 | + this.gbSendStreamStrict = gbSendStreamStrict; | |
| 188 | + } | |
| 159 | 189 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/VersionInfo.java
| ... | ... | @@ -19,6 +19,7 @@ public class VersionInfo { |
| 19 | 19 | versionPo.setBUILD_DATE(gitUtil.getBuildDate()); |
| 20 | 20 | versionPo.setGIT_Revision_SHORT(gitUtil.getCommitIdShort()); |
| 21 | 21 | versionPo.setVersion(gitUtil.getBuildVersion()); |
| 22 | + versionPo.setGIT_DATE(gitUtil.getCommitTime()); | |
| 22 | 23 | |
| 23 | 24 | return versionPo; |
| 24 | 25 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/WVPTimerTask.java
| 1 | 1 | package com.genersoft.iot.vmp.conf; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 5 | 5 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 6 | 6 | import org.springframework.beans.factory.annotation.Autowired; | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/redis/RedisConfig.java
| 1 | 1 | package com.genersoft.iot.vmp.conf.redis; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -import com.alibaba.fastjson.parser.ParserConfig; | |
| 5 | 4 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 6 | 5 | import com.genersoft.iot.vmp.service.redisMsg.*; |
| 7 | 6 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -55,8 +54,7 @@ public class RedisConfig extends CachingConfigurerSupport { |
| 55 | 54 | // value值的序列化采用fastJsonRedisSerializer |
| 56 | 55 | redisTemplate.setValueSerializer(fastJsonRedisSerializer); |
| 57 | 56 | redisTemplate.setHashValueSerializer(fastJsonRedisSerializer); |
| 58 | - // 全局开启AutoType,不建议使用 | |
| 59 | - ParserConfig.getGlobalInstance().setAutoTypeSupport(true); | |
| 57 | + | |
| 60 | 58 | // key的序列化采用StringRedisSerializer |
| 61 | 59 | redisTemplate.setKeySerializer(new StringRedisSerializer()); |
| 62 | 60 | redisTemplate.setHashKeySerializer(new StringRedisSerializer()); | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java
src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
| ... | ... | @@ -8,16 +8,18 @@ import gov.nist.javax.sip.SipStackImpl; |
| 8 | 8 | import org.slf4j.Logger; |
| 9 | 9 | import org.slf4j.LoggerFactory; |
| 10 | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | -import org.springframework.context.annotation.Bean; | |
| 12 | -import org.springframework.context.annotation.Configuration; | |
| 13 | -import org.springframework.context.annotation.DependsOn; | |
| 11 | +import org.springframework.boot.CommandLineRunner; | |
| 12 | +import org.springframework.core.annotation.Order; | |
| 13 | +import org.springframework.stereotype.Component; | |
| 14 | +import org.springframework.util.ObjectUtils; | |
| 14 | 15 | |
| 15 | 16 | import javax.sip.*; |
| 16 | -import java.util.Properties; | |
| 17 | -import java.util.TooManyListenersException; | |
| 17 | +import java.util.*; | |
| 18 | +import java.util.concurrent.ConcurrentHashMap; | |
| 18 | 19 | |
| 19 | -@Configuration | |
| 20 | -public class SipLayer{ | |
| 20 | +@Component | |
| 21 | +@Order(value=1) | |
| 22 | +public class SipLayer implements CommandLineRunner { | |
| 21 | 23 | |
| 22 | 24 | private final static Logger logger = LoggerFactory.getLogger(SipLayer.class); |
| 23 | 25 | |
| ... | ... | @@ -27,70 +29,117 @@ public class SipLayer{ |
| 27 | 29 | @Autowired |
| 28 | 30 | private ISIPProcessorObserver sipProcessorObserver; |
| 29 | 31 | |
| 30 | - private SipStackImpl sipStack; | |
| 32 | + | |
| 33 | + | |
| 34 | + private final Map<String, SipProviderImpl> tcpSipProviderMap = new ConcurrentHashMap<>(); | |
| 35 | + private final Map<String, SipProviderImpl> udpSipProviderMap = new ConcurrentHashMap<>(); | |
| 31 | 36 | |
| 32 | 37 | private SipFactory sipFactory; |
| 33 | 38 | |
| 39 | + @Override | |
| 40 | + public void run(String... args) { | |
| 41 | + List<String> monitorIps = new ArrayList<>(); | |
| 42 | + // 使用逗号分割多个ip | |
| 43 | + String separator = ","; | |
| 44 | + if (sipConfig.getIp().indexOf(separator) > 0) { | |
| 45 | + String[] split = sipConfig.getIp().split(separator); | |
| 46 | + monitorIps.addAll(Arrays.asList(split)); | |
| 47 | + }else { | |
| 48 | + monitorIps.add(sipConfig.getIp()); | |
| 49 | + } | |
| 34 | 50 | |
| 35 | - @Bean("sipFactory") | |
| 36 | - SipFactory createSipFactory() { | |
| 37 | 51 | sipFactory = SipFactory.getInstance(); |
| 38 | 52 | sipFactory.setPathName("gov.nist"); |
| 39 | - return sipFactory; | |
| 40 | - } | |
| 41 | - | |
| 42 | - @Bean("sipStack") | |
| 43 | - @DependsOn({"sipFactory"}) | |
| 44 | - SipStackImpl createSipStack() throws PeerUnavailableException { | |
| 45 | - sipStack = ( SipStackImpl )sipFactory.createSipStack(DefaultProperties.getProperties(sipConfig.getMonitorIp(), false)); | |
| 46 | - return sipStack; | |
| 53 | + if (monitorIps.size() > 0) { | |
| 54 | + for (String monitorIp : monitorIps) { | |
| 55 | + addListeningPoint(monitorIp, sipConfig.getPort()); | |
| 56 | + } | |
| 57 | + if (udpSipProviderMap.size() + tcpSipProviderMap.size() == 0) { | |
| 58 | + System.exit(1); | |
| 59 | + } | |
| 60 | + } | |
| 47 | 61 | } |
| 48 | 62 | |
| 49 | - @Bean(name = "tcpSipProvider") | |
| 50 | - @DependsOn("sipStack") | |
| 51 | - SipProviderImpl startTcpListener() { | |
| 52 | - ListeningPoint tcpListeningPoint = null; | |
| 53 | - SipProviderImpl tcpSipProvider = null; | |
| 63 | + private void addListeningPoint(String monitorIp, int port){ | |
| 64 | + SipStackImpl sipStack; | |
| 65 | + try { | |
| 66 | + sipStack = (SipStackImpl)sipFactory.createSipStack(DefaultProperties.getProperties(monitorIp, false)); | |
| 67 | + } catch (PeerUnavailableException e) { | |
| 68 | + logger.error("[Sip Server] SIP服务启动失败, 监听地址{}失败,请检查ip是否正确", monitorIp); | |
| 69 | + return; | |
| 70 | + } | |
| 71 | + | |
| 54 | 72 | try { |
| 55 | - tcpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getPort(), "TCP"); | |
| 56 | - tcpSipProvider = (SipProviderImpl)sipStack.createSipProvider(tcpListeningPoint); | |
| 73 | + ListeningPoint tcpListeningPoint = sipStack.createListeningPoint(monitorIp, port, "TCP"); | |
| 74 | + SipProviderImpl tcpSipProvider = (SipProviderImpl)sipStack.createSipProvider(tcpListeningPoint); | |
| 75 | + | |
| 57 | 76 | tcpSipProvider.setDialogErrorsAutomaticallyHandled(); |
| 58 | 77 | tcpSipProvider.addSipListener(sipProcessorObserver); |
| 59 | - logger.info("[Sip Server] TCP 启动成功 {}:{}", sipConfig.getMonitorIp(), sipConfig.getPort()); | |
| 60 | - } catch (TransportNotSupportedException e) { | |
| 61 | - e.printStackTrace(); | |
| 62 | - } catch (InvalidArgumentException e) { | |
| 63 | - logger.error("[Sip Server] 无法使用 [ {}:{} ]作为SIP[ TCP ]服务,可排查: 1. sip.monitor-ip 是否为本机网卡IP; 2. sip.port 是否已被占用" | |
| 64 | - , sipConfig.getMonitorIp(), sipConfig.getPort()); | |
| 65 | - } catch (TooManyListenersException e) { | |
| 66 | - e.printStackTrace(); | |
| 67 | - } catch (ObjectInUseException e) { | |
| 68 | - e.printStackTrace(); | |
| 78 | + tcpSipProviderMap.put(monitorIp, tcpSipProvider); | |
| 79 | + | |
| 80 | + logger.info("[Sip Server] tcp://{}:{} 启动成功", monitorIp, port); | |
| 81 | + } catch (TransportNotSupportedException | |
| 82 | + | TooManyListenersException | |
| 83 | + | ObjectInUseException | |
| 84 | + | InvalidArgumentException e) { | |
| 85 | + logger.error("[Sip Server] tcp://{}:{} SIP服务启动失败,请检查端口是否被占用或者ip是否正确" | |
| 86 | + , monitorIp, port); | |
| 69 | 87 | } |
| 70 | - return tcpSipProvider; | |
| 71 | - } | |
| 72 | - | |
| 73 | - @Bean(name = "udpSipProvider") | |
| 74 | - @DependsOn("sipStack") | |
| 75 | - SipProviderImpl startUdpListener() { | |
| 76 | - ListeningPoint udpListeningPoint = null; | |
| 77 | - SipProviderImpl udpSipProvider = null; | |
| 88 | + | |
| 78 | 89 | try { |
| 79 | - udpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getPort(), "UDP"); | |
| 80 | - udpSipProvider = (SipProviderImpl)sipStack.createSipProvider(udpListeningPoint); | |
| 90 | + ListeningPoint udpListeningPoint = sipStack.createListeningPoint(monitorIp, port, "UDP"); | |
| 91 | + | |
| 92 | + SipProviderImpl udpSipProvider = (SipProviderImpl)sipStack.createSipProvider(udpListeningPoint); | |
| 81 | 93 | udpSipProvider.addSipListener(sipProcessorObserver); |
| 82 | - } catch (TransportNotSupportedException e) { | |
| 83 | - e.printStackTrace(); | |
| 84 | - } catch (InvalidArgumentException e) { | |
| 85 | - logger.error("[Sip Server] 无法使用 [ {}:{} ]作为SIP[ UDP ]服务,可排查: 1. sip.monitor-ip 是否为本机网卡IP; 2. sip.port 是否已被占用" | |
| 86 | - , sipConfig.getMonitorIp(), sipConfig.getPort()); | |
| 87 | - } catch (TooManyListenersException e) { | |
| 88 | - e.printStackTrace(); | |
| 89 | - } catch (ObjectInUseException e) { | |
| 90 | - e.printStackTrace(); | |
| 94 | + | |
| 95 | + udpSipProviderMap.put(monitorIp, udpSipProvider); | |
| 96 | + | |
| 97 | + logger.info("[Sip Server] udp://{}:{} 启动成功", monitorIp, port); | |
| 98 | + } catch (TransportNotSupportedException | |
| 99 | + | TooManyListenersException | |
| 100 | + | ObjectInUseException | |
| 101 | + | InvalidArgumentException e) { | |
| 102 | + logger.error("[Sip Server] udp://{}:{} SIP服务启动失败,请检查端口是否被占用或者ip是否正确" | |
| 103 | + , monitorIp, port); | |
| 91 | 104 | } |
| 92 | - logger.info("[Sip Server] UDP 启动成功 {}:{}", sipConfig.getMonitorIp(), sipConfig.getPort()); | |
| 93 | - return udpSipProvider; | |
| 94 | 105 | } |
| 95 | 106 | |
| 107 | + public SipFactory getSipFactory() { | |
| 108 | + return sipFactory; | |
| 109 | + } | |
| 110 | + | |
| 111 | + public SipProviderImpl getUdpSipProvider(String ip) { | |
| 112 | + if (ObjectUtils.isEmpty(ip)) { | |
| 113 | + return null; | |
| 114 | + } | |
| 115 | + return udpSipProviderMap.get(ip); | |
| 116 | + } | |
| 117 | + | |
| 118 | + public SipProviderImpl getUdpSipProvider() { | |
| 119 | + if (udpSipProviderMap.size() != 1) { | |
| 120 | + return null; | |
| 121 | + } | |
| 122 | + return udpSipProviderMap.values().stream().findFirst().get(); | |
| 123 | + } | |
| 124 | + | |
| 125 | + public SipProviderImpl getTcpSipProvider() { | |
| 126 | + if (tcpSipProviderMap.size() != 1) { | |
| 127 | + return null; | |
| 128 | + } | |
| 129 | + return tcpSipProviderMap.values().stream().findFirst().get(); | |
| 130 | + } | |
| 131 | + | |
| 132 | + public SipProviderImpl getTcpSipProvider(String ip) { | |
| 133 | + if (ObjectUtils.isEmpty(ip)) { | |
| 134 | + return null; | |
| 135 | + } | |
| 136 | + return tcpSipProviderMap.get(ip); | |
| 137 | + } | |
| 138 | + | |
| 139 | + public String getLocalIp(String deviceLocalIp) { | |
| 140 | + if (!ObjectUtils.isEmpty(deviceLocalIp)) { | |
| 141 | + return deviceLocalIp; | |
| 142 | + } | |
| 143 | + return getUdpSipProvider().getListeningPoint().getIPAddress(); | |
| 144 | + } | |
| 96 | 145 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java
| ... | ... | @@ -172,6 +172,15 @@ public class Device { |
| 172 | 172 | @Schema(description = "树类型 国标规定了两种树的展现方式 行政区划:CivilCode 和业务分组:BusinessGroup") |
| 173 | 173 | private String treeType; |
| 174 | 174 | |
| 175 | + @Schema(description = "密码") | |
| 176 | + private String password; | |
| 177 | + | |
| 178 | + @Schema(description = "收流IP") | |
| 179 | + private String sdpIp; | |
| 180 | + | |
| 181 | + @Schema(description = "SIP交互IP(设备访问平台的IP)") | |
| 182 | + private String localIp; | |
| 183 | + | |
| 175 | 184 | |
| 176 | 185 | public String getDeviceId() { |
| 177 | 186 | return deviceId; |
| ... | ... | @@ -382,4 +391,27 @@ public class Device { |
| 382 | 391 | this.treeType = treeType; |
| 383 | 392 | } |
| 384 | 393 | |
| 394 | + public String getPassword() { | |
| 395 | + return password; | |
| 396 | + } | |
| 397 | + | |
| 398 | + public void setPassword(String password) { | |
| 399 | + this.password = password; | |
| 400 | + } | |
| 401 | + | |
| 402 | + public String getSdpIp() { | |
| 403 | + return sdpIp; | |
| 404 | + } | |
| 405 | + | |
| 406 | + public void setSdpIp(String sdpIp) { | |
| 407 | + this.sdpIp = sdpIp; | |
| 408 | + } | |
| 409 | + | |
| 410 | + public String getLocalIp() { | |
| 411 | + return localIp; | |
| 412 | + } | |
| 413 | + | |
| 414 | + public void setLocalIp(String localIp) { | |
| 415 | + this.localIp = localIp; | |
| 416 | + } | |
| 385 | 417 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamInfo.java
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java
| ... | ... | @@ -3,15 +3,13 @@ package com.genersoft.iot.vmp.gb28181.bean; |
| 3 | 3 | import gov.nist.javax.sip.message.SIPRequest; |
| 4 | 4 | import gov.nist.javax.sip.message.SIPResponse; |
| 5 | 5 | |
| 6 | -import javax.sip.ServerTransaction; | |
| 7 | 6 | import javax.sip.header.*; |
| 8 | 7 | |
| 9 | 8 | public class SubscribeInfo { |
| 10 | 9 | |
| 11 | 10 | |
| 12 | - public SubscribeInfo(ServerTransaction serverTransaction, String id) { | |
| 11 | + public SubscribeInfo(SIPRequest request, String id) { | |
| 13 | 12 | this.id = id; |
| 14 | - SIPRequest request = (SIPRequest)serverTransaction.getRequest(); | |
| 15 | 13 | this.request = request; |
| 16 | 14 | this.expires = request.getExpires().getExpires(); |
| 17 | 15 | EventHeader eventHeader = (EventHeader)request.getHeader(EventHeader.NAME); | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/conf/SipLoggerPass.java
src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java
| ... | ... | @@ -8,10 +8,12 @@ import org.slf4j.LoggerFactory; |
| 8 | 8 | import org.springframework.scheduling.annotation.Scheduled; |
| 9 | 9 | import org.springframework.stereotype.Component; |
| 10 | 10 | |
| 11 | -import javax.sip.*; | |
| 11 | +import javax.sip.DialogTerminatedEvent; | |
| 12 | +import javax.sip.ResponseEvent; | |
| 13 | +import javax.sip.TimeoutEvent; | |
| 14 | +import javax.sip.TransactionTerminatedEvent; | |
| 12 | 15 | import javax.sip.header.CallIdHeader; |
| 13 | 16 | import javax.sip.message.Response; |
| 14 | -import java.text.ParseException; | |
| 15 | 17 | import java.time.Instant; |
| 16 | 18 | import java.util.Map; |
| 17 | 19 | import java.util.concurrent.ConcurrentHashMap; |
| ... | ... | @@ -30,6 +32,7 @@ public class SipSubscribe { |
| 30 | 32 | private Map<String, SipSubscribe.Event> okSubscribes = new ConcurrentHashMap<>(); |
| 31 | 33 | |
| 32 | 34 | private Map<String, Instant> okTimeSubscribes = new ConcurrentHashMap<>(); |
| 35 | + | |
| 33 | 36 | private Map<String, Instant> errorTimeSubscribes = new ConcurrentHashMap<>(); |
| 34 | 37 | |
| 35 | 38 | // @Scheduled(cron="*/5 * * * * ?") //每五秒执行一次 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEventListener.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.event.record; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; |
| 4 | -import com.genersoft.iot.vmp.gb28181.bean.RecordItem; | |
| 5 | 4 | import org.slf4j.Logger; |
| 6 | 5 | import org.slf4j.LoggerFactory; |
| 7 | 6 | import org.springframework.context.ApplicationListener; |
| 8 | 7 | import org.springframework.stereotype.Component; |
| 9 | -import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; | |
| 10 | 8 | |
| 11 | -import java.io.IOException; | |
| 12 | -import java.util.*; | |
| 9 | +import java.util.Map; | |
| 10 | +import java.util.concurrent.ConcurrentHashMap; | |
| 13 | 11 | |
| 14 | 12 | /** |
| 15 | - * @description: 录像查询结束时间 | |
| 13 | + * @description: 录像查询结束事件 | |
| 16 | 14 | * @author: pan |
| 17 | 15 | * @data: 2022-02-23 |
| 18 | 16 | */ |
| ... | ... | @@ -22,13 +20,12 @@ public class RecordEndEventListener implements ApplicationListener<RecordEndEven |
| 22 | 20 | |
| 23 | 21 | private final static Logger logger = LoggerFactory.getLogger(RecordEndEventListener.class); |
| 24 | 22 | |
| 25 | - private static Map<String, SseEmitter> sseEmitters = new Hashtable<>(); | |
| 26 | - | |
| 27 | 23 | public interface RecordEndEventHandler{ |
| 28 | 24 | void handler(RecordInfo recordInfo); |
| 29 | 25 | } |
| 30 | 26 | |
| 31 | - private Map<String, RecordEndEventHandler> handlerMap = new HashMap<>(); | |
| 27 | + private Map<String, RecordEndEventHandler> handlerMap = new ConcurrentHashMap<>(); | |
| 28 | + | |
| 32 | 29 | @Override |
| 33 | 30 | public void onApplicationEvent(RecordEndEvent event) { |
| 34 | 31 | logger.info("录像查询完成事件触发,deviceId:{}, channelId: {}, 录像数量{}条", event.getRecordInfo().getDeviceId(), |
| ... | ... | @@ -38,7 +35,6 @@ public class RecordEndEventListener implements ApplicationListener<RecordEndEven |
| 38 | 35 | recordEndEventHandler.handler(event.getRecordInfo()); |
| 39 | 36 | } |
| 40 | 37 | } |
| 41 | - | |
| 42 | 38 | } |
| 43 | 39 | |
| 44 | 40 | public void addEndEventHandler(String device, String channelId, RecordEndEventHandler recordEndEventHandler) { | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java
| ... | ... | @@ -42,7 +42,7 @@ public class CatalogDataCatch { |
| 42 | 42 | catalogData.setSn(sn); |
| 43 | 43 | catalogData.setTotal(total); |
| 44 | 44 | catalogData.setDevice(device); |
| 45 | - catalogData.setChannelList(Collections.synchronizedList(new ArrayList<>())); | |
| 45 | + catalogData.setChannelList(deviceChannelList); | |
| 46 | 46 | catalogData.setStatus(CatalogData.CatalogDataStatus.runIng); |
| 47 | 47 | catalogData.setLastTime(Instant.now()); |
| 48 | 48 | data.put(deviceId, catalogData); | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/task/SipDeviceRunner.java renamed to src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.task; |
| 2 | 2 | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 3 | 4 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 4 | 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 6 | +import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | |
| 7 | +import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; | |
| 8 | +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; | |
| 9 | +import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; | |
| 10 | +import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | |
| 5 | 11 | import com.genersoft.iot.vmp.service.IDeviceService; |
| 12 | +import com.genersoft.iot.vmp.service.IMediaServerService; | |
| 13 | +import com.genersoft.iot.vmp.service.IPlatformService; | |
| 6 | 14 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 7 | 15 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 8 | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -10,8 +18,9 @@ import org.springframework.boot.CommandLineRunner; |
| 10 | 18 | import org.springframework.core.annotation.Order; |
| 11 | 19 | import org.springframework.stereotype.Component; |
| 12 | 20 | |
| 13 | -import java.util.ArrayList; | |
| 21 | +import java.util.HashMap; | |
| 14 | 22 | import java.util.List; |
| 23 | +import java.util.Map; | |
| 15 | 24 | |
| 16 | 25 | |
| 17 | 26 | /** |
| ... | ... | @@ -20,7 +29,7 @@ import java.util.List; |
| 20 | 29 | */ |
| 21 | 30 | @Component |
| 22 | 31 | @Order(value=4) |
| 23 | -public class SipDeviceRunner implements CommandLineRunner { | |
| 32 | +public class SipRunner implements CommandLineRunner { | |
| 24 | 33 | |
| 25 | 34 | @Autowired |
| 26 | 35 | private IVideoManagerStorage storager; |
| ... | ... | @@ -34,6 +43,18 @@ public class SipDeviceRunner implements CommandLineRunner { |
| 34 | 43 | @Autowired |
| 35 | 44 | private IDeviceService deviceService; |
| 36 | 45 | |
| 46 | + @Autowired | |
| 47 | + private ZLMRESTfulUtils zlmresTfulUtils; | |
| 48 | + | |
| 49 | + @Autowired | |
| 50 | + private IMediaServerService mediaServerService; | |
| 51 | + | |
| 52 | + @Autowired | |
| 53 | + private IPlatformService platformService; | |
| 54 | + | |
| 55 | + @Autowired | |
| 56 | + private ISIPCommanderForPlatform commanderForPlatform; | |
| 57 | + | |
| 37 | 58 | @Override |
| 38 | 59 | public void run(String... args) throws Exception { |
| 39 | 60 | List<Device> deviceList = deviceService.getAllOnlineDevice(); |
| ... | ... | @@ -47,5 +68,28 @@ public class SipDeviceRunner implements CommandLineRunner { |
| 47 | 68 | } |
| 48 | 69 | // 重置cseq计数 |
| 49 | 70 | redisCatchStorage.resetAllCSEQ(); |
| 71 | + // 清理redis | |
| 72 | + // 查找国标推流 | |
| 73 | + List<SendRtpItem> sendRtpItems = redisCatchStorage.queryAllSendRTPServer(); | |
| 74 | + if (sendRtpItems.size() > 0) { | |
| 75 | + for (SendRtpItem sendRtpItem : sendRtpItems) { | |
| 76 | + MediaServerItem mediaServerItem = mediaServerService.getOne(sendRtpItem.getMediaServerId()); | |
| 77 | + redisCatchStorage.deleteSendRTPServer(sendRtpItem.getPlatformId(),sendRtpItem.getChannelId(), sendRtpItem.getCallId(),sendRtpItem.getStreamId()); | |
| 78 | + if (mediaServerItem != null) { | |
| 79 | + Map<String, Object> param = new HashMap<>(); | |
| 80 | + param.put("vhost","__defaultVhost__"); | |
| 81 | + param.put("app",sendRtpItem.getApp()); | |
| 82 | + param.put("stream",sendRtpItem.getStreamId()); | |
| 83 | + param.put("ssrc",sendRtpItem.getSsrc()); | |
| 84 | + JSONObject jsonObject = zlmresTfulUtils.stopSendRtp(mediaServerItem, param); | |
| 85 | + if (jsonObject != null && jsonObject.getInteger("code") == 0) { | |
| 86 | + ParentPlatform platform = platformService.queryPlatformByServerGBId(sendRtpItem.getPlatformId()); | |
| 87 | + if (platform != null) { | |
| 88 | + commanderForPlatform.streamByeCmd(platform, sendRtpItem.getCallId()); | |
| 89 | + } | |
| 90 | + } | |
| 91 | + } | |
| 92 | + } | |
| 93 | + } | |
| 50 | 94 | } |
| 51 | 95 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java
| ... | ... | @@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.transmit.event.response.ISIPResponseProcessor; |
| 7 | 7 | import com.genersoft.iot.vmp.gb28181.transmit.event.timeout.ITimeoutProcessor; |
| 8 | +import gov.nist.javax.sip.message.SIPRequest; | |
| 8 | 9 | import org.slf4j.Logger; |
| 9 | 10 | import org.slf4j.LoggerFactory; |
| 10 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -15,6 +16,7 @@ import javax.sip.*; |
| 15 | 16 | import javax.sip.header.*; |
| 16 | 17 | import javax.sip.message.Request; |
| 17 | 18 | import javax.sip.message.Response; |
| 19 | +import java.net.InetAddress; | |
| 18 | 20 | import java.util.Map; |
| 19 | 21 | import java.util.concurrent.ConcurrentHashMap; |
| 20 | 22 | |
| ... | ... | @@ -75,6 +77,7 @@ public class SIPProcessorObserver implements ISIPProcessorObserver { |
| 75 | 77 | ISIPRequestProcessor sipRequestProcessor = requestProcessorMap.get(method); |
| 76 | 78 | if (sipRequestProcessor == null) { |
| 77 | 79 | logger.warn("不支持方法{}的request", method); |
| 80 | + // TODO 回复错误玛 | |
| 78 | 81 | return; |
| 79 | 82 | } |
| 80 | 83 | requestProcessorMap.get(method).process(requestEvent); | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPSender.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.gb28181.transmit; | |
| 2 | + | |
| 3 | +import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 4 | +import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; | |
| 5 | +import com.genersoft.iot.vmp.gb28181.utils.SipUtils; | |
| 6 | +import com.genersoft.iot.vmp.utils.GitUtil; | |
| 7 | +import gov.nist.javax.sip.SipProviderImpl; | |
| 8 | +import org.slf4j.Logger; | |
| 9 | +import org.slf4j.LoggerFactory; | |
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 11 | +import org.springframework.stereotype.Component; | |
| 12 | +import org.springframework.util.ObjectUtils; | |
| 13 | + | |
| 14 | +import javax.sip.SipException; | |
| 15 | +import javax.sip.header.CallIdHeader; | |
| 16 | +import javax.sip.header.UserAgentHeader; | |
| 17 | +import javax.sip.header.ViaHeader; | |
| 18 | +import javax.sip.message.Message; | |
| 19 | +import javax.sip.message.Request; | |
| 20 | +import javax.sip.message.Response; | |
| 21 | +import java.text.ParseException; | |
| 22 | + | |
| 23 | +/** | |
| 24 | + * 发送SIP消息 | |
| 25 | + * @author lin | |
| 26 | + */ | |
| 27 | +@Component | |
| 28 | +public class SIPSender { | |
| 29 | + | |
| 30 | + private final Logger logger = LoggerFactory.getLogger(SIPSender.class); | |
| 31 | + | |
| 32 | + @Autowired | |
| 33 | + private SipLayer sipLayer; | |
| 34 | + | |
| 35 | + @Autowired | |
| 36 | + private GitUtil gitUtil; | |
| 37 | + | |
| 38 | + @Autowired | |
| 39 | + private SipSubscribe sipSubscribe; | |
| 40 | + | |
| 41 | + public void transmitRequest(String ip, Message message) throws SipException, ParseException { | |
| 42 | + transmitRequest(ip, message, null, null); | |
| 43 | + } | |
| 44 | + | |
| 45 | + public void transmitRequest(String ip, Message message, SipSubscribe.Event errorEvent) throws SipException, ParseException { | |
| 46 | + transmitRequest(ip, message, errorEvent, null); | |
| 47 | + } | |
| 48 | + | |
| 49 | + public void transmitRequest(String ip, Message message, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, ParseException { | |
| 50 | + ViaHeader viaHeader = (ViaHeader)message.getHeader(ViaHeader.NAME); | |
| 51 | + String transport = "UDP"; | |
| 52 | + if (viaHeader == null) { | |
| 53 | + logger.warn("[消息头缺失]: ViaHeader, 使用默认的UDP方式处理数据"); | |
| 54 | + }else { | |
| 55 | + transport = viaHeader.getTransport(); | |
| 56 | + } | |
| 57 | + if (message.getHeader(UserAgentHeader.NAME) == null) { | |
| 58 | + try { | |
| 59 | + message.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 60 | + } catch (ParseException e) { | |
| 61 | + logger.error("添加UserAgentHeader失败", e); | |
| 62 | + } | |
| 63 | + } | |
| 64 | + | |
| 65 | + CallIdHeader callIdHeader = (CallIdHeader) message.getHeader(CallIdHeader.NAME); | |
| 66 | + // 添加错误订阅 | |
| 67 | + if (errorEvent != null) { | |
| 68 | + sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (eventResult -> { | |
| 69 | + errorEvent.response(eventResult); | |
| 70 | + sipSubscribe.removeErrorSubscribe(eventResult.callId); | |
| 71 | + sipSubscribe.removeOkSubscribe(eventResult.callId); | |
| 72 | + })); | |
| 73 | + } | |
| 74 | + // 添加订阅 | |
| 75 | + if (okEvent != null) { | |
| 76 | + sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), eventResult -> { | |
| 77 | + okEvent.response(eventResult); | |
| 78 | + sipSubscribe.removeOkSubscribe(eventResult.callId); | |
| 79 | + sipSubscribe.removeErrorSubscribe(eventResult.callId); | |
| 80 | + }); | |
| 81 | + } | |
| 82 | + if ("TCP".equals(transport)) { | |
| 83 | + SipProviderImpl tcpSipProvider = sipLayer.getTcpSipProvider(ip); | |
| 84 | + if (tcpSipProvider == null) { | |
| 85 | + logger.error("[发送信息失败] 未找到tcp://{}的监听信息", ip); | |
| 86 | + return; | |
| 87 | + } | |
| 88 | + if (message instanceof Request) { | |
| 89 | + tcpSipProvider.sendRequest((Request)message); | |
| 90 | + }else if (message instanceof Response) { | |
| 91 | + tcpSipProvider.sendResponse((Response)message); | |
| 92 | + } | |
| 93 | + | |
| 94 | + } else if ("UDP".equals(transport)) { | |
| 95 | + SipProviderImpl sipProvider = sipLayer.getUdpSipProvider(ip); | |
| 96 | + if (sipProvider == null) { | |
| 97 | + logger.error("[发送信息失败] 未找到udp://{}的监听信息", ip); | |
| 98 | + return; | |
| 99 | + } | |
| 100 | + if (message instanceof Request) { | |
| 101 | + sipProvider.sendRequest((Request)message); | |
| 102 | + }else if (message instanceof Response) { | |
| 103 | + sipProvider.sendResponse((Response)message); | |
| 104 | + } | |
| 105 | + } | |
| 106 | + } | |
| 107 | + | |
| 108 | + public CallIdHeader getNewCallIdHeader(String ip, String transport){ | |
| 109 | + if (ObjectUtils.isEmpty(transport)) { | |
| 110 | + return sipLayer.getUdpSipProvider().getNewCallId(); | |
| 111 | + } | |
| 112 | + SipProviderImpl sipProvider; | |
| 113 | + if (ObjectUtils.isEmpty(ip)) { | |
| 114 | + sipProvider = transport.equalsIgnoreCase("TCP") ? sipLayer.getTcpSipProvider() | |
| 115 | + : sipLayer.getUdpSipProvider(); | |
| 116 | + }else { | |
| 117 | + sipProvider = transport.equalsIgnoreCase("TCP") ? sipLayer.getTcpSipProvider(ip) | |
| 118 | + : sipLayer.getUdpSipProvider(ip); | |
| 119 | + } | |
| 120 | + | |
| 121 | + if (sipProvider == null) { | |
| 122 | + sipProvider = sipLayer.getUdpSipProvider(); | |
| 123 | + } | |
| 124 | + | |
| 125 | + if (sipProvider != null) { | |
| 126 | + return sipProvider.getNewCallId(); | |
| 127 | + }else { | |
| 128 | + logger.warn("[新建CallIdHeader失败], ip={}, transport={}", ip, transport); | |
| 129 | + return null; | |
| 130 | + } | |
| 131 | + } | |
| 132 | +} | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.callback; |
| 2 | 2 | |
| 3 | -import java.util.HashMap; | |
| 3 | +import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx; | |
| 4 | +import org.springframework.stereotype.Component; | |
| 5 | +import org.springframework.util.ObjectUtils; | |
| 6 | +import org.springframework.web.context.request.async.DeferredResult; | |
| 7 | + | |
| 8 | +import java.util.Collection; | |
| 4 | 9 | import java.util.Map; |
| 5 | 10 | import java.util.Set; |
| 6 | 11 | import java.util.concurrent.ConcurrentHashMap; |
| 7 | 12 | |
| 8 | -import org.springframework.http.HttpStatus; | |
| 9 | -import org.springframework.http.ResponseEntity; | |
| 10 | -import org.springframework.stereotype.Component; | |
| 11 | -import org.springframework.web.context.request.async.DeferredResult; | |
| 12 | - | |
| 13 | 13 | /** |
| 14 | 14 | * @description: 异步请求处理 |
| 15 | 15 | * @author: swwheihei |
| ... | ... | @@ -51,31 +51,48 @@ public class DeferredResultHolder { |
| 51 | 51 | |
| 52 | 52 | public static final String CALLBACK_CMD_BROADCAST = "CALLBACK_BROADCAST"; |
| 53 | 53 | |
| 54 | - private Map<String, Map<String, DeferredResult>> map = new ConcurrentHashMap<>(); | |
| 54 | + private Map<String, Map<String, DeferredResultEx>> map = new ConcurrentHashMap<>(); | |
| 55 | 55 | |
| 56 | 56 | |
| 57 | - public void put(String key, String id, DeferredResult result) { | |
| 58 | - Map<String, DeferredResult> deferredResultMap = map.get(key); | |
| 57 | + public void put(String key, String id, DeferredResultEx result) { | |
| 58 | + Map<String, DeferredResultEx> deferredResultMap = map.get(key); | |
| 59 | 59 | if (deferredResultMap == null) { |
| 60 | 60 | deferredResultMap = new ConcurrentHashMap<>(); |
| 61 | 61 | map.put(key, deferredResultMap); |
| 62 | 62 | } |
| 63 | 63 | deferredResultMap.put(id, result); |
| 64 | 64 | } |
| 65 | - | |
| 66 | - public DeferredResult get(String key, String id) { | |
| 67 | - Map<String, DeferredResult> deferredResultMap = map.get(key); | |
| 65 | + | |
| 66 | + public void put(String key, String id, DeferredResult result) { | |
| 67 | + Map<String, DeferredResultEx> deferredResultMap = map.get(key); | |
| 68 | 68 | if (deferredResultMap == null) { |
| 69 | + deferredResultMap = new ConcurrentHashMap<>(); | |
| 70 | + map.put(key, deferredResultMap); | |
| 71 | + } | |
| 72 | + deferredResultMap.put(id, new DeferredResultEx(result)); | |
| 73 | + } | |
| 74 | + | |
| 75 | + public DeferredResultEx get(String key, String id) { | |
| 76 | + Map<String, DeferredResultEx> deferredResultMap = map.get(key); | |
| 77 | + if (deferredResultMap == null || ObjectUtils.isEmpty(id)) { | |
| 69 | 78 | return null; |
| 70 | 79 | } |
| 71 | 80 | return deferredResultMap.get(id); |
| 72 | 81 | } |
| 73 | 82 | |
| 83 | + public Collection<DeferredResultEx> getAllByKey(String key) { | |
| 84 | + Map<String, DeferredResultEx> deferredResultMap = map.get(key); | |
| 85 | + if (deferredResultMap == null) { | |
| 86 | + return null; | |
| 87 | + } | |
| 88 | + return deferredResultMap.values(); | |
| 89 | + } | |
| 90 | + | |
| 74 | 91 | public boolean exist(String key, String id){ |
| 75 | 92 | if (key == null) { |
| 76 | 93 | return false; |
| 77 | 94 | } |
| 78 | - Map<String, DeferredResult> deferredResultMap = map.get(key); | |
| 95 | + Map<String, DeferredResultEx> deferredResultMap = map.get(key); | |
| 79 | 96 | if (id == null) { |
| 80 | 97 | return deferredResultMap != null; |
| 81 | 98 | }else { |
| ... | ... | @@ -88,15 +105,15 @@ public class DeferredResultHolder { |
| 88 | 105 | * @param msg |
| 89 | 106 | */ |
| 90 | 107 | public void invokeResult(RequestMessage msg) { |
| 91 | - Map<String, DeferredResult> deferredResultMap = map.get(msg.getKey()); | |
| 108 | + Map<String, DeferredResultEx> deferredResultMap = map.get(msg.getKey()); | |
| 92 | 109 | if (deferredResultMap == null) { |
| 93 | 110 | return; |
| 94 | 111 | } |
| 95 | - DeferredResult result = deferredResultMap.get(msg.getId()); | |
| 112 | + DeferredResultEx result = deferredResultMap.get(msg.getId()); | |
| 96 | 113 | if (result == null) { |
| 97 | 114 | return; |
| 98 | 115 | } |
| 99 | - result.setResult(msg.getData()); | |
| 116 | + result.getDeferredResult().setResult(msg.getData()); | |
| 100 | 117 | deferredResultMap.remove(msg.getId()); |
| 101 | 118 | if (deferredResultMap.size() == 0) { |
| 102 | 119 | map.remove(msg.getKey()); |
| ... | ... | @@ -108,18 +125,30 @@ public class DeferredResultHolder { |
| 108 | 125 | * @param msg |
| 109 | 126 | */ |
| 110 | 127 | public void invokeAllResult(RequestMessage msg) { |
| 111 | - Map<String, DeferredResult> deferredResultMap = map.get(msg.getKey()); | |
| 128 | + Map<String, DeferredResultEx> deferredResultMap = map.get(msg.getKey()); | |
| 112 | 129 | if (deferredResultMap == null) { |
| 113 | 130 | return; |
| 114 | 131 | } |
| 115 | - Set<String> ids = deferredResultMap.keySet(); | |
| 116 | - for (String id : ids) { | |
| 117 | - DeferredResult result = deferredResultMap.get(id); | |
| 118 | - if (result == null) { | |
| 132 | + synchronized (this) { | |
| 133 | + deferredResultMap = map.get(msg.getKey()); | |
| 134 | + if (deferredResultMap == null) { | |
| 119 | 135 | return; |
| 120 | 136 | } |
| 121 | - result.setResult(msg.getData()); | |
| 137 | + Set<String> ids = deferredResultMap.keySet(); | |
| 138 | + for (String id : ids) { | |
| 139 | + DeferredResultEx result = deferredResultMap.get(id); | |
| 140 | + if (result == null) { | |
| 141 | + return; | |
| 142 | + } | |
| 143 | + if (result.getFilter() != null) { | |
| 144 | + Object handler = result.getFilter().handler(msg.getData()); | |
| 145 | + result.getDeferredResult().setResult(handler); | |
| 146 | + }else { | |
| 147 | + result.getDeferredResult().setResult(msg.getData()); | |
| 148 | + } | |
| 149 | + | |
| 150 | + } | |
| 151 | + map.remove(msg.getKey()); | |
| 122 | 152 | } |
| 123 | - map.remove(msg.getKey()); | |
| 124 | 153 | } |
| 125 | 154 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java
| ... | ... | @@ -12,6 +12,8 @@ import gov.nist.javax.sip.message.SIPRequest; |
| 12 | 12 | import javax.sip.InvalidArgumentException; |
| 13 | 13 | import javax.sip.PeerUnavailableException; |
| 14 | 14 | import javax.sip.SipException; |
| 15 | +import javax.sip.message.Message; | |
| 16 | +import javax.sip.message.Request; | |
| 15 | 17 | import java.text.ParseException; |
| 16 | 18 | import javax.sip.message.Request; |
| 17 | 19 | |
| ... | ... | @@ -359,9 +361,4 @@ public interface ISIPCommander { |
| 359 | 361 | */ |
| 360 | 362 | void sendAlarmMessage(Device device, DeviceAlarm deviceAlarm) throws InvalidArgumentException, SipException, ParseException; |
| 361 | 363 | |
| 362 | - void transmitRequest(String transport, Request request) throws SipException, ParseException ; | |
| 363 | - | |
| 364 | - void transmitRequest(String transport, Request request, SipSubscribe.Event errorEvent) throws SipException, ParseException; | |
| 365 | - | |
| 366 | - void transmitRequest(String transport, Request request, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws SipException, ParseException; | |
| 367 | 364 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 4 | +import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 4 | 5 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 5 | 6 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| 6 | 7 | import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo; |
| ... | ... | @@ -36,7 +37,7 @@ public class SIPRequestHeaderPlarformProvider { |
| 36 | 37 | private SipConfig sipConfig; |
| 37 | 38 | |
| 38 | 39 | @Autowired |
| 39 | - private SipFactory sipFactory; | |
| 40 | + private SipLayer sipLayer; | |
| 40 | 41 | |
| 41 | 42 | @Autowired |
| 42 | 43 | private GitUtil gitUtil; |
| ... | ... | @@ -44,42 +45,42 @@ public class SIPRequestHeaderPlarformProvider { |
| 44 | 45 | @Autowired |
| 45 | 46 | private IRedisCatchStorage redisCatchStorage; |
| 46 | 47 | |
| 47 | - public Request createRegisterRequest(@NotNull ParentPlatform platform, long CSeq, String fromTag, String viaTag, CallIdHeader callIdHeader, boolean isRegister) throws ParseException, InvalidArgumentException, PeerUnavailableException { | |
| 48 | + public Request createRegisterRequest(@NotNull ParentPlatform parentPlatform, long CSeq, String fromTag, String viaTag, CallIdHeader callIdHeader, boolean isRegister) throws ParseException, InvalidArgumentException, PeerUnavailableException { | |
| 48 | 49 | Request request = null; |
| 49 | - String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort(); | |
| 50 | + String sipAddress = parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort(); | |
| 50 | 51 | //请求行 |
| 51 | - SipURI requestLine = sipFactory.createAddressFactory().createSipURI(platform.getServerGBId(), | |
| 52 | - platform.getServerIP() + ":" + platform.getServerPort()); | |
| 52 | + SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), | |
| 53 | + parentPlatform.getServerIP() + ":" + parentPlatform.getServerPort()); | |
| 53 | 54 | //via |
| 54 | 55 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 55 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(platform.getServerIP(), platform.getServerPort(), platform.getTransport(), viaTag); | |
| 56 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(parentPlatform.getServerIP(), parentPlatform.getServerPort(), parentPlatform.getTransport(), viaTag); | |
| 56 | 57 | viaHeader.setRPort(); |
| 57 | 58 | viaHeaders.add(viaHeader); |
| 58 | 59 | //from |
| 59 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(platform.getDeviceGBId(), sipConfig.getDomain()); | |
| 60 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 61 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); | |
| 60 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain()); | |
| 61 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 62 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag); | |
| 62 | 63 | //to |
| 63 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(platform.getDeviceGBId(), sipConfig.getDomain()); | |
| 64 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 65 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null); | |
| 64 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain()); | |
| 65 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 66 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress,null); | |
| 66 | 67 | |
| 67 | 68 | //Forwards |
| 68 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 69 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 69 | 70 | |
| 70 | 71 | //ceq |
| 71 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(CSeq, Request.REGISTER); | |
| 72 | - request = sipFactory.createMessageFactory().createRequest(requestLine, Request.REGISTER, callIdHeader, | |
| 72 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(CSeq, Request.REGISTER); | |
| 73 | + request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.REGISTER, callIdHeader, | |
| 73 | 74 | cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); |
| 74 | 75 | |
| 75 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory() | |
| 76 | - .createSipURI(platform.getDeviceGBId(), sipAddress)); | |
| 77 | - request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | |
| 76 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory() | |
| 77 | + .createSipURI(parentPlatform.getDeviceGBId(), sipAddress)); | |
| 78 | + request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | |
| 78 | 79 | |
| 79 | - ExpiresHeader expires = sipFactory.createHeaderFactory().createExpiresHeader(isRegister ? platform.getExpires() : 0); | |
| 80 | + ExpiresHeader expires = sipLayer.getSipFactory().createHeaderFactory().createExpiresHeader(isRegister ? parentPlatform.getExpires() : 0); | |
| 80 | 81 | request.addHeader(expires); |
| 81 | 82 | |
| 82 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 83 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 83 | 84 | |
| 84 | 85 | return request; |
| 85 | 86 | } |
| ... | ... | @@ -89,9 +90,9 @@ public class SIPRequestHeaderPlarformProvider { |
| 89 | 90 | |
| 90 | 91 | |
| 91 | 92 | Request registerRequest = createRegisterRequest(parentPlatform, redisCatchStorage.getCSEQ(), fromTag, viaTag, callIdHeader, isRegister); |
| 92 | - SipURI requestURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP() + ":" + parentPlatform.getServerPort()); | |
| 93 | + SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP() + ":" + parentPlatform.getServerPort()); | |
| 93 | 94 | if (www == null) { |
| 94 | - AuthorizationHeader authorizationHeader = sipFactory.createHeaderFactory().createAuthorizationHeader("Digest"); | |
| 95 | + AuthorizationHeader authorizationHeader = sipLayer.getSipFactory().createHeaderFactory().createAuthorizationHeader("Digest"); | |
| 95 | 96 | authorizationHeader.setUsername(parentPlatform.getDeviceGBId()); |
| 96 | 97 | authorizationHeader.setURI(requestURI); |
| 97 | 98 | authorizationHeader.setAlgorithm("MD5"); |
| ... | ... | @@ -140,7 +141,7 @@ public class SIPRequestHeaderPlarformProvider { |
| 140 | 141 | |
| 141 | 142 | String RESPONSE = DigestUtils.md5DigestAsHex(reStr.toString().getBytes()); |
| 142 | 143 | |
| 143 | - AuthorizationHeader authorizationHeader = sipFactory.createHeaderFactory().createAuthorizationHeader(scheme); | |
| 144 | + AuthorizationHeader authorizationHeader = sipLayer.getSipFactory().createHeaderFactory().createAuthorizationHeader(scheme); | |
| 144 | 145 | authorizationHeader.setUsername(parentPlatform.getDeviceGBId()); |
| 145 | 146 | authorizationHeader.setRealm(realm); |
| 146 | 147 | authorizationHeader.setNonce(nonce); |
| ... | ... | @@ -158,7 +159,7 @@ public class SIPRequestHeaderPlarformProvider { |
| 158 | 159 | } |
| 159 | 160 | |
| 160 | 161 | public Request createMessageRequest(ParentPlatform parentPlatform, String content, SendRtpItem sendRtpItem) throws PeerUnavailableException, ParseException, InvalidArgumentException { |
| 161 | - CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(sendRtpItem.getCallId()); | |
| 162 | + CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(sendRtpItem.getCallId()); | |
| 162 | 163 | return createMessageRequest(parentPlatform, content, sendRtpItem.getToTag(), SipUtils.getNewViaTag(), sendRtpItem.getFromTag(), callIdHeader); |
| 163 | 164 | } |
| 164 | 165 | |
| ... | ... | @@ -171,36 +172,36 @@ public class SIPRequestHeaderPlarformProvider { |
| 171 | 172 | Request request = null; |
| 172 | 173 | String serverAddress = parentPlatform.getServerIP()+ ":" + parentPlatform.getServerPort(); |
| 173 | 174 | // sipuri |
| 174 | - SipURI requestURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), serverAddress); | |
| 175 | + SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), serverAddress); | |
| 175 | 176 | // via |
| 176 | 177 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 177 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()), | |
| 178 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()), | |
| 178 | 179 | parentPlatform.getTransport(), viaTag); |
| 179 | 180 | viaHeader.setRPort(); |
| 180 | 181 | viaHeaders.add(viaHeader); |
| 181 | 182 | // from |
| 182 | - // SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), parentPlatform.getDeviceIp() + ":" + parentPlatform.getDeviceIp()); | |
| 183 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain()); | |
| 184 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 185 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); | |
| 183 | + // SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), parentPlatform.getDeviceIp() + ":" + parentPlatform.getDeviceIp()); | |
| 184 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain()); | |
| 185 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 186 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag); | |
| 186 | 187 | // to |
| 187 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), serverAddress); | |
| 188 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 189 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, toTag); | |
| 188 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), serverAddress); | |
| 189 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 190 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, toTag); | |
| 190 | 191 | |
| 191 | 192 | // Forwards |
| 192 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 193 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 193 | 194 | // ceq |
| 194 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE); | |
| 195 | - MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipFactory.createMessageFactory(); | |
| 195 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE); | |
| 196 | + MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipLayer.getSipFactory().createMessageFactory(); | |
| 196 | 197 | // 设置编码, 防止中文乱码 |
| 197 | 198 | messageFactory.setDefaultContentEncodingCharset(parentPlatform.getCharacterSet()); |
| 198 | 199 | request = messageFactory.createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader, |
| 199 | 200 | toHeader, viaHeaders, maxForwards); |
| 200 | 201 | |
| 201 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 202 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 202 | 203 | |
| 203 | - ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | |
| 204 | + ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | |
| 204 | 205 | request.setContent(content, contentTypeHeader); |
| 205 | 206 | return request; |
| 206 | 207 | } |
| ... | ... | @@ -208,54 +209,54 @@ public class SIPRequestHeaderPlarformProvider { |
| 208 | 209 | public SIPRequest createNotifyRequest(ParentPlatform parentPlatform, String content, SubscribeInfo subscribeInfo) throws PeerUnavailableException, ParseException, InvalidArgumentException { |
| 209 | 210 | SIPRequest request = null; |
| 210 | 211 | // sipuri |
| 211 | - SipURI requestURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP()+ ":" + parentPlatform.getServerPort()); | |
| 212 | + SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP()+ ":" + parentPlatform.getServerPort()); | |
| 212 | 213 | // via |
| 213 | 214 | ArrayList<ViaHeader> viaHeaders = new ArrayList<>(); |
| 214 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()), | |
| 215 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()), | |
| 215 | 216 | parentPlatform.getTransport(), SipUtils.getNewViaTag()); |
| 216 | 217 | viaHeader.setRPort(); |
| 217 | 218 | viaHeaders.add(viaHeader); |
| 218 | 219 | // from |
| 219 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), | |
| 220 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), | |
| 220 | 221 | parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort()); |
| 221 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 222 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, subscribeInfo.getResponse().getToTag()); | |
| 222 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 223 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, subscribeInfo.getResponse().getToTag()); | |
| 223 | 224 | // to |
| 224 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerGBDomain()); | |
| 225 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 226 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, subscribeInfo.getRequest().getFromTag()); | |
| 225 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerGBDomain()); | |
| 226 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 227 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, subscribeInfo.getRequest().getFromTag()); | |
| 227 | 228 | |
| 228 | 229 | // Forwards |
| 229 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 230 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 230 | 231 | // ceq |
| 231 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.NOTIFY); | |
| 232 | - MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipFactory.createMessageFactory(); | |
| 232 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.NOTIFY); | |
| 233 | + MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipLayer.getSipFactory().createMessageFactory(); | |
| 233 | 234 | // 设置编码, 防止中文乱码 |
| 234 | 235 | messageFactory.setDefaultContentEncodingCharset("gb2312"); |
| 235 | 236 | |
| 236 | - CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(subscribeInfo.getRequest().getCallIdHeader().getCallId()); | |
| 237 | + CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(subscribeInfo.getRequest().getCallIdHeader().getCallId()); | |
| 237 | 238 | |
| 238 | 239 | request = (SIPRequest) messageFactory.createRequest(requestURI, Request.NOTIFY, callIdHeader, cSeqHeader, fromHeader, |
| 239 | 240 | toHeader, viaHeaders, maxForwards); |
| 240 | 241 | |
| 241 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 242 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 242 | 243 | |
| 243 | - EventHeader event = sipFactory.createHeaderFactory().createEventHeader(subscribeInfo.getEventType()); | |
| 244 | + EventHeader event = sipLayer.getSipFactory().createHeaderFactory().createEventHeader(subscribeInfo.getEventType()); | |
| 244 | 245 | if (subscribeInfo.getEventId() != null) { |
| 245 | 246 | event.setEventId(subscribeInfo.getEventId()); |
| 246 | 247 | } |
| 247 | 248 | |
| 248 | 249 | request.addHeader(event); |
| 249 | 250 | |
| 250 | - SubscriptionStateHeader active = sipFactory.createHeaderFactory().createSubscriptionStateHeader("active"); | |
| 251 | + SubscriptionStateHeader active = sipLayer.getSipFactory().createHeaderFactory().createSubscriptionStateHeader("active"); | |
| 251 | 252 | request.setHeader(active); |
| 252 | 253 | |
| 253 | - String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort(); | |
| 254 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory() | |
| 254 | + String sipAddress = parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort(); | |
| 255 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory() | |
| 255 | 256 | .createSipURI(parentPlatform.getDeviceGBId(), sipAddress)); |
| 256 | - request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | |
| 257 | + request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | |
| 257 | 258 | |
| 258 | - ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | |
| 259 | + ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | |
| 259 | 260 | request.setContent(content, contentTypeHeader); |
| 260 | 261 | return request; |
| 261 | 262 | } |
| ... | ... | @@ -268,42 +269,42 @@ public class SIPRequestHeaderPlarformProvider { |
| 268 | 269 | |
| 269 | 270 | SIPRequest request = null; |
| 270 | 271 | // sipuri |
| 271 | - SipURI requestURI = sipFactory.createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerIP()+ ":" + platform.getServerPort()); | |
| 272 | + SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerIP()+ ":" + platform.getServerPort()); | |
| 272 | 273 | // via |
| 273 | 274 | ArrayList<ViaHeader> viaHeaders = new ArrayList<>(); |
| 274 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(platform.getDeviceIp(), Integer.parseInt(platform.getDevicePort()), | |
| 275 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(platform.getDeviceIp(), Integer.parseInt(platform.getDevicePort()), | |
| 275 | 276 | platform.getTransport(), SipUtils.getNewViaTag()); |
| 276 | 277 | viaHeader.setRPort(); |
| 277 | 278 | viaHeaders.add(viaHeader); |
| 278 | 279 | // from |
| 279 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(platform.getDeviceGBId(), | |
| 280 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getDeviceGBId(), | |
| 280 | 281 | platform.getDeviceIp() + ":" + platform.getDevicePort()); |
| 281 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 282 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, sendRtpItem.getToTag()); | |
| 282 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 283 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, sendRtpItem.getToTag()); | |
| 283 | 284 | // to |
| 284 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerGBDomain()); | |
| 285 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 286 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, sendRtpItem.getFromTag()); | |
| 285 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerGBDomain()); | |
| 286 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 287 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, sendRtpItem.getFromTag()); | |
| 287 | 288 | |
| 288 | 289 | // Forwards |
| 289 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 290 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 290 | 291 | // ceq |
| 291 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE); | |
| 292 | - MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipFactory.createMessageFactory(); | |
| 292 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE); | |
| 293 | + MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipLayer.getSipFactory().createMessageFactory(); | |
| 293 | 294 | // 设置编码, 防止中文乱码 |
| 294 | 295 | messageFactory.setDefaultContentEncodingCharset("gb2312"); |
| 295 | 296 | |
| 296 | - CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(sendRtpItem.getCallId()); | |
| 297 | + CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(sendRtpItem.getCallId()); | |
| 297 | 298 | |
| 298 | 299 | request = (SIPRequest) messageFactory.createRequest(requestURI, Request.BYE, callIdHeader, cSeqHeader, fromHeader, |
| 299 | 300 | toHeader, viaHeaders, maxForwards); |
| 300 | 301 | |
| 301 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 302 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 302 | 303 | |
| 303 | - String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort(); | |
| 304 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory() | |
| 304 | + String sipAddress = platform.getDeviceIp() + ":" + platform.getDevicePort(); | |
| 305 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory() | |
| 305 | 306 | .createSipURI(platform.getDeviceGBId(), sipAddress)); |
| 306 | - request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | |
| 307 | + request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | |
| 307 | 308 | |
| 308 | 309 | return request; |
| 309 | 310 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd; |
| 2 | 2 | |
| 3 | -import java.text.ParseException; | |
| 4 | -import java.util.ArrayList; | |
| 5 | - | |
| 6 | -import javax.sip.*; | |
| 7 | -import javax.sip.address.Address; | |
| 8 | -import javax.sip.address.SipURI; | |
| 9 | -import javax.sip.header.*; | |
| 10 | -import javax.sip.message.Request; | |
| 11 | - | |
| 12 | -import com.genersoft.iot.vmp.common.StreamInfo; | |
| 13 | -import com.genersoft.iot.vmp.gb28181.bean.SipMsgInfo; | |
| 3 | +import com.genersoft.iot.vmp.conf.SipConfig; | |
| 4 | +import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 5 | +import com.genersoft.iot.vmp.gb28181.bean.Device; | |
| 14 | 6 | import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; |
| 15 | -import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; | |
| 16 | 7 | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| 17 | 8 | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; |
| 18 | 9 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 19 | 10 | import com.genersoft.iot.vmp.utils.GitUtil; |
| 20 | -import gov.nist.javax.sip.SipProviderImpl; | |
| 21 | -import gov.nist.javax.sip.SipStackImpl; | |
| 22 | 11 | import gov.nist.javax.sip.message.SIPRequest; |
| 23 | 12 | import gov.nist.javax.sip.message.SIPResponse; |
| 24 | -import gov.nist.javax.sip.stack.SIPDialog; | |
| 25 | 13 | import org.springframework.beans.factory.annotation.Autowired; |
| 26 | -import org.springframework.beans.factory.annotation.Qualifier; | |
| 27 | 14 | import org.springframework.stereotype.Component; |
| 28 | 15 | |
| 29 | -import com.genersoft.iot.vmp.conf.SipConfig; | |
| 30 | -import com.genersoft.iot.vmp.gb28181.bean.Device; | |
| 16 | +import javax.sip.InvalidArgumentException; | |
| 17 | +import javax.sip.PeerUnavailableException; | |
| 18 | +import javax.sip.SipException; | |
| 19 | +import javax.sip.address.Address; | |
| 20 | +import javax.sip.address.SipURI; | |
| 21 | +import javax.sip.header.*; | |
| 22 | +import javax.sip.message.Request; | |
| 23 | +import java.text.ParseException; | |
| 24 | +import java.util.ArrayList; | |
| 31 | 25 | |
| 32 | 26 | /** |
| 33 | 27 | * @description:摄像头命令request创造器 TODO 冗余代码太多待优化 |
| ... | ... | @@ -41,7 +35,7 @@ public class SIPRequestHeaderProvider { |
| 41 | 35 | private SipConfig sipConfig; |
| 42 | 36 | |
| 43 | 37 | @Autowired |
| 44 | - private SipFactory sipFactory; | |
| 38 | + private SipLayer sipLayer; | |
| 45 | 39 | |
| 46 | 40 | @Autowired |
| 47 | 41 | private GitUtil gitUtil; |
| ... | ... | @@ -51,44 +45,36 @@ public class SIPRequestHeaderProvider { |
| 51 | 45 | |
| 52 | 46 | @Autowired |
| 53 | 47 | private VideoStreamSessionManager streamSession; |
| 54 | - | |
| 55 | - @Autowired | |
| 56 | - @Qualifier(value="tcpSipProvider") | |
| 57 | - private SipProviderImpl tcpSipProvider; | |
| 58 | - | |
| 59 | - @Autowired | |
| 60 | - @Qualifier(value="udpSipProvider") | |
| 61 | - private SipProviderImpl udpSipProvider; | |
| 62 | 48 | |
| 63 | 49 | public Request createMessageRequest(Device device, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 64 | 50 | Request request = null; |
| 65 | 51 | // sipuri |
| 66 | - SipURI requestURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | |
| 52 | + SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | |
| 67 | 53 | // via |
| 68 | 54 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 69 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag); | |
| 55 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag); | |
| 70 | 56 | viaHeader.setRPort(); |
| 71 | 57 | viaHeaders.add(viaHeader); |
| 72 | 58 | // from |
| 73 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); | |
| 74 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 75 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); | |
| 59 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); | |
| 60 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 61 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag); | |
| 76 | 62 | // to |
| 77 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | |
| 78 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 79 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, toTag); | |
| 63 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | |
| 64 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 65 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, toTag); | |
| 80 | 66 | |
| 81 | 67 | // Forwards |
| 82 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 68 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 83 | 69 | // ceq |
| 84 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE); | |
| 70 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE); | |
| 85 | 71 | |
| 86 | - request = sipFactory.createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader, | |
| 72 | + request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader, | |
| 87 | 73 | toHeader, viaHeaders, maxForwards); |
| 88 | 74 | |
| 89 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 75 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 90 | 76 | |
| 91 | - ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | |
| 77 | + ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | |
| 92 | 78 | request.setContent(content, contentTypeHeader); |
| 93 | 79 | return request; |
| 94 | 80 | } |
| ... | ... | @@ -96,38 +82,39 @@ public class SIPRequestHeaderProvider { |
| 96 | 82 | public Request createInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, String ssrc, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 97 | 83 | Request request = null; |
| 98 | 84 | //请求行 |
| 99 | - SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 85 | + SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 100 | 86 | //via |
| 101 | 87 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 102 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag); | |
| 88 | + HeaderFactory headerFactory = sipLayer.getSipFactory().createHeaderFactory(); | |
| 89 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag); | |
| 103 | 90 | viaHeader.setRPort(); |
| 104 | 91 | viaHeaders.add(viaHeader); |
| 105 | 92 | |
| 106 | 93 | //from |
| 107 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); | |
| 108 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 109 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack | |
| 94 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); | |
| 95 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 96 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack | |
| 110 | 97 | //to |
| 111 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 112 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 113 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null); | |
| 98 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 99 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 100 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress,null); | |
| 114 | 101 | |
| 115 | 102 | //Forwards |
| 116 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 103 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 117 | 104 | |
| 118 | 105 | //ceq |
| 119 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE); | |
| 120 | - request = sipFactory.createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | |
| 106 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE); | |
| 107 | + request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | |
| 121 | 108 | |
| 122 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 109 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 123 | 110 | |
| 124 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); | |
| 125 | - // Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort())); | |
| 126 | - request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | |
| 111 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort())); | |
| 112 | + // Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort())); | |
| 113 | + request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | |
| 127 | 114 | // Subject |
| 128 | - SubjectHeader subjectHeader = sipFactory.createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0)); | |
| 115 | + SubjectHeader subjectHeader = sipLayer.getSipFactory().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0)); | |
| 129 | 116 | request.addHeader(subjectHeader); |
| 130 | - ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP"); | |
| 117 | + ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP"); | |
| 131 | 118 | request.setContent(content, contentTypeHeader); |
| 132 | 119 | return request; |
| 133 | 120 | } |
| ... | ... | @@ -135,39 +122,39 @@ public class SIPRequestHeaderProvider { |
| 135 | 122 | public Request createPlaybackInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader, String ssrc) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 136 | 123 | Request request = null; |
| 137 | 124 | //请求行 |
| 138 | - SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 125 | + SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 139 | 126 | // via |
| 140 | 127 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 141 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag); | |
| 128 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag); | |
| 142 | 129 | viaHeader.setRPort(); |
| 143 | 130 | viaHeaders.add(viaHeader); |
| 144 | 131 | //from |
| 145 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); | |
| 146 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 147 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack | |
| 132 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); | |
| 133 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 134 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack | |
| 148 | 135 | //to |
| 149 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 150 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 151 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null); | |
| 136 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 137 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 138 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress,null); | |
| 152 | 139 | |
| 153 | 140 | //Forwards |
| 154 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 141 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 155 | 142 | |
| 156 | 143 | //ceq |
| 157 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE); | |
| 158 | - request = sipFactory.createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | |
| 144 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE); | |
| 145 | + request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | |
| 159 | 146 | |
| 160 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); | |
| 161 | - // Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort())); | |
| 162 | - request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | |
| 147 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort())); | |
| 148 | + // Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort())); | |
| 149 | + request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | |
| 163 | 150 | |
| 164 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 151 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 165 | 152 | |
| 166 | 153 | // Subject |
| 167 | - SubjectHeader subjectHeader = sipFactory.createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0)); | |
| 154 | + SubjectHeader subjectHeader = sipLayer.getSipFactory().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0)); | |
| 168 | 155 | request.addHeader(subjectHeader); |
| 169 | 156 | |
| 170 | - ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP"); | |
| 157 | + ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP"); | |
| 171 | 158 | request.setContent(content, contentTypeHeader); |
| 172 | 159 | return request; |
| 173 | 160 | } |
| ... | ... | @@ -175,34 +162,34 @@ public class SIPRequestHeaderProvider { |
| 175 | 162 | public Request createByteRequest(Device device, String channelId, SipTransactionInfo transactionInfo) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 176 | 163 | Request request = null; |
| 177 | 164 | //请求行 |
| 178 | - SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 165 | + SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 179 | 166 | // via |
| 180 | 167 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 181 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); | |
| 168 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); | |
| 182 | 169 | viaHeaders.add(viaHeader); |
| 183 | 170 | //from |
| 184 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); | |
| 185 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 186 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag()); | |
| 171 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); | |
| 172 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 173 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag()); | |
| 187 | 174 | //to |
| 188 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId,device.getHostAddress()); | |
| 189 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 190 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag()); | |
| 175 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId,device.getHostAddress()); | |
| 176 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 177 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag()); | |
| 191 | 178 | |
| 192 | 179 | //Forwards |
| 193 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 180 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 194 | 181 | |
| 195 | 182 | //ceq |
| 196 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE); | |
| 197 | - CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(transactionInfo.getCallId()); | |
| 198 | - request = sipFactory.createMessageFactory().createRequest(requestLine, Request.BYE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | |
| 183 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE); | |
| 184 | + CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(transactionInfo.getCallId()); | |
| 185 | + request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.BYE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | |
| 199 | 186 | |
| 200 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 187 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 201 | 188 | |
| 202 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); | |
| 203 | - request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | |
| 189 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort())); | |
| 190 | + request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | |
| 204 | 191 | |
| 205 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 192 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 206 | 193 | |
| 207 | 194 | return request; |
| 208 | 195 | } |
| ... | ... | @@ -210,50 +197,50 @@ public class SIPRequestHeaderProvider { |
| 210 | 197 | public Request createSubscribeRequest(Device device, String content, SIPRequest requestOld, Integer expires, String event, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 211 | 198 | Request request = null; |
| 212 | 199 | // sipuri |
| 213 | - SipURI requestURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | |
| 200 | + SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | |
| 214 | 201 | // via |
| 215 | 202 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 216 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), | |
| 203 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), | |
| 217 | 204 | device.getTransport(), SipUtils.getNewViaTag()); |
| 218 | 205 | viaHeader.setRPort(); |
| 219 | 206 | viaHeaders.add(viaHeader); |
| 220 | 207 | // from |
| 221 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); | |
| 222 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 223 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, requestOld == null ? SipUtils.getNewFromTag() :requestOld.getFromTag()); | |
| 208 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); | |
| 209 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 210 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, requestOld == null ? SipUtils.getNewFromTag() :requestOld.getFromTag()); | |
| 224 | 211 | // to |
| 225 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | |
| 226 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 227 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, requestOld == null ? null :requestOld.getToTag()); | |
| 212 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); | |
| 213 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 214 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, requestOld == null ? null :requestOld.getToTag()); | |
| 228 | 215 | |
| 229 | 216 | // Forwards |
| 230 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 217 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 231 | 218 | |
| 232 | 219 | // ceq |
| 233 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.SUBSCRIBE); | |
| 220 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.SUBSCRIBE); | |
| 234 | 221 | |
| 235 | - request = sipFactory.createMessageFactory().createRequest(requestURI, Request.SUBSCRIBE, callIdHeader, cSeqHeader, fromHeader, | |
| 222 | + request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestURI, Request.SUBSCRIBE, callIdHeader, cSeqHeader, fromHeader, | |
| 236 | 223 | toHeader, viaHeaders, maxForwards); |
| 237 | 224 | |
| 238 | 225 | |
| 239 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); | |
| 240 | - request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | |
| 226 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort())); | |
| 227 | + request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | |
| 241 | 228 | |
| 242 | 229 | // Expires |
| 243 | - ExpiresHeader expireHeader = sipFactory.createHeaderFactory().createExpiresHeader(expires); | |
| 230 | + ExpiresHeader expireHeader = sipLayer.getSipFactory().createHeaderFactory().createExpiresHeader(expires); | |
| 244 | 231 | request.addHeader(expireHeader); |
| 245 | 232 | |
| 246 | 233 | // Event |
| 247 | - EventHeader eventHeader = sipFactory.createHeaderFactory().createEventHeader(event); | |
| 234 | + EventHeader eventHeader = sipLayer.getSipFactory().createHeaderFactory().createEventHeader(event); | |
| 248 | 235 | |
| 249 | 236 | int random = (int) Math.floor(Math.random() * 10000); |
| 250 | 237 | eventHeader.setEventId(random + ""); |
| 251 | 238 | request.addHeader(eventHeader); |
| 252 | 239 | |
| 253 | - ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | |
| 240 | + ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | |
| 254 | 241 | request.setContent(content, contentTypeHeader); |
| 255 | 242 | |
| 256 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 243 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 257 | 244 | |
| 258 | 245 | return request; |
| 259 | 246 | } |
| ... | ... | @@ -265,64 +252,65 @@ public class SIPRequestHeaderProvider { |
| 265 | 252 | } |
| 266 | 253 | SIPRequest request = null; |
| 267 | 254 | //请求行 |
| 268 | - SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 255 | + SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); | |
| 269 | 256 | // via |
| 270 | 257 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 271 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); | |
| 258 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); | |
| 272 | 259 | viaHeaders.add(viaHeader); |
| 273 | 260 | //from |
| 274 | - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); | |
| 275 | - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | |
| 276 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag()); | |
| 261 | + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); | |
| 262 | + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); | |
| 263 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag()); | |
| 277 | 264 | //to |
| 278 | - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId,device.getHostAddress()); | |
| 279 | - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | |
| 280 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag()); | |
| 265 | + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId,device.getHostAddress()); | |
| 266 | + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); | |
| 267 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag()); | |
| 281 | 268 | |
| 282 | 269 | //Forwards |
| 283 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 270 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 284 | 271 | |
| 285 | 272 | //ceq |
| 286 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INFO); | |
| 287 | - CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(transactionInfo.getCallId()); | |
| 288 | - request = (SIPRequest)sipFactory.createMessageFactory().createRequest(requestLine, Request.INFO, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | |
| 273 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INFO); | |
| 274 | + CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(transactionInfo.getCallId()); | |
| 275 | + request = (SIPRequest)sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.INFO, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | |
| 289 | 276 | |
| 290 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 277 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 291 | 278 | |
| 292 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); | |
| 293 | - request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | |
| 279 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort())); | |
| 280 | + request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | |
| 294 | 281 | |
| 295 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 282 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 296 | 283 | |
| 297 | 284 | if (content != null) { |
| 298 | - ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", | |
| 285 | + ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application", | |
| 299 | 286 | "MANSRTSP"); |
| 300 | 287 | request.setContent(content, contentTypeHeader); |
| 301 | 288 | } |
| 302 | 289 | return request; |
| 303 | 290 | } |
| 304 | 291 | |
| 305 | - public Request createAckRequest(SipURI sipURI, SIPResponse sipResponse) throws ParseException, InvalidArgumentException, PeerUnavailableException { | |
| 292 | + public Request createAckRequest(String localIp, SipURI sipURI, SIPResponse sipResponse) throws ParseException, InvalidArgumentException, PeerUnavailableException { | |
| 293 | + | |
| 306 | 294 | |
| 307 | 295 | // via |
| 308 | 296 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 309 | - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), sipResponse.getTopmostViaHeader().getTransport(), SipUtils.getNewViaTag()); | |
| 297 | + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(localIp, sipConfig.getPort(), sipResponse.getTopmostViaHeader().getTransport(), SipUtils.getNewViaTag()); | |
| 310 | 298 | viaHeaders.add(viaHeader); |
| 311 | 299 | |
| 312 | 300 | //Forwards |
| 313 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | |
| 301 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | |
| 314 | 302 | |
| 315 | 303 | //ceq |
| 316 | - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(sipResponse.getCSeqHeader().getSeqNumber(), Request.ACK); | |
| 304 | + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(sipResponse.getCSeqHeader().getSeqNumber(), Request.ACK); | |
| 317 | 305 | |
| 318 | - Request request = sipFactory.createMessageFactory().createRequest(sipURI, Request.ACK, sipResponse.getCallIdHeader(), cSeqHeader, sipResponse.getFromHeader(), sipResponse.getToHeader(), viaHeaders, maxForwards); | |
| 306 | + Request request = sipLayer.getSipFactory().createMessageFactory().createRequest(sipURI, Request.ACK, sipResponse.getCallIdHeader(), cSeqHeader, sipResponse.getFromHeader(), sipResponse.getToHeader(), viaHeaders, maxForwards); | |
| 319 | 307 | |
| 320 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 308 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 321 | 309 | |
| 322 | - Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); | |
| 323 | - request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | |
| 310 | + Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), localIp + ":"+sipConfig.getPort())); | |
| 311 | + request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); | |
| 324 | 312 | |
| 325 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 313 | + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); | |
| 326 | 314 | |
| 327 | 315 | return request; |
| 328 | 316 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 5 | 5 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 6 | 6 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 7 | 7 | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; |
| 8 | +import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 8 | 9 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 9 | 10 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 10 | 11 | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| 12 | +import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; | |
| 11 | 13 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; |
| 12 | 14 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderProvider; |
| 15 | +import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; | |
| 13 | 16 | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; |
| 14 | 17 | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; |
| 18 | +import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; | |
| 15 | 19 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; |
| 16 | 20 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; |
| 17 | 21 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamPush; |
| ... | ... | @@ -23,16 +27,20 @@ import com.genersoft.iot.vmp.service.IMediaServerService; |
| 23 | 27 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| 24 | 28 | import com.genersoft.iot.vmp.utils.GitUtil; |
| 25 | 29 | import gov.nist.javax.sip.SipProviderImpl; |
| 30 | +import com.genersoft.iot.vmp.utils.DateUtil; | |
| 26 | 31 | import gov.nist.javax.sip.message.SIPRequest; |
| 27 | 32 | import gov.nist.javax.sip.message.SIPResponse; |
| 28 | 33 | import org.slf4j.Logger; |
| 29 | 34 | import org.slf4j.LoggerFactory; |
| 30 | 35 | import org.springframework.beans.factory.annotation.Autowired; |
| 31 | -import org.springframework.beans.factory.annotation.Qualifier; | |
| 32 | 36 | import org.springframework.context.annotation.DependsOn; |
| 33 | 37 | import org.springframework.stereotype.Component; |
| 34 | 38 | import org.springframework.util.ObjectUtils; |
| 35 | 39 | |
| 40 | +import javax.sip.InvalidArgumentException; | |
| 41 | +import javax.sip.ResponseEvent; | |
| 42 | +import javax.sip.SipException; | |
| 43 | +import javax.sip.header.CallIdHeader; | |
| 36 | 44 | import javax.sip.*; |
| 37 | 45 | import javax.sip.header.*; |
| 38 | 46 | import javax.sip.message.Request; |
| ... | ... | @@ -53,18 +61,10 @@ public class SIPCommander implements ISIPCommander { |
| 53 | 61 | private SipConfig sipConfig; |
| 54 | 62 | |
| 55 | 63 | @Autowired |
| 56 | - private SipFactory sipFactory; | |
| 57 | - | |
| 58 | - @Autowired | |
| 59 | - private GitUtil gitUtil; | |
| 60 | - | |
| 61 | - @Autowired | |
| 62 | - @Qualifier(value = "tcpSipProvider") | |
| 63 | - private SipProviderImpl tcpSipProvider; | |
| 64 | + private SipLayer sipLayer; | |
| 64 | 65 | |
| 65 | 66 | @Autowired |
| 66 | - @Qualifier(value = "udpSipProvider") | |
| 67 | - private SipProviderImpl udpSipProvider; | |
| 67 | + private SIPSender sipSender; | |
| 68 | 68 | |
| 69 | 69 | @Autowired |
| 70 | 70 | private SIPRequestHeaderProvider headerProvider; |
| ... | ... | @@ -78,8 +78,7 @@ public class SIPCommander implements ISIPCommander { |
| 78 | 78 | @Autowired |
| 79 | 79 | private ZlmHttpHookSubscribe subscribe; |
| 80 | 80 | |
| 81 | - @Autowired | |
| 82 | - private SipSubscribe sipSubscribe; | |
| 81 | + | |
| 83 | 82 | |
| 84 | 83 | @Autowired |
| 85 | 84 | private IMediaServerService mediaServerService; |
| ... | ... | @@ -181,7 +180,7 @@ public class SIPCommander implements ISIPCommander { |
| 181 | 180 | public void ptzCmd(Device device, String channelId, int leftRight, int upDown, int inOut, int moveSpeed, |
| 182 | 181 | int zoomSpeed) throws InvalidArgumentException, SipException, ParseException { |
| 183 | 182 | String cmdStr = SipUtils.cmdString(leftRight, upDown, inOut, moveSpeed, zoomSpeed); |
| 184 | - StringBuffer ptzXml = new StringBuffer(200); | |
| 183 | + StringBuilder ptzXml = new StringBuilder(200); | |
| 185 | 184 | String charset = device.getCharset(); |
| 186 | 185 | ptzXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n"); |
| 187 | 186 | ptzXml.append("<Control>\r\n"); |
| ... | ... | @@ -194,12 +193,9 @@ public class SIPCommander implements ISIPCommander { |
| 194 | 193 | ptzXml.append("</Info>\r\n"); |
| 195 | 194 | ptzXml.append("</Control>\r\n"); |
| 196 | 195 | |
| 197 | - CallIdHeader callIdHeader = device.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() | |
| 198 | - : udpSipProvider.getNewCallId(); | |
| 199 | - | |
| 200 | - Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, callIdHeader); | |
| 196 | + Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 201 | 197 | |
| 202 | - transmitRequest(device.getTransport(), request); | |
| 198 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request); | |
| 203 | 199 | } |
| 204 | 200 | |
| 205 | 201 | /** |
| ... | ... | @@ -230,11 +226,10 @@ public class SIPCommander implements ISIPCommander { |
| 230 | 226 | ptzXml.append("</Control>\r\n"); |
| 231 | 227 | |
| 232 | 228 | |
| 233 | - CallIdHeader callIdHeader = device.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() | |
| 234 | - : udpSipProvider.getNewCallId(); | |
| 235 | 229 | |
| 236 | - SIPRequest request = (SIPRequest) headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, callIdHeader); | |
| 237 | - transmitRequest(device.getTransport(), request); | |
| 230 | + | |
| 231 | + SIPRequest request = (SIPRequest) headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 232 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request); | |
| 238 | 233 | |
| 239 | 234 | } |
| 240 | 235 | |
| ... | ... | @@ -262,11 +257,8 @@ public class SIPCommander implements ISIPCommander { |
| 262 | 257 | ptzXml.append("</Control>\r\n"); |
| 263 | 258 | |
| 264 | 259 | |
| 265 | - CallIdHeader callIdHeader = device.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() | |
| 266 | - : udpSipProvider.getNewCallId(); | |
| 267 | - | |
| 268 | - Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, callIdHeader); | |
| 269 | - transmitRequest(device.getTransport(), request, errorEvent, okEvent); | |
| 260 | + Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 261 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request, errorEvent, okEvent); | |
| 270 | 262 | |
| 271 | 263 | } |
| 272 | 264 | |
| ... | ... | @@ -295,12 +287,17 @@ public class SIPCommander implements ISIPCommander { |
| 295 | 287 | subscribe.removeSubscribe(hookSubscribe); |
| 296 | 288 | } |
| 297 | 289 | }); |
| 298 | - // | |
| 290 | + String sdpIp; | |
| 291 | + if (!ObjectUtils.isEmpty(device.getSdpIp())) { | |
| 292 | + sdpIp = device.getSdpIp(); | |
| 293 | + }else { | |
| 294 | + sdpIp = mediaServerItem.getSdpIp(); | |
| 295 | + } | |
| 299 | 296 | StringBuffer content = new StringBuffer(200); |
| 300 | 297 | content.append("v=0\r\n"); |
| 301 | - content.append("o=" + channelId + " 0 0 IN IP4 " + mediaServerItem.getSdpIp() + "\r\n"); | |
| 298 | + content.append("o=" + channelId + " 0 0 IN IP4 " + sdpIp + "\r\n"); | |
| 302 | 299 | content.append("s=Play\r\n"); |
| 303 | - content.append("c=IN IP4 " + mediaServerItem.getSdpIp() + "\r\n"); | |
| 300 | + content.append("c=IN IP4 " + sdpIp + "\r\n"); | |
| 304 | 301 | content.append("t=0 0\r\n"); |
| 305 | 302 | |
| 306 | 303 | if (userSetting.isSeniorSdp()) { |
| ... | ... | @@ -353,11 +350,10 @@ public class SIPCommander implements ISIPCommander { |
| 353 | 350 | // f字段:f= v/编码格式/分辨率/帧率/码率类型/码率大小a/编码格式/码率大小/采样率 |
| 354 | 351 | // content.append("f=v/2/5/25/1/4000a/1/8/1" + "\r\n"); // 未发现支持此特性的设备 |
| 355 | 352 | |
| 356 | - CallIdHeader callIdHeader = device.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() | |
| 357 | - : udpSipProvider.getNewCallId(); | |
| 358 | 353 | |
| 359 | - Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, ssrcInfo.getSsrc(), callIdHeader); | |
| 360 | - transmitRequest(device.getTransport(), request, (e -> { | |
| 354 | + | |
| 355 | + Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, ssrcInfo.getSsrc(),sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 356 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, (e -> { | |
| 361 | 357 | streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); |
| 362 | 358 | mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); |
| 363 | 359 | errorEvent.response(e); |
| ... | ... | @@ -385,13 +381,18 @@ public class SIPCommander implements ISIPCommander { |
| 385 | 381 | |
| 386 | 382 | |
| 387 | 383 | logger.info("{} 分配的ZLM为: {} [{}:{}]", ssrcInfo.getStream(), mediaServerItem.getId(), mediaServerItem.getIp(), ssrcInfo.getPort()); |
| 388 | - | |
| 384 | + String sdpIp; | |
| 385 | + if (!ObjectUtils.isEmpty(device.getSdpIp())) { | |
| 386 | + sdpIp = device.getSdpIp(); | |
| 387 | + }else { | |
| 388 | + sdpIp = mediaServerItem.getSdpIp(); | |
| 389 | + } | |
| 389 | 390 | StringBuffer content = new StringBuffer(200); |
| 390 | 391 | content.append("v=0\r\n"); |
| 391 | - content.append("o=" + channelId + " 0 0 IN IP4 " + mediaServerItem.getSdpIp() + "\r\n"); | |
| 392 | + content.append("o=" + channelId + " 0 0 IN IP4 " + sdpIp + "\r\n"); | |
| 392 | 393 | content.append("s=Playback\r\n"); |
| 393 | 394 | content.append("u=" + channelId + ":0\r\n"); |
| 394 | - content.append("c=IN IP4 " + mediaServerItem.getSdpIp() + "\r\n"); | |
| 395 | + content.append("c=IN IP4 " + sdpIp + "\r\n"); | |
| 395 | 396 | content.append("t=" + DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime) + " " |
| 396 | 397 | + DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) + "\r\n"); |
| 397 | 398 | |
| ... | ... | @@ -434,38 +435,39 @@ public class SIPCommander implements ISIPCommander { |
| 434 | 435 | content.append("a=rtpmap:97 MPEG4/90000\r\n"); |
| 435 | 436 | content.append("a=rtpmap:98 H264/90000\r\n"); |
| 436 | 437 | content.append("a=rtpmap:99 H265/90000\r\n"); |
| 437 | - if ("TCP-PASSIVE".equalsIgnoreCase(streamMode)) { // tcp被动模式 | |
| 438 | + if ("TCP-PASSIVE".equalsIgnoreCase(streamMode)) { | |
| 439 | + // tcp被动模式 | |
| 438 | 440 | content.append("a=setup:passive\r\n"); |
| 439 | 441 | content.append("a=connection:new\r\n"); |
| 440 | - } else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { // tcp主动模式 | |
| 442 | + } else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { | |
| 443 | + // tcp主动模式 | |
| 441 | 444 | content.append("a=setup:active\r\n"); |
| 442 | 445 | content.append("a=connection:new\r\n"); |
| 443 | 446 | } |
| 444 | 447 | } |
| 445 | 448 | |
| 446 | - content.append("y=" + ssrcInfo.getSsrc() + "\r\n");//ssrc | |
| 449 | + //ssrc | |
| 450 | + content.append("y=" + ssrcInfo.getSsrc() + "\r\n"); | |
| 447 | 451 | |
| 448 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 449 | - : udpSipProvider.getNewCallId(); | |
| 450 | 452 | HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, "rtsp", mediaServerItem.getId()); |
| 451 | 453 | // 添加订阅 |
| 452 | 454 | subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json) -> { |
| 453 | 455 | if (hookEvent != null) { |
| 454 | - InviteStreamInfo inviteStreamInfo = new InviteStreamInfo(mediaServerItemInUse, json, callIdHeader.getCallId(), "rtp", ssrcInfo.getStream()); | |
| 456 | + InviteStreamInfo inviteStreamInfo = new InviteStreamInfo(mediaServerItemInUse, json,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream()); | |
| 455 | 457 | hookEvent.call(inviteStreamInfo); |
| 456 | 458 | } |
| 457 | 459 | subscribe.removeSubscribe(hookSubscribe); |
| 458 | 460 | }); |
| 459 | - Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, SipUtils.getNewFromTag(), null, callIdHeader, ssrcInfo.getSsrc()); | |
| 461 | + Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()), ssrcInfo.getSsrc()); | |
| 460 | 462 | |
| 461 | - transmitRequest(device.getTransport(), request, errorEvent, event -> { | |
| 463 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, event -> { | |
| 462 | 464 | ResponseEvent responseEvent = (ResponseEvent) event.event; |
| 463 | 465 | SIPResponse response = (SIPResponse) responseEvent.getResponse(); |
| 464 | - streamSession.put(device.getDeviceId(), channelId, callIdHeader.getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.playback); | |
| 466 | + streamSession.put(device.getDeviceId(), channelId,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.playback); | |
| 465 | 467 | okEvent.response(event); |
| 466 | 468 | }); |
| 467 | 469 | if (inviteStreamCallback != null) { |
| 468 | - inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null, callIdHeader.getCallId(), "rtp", ssrcInfo.getStream())); | |
| 470 | + inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream())); | |
| 469 | 471 | } |
| 470 | 472 | } |
| 471 | 473 | |
| ... | ... | @@ -484,13 +486,18 @@ public class SIPCommander implements ISIPCommander { |
| 484 | 486 | SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException { |
| 485 | 487 | |
| 486 | 488 | logger.info("{} 分配的ZLM为: {} [{}:{}]", ssrcInfo.getStream(), mediaServerItem.getId(), mediaServerItem.getIp(), ssrcInfo.getPort()); |
| 487 | - | |
| 489 | + String sdpIp; | |
| 490 | + if (!ObjectUtils.isEmpty(device.getSdpIp())) { | |
| 491 | + sdpIp = device.getSdpIp(); | |
| 492 | + }else { | |
| 493 | + sdpIp = mediaServerItem.getSdpIp(); | |
| 494 | + } | |
| 488 | 495 | StringBuffer content = new StringBuffer(200); |
| 489 | 496 | content.append("v=0\r\n"); |
| 490 | - content.append("o=" + channelId + " 0 0 IN IP4 " + mediaServerItem.getSdpIp() + "\r\n"); | |
| 497 | + content.append("o=" + channelId + " 0 0 IN IP4 " + sdpIp + "\r\n"); | |
| 491 | 498 | content.append("s=Download\r\n"); |
| 492 | 499 | content.append("u=" + channelId + ":0\r\n"); |
| 493 | - content.append("c=IN IP4 " + mediaServerItem.getSdpIp() + "\r\n"); | |
| 500 | + content.append("c=IN IP4 " + sdpIp + "\r\n"); | |
| 494 | 501 | content.append("t=" + DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime) + " " |
| 495 | 502 | + DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) + "\r\n"); |
| 496 | 503 | |
| ... | ... | @@ -546,13 +553,10 @@ public class SIPCommander implements ISIPCommander { |
| 546 | 553 | |
| 547 | 554 | content.append("y=" + ssrcInfo.getSsrc() + "\r\n");//ssrc |
| 548 | 555 | |
| 549 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 550 | - : udpSipProvider.getNewCallId(); | |
| 551 | - | |
| 552 | 556 | HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, null, mediaServerItem.getId()); |
| 553 | 557 | // 添加订阅 |
| 554 | 558 | subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json) -> { |
| 555 | - hookEvent.call(new InviteStreamInfo(mediaServerItem, json, callIdHeader.getCallId(), "rtp", ssrcInfo.getStream())); | |
| 559 | + hookEvent.call(new InviteStreamInfo(mediaServerItem, json,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream())); | |
| 556 | 560 | subscribe.removeSubscribe(hookSubscribe); |
| 557 | 561 | hookSubscribe.getContent().put("regist", false); |
| 558 | 562 | hookSubscribe.getContent().put("schema", "rtsp"); |
| ... | ... | @@ -561,7 +565,7 @@ public class SIPCommander implements ISIPCommander { |
| 561 | 565 | (MediaServerItem mediaServerItemForEnd, JSONObject jsonForEnd) -> { |
| 562 | 566 | logger.info("[录像]下载结束, 发送BYE"); |
| 563 | 567 | try { |
| 564 | - streamByeCmd(device, channelId, ssrcInfo.getStream(), callIdHeader.getCallId()); | |
| 568 | + streamByeCmd(device, channelId, ssrcInfo.getStream(),sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId()); | |
| 565 | 569 | } catch (InvalidArgumentException | ParseException | SipException | |
| 566 | 570 | SsrcTransactionNotFoundException e) { |
| 567 | 571 | logger.error("[录像]下载结束, 发送BYE失败 {}", e.getMessage()); |
| ... | ... | @@ -569,14 +573,14 @@ public class SIPCommander implements ISIPCommander { |
| 569 | 573 | }); |
| 570 | 574 | }); |
| 571 | 575 | |
| 572 | - Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, SipUtils.getNewFromTag(), null, callIdHeader, ssrcInfo.getSsrc()); | |
| 576 | + Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()), ssrcInfo.getSsrc()); | |
| 573 | 577 | if (inviteStreamCallback != null) { |
| 574 | - inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null, callIdHeader.getCallId(), "rtp", ssrcInfo.getStream())); | |
| 578 | + inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream())); | |
| 575 | 579 | } |
| 576 | - transmitRequest(device.getTransport(), request, errorEvent, okEvent -> { | |
| 580 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent -> { | |
| 577 | 581 | ResponseEvent responseEvent = (ResponseEvent) okEvent.event; |
| 578 | 582 | SIPResponse response = (SIPResponse) responseEvent.getResponse(); |
| 579 | - streamSession.put(device.getDeviceId(), channelId, callIdHeader.getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.download); | |
| 583 | + streamSession.put(device.getDeviceId(), channelId,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.download); | |
| 580 | 584 | }); |
| 581 | 585 | } |
| 582 | 586 | |
| ... | ... | @@ -665,7 +669,7 @@ public class SIPCommander implements ISIPCommander { |
| 665 | 669 | streamSession.remove(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream()); |
| 666 | 670 | |
| 667 | 671 | Request byteRequest = headerProvider.createByteRequest(device, channelId, ssrcTransaction.getSipTransactionInfo()); |
| 668 | - transmitRequest(device.getTransport(), byteRequest, null, okEvent); | |
| 672 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), byteRequest, null, okEvent); | |
| 669 | 673 | } |
| 670 | 674 | |
| 671 | 675 | @Override |
| ... | ... | @@ -691,11 +695,10 @@ public class SIPCommander implements ISIPCommander { |
| 691 | 695 | broadcastXml.append("<TargetID>" + channelId + "</TargetID>\r\n"); |
| 692 | 696 | broadcastXml.append("</Notify>\r\n"); |
| 693 | 697 | |
| 694 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 695 | - : udpSipProvider.getNewCallId(); | |
| 696 | 698 | |
| 697 | - Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, callIdHeader); | |
| 698 | - transmitRequest(device.getTransport(), request, errorEvent, okEvent); | |
| 699 | + | |
| 700 | + Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 701 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); | |
| 699 | 702 | |
| 700 | 703 | } |
| 701 | 704 | |
| ... | ... | @@ -723,11 +726,10 @@ public class SIPCommander implements ISIPCommander { |
| 723 | 726 | cmdXml.append("<RecordCmd>" + recordCmdStr + "</RecordCmd>\r\n"); |
| 724 | 727 | cmdXml.append("</Control>\r\n"); |
| 725 | 728 | |
| 726 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 727 | - : udpSipProvider.getNewCallId(); | |
| 728 | 729 | |
| 729 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null, callIdHeader); | |
| 730 | - transmitRequest(device.getTransport(), request, errorEvent); | |
| 730 | + | |
| 731 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 732 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 731 | 733 | } |
| 732 | 734 | |
| 733 | 735 | /** |
| ... | ... | @@ -748,11 +750,10 @@ public class SIPCommander implements ISIPCommander { |
| 748 | 750 | cmdXml.append("<TeleBoot>Boot</TeleBoot>\r\n"); |
| 749 | 751 | cmdXml.append("</Control>\r\n"); |
| 750 | 752 | |
| 751 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 752 | - : udpSipProvider.getNewCallId(); | |
| 753 | 753 | |
| 754 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null, callIdHeader); | |
| 755 | - transmitRequest(device.getTransport(), request); | |
| 754 | + | |
| 755 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 756 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); | |
| 756 | 757 | } |
| 757 | 758 | |
| 758 | 759 | /** |
| ... | ... | @@ -774,11 +775,10 @@ public class SIPCommander implements ISIPCommander { |
| 774 | 775 | cmdXml.append("<GuardCmd>" + guardCmdStr + "</GuardCmd>\r\n"); |
| 775 | 776 | cmdXml.append("</Control>\r\n"); |
| 776 | 777 | |
| 777 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 778 | - : udpSipProvider.getNewCallId(); | |
| 779 | 778 | |
| 780 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null, callIdHeader); | |
| 781 | - transmitRequest(device.getTransport(), request, errorEvent); | |
| 779 | + | |
| 780 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 781 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 782 | 782 | } |
| 783 | 783 | |
| 784 | 784 | /** |
| ... | ... | @@ -811,11 +811,10 @@ public class SIPCommander implements ISIPCommander { |
| 811 | 811 | } |
| 812 | 812 | cmdXml.append("</Control>\r\n"); |
| 813 | 813 | |
| 814 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 815 | - : udpSipProvider.getNewCallId(); | |
| 816 | 814 | |
| 817 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null, callIdHeader); | |
| 818 | - transmitRequest(device.getTransport(), request, errorEvent); | |
| 815 | + | |
| 816 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 817 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 819 | 818 | } |
| 820 | 819 | |
| 821 | 820 | /** |
| ... | ... | @@ -841,11 +840,10 @@ public class SIPCommander implements ISIPCommander { |
| 841 | 840 | cmdXml.append("<IFameCmd>Send</IFameCmd>\r\n"); |
| 842 | 841 | cmdXml.append("</Control>\r\n"); |
| 843 | 842 | |
| 844 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 845 | - : udpSipProvider.getNewCallId(); | |
| 846 | 843 | |
| 847 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null, callIdHeader); | |
| 848 | - transmitRequest(device.getTransport(), request); | |
| 844 | + | |
| 845 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 846 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); | |
| 849 | 847 | } |
| 850 | 848 | |
| 851 | 849 | /** |
| ... | ... | @@ -889,11 +887,10 @@ public class SIPCommander implements ISIPCommander { |
| 889 | 887 | cmdXml.append("</HomePosition>\r\n"); |
| 890 | 888 | cmdXml.append("</Control>\r\n"); |
| 891 | 889 | |
| 892 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 893 | - : udpSipProvider.getNewCallId(); | |
| 894 | 890 | |
| 895 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null, callIdHeader); | |
| 896 | - transmitRequest(device.getTransport(), request, errorEvent); | |
| 891 | + | |
| 892 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 893 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 897 | 894 | } |
| 898 | 895 | |
| 899 | 896 | /** |
| ... | ... | @@ -953,11 +950,10 @@ public class SIPCommander implements ISIPCommander { |
| 953 | 950 | cmdXml.append("</BasicParam>\r\n"); |
| 954 | 951 | cmdXml.append("</Control>\r\n"); |
| 955 | 952 | |
| 956 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 957 | - : udpSipProvider.getNewCallId(); | |
| 958 | 953 | |
| 959 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null, callIdHeader); | |
| 960 | - transmitRequest(device.getTransport(), request, errorEvent); | |
| 954 | + | |
| 955 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 956 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 961 | 957 | } |
| 962 | 958 | |
| 963 | 959 | /** |
| ... | ... | @@ -977,12 +973,11 @@ public class SIPCommander implements ISIPCommander { |
| 977 | 973 | catalogXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); |
| 978 | 974 | catalogXml.append("</Query>\r\n"); |
| 979 | 975 | |
| 980 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 981 | - : udpSipProvider.getNewCallId(); | |
| 982 | 976 | |
| 983 | - Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), null, SipUtils.getNewFromTag(), null, callIdHeader); | |
| 984 | 977 | |
| 985 | - transmitRequest(device.getTransport(), request, errorEvent); | |
| 978 | + Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 979 | + | |
| 980 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 986 | 981 | } |
| 987 | 982 | |
| 988 | 983 | /** |
| ... | ... | @@ -1002,12 +997,11 @@ public class SIPCommander implements ISIPCommander { |
| 1002 | 997 | catalogXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); |
| 1003 | 998 | catalogXml.append("</Query>\r\n"); |
| 1004 | 999 | |
| 1005 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 1006 | - : udpSipProvider.getNewCallId(); | |
| 1007 | 1000 | |
| 1008 | - Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, callIdHeader); | |
| 1009 | 1001 | |
| 1010 | - transmitRequest(device.getTransport(), request); | |
| 1002 | + Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 1003 | + | |
| 1004 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); | |
| 1011 | 1005 | |
| 1012 | 1006 | } |
| 1013 | 1007 | |
| ... | ... | @@ -1028,12 +1022,11 @@ public class SIPCommander implements ISIPCommander { |
| 1028 | 1022 | catalogXml.append(" <DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); |
| 1029 | 1023 | catalogXml.append("</Query>\r\n"); |
| 1030 | 1024 | |
| 1031 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 1032 | - : udpSipProvider.getNewCallId(); | |
| 1033 | 1025 | |
| 1034 | - Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, callIdHeader); | |
| 1035 | 1026 | |
| 1036 | - transmitRequest(device.getTransport(), request, errorEvent); | |
| 1027 | + Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 1028 | + | |
| 1029 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 1037 | 1030 | } |
| 1038 | 1031 | |
| 1039 | 1032 | /** |
| ... | ... | @@ -1074,13 +1067,12 @@ public class SIPCommander implements ISIPCommander { |
| 1074 | 1067 | } |
| 1075 | 1068 | recordInfoXml.append("</Query>\r\n"); |
| 1076 | 1069 | |
| 1077 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 1078 | - : udpSipProvider.getNewCallId(); | |
| 1070 | + | |
| 1079 | 1071 | |
| 1080 | 1072 | Request request = headerProvider.createMessageRequest(device, recordInfoXml.toString(), |
| 1081 | - SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, callIdHeader); | |
| 1073 | + SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 1082 | 1074 | |
| 1083 | - transmitRequest(device.getTransport(), request, errorEvent, okEvent); | |
| 1075 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent); | |
| 1084 | 1076 | } |
| 1085 | 1077 | |
| 1086 | 1078 | /** |
| ... | ... | @@ -1126,11 +1118,10 @@ public class SIPCommander implements ISIPCommander { |
| 1126 | 1118 | } |
| 1127 | 1119 | cmdXml.append("</Query>\r\n"); |
| 1128 | 1120 | |
| 1129 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 1130 | - : udpSipProvider.getNewCallId(); | |
| 1131 | 1121 | |
| 1132 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null, callIdHeader); | |
| 1133 | - transmitRequest(device.getTransport(), request, errorEvent); | |
| 1122 | + | |
| 1123 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 1124 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 1134 | 1125 | } |
| 1135 | 1126 | |
| 1136 | 1127 | /** |
| ... | ... | @@ -1157,11 +1148,10 @@ public class SIPCommander implements ISIPCommander { |
| 1157 | 1148 | cmdXml.append("<ConfigType>" + configType + "</ConfigType>\r\n"); |
| 1158 | 1149 | cmdXml.append("</Query>\r\n"); |
| 1159 | 1150 | |
| 1160 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 1161 | - : udpSipProvider.getNewCallId(); | |
| 1162 | 1151 | |
| 1163 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null, callIdHeader); | |
| 1164 | - transmitRequest(device.getTransport(), request, errorEvent); | |
| 1152 | + | |
| 1153 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 1154 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 1165 | 1155 | } |
| 1166 | 1156 | |
| 1167 | 1157 | /** |
| ... | ... | @@ -1185,11 +1175,10 @@ public class SIPCommander implements ISIPCommander { |
| 1185 | 1175 | } |
| 1186 | 1176 | cmdXml.append("</Query>\r\n"); |
| 1187 | 1177 | |
| 1188 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 1189 | - : udpSipProvider.getNewCallId(); | |
| 1190 | 1178 | |
| 1191 | - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null, callIdHeader); | |
| 1192 | - transmitRequest(device.getTransport(), request, errorEvent); | |
| 1179 | + | |
| 1180 | + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 1181 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 1193 | 1182 | } |
| 1194 | 1183 | |
| 1195 | 1184 | /** |
| ... | ... | @@ -1210,12 +1199,11 @@ public class SIPCommander implements ISIPCommander { |
| 1210 | 1199 | mobilePostitionXml.append("<Interval>60</Interval>\r\n"); |
| 1211 | 1200 | mobilePostitionXml.append("</Query>\r\n"); |
| 1212 | 1201 | |
| 1213 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 1214 | - : udpSipProvider.getNewCallId(); | |
| 1215 | 1202 | |
| 1216 | - Request request = headerProvider.createMessageRequest(device, mobilePostitionXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, callIdHeader); | |
| 1217 | 1203 | |
| 1218 | - transmitRequest(device.getTransport(), request, errorEvent); | |
| 1204 | + Request request = headerProvider.createMessageRequest(device, mobilePostitionXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 1205 | + | |
| 1206 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); | |
| 1219 | 1207 | |
| 1220 | 1208 | } |
| 1221 | 1209 | |
| ... | ... | @@ -1243,14 +1231,13 @@ public class SIPCommander implements ISIPCommander { |
| 1243 | 1231 | CallIdHeader callIdHeader; |
| 1244 | 1232 | |
| 1245 | 1233 | if (requestOld != null) { |
| 1246 | - callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(requestOld.getCallIdHeader().getCallId()); | |
| 1234 | + callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(requestOld.getCallIdHeader().getCallId()); | |
| 1247 | 1235 | } else { |
| 1248 | - callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 1249 | - : udpSipProvider.getNewCallId(); | |
| 1236 | + callIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()); | |
| 1250 | 1237 | } |
| 1251 | - SIPRequest request = (SIPRequest) headerProvider.createSubscribeRequest(device, subscribePostitionXml.toString(), requestOld, device.getSubscribeCycleForMobilePosition(), "presence", callIdHeader); //Position;id=" + tm.substring(tm.length() - 4)); | |
| 1238 | + SIPRequest request = (SIPRequest) headerProvider.createSubscribeRequest(device, subscribePostitionXml.toString(), requestOld, device.getSubscribeCycleForMobilePosition(), "presence",callIdHeader); //Position;id=" + tm.substring(tm.length() - 4)); | |
| 1252 | 1239 | |
| 1253 | - transmitRequest(device.getTransport(), request, errorEvent, okEvent); | |
| 1240 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent); | |
| 1254 | 1241 | return request; |
| 1255 | 1242 | } |
| 1256 | 1243 | |
| ... | ... | @@ -1297,11 +1284,10 @@ public class SIPCommander implements ISIPCommander { |
| 1297 | 1284 | } |
| 1298 | 1285 | cmdXml.append("</Query>\r\n"); |
| 1299 | 1286 | |
| 1300 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 1301 | - : udpSipProvider.getNewCallId(); | |
| 1302 | 1287 | |
| 1303 | - Request request = headerProvider.createSubscribeRequest(device, cmdXml.toString(), null, expires, "presence", callIdHeader); | |
| 1304 | - transmitRequest(device.getTransport(), request); | |
| 1288 | + | |
| 1289 | + Request request = headerProvider.createSubscribeRequest(device, cmdXml.toString(), null, expires, "presence",sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 1290 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); | |
| 1305 | 1291 | |
| 1306 | 1292 | } |
| 1307 | 1293 | |
| ... | ... | @@ -1320,16 +1306,15 @@ public class SIPCommander implements ISIPCommander { |
| 1320 | 1306 | CallIdHeader callIdHeader; |
| 1321 | 1307 | |
| 1322 | 1308 | if (requestOld != null) { |
| 1323 | - callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(requestOld.getCallIdHeader().getCallId()); | |
| 1309 | + callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(requestOld.getCallIdHeader().getCallId()); | |
| 1324 | 1310 | } else { |
| 1325 | - callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 1326 | - : udpSipProvider.getNewCallId(); | |
| 1311 | + callIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()); | |
| 1327 | 1312 | } |
| 1328 | 1313 | |
| 1329 | 1314 | // 有效时间默认为60秒以上 |
| 1330 | 1315 | SIPRequest request = (SIPRequest) headerProvider.createSubscribeRequest(device, cmdXml.toString(), requestOld, device.getSubscribeCycleForCatalog(), "Catalog", |
| 1331 | 1316 | callIdHeader); |
| 1332 | - transmitRequest(device.getTransport(), request, errorEvent, okEvent); | |
| 1317 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent); | |
| 1333 | 1318 | return request; |
| 1334 | 1319 | } |
| 1335 | 1320 | |
| ... | ... | @@ -1349,59 +1334,14 @@ public class SIPCommander implements ISIPCommander { |
| 1349 | 1334 | } |
| 1350 | 1335 | dragXml.append(cmdString); |
| 1351 | 1336 | dragXml.append("</Control>\r\n"); |
| 1352 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 1353 | - : udpSipProvider.getNewCallId(); | |
| 1354 | - Request request = headerProvider.createMessageRequest(device, dragXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, callIdHeader); | |
| 1355 | - logger.debug("拉框信令: " + request.toString()); | |
| 1356 | - transmitRequest(device.getTransport(), request); | |
| 1357 | - } | |
| 1358 | - | |
| 1359 | - | |
| 1360 | - @Override | |
| 1361 | - public void transmitRequest(String transport, Request request) throws SipException, ParseException { | |
| 1362 | - transmitRequest(transport, request, null, null); | |
| 1363 | - } | |
| 1364 | 1337 | |
| 1365 | - @Override | |
| 1366 | - public void transmitRequest(String transport, Request request, SipSubscribe.Event errorEvent) throws SipException, ParseException { | |
| 1367 | - transmitRequest(transport, request, errorEvent, null); | |
| 1338 | + Request request = headerProvider.createMessageRequest(device, dragXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 1339 | + logger.debug("拉框信令: " + request.toString()); | |
| 1340 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request); | |
| 1368 | 1341 | } |
| 1369 | 1342 | |
| 1370 | - @Override | |
| 1371 | - public void transmitRequest(String transport, Request request, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, ParseException { | |
| 1372 | - | |
| 1373 | - if (request.getHeader(UserAgentHeader.NAME) == null) { | |
| 1374 | - try { | |
| 1375 | - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); | |
| 1376 | - } catch (ParseException e) { | |
| 1377 | - logger.error("添加UserAgentHeader失败", e); | |
| 1378 | - } | |
| 1379 | - } | |
| 1380 | 1343 | |
| 1381 | - CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME); | |
| 1382 | - // 添加错误订阅 | |
| 1383 | - if (errorEvent != null) { | |
| 1384 | - sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (eventResult -> { | |
| 1385 | - errorEvent.response(eventResult); | |
| 1386 | - sipSubscribe.removeErrorSubscribe(eventResult.callId); | |
| 1387 | - sipSubscribe.removeOkSubscribe(eventResult.callId); | |
| 1388 | - })); | |
| 1389 | - } | |
| 1390 | - // 添加订阅 | |
| 1391 | - if (okEvent != null) { | |
| 1392 | - sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), eventResult -> { | |
| 1393 | - okEvent.response(eventResult); | |
| 1394 | - sipSubscribe.removeOkSubscribe(eventResult.callId); | |
| 1395 | - sipSubscribe.removeErrorSubscribe(eventResult.callId); | |
| 1396 | - }); | |
| 1397 | - } | |
| 1398 | - if ("TCP".equals(transport)) { | |
| 1399 | - tcpSipProvider.sendRequest(request); | |
| 1400 | - } else if ("UDP".equals(transport)) { | |
| 1401 | - udpSipProvider.sendRequest(request); | |
| 1402 | - } | |
| 1403 | 1344 | |
| 1404 | - } | |
| 1405 | 1345 | |
| 1406 | 1346 | |
| 1407 | 1347 | /** |
| ... | ... | @@ -1476,7 +1416,7 @@ public class SIPCommander implements ISIPCommander { |
| 1476 | 1416 | return; |
| 1477 | 1417 | } |
| 1478 | 1418 | |
| 1479 | - transmitRequest(device.getTransport(), request, errorEvent, okEvent); | |
| 1419 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent); | |
| 1480 | 1420 | } |
| 1481 | 1421 | |
| 1482 | 1422 | @Override |
| ... | ... | @@ -1505,10 +1445,9 @@ public class SIPCommander implements ISIPCommander { |
| 1505 | 1445 | deviceStatusXml.append("</info>\r\n"); |
| 1506 | 1446 | deviceStatusXml.append("</Notify>\r\n"); |
| 1507 | 1447 | |
| 1508 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 1509 | - : udpSipProvider.getNewCallId(); | |
| 1510 | - Request request = headerProvider.createMessageRequest(device, deviceStatusXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, callIdHeader); | |
| 1511 | - transmitRequest(device.getTransport(), request); | |
| 1448 | + | |
| 1449 | + Request request = headerProvider.createMessageRequest(device, deviceStatusXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | |
| 1450 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request); | |
| 1512 | 1451 | |
| 1513 | 1452 | |
| 1514 | 1453 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 5 | +import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 4 | 6 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 5 | 7 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 8 | +import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; | |
| 6 | 9 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| 7 | 10 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderPlarformProvider; |
| 8 | 11 | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; |
| ... | ... | @@ -13,15 +16,12 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 13 | 16 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 14 | 17 | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; |
| 15 | 18 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 16 | -import gov.nist.javax.sip.SipProviderImpl; | |
| 17 | 19 | import gov.nist.javax.sip.message.MessageFactoryImpl; |
| 18 | 20 | import gov.nist.javax.sip.message.SIPRequest; |
| 19 | 21 | import org.slf4j.Logger; |
| 20 | 22 | import org.slf4j.LoggerFactory; |
| 21 | 23 | import org.springframework.beans.factory.annotation.Autowired; |
| 22 | -import org.springframework.beans.factory.annotation.Qualifier; | |
| 23 | 24 | import org.springframework.context.annotation.DependsOn; |
| 24 | -import org.springframework.context.annotation.Lazy; | |
| 25 | 25 | import org.springframework.lang.Nullable; |
| 26 | 26 | import org.springframework.stereotype.Component; |
| 27 | 27 | import org.springframework.util.ObjectUtils; |
| ... | ... | @@ -56,21 +56,11 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 56 | 56 | @Autowired |
| 57 | 57 | private ZLMRTPServerFactory zlmrtpServerFactory; |
| 58 | 58 | |
| 59 | - @Lazy | |
| 60 | 59 | @Autowired |
| 61 | - @Qualifier(value="tcpSipProvider") | |
| 62 | - private SipProviderImpl tcpSipProvider; | |
| 60 | + private SipLayer sipLayer; | |
| 63 | 61 | |
| 64 | - @Lazy | |
| 65 | 62 | @Autowired |
| 66 | - @Qualifier(value="udpSipProvider") | |
| 67 | - private SipProviderImpl udpSipProvider; | |
| 68 | - | |
| 69 | - @Autowired | |
| 70 | - private SipFactory sipFactory; | |
| 71 | - | |
| 72 | - @Autowired | |
| 73 | - private SubscribeHolder subscribeHolder; | |
| 63 | + private SIPSender sipSender; | |
| 74 | 64 | |
| 75 | 65 | @Override |
| 76 | 66 | public void register(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException { |
| ... | ... | @@ -87,13 +77,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 87 | 77 | SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent, boolean registerAgain, boolean isRegister) throws SipException, InvalidArgumentException, ParseException { |
| 88 | 78 | Request request; |
| 89 | 79 | if (!registerAgain ) { |
| 90 | - CallIdHeader callIdHeader = null; | |
| 91 | - if(parentPlatform.getTransport().equalsIgnoreCase("TCP")) { | |
| 92 | - callIdHeader = tcpSipProvider.getNewCallId(); | |
| 93 | - } | |
| 94 | - if(parentPlatform.getTransport().equalsIgnoreCase("UDP")) { | |
| 95 | - callIdHeader = udpSipProvider.getNewCallId(); | |
| 96 | - } | |
| 80 | + CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); | |
| 97 | 81 | |
| 98 | 82 | request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform, |
| 99 | 83 | redisCatchStorage.getCSEQ(), SipUtils.getNewFromTag(), |
| ... | ... | @@ -115,12 +99,11 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 115 | 99 | }); |
| 116 | 100 | |
| 117 | 101 | }else { |
| 118 | - CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() | |
| 119 | - : udpSipProvider.getNewCallId(); | |
| 102 | + CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); | |
| 120 | 103 | request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform, SipUtils.getNewFromTag(), null, callId, www, callIdHeader, isRegister); |
| 121 | 104 | } |
| 122 | 105 | |
| 123 | - transmitRequest(parentPlatform, request, null, okEvent); | |
| 106 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, null, okEvent); | |
| 124 | 107 | } |
| 125 | 108 | |
| 126 | 109 | @Override |
| ... | ... | @@ -135,8 +118,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 135 | 118 | keepaliveXml.append("<Status>OK</Status>\r\n"); |
| 136 | 119 | keepaliveXml.append("</Notify>\r\n"); |
| 137 | 120 | |
| 138 | - CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() | |
| 139 | - : udpSipProvider.getNewCallId(); | |
| 121 | + CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); | |
| 140 | 122 | |
| 141 | 123 | Request request = headerProviderPlatformProvider.createMessageRequest( |
| 142 | 124 | parentPlatform, |
| ... | ... | @@ -144,39 +126,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 144 | 126 | SipUtils.getNewFromTag(), |
| 145 | 127 | SipUtils.getNewViaTag(), |
| 146 | 128 | callIdHeader); |
| 147 | - transmitRequest(parentPlatform, request, errorEvent, okEvent); | |
| 129 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, errorEvent, okEvent); | |
| 148 | 130 | return callIdHeader.getCallId(); |
| 149 | 131 | } |
| 150 | 132 | |
| 151 | - private void transmitRequest(ParentPlatform parentPlatform, Request request) throws SipException { | |
| 152 | - transmitRequest(parentPlatform, request, null, null); | |
| 153 | - } | |
| 154 | - | |
| 155 | - private void transmitRequest(ParentPlatform parentPlatform, Request request, SipSubscribe.Event errorEvent) throws SipException { | |
| 156 | - transmitRequest(parentPlatform, request, errorEvent, null); | |
| 157 | - } | |
| 158 | - | |
| 159 | - private void transmitRequest(ParentPlatform parentPlatform, Request request, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws SipException { | |
| 160 | - logger.debug("\n发送消息:\n{}", request); | |
| 161 | - if("TCP".equalsIgnoreCase(parentPlatform.getTransport())) { | |
| 162 | - tcpSipProvider.sendRequest(request); | |
| 163 | - | |
| 164 | - } else if("UDP".equalsIgnoreCase(parentPlatform.getTransport())) { | |
| 165 | - udpSipProvider.sendRequest(request); | |
| 166 | - } | |
| 167 | - | |
| 168 | - CallIdHeader callIdHeader = (CallIdHeader)request.getHeader(CallIdHeader.NAME); | |
| 169 | - // 添加错误订阅 | |
| 170 | - if (errorEvent != null) { | |
| 171 | - sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), errorEvent); | |
| 172 | - } | |
| 173 | - // 添加订阅 | |
| 174 | - if (okEvent != null) { | |
| 175 | - sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), okEvent); | |
| 176 | - } | |
| 177 | - | |
| 178 | - } | |
| 179 | - | |
| 180 | 133 | /** |
| 181 | 134 | * 向上级回复通道信息 |
| 182 | 135 | * @param channel 通道信息 |
| ... | ... | @@ -196,11 +149,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 196 | 149 | String catalogXml = getCatalogXml(channels, sn, parentPlatform, size); |
| 197 | 150 | |
| 198 | 151 | // callid |
| 199 | - CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() | |
| 200 | - : udpSipProvider.getNewCallId(); | |
| 152 | + CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); | |
| 201 | 153 | |
| 202 | 154 | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| 203 | - transmitRequest(parentPlatform, request); | |
| 155 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); | |
| 204 | 156 | |
| 205 | 157 | } |
| 206 | 158 | |
| ... | ... | @@ -283,11 +235,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 283 | 235 | } |
| 284 | 236 | String catalogXml = getCatalogXml(deviceChannels, sn, parentPlatform, channels.size()); |
| 285 | 237 | // callid |
| 286 | - CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() | |
| 287 | - : udpSipProvider.getNewCallId(); | |
| 238 | + CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); | |
| 288 | 239 | |
| 289 | 240 | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml, fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| 290 | - transmitRequest(parentPlatform, request, null, eventResult -> { | |
| 241 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, null, eventResult -> { | |
| 291 | 242 | int indexNext = index + parentPlatform.getCatalogGroup(); |
| 292 | 243 | try { |
| 293 | 244 | sendCatalogResponse(channels, parentPlatform, sn, fromTag, indexNext); |
| ... | ... | @@ -323,11 +274,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 323 | 274 | deviceInfoXml.append("<Result>OK</Result>\r\n"); |
| 324 | 275 | deviceInfoXml.append("</Response>\r\n"); |
| 325 | 276 | |
| 326 | - CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() | |
| 327 | - : udpSipProvider.getNewCallId(); | |
| 277 | + CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); | |
| 328 | 278 | |
| 329 | 279 | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceInfoXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| 330 | - transmitRequest(parentPlatform, request); | |
| 280 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); | |
| 331 | 281 | } |
| 332 | 282 | |
| 333 | 283 | /** |
| ... | ... | @@ -354,11 +304,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 354 | 304 | deviceStatusXml.append("<Status>OK</Status>\r\n"); |
| 355 | 305 | deviceStatusXml.append("</Response>\r\n"); |
| 356 | 306 | |
| 357 | - CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() | |
| 358 | - : udpSipProvider.getNewCallId(); | |
| 307 | + CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); | |
| 359 | 308 | |
| 360 | 309 | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| 361 | - transmitRequest(parentPlatform, request); | |
| 310 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); | |
| 362 | 311 | |
| 363 | 312 | } |
| 364 | 313 | |
| ... | ... | @@ -398,7 +347,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 398 | 347 | return; |
| 399 | 348 | } |
| 400 | 349 | logger.info("[发送报警通知] {}/{}->{},{}: {}", parentPlatform.getServerGBId(), deviceAlarm.getChannelId(), |
| 401 | - deviceAlarm.getLongitude(), deviceAlarm.getLatitude(), JSONObject.toJSON(deviceAlarm)); | |
| 350 | + deviceAlarm.getLongitude(), deviceAlarm.getLatitude(), JSON.toJSONString(deviceAlarm)); | |
| 402 | 351 | String characterSet = parentPlatform.getCharacterSet(); |
| 403 | 352 | StringBuffer deviceStatusXml = new StringBuffer(600); |
| 404 | 353 | deviceStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n"); |
| ... | ... | @@ -417,11 +366,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 417 | 366 | deviceStatusXml.append("</info>\r\n"); |
| 418 | 367 | deviceStatusXml.append("</Notify>\r\n"); |
| 419 | 368 | |
| 420 | - CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() | |
| 421 | - : udpSipProvider.getNewCallId(); | |
| 369 | + CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); | |
| 422 | 370 | |
| 423 | 371 | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), SipUtils.getNewFromTag(), SipUtils.getNewViaTag(), callIdHeader); |
| 424 | - transmitRequest(parentPlatform, request); | |
| 372 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); | |
| 425 | 373 | |
| 426 | 374 | } |
| 427 | 375 | |
| ... | ... | @@ -461,14 +409,14 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 461 | 409 | private void sendNotify(ParentPlatform parentPlatform, String catalogXmlContent, |
| 462 | 410 | SubscribeInfo subscribeInfo, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent ) |
| 463 | 411 | throws SipException, ParseException, InvalidArgumentException { |
| 464 | - MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipFactory.createMessageFactory(); | |
| 412 | + MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipLayer.getSipFactory().createMessageFactory(); | |
| 465 | 413 | String characterSet = parentPlatform.getCharacterSet(); |
| 466 | 414 | // 设置编码, 防止中文乱码 |
| 467 | 415 | messageFactory.setDefaultContentEncodingCharset(characterSet); |
| 468 | 416 | |
| 469 | 417 | SIPRequest notifyRequest = headerProviderPlatformProvider.createNotifyRequest(parentPlatform, catalogXmlContent, subscribeInfo); |
| 470 | 418 | |
| 471 | - transmitRequest(parentPlatform, notifyRequest); | |
| 419 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(), notifyRequest); | |
| 472 | 420 | } |
| 473 | 421 | |
| 474 | 422 | private String getCatalogXmlContentForCatalogAddOrUpdate(ParentPlatform parentPlatform, List<DeviceChannel> channels, int sumNum, String type, SubscribeInfo subscribeInfo) { |
| ... | ... | @@ -633,21 +581,21 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 633 | 581 | recordXml.append("</Response>\r\n"); |
| 634 | 582 | |
| 635 | 583 | // callid |
| 636 | - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | |
| 637 | - : udpSipProvider.getNewCallId(); | |
| 584 | + CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); | |
| 585 | + | |
| 638 | 586 | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, recordXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| 639 | - transmitRequest(parentPlatform, request); | |
| 587 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); | |
| 640 | 588 | |
| 641 | 589 | } |
| 642 | 590 | |
| 643 | 591 | @Override |
| 644 | - public void sendMediaStatusNotify(ParentPlatform platform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException { | |
| 645 | - if (sendRtpItem == null || platform == null) { | |
| 592 | + public void sendMediaStatusNotify(ParentPlatform parentPlatform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException { | |
| 593 | + if (sendRtpItem == null || parentPlatform == null) { | |
| 646 | 594 | return; |
| 647 | 595 | } |
| 648 | 596 | |
| 649 | 597 | |
| 650 | - String characterSet = platform.getCharacterSet(); | |
| 598 | + String characterSet = parentPlatform.getCharacterSet(); | |
| 651 | 599 | StringBuffer mediaStatusXml = new StringBuffer(200); |
| 652 | 600 | mediaStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n"); |
| 653 | 601 | mediaStatusXml.append("<Notify>\r\n"); |
| ... | ... | @@ -657,10 +605,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 657 | 605 | mediaStatusXml.append("<NotifyType>121</NotifyType>\r\n"); |
| 658 | 606 | mediaStatusXml.append("</Notify>\r\n"); |
| 659 | 607 | |
| 660 | - SIPRequest messageRequest = (SIPRequest)headerProviderPlatformProvider.createMessageRequest(platform, mediaStatusXml.toString(), | |
| 608 | + SIPRequest messageRequest = (SIPRequest)headerProviderPlatformProvider.createMessageRequest(parentPlatform, mediaStatusXml.toString(), | |
| 661 | 609 | sendRtpItem); |
| 662 | 610 | |
| 663 | - transmitRequest(platform, messageRequest); | |
| 611 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(),messageRequest); | |
| 664 | 612 | |
| 665 | 613 | } |
| 666 | 614 | |
| ... | ... | @@ -681,21 +629,21 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 681 | 629 | logger.info("[向上级发送BYE], sendRtpItem 为NULL"); |
| 682 | 630 | return; |
| 683 | 631 | } |
| 684 | - if (platform == null) { | |
| 632 | + if (parentPlatform == null) { | |
| 685 | 633 | logger.info("[向上级发送BYE], platform 为NULL"); |
| 686 | 634 | return; |
| 687 | 635 | } |
| 688 | - logger.info("[向上级发送BYE], {}/{}", platform.getServerGBId(), sendRtpItem.getChannelId()); | |
| 636 | + logger.info("[向上级发送BYE], {}/{}", parentPlatform.getServerGBId(), sendRtpItem.getChannelId()); | |
| 689 | 637 | String mediaServerId = sendRtpItem.getMediaServerId(); |
| 690 | 638 | MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); |
| 691 | 639 | if (mediaServerItem != null) { |
| 692 | 640 | mediaServerService.releaseSsrc(mediaServerItem.getId(), sendRtpItem.getSsrc()); |
| 693 | - zlmrtpServerFactory.closeRTPServer(mediaServerItem, sendRtpItem.getStreamId()); | |
| 641 | + zlmrtpServerFactory.closeRtpServer(mediaServerItem, sendRtpItem.getStreamId()); | |
| 694 | 642 | } |
| 695 | - SIPRequest byeRequest = headerProviderPlatformProvider.createByeRequest(platform, sendRtpItem); | |
| 643 | + SIPRequest byeRequest = headerProviderPlatformProvider.createByeRequest(parentPlatform, sendRtpItem); | |
| 696 | 644 | if (byeRequest == null) { |
| 697 | 645 | logger.warn("[向上级发送bye]:无法创建 byeRequest"); |
| 698 | 646 | } |
| 699 | - transmitRequest(platform,byeRequest); | |
| 647 | + sipSender.transmitRequest(parentPlatform.getDeviceIp(),byeRequest); | |
| 700 | 648 | } |
| 701 | 649 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java
| ... | ... | @@ -2,9 +2,9 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 4 | 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 5 | +import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; | |
| 5 | 6 | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; |
| 6 | 7 | import gov.nist.javax.sip.SipProviderImpl; |
| 7 | -import gov.nist.javax.sip.SipStackImpl; | |
| 8 | 8 | import gov.nist.javax.sip.message.SIPRequest; |
| 9 | 9 | import gov.nist.javax.sip.message.SIPResponse; |
| 10 | 10 | import gov.nist.javax.sip.stack.SIPServerTransactionImpl; |
| ... | ... | @@ -42,58 +42,8 @@ public abstract class SIPRequestProcessorParent { |
| 42 | 42 | private final static Logger logger = LoggerFactory.getLogger(SIPRequestProcessorParent.class); |
| 43 | 43 | |
| 44 | 44 | @Autowired |
| 45 | - @Qualifier(value="tcpSipProvider") | |
| 46 | - private SipProviderImpl tcpSipProvider; | |
| 45 | + private SIPSender sipSender; | |
| 47 | 46 | |
| 48 | - @Autowired | |
| 49 | - @Qualifier(value="udpSipProvider") | |
| 50 | - private SipProviderImpl udpSipProvider; | |
| 51 | - | |
| 52 | - @Autowired | |
| 53 | - private SipConfig sipConfig; | |
| 54 | - | |
| 55 | - /** | |
| 56 | - * 根据 RequestEvent 获取 ServerTransaction | |
| 57 | - * @param evt | |
| 58 | - * @return | |
| 59 | - */ | |
| 60 | - public ServerTransaction getServerTransaction(RequestEvent evt) { | |
| 61 | - Request request = evt.getRequest(); | |
| 62 | - SIPServerTransactionImpl serverTransaction = (SIPServerTransactionImpl)evt.getServerTransaction(); | |
| 63 | - // 判断TCP还是UDP | |
| 64 | - boolean isTcp = false; | |
| 65 | - ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME); | |
| 66 | - String transport = reqViaHeader.getTransport(); | |
| 67 | - if (transport.equalsIgnoreCase("TCP")) { | |
| 68 | - isTcp = true; | |
| 69 | - } | |
| 70 | - if (serverTransaction != null && serverTransaction.getOriginalRequest() == null) { | |
| 71 | - serverTransaction.setOriginalRequest((SIPRequest) evt.getRequest()); | |
| 72 | - } | |
| 73 | - if (serverTransaction == null) { | |
| 74 | - try { | |
| 75 | - if (isTcp) { | |
| 76 | - SipStackImpl stack = (SipStackImpl)tcpSipProvider.getSipStack(); | |
| 77 | - serverTransaction = (SIPServerTransactionImpl) stack.findTransaction((SIPRequest)request, true); | |
| 78 | - if (serverTransaction == null) { | |
| 79 | - serverTransaction = (SIPServerTransactionImpl)tcpSipProvider.getNewServerTransaction(request); | |
| 80 | - } | |
| 81 | - } else { | |
| 82 | - SipStackImpl stack = (SipStackImpl)udpSipProvider.getSipStack(); | |
| 83 | - serverTransaction = (SIPServerTransactionImpl) stack.findTransaction((SIPRequest)request, true); | |
| 84 | - if (serverTransaction == null) { | |
| 85 | - serverTransaction = (SIPServerTransactionImpl)udpSipProvider.getNewServerTransaction(request); | |
| 86 | - } | |
| 87 | - } | |
| 88 | - } catch (TransactionAlreadyExistsException e) { | |
| 89 | - logger.error(e.getMessage()); | |
| 90 | - } catch (TransactionUnavailableException e) { | |
| 91 | - logger.error(e.getMessage()); | |
| 92 | - } | |
| 93 | - } | |
| 94 | - return serverTransaction; | |
| 95 | - } | |
| 96 | - | |
| 97 | 47 | public AddressFactory getAddressFactory() { |
| 98 | 48 | try { |
| 99 | 49 | return SipFactory.getInstance().createAddressFactory(); |
| ... | ... | @@ -135,25 +85,73 @@ public abstract class SIPRequestProcessorParent { |
| 135 | 85 | * 400 |
| 136 | 86 | * 404 |
| 137 | 87 | */ |
| 138 | - public SIPResponse responseAck(ServerTransaction serverTransaction, int statusCode) throws SipException, InvalidArgumentException, ParseException { | |
| 139 | - return responseAck(serverTransaction, statusCode, null); | |
| 88 | + public SIPResponse responseAck(SIPRequest sipRequest, int statusCode) throws SipException, InvalidArgumentException, ParseException { | |
| 89 | + return responseAck(sipRequest, statusCode, null); | |
| 140 | 90 | } |
| 141 | 91 | |
| 142 | - public SIPResponse responseAck(ServerTransaction serverTransaction, int statusCode, String msg) throws SipException, InvalidArgumentException, ParseException { | |
| 143 | - return responseAck(serverTransaction, statusCode, msg, null); | |
| 92 | + public SIPResponse responseAck(SIPRequest sipRequest, int statusCode, String msg) throws SipException, InvalidArgumentException, ParseException { | |
| 93 | + return responseAck(sipRequest, statusCode, msg, null); | |
| 144 | 94 | } |
| 145 | 95 | |
| 146 | - public SIPResponse responseAck(ServerTransaction serverTransaction, int statusCode, String msg, ResponseAckExtraParam responseAckExtraParam) throws SipException, InvalidArgumentException, ParseException { | |
| 147 | - ToHeader toHeader = (ToHeader) serverTransaction.getRequest().getHeader(ToHeader.NAME); | |
| 148 | - if (toHeader.getTag() == null) { | |
| 149 | - toHeader.setTag(SipUtils.getNewTag()); | |
| 96 | +// public SIPResponse responseAck(ServerTransaction serverTransaction, int statusCode, String msg, ResponseAckExtraParam responseAckExtraParam) throws SipException, InvalidArgumentException, ParseException { | |
| 97 | +// if (serverTransaction == null) { | |
| 98 | +// logger.warn("[回复消息] ServerTransaction 为null"); | |
| 99 | +// return null; | |
| 100 | +// } | |
| 101 | +// ToHeader toHeader = (ToHeader) serverTransaction.getRequest().getHeader(ToHeader.NAME); | |
| 102 | +// if (toHeader.getTag() == null) { | |
| 103 | +// toHeader.setTag(SipUtils.getNewTag()); | |
| 104 | +// } | |
| 105 | +// SIPResponse response = (SIPResponse)getMessageFactory().createResponse(statusCode, serverTransaction.getRequest()); | |
| 106 | +// if (msg != null) { | |
| 107 | +// response.setReasonPhrase(msg); | |
| 108 | +// } | |
| 109 | +// if (responseAckExtraParam != null) { | |
| 110 | +// if (responseAckExtraParam.sipURI != null && serverTransaction.getRequest().getMethod().equals(Request.INVITE)) { | |
| 111 | +// logger.debug("responseSdpAck SipURI: {}:{}", responseAckExtraParam.sipURI.getHost(), responseAckExtraParam.sipURI.getPort()); | |
| 112 | +// Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress( | |
| 113 | +// SipFactory.getInstance().createAddressFactory().createSipURI(responseAckExtraParam.sipURI.getUser(), responseAckExtraParam.sipURI.getHost()+":"+responseAckExtraParam.sipURI.getPort() | |
| 114 | +// )); | |
| 115 | +// response.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress)); | |
| 116 | +// } | |
| 117 | +// if (responseAckExtraParam.contentTypeHeader != null) { | |
| 118 | +// response.setContent(responseAckExtraParam.content, responseAckExtraParam.contentTypeHeader); | |
| 119 | +// } | |
| 120 | +// | |
| 121 | +// if (serverTransaction.getRequest().getMethod().equals(Request.SUBSCRIBE)) { | |
| 122 | +// if (responseAckExtraParam.expires == -1) { | |
| 123 | +// logger.error("[参数不全] 2xx的SUBSCRIBE回复,必须设置Expires header"); | |
| 124 | +// }else { | |
| 125 | +// ExpiresHeader expiresHeader = SipFactory.getInstance().createHeaderFactory().createExpiresHeader(responseAckExtraParam.expires); | |
| 126 | +// response.addHeader(expiresHeader); | |
| 127 | +// } | |
| 128 | +// } | |
| 129 | +// }else { | |
| 130 | +// if (serverTransaction.getRequest().getMethod().equals(Request.SUBSCRIBE)) { | |
| 131 | +// logger.error("[参数不全] 2xx的SUBSCRIBE回复,必须设置Expires header"); | |
| 132 | +// } | |
| 133 | +// } | |
| 134 | +// serverTransaction.sendResponse(response); | |
| 135 | +// if (statusCode >= 200 && !"NOTIFY".equalsIgnoreCase(serverTransaction.getRequest().getMethod())) { | |
| 136 | +// if (serverTransaction.getDialog() != null) { | |
| 137 | +// serverTransaction.getDialog().delete(); | |
| 138 | +// } | |
| 139 | +// } | |
| 140 | +// return response; | |
| 141 | +// } | |
| 142 | + | |
| 143 | + public SIPResponse responseAck(SIPRequest sipRequest, int statusCode, String msg, ResponseAckExtraParam responseAckExtraParam) throws SipException, InvalidArgumentException, ParseException { | |
| 144 | + if (sipRequest.getToHeader().getTag() == null) { | |
| 145 | + sipRequest.getToHeader().setTag(SipUtils.getNewTag()); | |
| 150 | 146 | } |
| 151 | - SIPResponse response = (SIPResponse)getMessageFactory().createResponse(statusCode, serverTransaction.getRequest()); | |
| 147 | + SIPResponse response = (SIPResponse)getMessageFactory().createResponse(statusCode, sipRequest); | |
| 148 | + response.setStatusCode(statusCode); | |
| 152 | 149 | if (msg != null) { |
| 153 | 150 | response.setReasonPhrase(msg); |
| 154 | 151 | } |
| 152 | + | |
| 155 | 153 | if (responseAckExtraParam != null) { |
| 156 | - if (responseAckExtraParam.sipURI != null && serverTransaction.getRequest().getMethod().equals(Request.INVITE)) { | |
| 154 | + if (responseAckExtraParam.sipURI != null && sipRequest.getMethod().equals(Request.INVITE)) { | |
| 157 | 155 | logger.debug("responseSdpAck SipURI: {}:{}", responseAckExtraParam.sipURI.getHost(), responseAckExtraParam.sipURI.getPort()); |
| 158 | 156 | Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress( |
| 159 | 157 | SipFactory.getInstance().createAddressFactory().createSipURI(responseAckExtraParam.sipURI.getUser(), responseAckExtraParam.sipURI.getHost()+":"+responseAckExtraParam.sipURI.getPort() |
| ... | ... | @@ -164,7 +162,7 @@ public abstract class SIPRequestProcessorParent { |
| 164 | 162 | response.setContent(responseAckExtraParam.content, responseAckExtraParam.contentTypeHeader); |
| 165 | 163 | } |
| 166 | 164 | |
| 167 | - if (serverTransaction.getRequest().getMethod().equals(Request.SUBSCRIBE)) { | |
| 165 | + if (sipRequest.getMethod().equals(Request.SUBSCRIBE)) { | |
| 168 | 166 | if (responseAckExtraParam.expires == -1) { |
| 169 | 167 | logger.error("[参数不全] 2xx的SUBSCRIBE回复,必须设置Expires header"); |
| 170 | 168 | }else { |
| ... | ... | @@ -173,27 +171,26 @@ public abstract class SIPRequestProcessorParent { |
| 173 | 171 | } |
| 174 | 172 | } |
| 175 | 173 | }else { |
| 176 | - if (serverTransaction.getRequest().getMethod().equals(Request.SUBSCRIBE)) { | |
| 174 | + if (sipRequest.getMethod().equals(Request.SUBSCRIBE)) { | |
| 177 | 175 | logger.error("[参数不全] 2xx的SUBSCRIBE回复,必须设置Expires header"); |
| 178 | 176 | } |
| 179 | 177 | } |
| 180 | - serverTransaction.sendResponse(response); | |
| 181 | - if (statusCode >= 200 && !"NOTIFY".equalsIgnoreCase(serverTransaction.getRequest().getMethod())) { | |
| 182 | - if (serverTransaction.getDialog() != null) { | |
| 183 | - serverTransaction.getDialog().delete(); | |
| 184 | - } | |
| 185 | - } | |
| 178 | + | |
| 179 | + // 发送response | |
| 180 | + sipSender.transmitRequest(sipRequest.getLocalAddress().getHostAddress(), response); | |
| 181 | + | |
| 186 | 182 | return response; |
| 187 | 183 | } |
| 188 | 184 | |
| 189 | 185 | /** |
| 190 | 186 | * 回复带sdp的200 |
| 191 | 187 | */ |
| 192 | - public SIPResponse responseSdpAck(ServerTransaction serverTransaction, String sdp, ParentPlatform platform) throws SipException, InvalidArgumentException, ParseException { | |
| 188 | + public SIPResponse responseSdpAck(SIPRequest request, String sdp, ParentPlatform platform) throws SipException, InvalidArgumentException, ParseException { | |
| 189 | + | |
| 193 | 190 | ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP"); |
| 194 | 191 | |
| 195 | 192 | // 兼容国标中的使用编码@域名作为RequestURI的情况 |
| 196 | - SipURI sipURI = (SipURI)serverTransaction.getRequest().getRequestURI(); | |
| 193 | + SipURI sipURI = (SipURI)request.getRequestURI(); | |
| 197 | 194 | if (sipURI.getPort() == -1) { |
| 198 | 195 | sipURI = SipFactory.getInstance().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerIP()+":"+platform.getServerPort()); |
| 199 | 196 | } |
| ... | ... | @@ -202,16 +199,16 @@ public abstract class SIPRequestProcessorParent { |
| 202 | 199 | responseAckExtraParam.content = sdp; |
| 203 | 200 | responseAckExtraParam.sipURI = sipURI; |
| 204 | 201 | |
| 205 | - return responseAck(serverTransaction, Response.OK, null, responseAckExtraParam); | |
| 202 | + return responseAck(request, Response.OK, null, responseAckExtraParam); | |
| 206 | 203 | } |
| 207 | 204 | |
| 208 | 205 | /** |
| 209 | 206 | * 回复带xml的200 |
| 210 | 207 | */ |
| 211 | - public SIPResponse responseXmlAck(ServerTransaction serverTransaction, String xml, ParentPlatform platform, Integer expires) throws SipException, InvalidArgumentException, ParseException { | |
| 208 | + public SIPResponse responseXmlAck(SIPRequest request, String xml, ParentPlatform platform, Integer expires) throws SipException, InvalidArgumentException, ParseException { | |
| 212 | 209 | ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); |
| 213 | 210 | |
| 214 | - SipURI sipURI = (SipURI)serverTransaction.getRequest().getRequestURI(); | |
| 211 | + SipURI sipURI = (SipURI)request.getRequestURI(); | |
| 215 | 212 | if (sipURI.getPort() == -1) { |
| 216 | 213 | sipURI = SipFactory.getInstance().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerIP()+":"+platform.getServerPort()); |
| 217 | 214 | } |
| ... | ... | @@ -220,7 +217,7 @@ public abstract class SIPRequestProcessorParent { |
| 220 | 217 | responseAckExtraParam.content = xml; |
| 221 | 218 | responseAckExtraParam.sipURI = sipURI; |
| 222 | 219 | responseAckExtraParam.expires = expires; |
| 223 | - return responseAck(serverTransaction, Response.OK, null, responseAckExtraParam); | |
| 220 | + return responseAck(request, Response.OK, null, responseAckExtraParam); | |
| 224 | 221 | } |
| 225 | 222 | |
| 226 | 223 | public Element getRootElement(RequestEvent evt) throws DocumentException { | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSON; | |
| 4 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 5 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| 5 | 6 | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; |
| 6 | 7 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| ... | ... | @@ -12,8 +13,8 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; |
| 12 | 13 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| 13 | 14 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; |
| 14 | 15 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| 15 | -import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; | |
| 16 | 16 | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; |
| 17 | +import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; | |
| 17 | 18 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 18 | 19 | import com.genersoft.iot.vmp.service.IDeviceService; |
| 19 | 20 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| ... | ... | @@ -40,7 +41,8 @@ import javax.sip.header.HeaderAddress; |
| 40 | 41 | import java.text.ParseException; |
| 41 | 42 | import javax.sip.header.ToHeader; |
| 42 | 43 | import java.text.ParseException; |
| 43 | -import java.util.*; | |
| 44 | +import java.util.HashMap; | |
| 45 | +import java.util.Map; | |
| 44 | 46 | |
| 45 | 47 | /** |
| 46 | 48 | * SIP命令类型: ACK请求 |
| ... | ... | @@ -71,6 +73,9 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In |
| 71 | 73 | private ZLMRTPServerFactory zlmrtpServerFactory; |
| 72 | 74 | |
| 73 | 75 | @Autowired |
| 76 | + private ZlmHttpHookSubscribe hookSubscribe; | |
| 77 | + | |
| 78 | + @Autowired | |
| 74 | 79 | private IMediaServerService mediaServerService; |
| 75 | 80 | |
| 76 | 81 | @Autowired |
| ... | ... | @@ -177,8 +182,18 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In |
| 177 | 182 | startSendRtpStreamHand(evt, sendRtpItem, parentPlatform, json, param, callIdHeader); |
| 178 | 183 | }); |
| 179 | 184 | } else { |
| 180 | - JSONObject startSendRtpStreamResult = zlmrtpServerFactory.startSendRtpStream(mediaInfo, param); | |
| 181 | - startSendRtpStreamHand(evt, sendRtpItem, parentPlatform, startSendRtpStreamResult, param, callIdHeader); | |
| 185 | + // 如果是非严格模式,需要关闭端口占用 | |
| 186 | + JSONObject startSendRtpStreamResult = null; | |
| 187 | + if (sendRtpItem.getLocalPort() != 0) { | |
| 188 | + if (zlmrtpServerFactory.releasePort(mediaInfo, sendRtpItem.getSsrc())) { | |
| 189 | + startSendRtpStreamResult = zlmrtpServerFactory.startSendRtpStream(mediaInfo, param); | |
| 190 | + } | |
| 191 | + }else { | |
| 192 | + startSendRtpStreamResult = zlmrtpServerFactory.startSendRtpStream(mediaInfo, param); | |
| 193 | + } | |
| 194 | + if (startSendRtpStreamResult != null) { | |
| 195 | + startSendRtpStreamHand(evt, sendRtpItem, parentPlatform, startSendRtpStreamResult, param, callIdHeader); | |
| 196 | + } | |
| 182 | 197 | } |
| 183 | 198 | |
| 184 | 199 | |
| ... | ... | @@ -192,7 +207,7 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In |
| 192 | 207 | logger.info("调用ZLM推流接口, 结果: {}", jsonObject); |
| 193 | 208 | logger.info("RTP推流成功[ {}/{} ],{}->{}:{}, " ,param.get("app"), param.get("stream"), jsonObject.getString("local_port"), param.get("dst_url"), param.get("dst_port")); |
| 194 | 209 | } else { |
| 195 | - logger.error("RTP推流失败: {}, 参数:{}",jsonObject.getString("msg"),JSONObject.toJSON(param)); | |
| 210 | + logger.error("RTP推流失败: {}, 参数:{}",jsonObject.getString("msg"), JSON.toJSONString(param)); | |
| 196 | 211 | if (sendRtpItem.isOnlyAudio()) { |
| 197 | 212 | // TODO 可能是语音对讲 |
| 198 | 213 | }else { | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java
| ... | ... | @@ -17,6 +17,7 @@ import com.genersoft.iot.vmp.service.IPlayService; |
| 17 | 17 | import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; |
| 18 | 18 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 19 | 19 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 20 | +import gov.nist.javax.sip.message.SIPRequest; | |
| 20 | 21 | import org.slf4j.Logger; |
| 21 | 22 | import org.slf4j.LoggerFactory; |
| 22 | 23 | import org.springframework.beans.factory.InitializingBean; |
| ... | ... | @@ -87,7 +88,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In |
| 87 | 88 | public void process(RequestEvent evt) { |
| 88 | 89 | |
| 89 | 90 | try { |
| 90 | - responseAck(getServerTransaction(evt), Response.OK); | |
| 91 | + responseAck((SIPRequest) evt.getRequest(), Response.OK); | |
| 91 | 92 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 92 | 93 | logger.error("[回复BYE信息失败],{}", e.getMessage()); |
| 93 | 94 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| 5 | 5 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 6 | 6 | import com.genersoft.iot.vmp.conf.UserSetting; |
| ... | ... | @@ -15,13 +15,15 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; |
| 15 | 15 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; |
| 16 | 16 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| 17 | 17 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; |
| 18 | +import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; | |
| 19 | +import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; | |
| 18 | 20 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; |
| 19 | 21 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| 20 | 22 | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; |
| 21 | -import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; | |
| 22 | 23 | import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager; |
| 23 | 24 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| 24 | 25 | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; |
| 26 | +import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; | |
| 25 | 27 | import com.genersoft.iot.vmp.media.zlm.dto.*; |
| 26 | 28 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 27 | 29 | import com.genersoft.iot.vmp.service.IMediaService; |
| ... | ... | @@ -48,12 +50,14 @@ import org.springframework.beans.factory.annotation.Autowired; |
| 48 | 50 | import org.springframework.stereotype.Component; |
| 49 | 51 | |
| 50 | 52 | import javax.sdp.*; |
| 51 | -import javax.sip.*; | |
| 53 | +import javax.sip.InvalidArgumentException; | |
| 54 | +import javax.sip.RequestEvent; | |
| 55 | +import javax.sip.SipException; | |
| 52 | 56 | import javax.sip.header.CallIdHeader; |
| 53 | -import javax.sip.message.Request; | |
| 54 | 57 | import javax.sip.message.Response; |
| 55 | 58 | import java.text.ParseException; |
| 56 | 59 | import java.time.Instant; |
| 60 | +import java.util.Random; | |
| 57 | 61 | import java.util.Vector; |
| 58 | 62 | |
| 59 | 63 | /** |
| ... | ... | @@ -92,7 +96,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 92 | 96 | private IPlayService playService; |
| 93 | 97 | |
| 94 | 98 | @Autowired |
| 95 | - private ISIPCommander commander; | |
| 99 | + private SIPSender sipSender; | |
| 96 | 100 | |
| 97 | 101 | @Autowired |
| 98 | 102 | private AudioBroadcastManager audioBroadcastManager; |
| ... | ... | @@ -154,16 +158,15 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 154 | 158 | public void process(RequestEvent evt) { |
| 155 | 159 | // Invite Request消息实现,此消息一般为级联消息,上级给下级发送请求视频指令 |
| 156 | 160 | try { |
| 157 | - Request request = evt.getRequest(); | |
| 161 | + SIPRequest request = (SIPRequest)evt.getRequest(); | |
| 158 | 162 | String channelId = SipUtils.getChannelIdFromRequest(request); |
| 159 | 163 | String requesterId = SipUtils.getUserIdFromFromHeader(request); |
| 160 | 164 | CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME); |
| 161 | - ServerTransaction serverTransaction = getServerTransaction(evt); | |
| 162 | - if (requesterId == null) { | |
| 163 | - logger.info("无法从FromHeader的Address中获取到平台/设备id,返回400"); | |
| 165 | + if (requesterId == null || channelId == null) { | |
| 166 | + logger.info("无法从FromHeader的Address中获取到平台id,返回400"); | |
| 164 | 167 | // 参数不全, 发400,请求错误 |
| 165 | 168 | try { |
| 166 | - responseAck(serverTransaction, Response.BAD_REQUEST); | |
| 169 | + responseAck(request, Response.BAD_REQUEST); | |
| 167 | 170 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 168 | 171 | logger.error("[命令发送失败] invite BAD_REQUEST: {}", e.getMessage()); |
| 169 | 172 | } |
| ... | ... | @@ -195,7 +198,8 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 195 | 198 | // 查询请求是否来自上级平台\设备 |
| 196 | 199 | ParentPlatform platform = storager.queryParentPlatByServerGBId(requesterId); |
| 197 | 200 | if (platform == null) { |
| 198 | - inviteFromDeviceHandle(serverTransaction, requesterId, channelId); | |
| 201 | + inviteFromDeviceHandle(request, requesterId, channelId); | |
| 202 | + | |
| 199 | 203 | } else { |
| 200 | 204 | // 查询平台下是否有该通道 |
| 201 | 205 | DeviceChannel channel = storager.queryChannelInParentPlatform(requesterId, channelId); |
| ... | ... | @@ -207,14 +211,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 207 | 211 | StreamProxyItem proxyByAppAndStream =null; |
| 208 | 212 | // 不是通道可能是直播流 |
| 209 | 213 | if (channel != null && gbStream == null) { |
| 210 | -// if (channel.getStatus() == 0) { | |
| 211 | -// logger.info("通道离线,返回400"); | |
| 212 | -// responseAck(serverTransaction, Response.BAD_REQUEST, "channel [" + channel.getChannelId() + "] offline"); | |
| 213 | -// return; | |
| 214 | -// } | |
| 215 | 214 | // 通道存在,发100,TRYING |
| 216 | 215 | try { |
| 217 | - responseAck(serverTransaction, Response.TRYING); | |
| 216 | + responseAck(request, Response.TRYING); | |
| 218 | 217 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 219 | 218 | logger.error("[命令发送失败] invite TRYING: {}", e.getMessage()); |
| 220 | 219 | } |
| ... | ... | @@ -226,7 +225,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 226 | 225 | if ("proxy".equals(gbStream.getStreamType())) { |
| 227 | 226 | logger.info("[ app={}, stream={} ]找不到zlm {},返回410", gbStream.getApp(), gbStream.getStream(), mediaServerId); |
| 228 | 227 | try { |
| 229 | - responseAck(serverTransaction, Response.GONE); | |
| 228 | + responseAck(request, Response.GONE); | |
| 230 | 229 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 231 | 230 | logger.error("[命令发送失败] invite GONE: {}", e.getMessage()); |
| 232 | 231 | } |
| ... | ... | @@ -236,7 +235,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 236 | 235 | if (streamPushItem == null || streamPushItem.getServerId().equals(userSetting.getServerId())) { |
| 237 | 236 | logger.info("[ app={}, stream={} ]找不到zlm {},返回410", gbStream.getApp(), gbStream.getStream(), mediaServerId); |
| 238 | 237 | try { |
| 239 | - responseAck(serverTransaction, Response.GONE); | |
| 238 | + responseAck(request, Response.GONE); | |
| 240 | 239 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 241 | 240 | logger.error("[命令发送失败] invite GONE: {}", e.getMessage()); |
| 242 | 241 | } |
| ... | ... | @@ -249,7 +248,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 249 | 248 | if (streamPushItem == null) { |
| 250 | 249 | logger.info("[ app={}, stream={} ]找不到zlm {},返回410", gbStream.getApp(), gbStream.getStream(), mediaServerId); |
| 251 | 250 | try { |
| 252 | - responseAck(serverTransaction, Response.GONE); | |
| 251 | + responseAck(request, Response.GONE); | |
| 253 | 252 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 254 | 253 | logger.error("[命令发送失败] invite GONE: {}", e.getMessage()); |
| 255 | 254 | } |
| ... | ... | @@ -260,7 +259,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 260 | 259 | if (proxyByAppAndStream == null) { |
| 261 | 260 | logger.info("[ app={}, stream={} ]找不到zlm {},返回410", gbStream.getApp(), gbStream.getStream(), mediaServerId); |
| 262 | 261 | try { |
| 263 | - responseAck(serverTransaction, Response.GONE); | |
| 262 | + responseAck(request, Response.GONE); | |
| 264 | 263 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 265 | 264 | logger.error("[命令发送失败] invite GONE: {}", e.getMessage()); |
| 266 | 265 | } |
| ... | ... | @@ -269,14 +268,14 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 269 | 268 | } |
| 270 | 269 | } |
| 271 | 270 | try { |
| 272 | - responseAck(serverTransaction, Response.CALL_IS_BEING_FORWARDED); | |
| 271 | + responseAck(request, Response.CALL_IS_BEING_FORWARDED); | |
| 273 | 272 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 274 | 273 | logger.error("[命令发送失败] invite CALL_IS_BEING_FORWARDED: {}", e.getMessage()); |
| 275 | 274 | } |
| 276 | 275 | } else if (catalog != null) { |
| 277 | 276 | try { |
| 278 | 277 | // 目录不支持点播 |
| 279 | - responseAck(serverTransaction, Response.BAD_REQUEST, "catalog channel can not play"); | |
| 278 | + responseAck(request, Response.BAD_REQUEST, "catalog channel can not play"); | |
| 280 | 279 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 281 | 280 | logger.error("[命令发送失败] invite 目录不支持点播: {}", e.getMessage()); |
| 282 | 281 | } |
| ... | ... | @@ -285,7 +284,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 285 | 284 | logger.info("通道不存在,返回404"); |
| 286 | 285 | try { |
| 287 | 286 | // 通道不存在,发404,资源不存在 |
| 288 | - responseAck(serverTransaction, Response.NOT_FOUND); | |
| 287 | + responseAck(request, Response.NOT_FOUND); | |
| 289 | 288 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 290 | 289 | logger.error("[命令发送失败] invite 通道不存在: {}", e.getMessage()); |
| 291 | 290 | } |
| ... | ... | @@ -360,7 +359,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 360 | 359 | // 回复不支持的格式 |
| 361 | 360 | try { |
| 362 | 361 | // 不支持的格式,发415 |
| 363 | - responseAck(serverTransaction, Response.UNSUPPORTED_MEDIA_TYPE); | |
| 362 | + responseAck(request, Response.UNSUPPORTED_MEDIA_TYPE); | |
| 364 | 363 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 365 | 364 | logger.error("[命令发送失败] invite 不支持的格式: {}", e.getMessage()); |
| 366 | 365 | } |
| ... | ... | @@ -377,7 +376,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 377 | 376 | if (device == null) { |
| 378 | 377 | logger.warn("点播平台{}的通道{}时未找到设备信息", requesterId, channel); |
| 379 | 378 | try { |
| 380 | - responseAck(serverTransaction, Response.SERVER_INTERNAL_ERROR); | |
| 379 | + responseAck(request, Response.SERVER_INTERNAL_ERROR); | |
| 381 | 380 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 382 | 381 | logger.error("[命令发送失败] invite 未找到设备信息: {}", e.getMessage()); |
| 383 | 382 | } |
| ... | ... | @@ -387,7 +386,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 387 | 386 | if (mediaServerItem == null) { |
| 388 | 387 | logger.warn("未找到可用的zlm"); |
| 389 | 388 | try { |
| 390 | - responseAck(serverTransaction, Response.BUSY_HERE); | |
| 389 | + responseAck(request, Response.BUSY_HERE); | |
| 391 | 390 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 392 | 391 | logger.error("[命令发送失败] invite BUSY_HERE: {}", e.getMessage()); |
| 393 | 392 | } |
| ... | ... | @@ -403,7 +402,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 403 | 402 | if (sendRtpItem == null) { |
| 404 | 403 | logger.warn("服务器端口资源不足"); |
| 405 | 404 | try { |
| 406 | - responseAck(serverTransaction, Response.BUSY_HERE); | |
| 405 | + responseAck(request, Response.BUSY_HERE); | |
| 407 | 406 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 408 | 407 | logger.error("[命令发送失败] invite 服务器端口资源不足: {}", e.getMessage()); |
| 409 | 408 | } |
| ... | ... | @@ -435,7 +434,12 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 435 | 434 | } else { |
| 436 | 435 | content.append("t=0 0\r\n"); |
| 437 | 436 | } |
| 438 | - content.append("m=video " + sendRtpItem.getLocalPort() + " RTP/AVP 96\r\n"); | |
| 437 | + int localPort = sendRtpItem.getLocalPort(); | |
| 438 | + if (localPort == 0) { | |
| 439 | + // 非严格模式端口不统一, 增加兼容性,修改为一个不为0的端口 | |
| 440 | + localPort = new Random().nextInt(65535) + 1; | |
| 441 | + } | |
| 442 | + content.append("m=video " + localPort + " RTP/AVP 96\r\n"); | |
| 439 | 443 | content.append("a=sendonly\r\n"); |
| 440 | 444 | content.append("a=rtpmap:96 PS/90000\r\n"); |
| 441 | 445 | content.append("y=" + sendRtpItem.getSsrc() + "\r\n"); |
| ... | ... | @@ -453,7 +457,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 453 | 457 | logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); |
| 454 | 458 | } |
| 455 | 459 | }, 60 * 1000); |
| 456 | - responseSdpAck(serverTransaction, content.toString(), platform); | |
| 460 | + responseSdpAck(request, content.toString(), platform); | |
| 457 | 461 | |
| 458 | 462 | } catch (SipException e) { |
| 459 | 463 | e.printStackTrace(); |
| ... | ... | @@ -467,21 +471,15 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 467 | 471 | // 未知错误。直接转发设备点播的错误 |
| 468 | 472 | try { |
| 469 | 473 | Response response = getMessageFactory().createResponse(event.statusCode, evt.getRequest()); |
| 470 | - serverTransaction.sendResponse(response); | |
| 471 | - System.out.println("未知错误。直接转发设备点播的错误"); | |
| 472 | - if (serverTransaction.getDialog() != null) { | |
| 473 | - serverTransaction.getDialog().delete(); | |
| 474 | - } | |
| 475 | - serverTransaction.getDialog().delete(); | |
| 476 | - | |
| 477 | - } catch (ParseException | SipException | InvalidArgumentException e) { | |
| 474 | + sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); | |
| 475 | + } catch (ParseException | SipException e) { | |
| 478 | 476 | e.printStackTrace(); |
| 479 | 477 | } |
| 480 | 478 | }); |
| 481 | 479 | sendRtpItem.setApp("rtp"); |
| 482 | 480 | if ("Playback".equalsIgnoreCase(sessionName)) { |
| 483 | 481 | sendRtpItem.setPlayType(InviteStreamType.PLAYBACK); |
| 484 | - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, true, true); | |
| 482 | + SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, device.isSsrcCheck(), true); | |
| 485 | 483 | sendRtpItem.setStreamId(ssrcInfo.getStream()); |
| 486 | 484 | // 写入redis, 超时时回复 |
| 487 | 485 | redisCatchStorage.updateSendRTPSever(sendRtpItem); |
| ... | ... | @@ -494,13 +492,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 494 | 492 | } |
| 495 | 493 | redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), finalChannelId, callIdHeader.getCallId(), null); |
| 496 | 494 | try { |
| 497 | - responseAck(serverTransaction, Response.REQUEST_TIMEOUT); | |
| 498 | - } catch (SipException e) { | |
| 499 | - e.printStackTrace(); | |
| 500 | - } catch (InvalidArgumentException e) { | |
| 501 | - e.printStackTrace(); | |
| 502 | - } catch (ParseException e) { | |
| 503 | - e.printStackTrace(); | |
| 495 | + responseAck(request, Response.REQUEST_TIMEOUT); | |
| 496 | + } catch (SipException | InvalidArgumentException | ParseException e) { | |
| 497 | + logger.error("[命令发送失败] 国标级联 录像回放 发送REQUEST_TIMEOUT: {}", e.getMessage()); | |
| 504 | 498 | } |
| 505 | 499 | } else { |
| 506 | 500 | if (result.getMediaServerItem() != null) { |
| ... | ... | @@ -536,10 +530,11 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 536 | 530 | |
| 537 | 531 | // 写入redis, 超时时回复 |
| 538 | 532 | redisCatchStorage.updateSendRTPSever(sendRtpItem); |
| 533 | + MediaServerItem finalMediaServerItem = mediaServerItem; | |
| 539 | 534 | playService.play(mediaServerItem, ssrcInfo, device, channelId, hookEvent, errorEvent, (code, msg) -> { |
| 540 | - logger.info("[上级点播]超时, 用户:{}, 通道:{}", username, finalChannelId); | |
| 541 | - redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), finalChannelId, callIdHeader.getCallId(), null); | |
| 542 | - }, null); | |
| 535 | + logger.info("[上级点播]超时, 用户:{}, 通道:{}", username, channelId); | |
| 536 | + redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null); | |
| 537 | + }); | |
| 543 | 538 | } else { |
| 544 | 539 | sendRtpItem.setStreamId(playTransaction.getStream()); |
| 545 | 540 | // 写入redis, 超时时回复 |
| ... | ... | @@ -554,30 +549,26 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 554 | 549 | if("push".equals(gbStream.getStreamType())) { |
| 555 | 550 | if (streamPushItem != null && streamPushItem.isPushIng()) { |
| 556 | 551 | // 推流状态 |
| 557 | - pushStream(evt, serverTransaction, gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 552 | + pushStream(evt, request, gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 558 | 553 | mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); |
| 559 | 554 | } else { |
| 560 | 555 | // 未推流 拉起 |
| 561 | - notifyStreamOnline(evt, serverTransaction,gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 556 | + notifyStreamOnline(evt, request,gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 562 | 557 | mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); |
| 563 | 558 | } |
| 564 | 559 | }else if ("proxy".equals(gbStream.getStreamType())){ |
| 565 | - if(null != proxyByAppAndStream &&proxyByAppAndStream.isStatus()){ | |
| 566 | - pushProxyStream(evt, serverTransaction, gbStream, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 567 | - mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); | |
| 568 | - }else{ | |
| 569 | - //开启代理拉流 | |
| 570 | - boolean start1 = streamProxyService.start(gbStream.getApp(), gbStream.getStream()); | |
| 571 | - if(start1) { | |
| 572 | - pushProxyStream(evt, serverTransaction, gbStream, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 560 | + if (null != proxyByAppAndStream) { | |
| 561 | + if(proxyByAppAndStream.isStatus()){ | |
| 562 | + pushProxyStream(evt, request, gbStream, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 573 | 563 | mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); |
| 574 | 564 | }else{ |
| 575 | - //失败后通知 | |
| 576 | - notifyStreamOnline(evt, serverTransaction,gbStream, null, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 565 | + //开启代理拉流 | |
| 566 | + notifyStreamOnline(evt, request,gbStream, null, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 577 | 567 | mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); |
| 578 | 568 | } |
| 579 | 569 | } |
| 580 | 570 | |
| 571 | + | |
| 581 | 572 | } |
| 582 | 573 | } |
| 583 | 574 | } |
| ... | ... | @@ -591,7 +582,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 591 | 582 | /** |
| 592 | 583 | * 安排推流 |
| 593 | 584 | */ |
| 594 | - private void pushProxyStream(RequestEvent evt, ServerTransaction serverTransaction, GbStream gbStream, ParentPlatform platform, | |
| 585 | + private void pushProxyStream(RequestEvent evt, SIPRequest request, GbStream gbStream, ParentPlatform platform, | |
| 595 | 586 | CallIdHeader callIdHeader, MediaServerItem mediaServerItem, |
| 596 | 587 | int port, Boolean tcpActive, boolean mediaTransmissionTCP, |
| 597 | 588 | String channelId, String addressStr, String ssrc, String requesterId) { |
| ... | ... | @@ -605,7 +596,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 605 | 596 | if (sendRtpItem == null) { |
| 606 | 597 | logger.warn("服务器端口资源不足"); |
| 607 | 598 | try { |
| 608 | - responseAck(serverTransaction, Response.BUSY_HERE); | |
| 599 | + responseAck(request, Response.BUSY_HERE); | |
| 609 | 600 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 610 | 601 | logger.error("[命令发送失败] invite 服务器端口资源不足: {}", e.getMessage()); |
| 611 | 602 | } |
| ... | ... | @@ -618,10 +609,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 618 | 609 | // 写入redis, 超时时回复 |
| 619 | 610 | sendRtpItem.setStatus(1); |
| 620 | 611 | sendRtpItem.setCallId(callIdHeader.getCallId()); |
| 621 | - SIPRequest request = (SIPRequest) evt.getRequest(); | |
| 622 | 612 | sendRtpItem.setFromTag(request.getFromTag()); |
| 623 | 613 | |
| 624 | - SIPResponse response = sendStreamAck(mediaServerItem, serverTransaction, sendRtpItem, platform, evt); | |
| 614 | + SIPResponse response = sendStreamAck(mediaServerItem, request, sendRtpItem, platform, evt); | |
| 625 | 615 | if (response != null) { |
| 626 | 616 | sendRtpItem.setToTag(response.getToTag()); |
| 627 | 617 | } |
| ... | ... | @@ -630,7 +620,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 630 | 620 | } |
| 631 | 621 | |
| 632 | 622 | } |
| 633 | - private void pushStream(RequestEvent evt, ServerTransaction serverTransaction, GbStream gbStream, StreamPushItem streamPushItem, ParentPlatform platform, | |
| 623 | + private void pushStream(RequestEvent evt, SIPRequest request, GbStream gbStream, StreamPushItem streamPushItem, ParentPlatform platform, | |
| 634 | 624 | CallIdHeader callIdHeader, MediaServerItem mediaServerItem, |
| 635 | 625 | int port, Boolean tcpActive, boolean mediaTransmissionTCP, |
| 636 | 626 | String channelId, String addressStr, String ssrc, String requesterId) { |
| ... | ... | @@ -646,7 +636,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 646 | 636 | if (sendRtpItem == null) { |
| 647 | 637 | logger.warn("服务器端口资源不足"); |
| 648 | 638 | try { |
| 649 | - responseAck(serverTransaction, Response.BUSY_HERE); | |
| 639 | + responseAck(request, Response.BUSY_HERE); | |
| 650 | 640 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 651 | 641 | logger.error("[命令发送失败] invite 服务器端口资源不足: {}", e.getMessage()); |
| 652 | 642 | } |
| ... | ... | @@ -660,9 +650,8 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 660 | 650 | sendRtpItem.setStatus(1); |
| 661 | 651 | sendRtpItem.setCallId(callIdHeader.getCallId()); |
| 662 | 652 | |
| 663 | - SIPRequest request = (SIPRequest) evt.getRequest(); | |
| 664 | 653 | sendRtpItem.setFromTag(request.getFromTag()); |
| 665 | - SIPResponse response = sendStreamAck(mediaServerItem, serverTransaction, sendRtpItem, platform, evt); | |
| 654 | + SIPResponse response = sendStreamAck(mediaServerItem, request, sendRtpItem, platform, evt); | |
| 666 | 655 | if (response != null) { |
| 667 | 656 | sendRtpItem.setToTag(response.getToTag()); |
| 668 | 657 | } |
| ... | ... | @@ -671,36 +660,59 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 671 | 660 | |
| 672 | 661 | } else { |
| 673 | 662 | // 不在线 拉起 |
| 674 | - notifyStreamOnline(evt, serverTransaction,gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 663 | + notifyStreamOnline(evt, request,gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 675 | 664 | mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); |
| 676 | 665 | } |
| 677 | 666 | |
| 678 | 667 | } else { |
| 679 | 668 | // 其他平台内容 |
| 680 | - otherWvpPushStream(evt, serverTransaction, gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 669 | + otherWvpPushStream(evt, request, gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 681 | 670 | mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); |
| 682 | 671 | } |
| 683 | 672 | } |
| 684 | 673 | /** |
| 685 | 674 | * 通知流上线 |
| 686 | 675 | */ |
| 687 | - private void notifyStreamOnline(RequestEvent evt, ServerTransaction serverTransaction, GbStream gbStream, StreamPushItem streamPushItem, ParentPlatform platform, | |
| 676 | + private void notifyStreamOnline(RequestEvent evt, SIPRequest request, GbStream gbStream, StreamPushItem streamPushItem, ParentPlatform platform, | |
| 688 | 677 | CallIdHeader callIdHeader, MediaServerItem mediaServerItem, |
| 689 | 678 | int port, Boolean tcpActive, boolean mediaTransmissionTCP, |
| 690 | 679 | String channelId, String addressStr, String ssrc, String requesterId) { |
| 691 | 680 | if ("proxy".equals(gbStream.getStreamType())) { |
| 692 | 681 | // TODO 控制启用以使设备上线 |
| 693 | 682 | logger.info("[ app={}, stream={} ]通道未推流,启用流后开始推流", gbStream.getApp(), gbStream.getStream()); |
| 694 | - try { | |
| 695 | - responseAck(serverTransaction, Response.BAD_REQUEST, "channel [" + gbStream.getGbId() + "] offline"); | |
| 696 | - } catch (SipException | InvalidArgumentException | ParseException e) { | |
| 697 | - logger.error("[命令发送失败] invite 通道未推流: {}", e.getMessage()); | |
| 683 | + // 监听流上线 | |
| 684 | + HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed(gbStream.getApp(), gbStream.getStream(), true, "rtsp", mediaServerItem.getId()); | |
| 685 | + zlmHttpHookSubscribe.addSubscribe(hookSubscribe, (mediaServerItemInUSe, responseJSON) -> { | |
| 686 | + String app = responseJSON.getString("app"); | |
| 687 | + String stream = responseJSON.getString("stream"); | |
| 688 | + logger.info("[上级点播]拉流代理已经就绪, {}/{}", app, stream); | |
| 689 | + dynamicTask.stop(callIdHeader.getCallId()); | |
| 690 | + pushProxyStream(evt, request, gbStream, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 691 | + mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); | |
| 692 | + }); | |
| 693 | + dynamicTask.startDelay(callIdHeader.getCallId(), () -> { | |
| 694 | + logger.info("[ app={}, stream={} ] 等待拉流代理流超时", gbStream.getApp(), gbStream.getStream()); | |
| 695 | + zlmHttpHookSubscribe.removeSubscribe(hookSubscribe); | |
| 696 | + }, userSetting.getPlatformPlayTimeout()); | |
| 697 | + boolean start = streamProxyService.start(gbStream.getApp(), gbStream.getStream()); | |
| 698 | + if (!start) { | |
| 699 | + try { | |
| 700 | + responseAck(request, Response.BUSY_HERE, "channel [" + gbStream.getGbId() + "] offline"); | |
| 701 | + } catch (SipException | InvalidArgumentException | ParseException e) { | |
| 702 | + logger.error("[命令发送失败] invite 通道未推流: {}", e.getMessage()); | |
| 703 | + } | |
| 704 | + zlmHttpHookSubscribe.removeSubscribe(hookSubscribe); | |
| 705 | + dynamicTask.stop(callIdHeader.getCallId()); | |
| 698 | 706 | } |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 699 | 710 | } else if ("push".equals(gbStream.getStreamType())) { |
| 700 | 711 | if (!platform.isStartOfflinePush()) { |
| 701 | 712 | // 平台设置中关闭了拉起离线的推流则直接回复 |
| 702 | 713 | try { |
| 703 | - responseAck(serverTransaction, Response.TEMPORARILY_UNAVAILABLE, "channel stream not pushing"); | |
| 714 | + logger.info("[上级点播] 失败,推流设备未推流,channel: {}, app: {}, stream: {}", gbStream.getGbId(), gbStream.getApp(), gbStream.getStream()); | |
| 715 | + responseAck(request, Response.TEMPORARILY_UNAVAILABLE, "channel stream not pushing"); | |
| 704 | 716 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 705 | 717 | logger.error("[命令发送失败] invite 通道未推流: {}", e.getMessage()); |
| 706 | 718 | } |
| ... | ... | @@ -718,7 +730,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 718 | 730 | logger.info("[ app={}, stream={} ] 等待设备开始推流超时", gbStream.getApp(), gbStream.getStream()); |
| 719 | 731 | try { |
| 720 | 732 | mediaListManager.removedChannelOnlineEventLister(gbStream.getApp(), gbStream.getStream()); |
| 721 | - responseAck(serverTransaction, Response.REQUEST_TIMEOUT); // 超时 | |
| 733 | + responseAck(request, Response.REQUEST_TIMEOUT); // 超时 | |
| 722 | 734 | } catch (SipException e) { |
| 723 | 735 | e.printStackTrace(); |
| 724 | 736 | } catch (InvalidArgumentException e) { |
| ... | ... | @@ -741,7 +753,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 741 | 753 | if (sendRtpItem == null) { |
| 742 | 754 | logger.warn("上级点时创建sendRTPItem失败,可能是服务器端口资源不足"); |
| 743 | 755 | try { |
| 744 | - responseAck(serverTransaction, Response.BUSY_HERE); | |
| 756 | + responseAck(request, Response.BUSY_HERE); | |
| 745 | 757 | } catch (SipException e) { |
| 746 | 758 | e.printStackTrace(); |
| 747 | 759 | } catch (InvalidArgumentException e) { |
| ... | ... | @@ -759,16 +771,15 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 759 | 771 | sendRtpItem.setStatus(1); |
| 760 | 772 | sendRtpItem.setCallId(callIdHeader.getCallId()); |
| 761 | 773 | |
| 762 | - SIPRequest request = (SIPRequest) evt.getRequest(); | |
| 763 | 774 | sendRtpItem.setFromTag(request.getFromTag()); |
| 764 | - SIPResponse response = sendStreamAck(mediaServerItem, serverTransaction, sendRtpItem, platform, evt); | |
| 775 | + SIPResponse response = sendStreamAck(mediaServerItem, request, sendRtpItem, platform, evt); | |
| 765 | 776 | if (response != null) { |
| 766 | 777 | sendRtpItem.setToTag(response.getToTag()); |
| 767 | 778 | } |
| 768 | 779 | redisCatchStorage.updateSendRTPSever(sendRtpItem); |
| 769 | 780 | } else { |
| 770 | 781 | // 其他平台内容 |
| 771 | - otherWvpPushStream(evt, serverTransaction, gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 782 | + otherWvpPushStream(evt, request, gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 772 | 783 | mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); |
| 773 | 784 | } |
| 774 | 785 | }); |
| ... | ... | @@ -779,7 +790,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 779 | 790 | dynamicTask.stop(callIdHeader.getCallId()); |
| 780 | 791 | mediaListManager.removedChannelOnlineEventLister(gbStream.getApp(), gbStream.getStream()); |
| 781 | 792 | try { |
| 782 | - responseAck(serverTransaction, Response.TEMPORARILY_UNAVAILABLE, response.getMsg()); | |
| 793 | + responseAck(request, Response.TEMPORARILY_UNAVAILABLE, response.getMsg()); | |
| 783 | 794 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 784 | 795 | logger.error("[命令发送失败] 国标级联 点播回复: {}", e.getMessage()); |
| 785 | 796 | } |
| ... | ... | @@ -791,7 +802,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 791 | 802 | /** |
| 792 | 803 | * 来自其他wvp的推流 |
| 793 | 804 | */ |
| 794 | - private void otherWvpPushStream(RequestEvent evt, ServerTransaction serverTransaction, GbStream gbStream, StreamPushItem streamPushItem, ParentPlatform platform, | |
| 805 | + private void otherWvpPushStream(RequestEvent evt, SIPRequest request, GbStream gbStream, StreamPushItem streamPushItem, ParentPlatform platform, | |
| 795 | 806 | CallIdHeader callIdHeader, MediaServerItem mediaServerItem, |
| 796 | 807 | int port, Boolean tcpActive, boolean mediaTransmissionTCP, |
| 797 | 808 | String channelId, String addressStr, String ssrc, String requesterId) { |
| ... | ... | @@ -804,7 +815,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 804 | 815 | if (sendRtpItem == null || responseSendItemMsg.getMediaServerItem() == null) { |
| 805 | 816 | logger.warn("服务器端口资源不足"); |
| 806 | 817 | try { |
| 807 | - responseAck(serverTransaction, Response.BUSY_HERE); | |
| 818 | + responseAck(request, Response.BUSY_HERE); | |
| 808 | 819 | } catch (SipException e) { |
| 809 | 820 | e.printStackTrace(); |
| 810 | 821 | } catch (InvalidArgumentException e) { |
| ... | ... | @@ -823,9 +834,8 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 823 | 834 | sendRtpItem.setStatus(1); |
| 824 | 835 | sendRtpItem.setCallId(callIdHeader.getCallId()); |
| 825 | 836 | |
| 826 | - SIPRequest request = (SIPRequest) evt.getRequest(); | |
| 827 | 837 | sendRtpItem.setFromTag(request.getFromTag()); |
| 828 | - SIPResponse response = sendStreamAck(responseSendItemMsg.getMediaServerItem(), serverTransaction,sendRtpItem, platform, evt); | |
| 838 | + SIPResponse response = sendStreamAck(responseSendItemMsg.getMediaServerItem(), request,sendRtpItem, platform, evt); | |
| 829 | 839 | if (response != null) { |
| 830 | 840 | sendRtpItem.setToTag(response.getToTag()); |
| 831 | 841 | } |
| ... | ... | @@ -839,24 +849,24 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 839 | 849 | StreamPushItem currentStreamPushItem = streamPushService.getPush(streamPushItem.getApp(), streamPushItem.getStream()); |
| 840 | 850 | if (currentStreamPushItem.isPushIng()) { |
| 841 | 851 | // 在线状态 |
| 842 | - pushStream(evt, serverTransaction, gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 852 | + pushStream(evt, request, gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 843 | 853 | mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); |
| 844 | 854 | |
| 845 | 855 | } else { |
| 846 | 856 | // 不在线 拉起 |
| 847 | - notifyStreamOnline(evt, serverTransaction, gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 857 | + notifyStreamOnline(evt, request, gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, | |
| 848 | 858 | mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); |
| 849 | 859 | } |
| 850 | 860 | } |
| 851 | 861 | try { |
| 852 | - responseAck(serverTransaction, Response.BUSY_HERE); | |
| 862 | + responseAck(request, Response.BUSY_HERE); | |
| 853 | 863 | } catch (InvalidArgumentException | ParseException | SipException e) { |
| 854 | 864 | logger.error("[命令发送失败] 国标级联 点播回复 BUSY_HERE: {}", e.getMessage()); |
| 855 | 865 | } |
| 856 | 866 | }); |
| 857 | 867 | } |
| 858 | 868 | |
| 859 | - public SIPResponse sendStreamAck(MediaServerItem mediaServerItem, ServerTransaction serverTransaction, SendRtpItem sendRtpItem, ParentPlatform platform, RequestEvent evt) { | |
| 869 | + public SIPResponse sendStreamAck(MediaServerItem mediaServerItem, SIPRequest request, SendRtpItem sendRtpItem, ParentPlatform platform, RequestEvent evt) { | |
| 860 | 870 | |
| 861 | 871 | StringBuffer content = new StringBuffer(200); |
| 862 | 872 | content.append("v=0\r\n"); |
| ... | ... | @@ -879,7 +889,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 879 | 889 | content.append("f=\r\n"); |
| 880 | 890 | |
| 881 | 891 | try { |
| 882 | - return responseSdpAck(serverTransaction, content.toString(), platform); | |
| 892 | + return responseSdpAck(request, content.toString(), platform); | |
| 883 | 893 | } catch (SipException e) { |
| 884 | 894 | e.printStackTrace(); |
| 885 | 895 | } catch (InvalidArgumentException e) { |
| ... | ... | @@ -890,7 +900,8 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 890 | 900 | return null; |
| 891 | 901 | } |
| 892 | 902 | |
| 893 | - public void inviteFromDeviceHandle(ServerTransaction serverTransaction, String requesterId, String channelId) { | |
| 903 | + public void inviteFromDeviceHandle(SIPRequest request, String requesterId, String channelId) { | |
| 904 | + | |
| 894 | 905 | // 非上级平台请求,查询是否设备请求(通常为接收语音广播的设备) |
| 895 | 906 | Device device = redisCatchStorage.getDevice(requesterId); |
| 896 | 907 | AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(requesterId, channelId); |
| ... | ... | @@ -907,11 +918,11 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 907 | 918 | if (device != null) { |
| 908 | 919 | logger.info("收到设备" + requesterId + "的语音广播Invite请求"); |
| 909 | 920 | try { |
| 910 | - responseAck(serverTransaction, Response.TRYING); | |
| 921 | + responseAck(request, Response.TRYING); | |
| 911 | 922 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 912 | 923 | logger.error("[命令发送失败] invite BAD_REQUEST: {}", e.getMessage()); |
| 913 | 924 | } |
| 914 | - String contentString = new String(serverTransaction.getRequest().getRawContent()); | |
| 925 | + String contentString = new String(request.getRawContent()); | |
| 915 | 926 | // jainSip不支持y=字段, 移除移除以解析。 |
| 916 | 927 | String substring = contentString; |
| 917 | 928 | String ssrc = "0000000404"; |
| ... | ... | @@ -961,7 +972,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 961 | 972 | logger.info("不支持的媒体格式,返回415"); |
| 962 | 973 | // 回复不支持的格式 |
| 963 | 974 | try { |
| 964 | - responseAck(serverTransaction, Response.UNSUPPORTED_MEDIA_TYPE); // 不支持的格式,发415 | |
| 975 | + responseAck(request, Response.UNSUPPORTED_MEDIA_TYPE); // 不支持的格式,发415 | |
| 965 | 976 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 966 | 977 | logger.error("[命令发送失败] invite 不支持的媒体格式: {}", e.getMessage()); |
| 967 | 978 | } |
| ... | ... | @@ -1024,7 +1035,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 1024 | 1035 | } else { |
| 1025 | 1036 | logger.warn("来自无效设备/平台的请求"); |
| 1026 | 1037 | try { |
| 1027 | - responseAck(serverTransaction, Response.BAD_REQUEST);; // 不支持的格式,发415 | |
| 1038 | + responseAck(request, Response.BAD_REQUEST);; // 不支持的格式,发415 | |
| 1028 | 1039 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 1029 | 1040 | logger.error("[命令发送失败] invite 来自无效设备/平台的请求, {}", e.getMessage()); |
| 1030 | 1041 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | +import com.alibaba.fastjson2.JSONObject; | |
| 4 | 4 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 5 | 5 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| ... | ... | @@ -19,6 +19,7 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 19 | 19 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 20 | 20 | import com.genersoft.iot.vmp.utils.DateUtil; |
| 21 | 21 | import com.genersoft.iot.vmp.utils.redis.RedisUtil; |
| 22 | +import gov.nist.javax.sip.message.SIPRequest; | |
| 22 | 23 | import org.dom4j.DocumentException; |
| 23 | 24 | import org.dom4j.Element; |
| 24 | 25 | import org.slf4j.Logger; |
| ... | ... | @@ -33,7 +34,6 @@ import org.springframework.util.StringUtils; |
| 33 | 34 | |
| 34 | 35 | import javax.sip.InvalidArgumentException; |
| 35 | 36 | import javax.sip.RequestEvent; |
| 36 | -import javax.sip.ServerTransaction; | |
| 37 | 37 | import javax.sip.SipException; |
| 38 | 38 | import javax.sip.header.FromHeader; |
| 39 | 39 | import javax.sip.message.Response; |
| ... | ... | @@ -92,9 +92,8 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements |
| 92 | 92 | |
| 93 | 93 | @Override |
| 94 | 94 | public void process(RequestEvent evt) { |
| 95 | - ServerTransaction serverTransaction = getServerTransaction(evt); | |
| 96 | 95 | try { |
| 97 | - responseAck(serverTransaction, Response.OK); | |
| 96 | + responseAck((SIPRequest) evt.getRequest(), Response.OK, null, null); | |
| 98 | 97 | }catch (SipException | InvalidArgumentException | ParseException e) { |
| 99 | 98 | e.printStackTrace(); |
| 100 | 99 | } | ... | ... |