/video 支持某些特殊情况下使用 实时回放 代替下载

This commit is contained in:
shikong 2023-10-09 15:07:36 +08:00
parent 4fc4d3a863
commit 845d049ad5

View File

@ -51,7 +51,6 @@ import org.springframework.stereotype.Service;
import javax.sdp.Connection;
import javax.sdp.SdpFactory;
import javax.sdp.TimeDescription;
import javax.sip.ListeningPoint;
import javax.sip.header.CallIdHeader;
import javax.sip.message.Request;
import javax.sip.message.Response;
@ -221,18 +220,24 @@ public class Gb28181DownloadService {
timeField.setStartTime(start);
timeField.setStopTime(end);
TimeDescription timeDescription = SdpFactory.getInstance().createTimeDescription(timeField);
GB28181Description gb28181Description = MediaSdpHelper.build(MediaSdpHelper.Action.DOWNLOAD, gbDeviceId, channel, Connection.IP4, ip, port, ssrc, streamMode, timeDescription);
gb28181Description.setSessionName(SdpFactory.getInstance().createSessionName(MediaSdpHelper.Action.DOWNLOAD.getAction()));
MediaSdpHelper.Action action = MediaSdpHelper.Action.DOWNLOAD;
if(proxySipConfig.isUsePlaybackToDownload()){
action = MediaSdpHelper.Action.PLAY_BACK;
}
GB28181Description gb28181Description = MediaSdpHelper.build(action, gbDeviceId, channel, Connection.IP4, ip, port, ssrc, streamMode, timeDescription);
gb28181Description.setSessionName(SdpFactory.getInstance().createSessionName(action.getAction()));
gb28181Description.setTimeDescriptions(new Vector<>(){{add(timeDescription);}});
MediaDescriptionImpl media = (MediaDescriptionImpl) gb28181Description.getMediaDescriptions(true).get(0);
if(proxySipConfig.getStreamMode() != StreamMode.UDP){
media.getMedia().setProtocol("RTP/AVP/TCP");
}
media.setAttribute("downloadspeed", String.valueOf(4));
if(!proxySipConfig.isUsePlaybackToDownload()){
media.setAttribute("downloadspeed", String.valueOf(4));
}
URIField uriField = new URIField();
uriField.setURI(StringUtils.joinWith(":", channel, "0"));
gb28181Description.setURI(uriField);
sender.sendRequest(inviteRequest(docking, device, gb28181Description, MediaSdpHelper.Action.DOWNLOAD, ssrc, streamId, result, time));
sender.sendRequest(inviteRequest(docking, device, gb28181Description, action, ssrc, streamId, result, time));
return result;
}