Commit 0f7cd3fd authored by 高飞's avatar 高飞

修改调用服务为传递rtsp 解析为flv

parent b04165ba
......@@ -338,26 +338,19 @@ public void sendevent( Alarm trffClientMessage){
//huode resid 中值、
if(null!=rtsp) {
if( null==stringRedisTemplate.opsForValue().get(resisvalue))
if( null==stringRedisTemplate.opsForValue().get(videoid))
{
log.info("flv-----");
flvCacheService.getvalue();
flvCacheService.getvalue(videoid,rtsp);
}
log.info(stringRedisTemplate.opsForValue().get(videoid));
JSONObject jsonObject = JSONObject.parseObject(stringRedisTemplate.opsForValue().get(videoid));
JSONArray jsonArr = JSONObject.parseArray(stringRedisTemplate.opsForValue().get(resisvalue));
log.info("jsonArr" + jsonArr.size());
for (int i = 0; i < jsonArr.size(); i++) {
JSONObject jsonObject = jsonArr.getJSONObject(i);
if (jsonObject.getString("source").equalsIgnoreCase(rtsp)) {
if (null != jsonObject.getJSONArray("play_uris") && jsonObject.getJSONArray("play_uris").size() > 3) {
return String.valueOf(jsonObject.getJSONArray("play_uris").get(2));
if (null != jsonObject.getJSONArray("play_list") && jsonObject.getJSONArray("play_list").size() > 0) {
return String.valueOf(jsonObject.getJSONArray("play_list").get(0));
}
}
}
}
return "";
......
......@@ -51,7 +51,7 @@ public class FileTransferManager {
/// System.out.println("connection.getResponseCode:" + connection.getResponseCode() );
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
InputStream inputStream = connection.getInputStream();
log.info("url:",url , " --- "+"key:",key);
log.info("url:"+url+" ---key:"+key);
String pname = DateUtils.formatCurrDayNoSign() + "_"+recordid+"_0000_"+key.replace("path","");
String fileName = pname +filesuff;
String ftputl = FTPUtil.getFtpUrl(ftp) + basePath + "/" + fileName;
......
......@@ -18,7 +18,6 @@ import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;
@Slf4j
@Component
public class MyApplicationStartingEventListener implements ApplicationListener<SpringApplicationEvent>, ApplicationContextAware {
private ApplicationContext applicationContext;
......
package com.hzjt.service;
import com.hzjt.domain.ResultObj;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import java.util.concurrent.TimeUnit;
......@@ -24,18 +28,20 @@ public class FLVCacheService {
@Value("${flv.url}")
private String url;
public void getvalue() {
public void getvalue(String videoid,String rtsp) {
try {
HttpHeaders headers = getHttpHeaders();
HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
HttpHeaders headers = new HttpHeaders();
RestTemplate client = new RestTemplate();
ResponseEntity<String> request = client.exchange((url), HttpMethod.GET, requestEntity, String.class);
String jsonString = "{\"video_id\":\""+videoid+"\",\"url\":\""+rtsp+"\"}";
log.info("jsonString"+jsonString);
headers.setContentType(MediaType.valueOf("application/json;UTF-8"));
HttpEntity<String> strEntity = new HttpEntity<>(jsonString,headers);
ResponseEntity<String> response = client.postForEntity(url, strEntity, String.class);
//解析返回结果
if (request.getBody() != null) {
log.info("response"+response.getBody());
if (response.getBody() != null) {
log.info("flv response success" );
stringRedisTemplate.opsForValue().set(resisvalue,request.getBody(), 32, TimeUnit.MINUTES);
stringRedisTemplate.opsForValue().set(videoid,response.getBody(), 10, TimeUnit.MINUTES);
} else {
log.error("flv response " + "empty...");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment