PlayController.java 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package com.genersoft.iot.vmp.vmanager.play;
  2. import org.slf4j.Logger;
  3. import org.slf4j.LoggerFactory;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.http.HttpStatus;
  6. import org.springframework.http.ResponseEntity;
  7. import org.springframework.web.bind.annotation.GetMapping;
  8. import org.springframework.web.bind.annotation.PathVariable;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.RestController;
  11. import com.genersoft.iot.vmp.gb28181.bean.Device;
  12. import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
  13. import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
  14. @RestController
  15. @RequestMapping("/api")
  16. public class PlayController {
  17. private final static Logger logger = LoggerFactory.getLogger(PlayController.class);
  18. @Autowired
  19. private SIPCommander cmder;
  20. @Autowired
  21. private IVideoManagerStorager storager;
  22. @GetMapping("/play/{deviceId}/{channelId}")
  23. public ResponseEntity<String> play(@PathVariable String deviceId,@PathVariable String channelId){
  24. Device device = storager.queryVideoDevice(deviceId);
  25. String ssrc = cmder.playStreamCmd(device, channelId);
  26. if (logger.isDebugEnabled()) {
  27. logger.debug(String.format("设备预览 API调用,deviceId:%s ,channelId:%s",deviceId, channelId));
  28. logger.debug("设备预览 API调用,ssrc:"+ssrc+",ZLMedia streamId:"+Integer.toHexString(Integer.parseInt(ssrc)));
  29. }
  30. if(ssrc!=null) {
  31. return new ResponseEntity<String>(ssrc,HttpStatus.OK);
  32. } else {
  33. logger.warn("设备预览API调用失败!");
  34. return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
  35. }
  36. }
  37. }