Commit d5026897c1855e92191e60545dcfea58c2efdfb6

Authored by Lawrence
1 parent 37b1978d

修正回放错误,优化sdp排序,提高设备兼容性

src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
... ... @@ -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 193 public static String frontEndCmdString(int cmdCode, int parameter1, int parameter2, int combineCode2) {
194 194 StringBuilder builder = new StringBuilder("A50F01");
195 195 String strTmp;
... ... @@ -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 222 @Override
223 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 333  
334 334 if (seniorSdp) {
335 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 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 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 342 content.append("a=recvonly\r\n");
  343 + content.append("a=rtpmap:96 PS/90000\r\n");
343 344 content.append("a=fmtp:126 profile-level-id=42e01e\r\n");
344 345 content.append("a=rtpmap:126 H264/90000\r\n");
345 346 content.append("a=rtpmap:125 H264S/90000\r\n");
... ... @@ -348,7 +349,6 @@ public class SIPCommander implements ISIPCommander {
348 349 content.append("a=fmtp:99 profile-level-id=3\r\n");
349 350 content.append("a=rtpmap:98 H264/90000\r\n");
350 351 content.append("a=rtpmap:97 MPEG4/90000\r\n");
351   - content.append("a=rtpmap:96 PS/90000\r\n");
352 352 if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式
353 353 content.append("a=setup:passive\r\n");
354 354 content.append("a=connection:new\r\n");
... ... @@ -387,9 +387,6 @@ public class SIPCommander implements ISIPCommander {
387 387  
388 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 390 Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), null, "live", null, ssrc);
394 391  
395 392 ClientTransaction transaction = transmitRequest(device, request, errorEvent);
... ... @@ -416,12 +413,15 @@ public class SIPCommander implements ISIPCommander {
416 413 try {
417 414 MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
418 415 String ssrc = null;
  416 + String streamId = null;
419 417 if (rtpEnable) {
420 418 ssrc = String.format("gb_playback_%s_%s", device.getDeviceId(), channelId);
  419 + streamId = ssrc;
421 420 }else {
422 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 426 JSONObject subscribeKey = new JSONObject();
427 427 subscribeKey.put("app", "rtp");
... ... @@ -429,7 +429,6 @@ public class SIPCommander implements ISIPCommander {
429 429  
430 430 subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, subscribeKey, event);
431 431  
432   - //
433 432 StringBuffer content = new StringBuffer(200);
434 433 content.append("v=0\r\n");
435 434 content.append("o="+sipConfig.getSipId()+" 0 0 IN IP4 "+sipConfig.getSipIp()+"\r\n");
... ... @@ -449,13 +448,14 @@ public class SIPCommander implements ISIPCommander {
449 448  
450 449 if (seniorSdp) {
451 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 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 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 457 content.append("a=recvonly\r\n");
  458 + content.append("a=rtpmap:96 PS/90000\r\n");
459 459 content.append("a=fmtp:126 profile-level-id=42e01e\r\n");
460 460 content.append("a=rtpmap:126 H264/90000\r\n");
461 461 content.append("a=rtpmap:125 H264S/90000\r\n");
... ... @@ -464,7 +464,6 @@ public class SIPCommander implements ISIPCommander {
464 464 content.append("a=fmtp:99 profile-level-id=3\r\n");
465 465 content.append("a=rtpmap:98 H264/90000\r\n");
466 466 content.append("a=rtpmap:97 MPEG4/90000\r\n");
467   - content.append("a=rtpmap:96 PS/90000\r\n");
468 467 if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式
469 468 content.append("a=setup:passive\r\n");
470 469 content.append("a=connection:new\r\n");
... ... @@ -533,9 +532,6 @@ public class SIPCommander implements ISIPCommander {
533 532 if (dialog == null) {
534 533 return;
535 534 }
536   -
537   -
538   -
539 535 Request byeRequest = dialog.createRequest(Request.BYE);
540 536 SipURI byeURI = (SipURI) byeRequest.getRequestURI();
541 537 String vh = transaction.getRequest().getHeader(ViaHeader.NAME).toString();
... ...