Commit c009637e0979741475e78c01551e7dcdcf99ecbf
1 parent
02262e5a
增加录像回放结束后对设备发出的MediaStatus的回应并关流
Showing
1 changed file
with
36 additions
and
1 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
| @@ -34,7 +34,7 @@ import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; | @@ -34,7 +34,7 @@ import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; | ||
| 34 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; | 34 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| 35 | import com.genersoft.iot.vmp.utils.redis.RedisUtil; | 35 | import com.genersoft.iot.vmp.utils.redis.RedisUtil; |
| 36 | import org.springframework.util.StringUtils; | 36 | import org.springframework.util.StringUtils; |
| 37 | - | 37 | +import com.genersoft.iot.vmp.common.StreamInfo; |
| 38 | /** | 38 | /** |
| 39 | * @Description:MESSAGE请求处理器 | 39 | * @Description:MESSAGE请求处理器 |
| 40 | * @author: swwheihei | 40 | * @author: swwheihei |
| @@ -64,6 +64,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { | @@ -64,6 +64,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { | ||
| 64 | private static final String MESSAGE_DEVICE_INFO = "DeviceInfo"; | 64 | private static final String MESSAGE_DEVICE_INFO = "DeviceInfo"; |
| 65 | private static final String MESSAGE_ALARM = "Alarm"; | 65 | private static final String MESSAGE_ALARM = "Alarm"; |
| 66 | private static final String MESSAGE_RECORD_INFO = "RecordInfo"; | 66 | private static final String MESSAGE_RECORD_INFO = "RecordInfo"; |
| 67 | + private static final String MESSAGE_MEDIA_STATUS = "MediaStatus"; | ||
| 67 | // private static final String MESSAGE_BROADCAST = "Broadcast"; | 68 | // private static final String MESSAGE_BROADCAST = "Broadcast"; |
| 68 | // private static final String MESSAGE_DEVICE_STATUS = "DeviceStatus"; | 69 | // private static final String MESSAGE_DEVICE_STATUS = "DeviceStatus"; |
| 69 | // private static final String MESSAGE_MOBILE_POSITION = "MobilePosition"; | 70 | // private static final String MESSAGE_MOBILE_POSITION = "MobilePosition"; |
| @@ -98,6 +99,11 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { | @@ -98,6 +99,11 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { | ||
| 98 | } else if (MESSAGE_RECORD_INFO.equals(cmd)) { | 99 | } else if (MESSAGE_RECORD_INFO.equals(cmd)) { |
| 99 | logger.info("接收到RecordInfo消息"); | 100 | logger.info("接收到RecordInfo消息"); |
| 100 | processMessageRecordInfo(evt); | 101 | processMessageRecordInfo(evt); |
| 102 | + }else if (MESSAGE_MEDIA_STATUS.equals(cmd)) { | ||
| 103 | + logger.info("接收到MediaStatus消息"); | ||
| 104 | + processMessageMediaStatus(evt); | ||
| 105 | + } else { | ||
| 106 | + logger.info("接收到消息:" + cmd); | ||
| 101 | } | 107 | } |
| 102 | } catch (DocumentException e) { | 108 | } catch (DocumentException e) { |
| 103 | e.printStackTrace(); | 109 | e.printStackTrace(); |
| @@ -399,6 +405,35 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { | @@ -399,6 +405,35 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { | ||
| 399 | } | 405 | } |
| 400 | } | 406 | } |
| 401 | 407 | ||
| 408 | + | ||
| 409 | + private void processMessageMediaStatus(RequestEvent evt){ | ||
| 410 | + try { | ||
| 411 | + // 回复200 OK | ||
| 412 | + responseAck(evt); | ||
| 413 | + Element rootElement = getRootElement(evt); | ||
| 414 | + String deviceId = XmlUtil.getText(rootElement, "DeviceID"); | ||
| 415 | + String NotifyType =XmlUtil.getText(rootElement, "NotifyType"); | ||
| 416 | + if (NotifyType.equals("121")){ | ||
| 417 | + logger.info("媒体播放完毕,通知关流"); | ||
| 418 | + StreamInfo streamInfo = storager.queryPlaybackByDevice(deviceId, "*"); | ||
| 419 | + if (streamInfo != null) { | ||
| 420 | + storager.stopPlayback(streamInfo); | ||
| 421 | + cmder.streamByeCmd(streamInfo.getSsrc()); | ||
| 422 | + } | ||
| 423 | + } | ||
| 424 | + } catch (ParseException | SipException | InvalidArgumentException | DocumentException e) { | ||
| 425 | + e.printStackTrace(); | ||
| 426 | + } | ||
| 427 | + } | ||
| 428 | + | ||
| 429 | + | ||
| 430 | + /*** | ||
| 431 | + * 回复200 OK | ||
| 432 | + * @param evt | ||
| 433 | + * @throws SipException | ||
| 434 | + * @throws InvalidArgumentException | ||
| 435 | + * @throws ParseException | ||
| 436 | + */ | ||
| 402 | private void responseAck(RequestEvent evt) throws SipException, InvalidArgumentException, ParseException { | 437 | private void responseAck(RequestEvent evt) throws SipException, InvalidArgumentException, ParseException { |
| 403 | Response response = getMessageFactory().createResponse(Response.OK, evt.getRequest()); | 438 | Response response = getMessageFactory().createResponse(Response.OK, evt.getRequest()); |
| 404 | getServerTransaction(evt).sendResponse(response); | 439 | getServerTransaction(evt).sendResponse(response); |