Commit d5026897c1855e92191e60545dcfea58c2efdfb6
1 parent
37b1978d
修正回放错误,优化sdp排序,提高设备兼容性
Showing
1 changed file
with
24 additions
and
28 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| @@ -185,11 +185,11 @@ public class SIPCommander implements ISIPCommander { | @@ -185,11 +185,11 @@ public class SIPCommander implements ISIPCommander { | ||
| 185 | /** | 185 | /** |
| 186 | * 云台指令码计算 | 186 | * 云台指令码计算 |
| 187 | * | 187 | * |
| 188 | - * @param cmdCode 指令码 | ||
| 189 | - * @param parameter1 数据1 | ||
| 190 | - * @param parameter2 数据2 | ||
| 191 | - * @param combineCode2 组合码2 | ||
| 192 | - */ | 188 | + * @param cmdCode 指令码 |
| 189 | + * @param parameter1 数据1 | ||
| 190 | + * @param parameter2 数据2 | ||
| 191 | + * @param combineCode2 组合码2 | ||
| 192 | + */ | ||
| 193 | public static String frontEndCmdString(int cmdCode, int parameter1, int parameter2, int combineCode2) { | 193 | public static String frontEndCmdString(int cmdCode, int parameter1, int parameter2, int combineCode2) { |
| 194 | StringBuilder builder = new StringBuilder("A50F01"); | 194 | StringBuilder builder = new StringBuilder("A50F01"); |
| 195 | String strTmp; | 195 | String strTmp; |
| @@ -211,13 +211,13 @@ public class SIPCommander implements ISIPCommander { | @@ -211,13 +211,13 @@ public class SIPCommander implements ISIPCommander { | ||
| 211 | /** | 211 | /** |
| 212 | * 云台控制,支持方向与缩放控制 | 212 | * 云台控制,支持方向与缩放控制 |
| 213 | * | 213 | * |
| 214 | - * @param device 控制设备 | ||
| 215 | - * @param channelId 预览通道 | ||
| 216 | - * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移 | ||
| 217 | - * @param upDown 镜头上移下移 0:停止 1:上移 2:下移 | ||
| 218 | - * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大 | ||
| 219 | - * @param moveSpeed 镜头移动速度 | ||
| 220 | - * @param zoomSpeed 镜头缩放速度 | 214 | + * @param device 控制设备 |
| 215 | + * @param channelId 预览通道 | ||
| 216 | + * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移 | ||
| 217 | + * @param upDown 镜头上移下移 0:停止 1:上移 2:下移 | ||
| 218 | + * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大 | ||
| 219 | + * @param moveSpeed 镜头移动速度 | ||
| 220 | + * @param zoomSpeed 镜头缩放速度 | ||
| 221 | */ | 221 | */ |
| 222 | @Override | 222 | @Override |
| 223 | public boolean ptzCmd(Device device, String channelId, int leftRight, int upDown, int inOut, int moveSpeed, | 223 | public boolean ptzCmd(Device device, String channelId, int leftRight, int upDown, int inOut, int moveSpeed, |
| @@ -333,13 +333,14 @@ public class SIPCommander implements ISIPCommander { | @@ -333,13 +333,14 @@ public class SIPCommander implements ISIPCommander { | ||
| 333 | 333 | ||
| 334 | if (seniorSdp) { | 334 | if (seniorSdp) { |
| 335 | if("TCP-PASSIVE".equals(streamMode)) { | 335 | if("TCP-PASSIVE".equals(streamMode)) { |
| 336 | - content.append("m=video "+ mediaPort +" TCP/RTP/AVP 126 125 99 34 98 97 96\r\n"); | 336 | + content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); |
| 337 | }else if ("TCP-ACTIVE".equals(streamMode)) { | 337 | }else if ("TCP-ACTIVE".equals(streamMode)) { |
| 338 | - content.append("m=video "+ mediaPort +" TCP/RTP/AVP 126 125 99 34 98 97 96\r\n"); | 338 | + content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); |
| 339 | }else if("UDP".equals(streamMode)) { | 339 | }else if("UDP".equals(streamMode)) { |
| 340 | - content.append("m=video "+ mediaPort +" RTP/AVP 126 125 99 34 98 97 96\r\n"); | 340 | + content.append("m=video "+ mediaPort +" RTP/AVP 96 126 125 99 34 98 97\r\n"); |
| 341 | } | 341 | } |
| 342 | content.append("a=recvonly\r\n"); | 342 | content.append("a=recvonly\r\n"); |
| 343 | + content.append("a=rtpmap:96 PS/90000\r\n"); | ||
| 343 | content.append("a=fmtp:126 profile-level-id=42e01e\r\n"); | 344 | content.append("a=fmtp:126 profile-level-id=42e01e\r\n"); |
| 344 | content.append("a=rtpmap:126 H264/90000\r\n"); | 345 | content.append("a=rtpmap:126 H264/90000\r\n"); |
| 345 | content.append("a=rtpmap:125 H264S/90000\r\n"); | 346 | content.append("a=rtpmap:125 H264S/90000\r\n"); |
| @@ -348,7 +349,6 @@ public class SIPCommander implements ISIPCommander { | @@ -348,7 +349,6 @@ public class SIPCommander implements ISIPCommander { | ||
| 348 | content.append("a=fmtp:99 profile-level-id=3\r\n"); | 349 | content.append("a=fmtp:99 profile-level-id=3\r\n"); |
| 349 | content.append("a=rtpmap:98 H264/90000\r\n"); | 350 | content.append("a=rtpmap:98 H264/90000\r\n"); |
| 350 | content.append("a=rtpmap:97 MPEG4/90000\r\n"); | 351 | content.append("a=rtpmap:97 MPEG4/90000\r\n"); |
| 351 | - content.append("a=rtpmap:96 PS/90000\r\n"); | ||
| 352 | if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式 | 352 | if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式 |
| 353 | content.append("a=setup:passive\r\n"); | 353 | content.append("a=setup:passive\r\n"); |
| 354 | content.append("a=connection:new\r\n"); | 354 | content.append("a=connection:new\r\n"); |
| @@ -387,9 +387,6 @@ public class SIPCommander implements ISIPCommander { | @@ -387,9 +387,6 @@ public class SIPCommander implements ISIPCommander { | ||
| 387 | 387 | ||
| 388 | content.append("y="+ssrc+"\r\n");//ssrc | 388 | content.append("y="+ssrc+"\r\n");//ssrc |
| 389 | 389 | ||
| 390 | -// String fromTag = UUID.randomUUID().toString(); | ||
| 391 | -// Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), null, fromTag, null, ssrc); | ||
| 392 | - | ||
| 393 | Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), null, "live", null, ssrc); | 390 | Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), null, "live", null, ssrc); |
| 394 | 391 | ||
| 395 | ClientTransaction transaction = transmitRequest(device, request, errorEvent); | 392 | ClientTransaction transaction = transmitRequest(device, request, errorEvent); |
| @@ -416,12 +413,15 @@ public class SIPCommander implements ISIPCommander { | @@ -416,12 +413,15 @@ public class SIPCommander implements ISIPCommander { | ||
| 416 | try { | 413 | try { |
| 417 | MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); | 414 | MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); |
| 418 | String ssrc = null; | 415 | String ssrc = null; |
| 416 | + String streamId = null; | ||
| 419 | if (rtpEnable) { | 417 | if (rtpEnable) { |
| 420 | ssrc = String.format("gb_playback_%s_%s", device.getDeviceId(), channelId); | 418 | ssrc = String.format("gb_playback_%s_%s", device.getDeviceId(), channelId); |
| 419 | + streamId = ssrc; | ||
| 421 | }else { | 420 | }else { |
| 422 | ssrc = streamSession.createPlayBackSsrc(); | 421 | ssrc = streamSession.createPlayBackSsrc(); |
| 422 | + streamId = String.format("%08x", Integer.parseInt(ssrc)).toUpperCase(); | ||
| 423 | } | 423 | } |
| 424 | - String streamId = String.format("%08x", Integer.parseInt(ssrc)).toUpperCase(); | 424 | + |
| 425 | // 添加订阅 | 425 | // 添加订阅 |
| 426 | JSONObject subscribeKey = new JSONObject(); | 426 | JSONObject subscribeKey = new JSONObject(); |
| 427 | subscribeKey.put("app", "rtp"); | 427 | subscribeKey.put("app", "rtp"); |
| @@ -429,7 +429,6 @@ public class SIPCommander implements ISIPCommander { | @@ -429,7 +429,6 @@ public class SIPCommander implements ISIPCommander { | ||
| 429 | 429 | ||
| 430 | subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, subscribeKey, event); | 430 | subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, subscribeKey, event); |
| 431 | 431 | ||
| 432 | - // | ||
| 433 | StringBuffer content = new StringBuffer(200); | 432 | StringBuffer content = new StringBuffer(200); |
| 434 | content.append("v=0\r\n"); | 433 | content.append("v=0\r\n"); |
| 435 | content.append("o="+sipConfig.getSipId()+" 0 0 IN IP4 "+sipConfig.getSipIp()+"\r\n"); | 434 | content.append("o="+sipConfig.getSipId()+" 0 0 IN IP4 "+sipConfig.getSipIp()+"\r\n"); |
| @@ -449,13 +448,14 @@ public class SIPCommander implements ISIPCommander { | @@ -449,13 +448,14 @@ public class SIPCommander implements ISIPCommander { | ||
| 449 | 448 | ||
| 450 | if (seniorSdp) { | 449 | if (seniorSdp) { |
| 451 | if("TCP-PASSIVE".equals(streamMode)) { | 450 | if("TCP-PASSIVE".equals(streamMode)) { |
| 452 | - content.append("m=video "+ mediaPort +" TCP/RTP/AVP 126 125 99 34 98 97 96\r\n"); | 451 | + content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); |
| 453 | }else if ("TCP-ACTIVE".equals(streamMode)) { | 452 | }else if ("TCP-ACTIVE".equals(streamMode)) { |
| 454 | - content.append("m=video "+ mediaPort +" TCP/RTP/AVP 126 125 99 34 98 97 96\r\n"); | 453 | + content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); |
| 455 | }else if("UDP".equals(streamMode)) { | 454 | }else if("UDP".equals(streamMode)) { |
| 456 | - content.append("m=video "+ mediaPort +" RTP/AVP 126 125 99 34 98 97 96\r\n"); | 455 | + content.append("m=video "+ mediaPort +" RTP/AVP 96 126 125 99 34 98 97\r\n"); |
| 457 | } | 456 | } |
| 458 | content.append("a=recvonly\r\n"); | 457 | content.append("a=recvonly\r\n"); |
| 458 | + content.append("a=rtpmap:96 PS/90000\r\n"); | ||
| 459 | content.append("a=fmtp:126 profile-level-id=42e01e\r\n"); | 459 | content.append("a=fmtp:126 profile-level-id=42e01e\r\n"); |
| 460 | content.append("a=rtpmap:126 H264/90000\r\n"); | 460 | content.append("a=rtpmap:126 H264/90000\r\n"); |
| 461 | content.append("a=rtpmap:125 H264S/90000\r\n"); | 461 | content.append("a=rtpmap:125 H264S/90000\r\n"); |
| @@ -464,7 +464,6 @@ public class SIPCommander implements ISIPCommander { | @@ -464,7 +464,6 @@ public class SIPCommander implements ISIPCommander { | ||
| 464 | content.append("a=fmtp:99 profile-level-id=3\r\n"); | 464 | content.append("a=fmtp:99 profile-level-id=3\r\n"); |
| 465 | content.append("a=rtpmap:98 H264/90000\r\n"); | 465 | content.append("a=rtpmap:98 H264/90000\r\n"); |
| 466 | content.append("a=rtpmap:97 MPEG4/90000\r\n"); | 466 | content.append("a=rtpmap:97 MPEG4/90000\r\n"); |
| 467 | - content.append("a=rtpmap:96 PS/90000\r\n"); | ||
| 468 | if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式 | 467 | if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式 |
| 469 | content.append("a=setup:passive\r\n"); | 468 | content.append("a=setup:passive\r\n"); |
| 470 | content.append("a=connection:new\r\n"); | 469 | content.append("a=connection:new\r\n"); |
| @@ -533,9 +532,6 @@ public class SIPCommander implements ISIPCommander { | @@ -533,9 +532,6 @@ public class SIPCommander implements ISIPCommander { | ||
| 533 | if (dialog == null) { | 532 | if (dialog == null) { |
| 534 | return; | 533 | return; |
| 535 | } | 534 | } |
| 536 | - | ||
| 537 | - | ||
| 538 | - | ||
| 539 | Request byeRequest = dialog.createRequest(Request.BYE); | 535 | Request byeRequest = dialog.createRequest(Request.BYE); |
| 540 | SipURI byeURI = (SipURI) byeRequest.getRequestURI(); | 536 | SipURI byeURI = (SipURI) byeRequest.getRequestURI(); |
| 541 | String vh = transaction.getRequest().getHeader(ViaHeader.NAME).toString(); | 537 | String vh = transaction.getRequest().getHeader(ViaHeader.NAME).toString(); |