| | |
| | | try {
|
| | |
|
| | | String ssrc = streamSession.createPlaySsrc();
|
| | | String transport = device.getTransport();
|
| | | String streamMode = device.getStreamMode().toUpperCase();
|
| | | MediaServerConfig mediaInfo = storager.getMediaInfo();
|
| | | String mediaPort = null;
|
| | | // 使用动态udp端口
|
| | |
| | | content.append("s=Play\r\n");
|
| | | content.append("c=IN IP4 "+mediaInfo.getLocalIP()+"\r\n");
|
| | | content.append("t=0 0\r\n");
|
| | | if("TCP".equals(transport)) {
|
| | | if("TCP-PASSIVE".equals(streamMode)) {
|
| | | content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 98 97\r\n");
|
| | | }
|
| | | if("UDP".equals(transport)) {
|
| | | }else if ("TCP-ACTIVE".equals(streamMode)) {
|
| | | content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 98 97\r\n");
|
| | | }else if("UDP".equals(streamMode)) {
|
| | | content.append("m=video "+ mediaPort +" RTP/AVP 96 98 97\r\n");
|
| | | }
|
| | | content.append("a=recvonly\r\n");
|
| | | content.append("a=rtpmap:96 PS/90000\r\n");
|
| | | content.append("a=rtpmap:98 H264/90000\r\n");
|
| | | content.append("a=rtpmap:97 MPEG4/90000\r\n");
|
| | | if("TCP".equals(transport)){
|
| | | content.append("a=setup:passive\r\n");
|
| | | content.append("a=connection:new\r\n");
|
| | | }
|
| | | if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式
|
| | | content.append("a=setup:passive\r\n");
|
| | | content.append("a=connection:new\r\n");
|
| | | }else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式
|
| | | content.append("a=setup:active\r\n");
|
| | | content.append("a=connection:new\r\n");
|
| | | }
|
| | | content.append("y="+ssrc+"\r\n");//ssrc
|
| | |
|
| | | Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), null, "live", null);
|
| | |
| | | * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss
|
| | | */
|
| | | @Override
|
| | | public String playbackStreamCmd(Device device, String channelId, String startTime, String endTime) {
|
| | | public StreamInfo playbackStreamCmd(Device device, String channelId, String startTime, String endTime) {
|
| | | try {
|
| | | MediaServerConfig mediaInfo = storager.getMediaInfo();
|
| | | String ssrc = streamSession.createPlayBackSsrc();
|
| | |
| | | content.append("s=Playback\r\n");
|
| | | content.append("u="+channelId+":0\r\n");
|
| | | content.append("c=IN IP4 "+mediaInfo.getLocalIP()+"\r\n");
|
| | | content.append("t="+DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime)+" "+DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) +"\r\n");
|
| | | if(device.getTransport().equals("TCP")) {
|
| | | content.append("m=video "+mediaInfo.getRtpProxyPort()+" TCP/RTP/AVP 96 98 97\r\n");
|
| | | content.append("t="+DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime)+" "
|
| | | +DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) +"\r\n");
|
| | | String mediaPort = null;
|
| | | // 使用动态udp端口
|
| | | if (rtpEnable) {
|
| | | mediaPort = zlmUtils.getNewRTPPort(ssrc) + "";
|
| | | }else {
|
| | | mediaPort = mediaInfo.getRtpProxyPort();
|
| | | }
|
| | | if(device.getTransport().equals("UDP")) {
|
| | | content.append("m=video "+mediaInfo.getRtpProxyPort()+" RTP/AVP 96 98 97\r\n");
|
| | | String streamMode = device.getStreamMode().toUpperCase();
|
| | | if("TCP-PASSIVE".equals(streamMode)) {
|
| | | content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 98 97\r\n");
|
| | | }else if ("TCP-ACTIVE".equals(streamMode)) {
|
| | | content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 98 97\r\n");
|
| | | }else if("UDP".equals(streamMode)) {
|
| | | content.append("m=video "+ mediaPort +" RTP/AVP 96 98 97\r\n");
|
| | | }
|
| | | content.append("a=recvonly\r\n");
|
| | | content.append("a=rtpmap:96 PS/90000\r\n");
|
| | | content.append("a=rtpmap:98 H264/90000\r\n");
|
| | | content.append("a=rtpmap:97 MPEG4/90000\r\n");
|
| | | if(device.getTransport().equals("TCP")){
|
| | | content.append("a=setup:passive\r\n");
|
| | | content.append("a=connection:new\r\n");
|
| | | }
|
| | | if("TCP-PASSIVE".equals(streamMode)){ // tcp被动模式
|
| | | content.append("a=setup:passive\r\n");
|
| | | content.append("a=connection:new\r\n");
|
| | | }else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式
|
| | | content.append("a=setup:active\r\n");
|
| | | content.append("a=connection:new\r\n");
|
| | | }
|
| | | content.append("y="+ssrc+"\r\n");//ssrc
|
| | |
|
| | | Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, "playback", null);
|
| | |
|
| | | ClientTransaction transaction = transmitRequest(device, request);
|
| | | streamSession.put(ssrc, transaction);
|
| | | return ssrc;
|
| | |
|
| | | StreamInfo streamInfo = new StreamInfo();
|
| | | streamInfo.setSsrc(ssrc);
|
| | | streamInfo.setCahnnelId(channelId);
|
| | | streamInfo.setDeviceID(device.getDeviceId());
|
| | | boolean b = storager.startPlayBlack(streamInfo);
|
| | | return streamInfo;
|
| | |
|
| | | } catch ( SipException | ParseException | InvalidArgumentException e) {
|
| | | e.printStackTrace();
|
| | |
| | | recordInfoXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
|
| | | recordInfoXml.append("<StartTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(startTime) + "</StartTime>\r\n");
|
| | | recordInfoXml.append("<EndTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(endTime) + "</EndTime>\r\n");
|
| | | recordInfoXml.append("<Secrecy>0</Secrecy>\\r\n");
|
| | | recordInfoXml.append("<Secrecy>0</Secrecy>\r\n");
|
| | | // 大华NVR要求必须增加一个值为all的文本元素节点Type
|
| | | recordInfoXml.append("<Type>all</Type>\r\n");
|
| | | recordInfoXml.append("</Query>\r\n");
|