StartSendRtp 延迟可配置
This commit is contained in:
parent
a69fa97ba6
commit
e4be1e1373
@ -4,9 +4,12 @@ import lombok.Data;
|
|||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConfigurationProperties(prefix = "media.local")
|
@ConfigurationProperties(prefix = "media.local")
|
||||||
public class ZlmHookConfig {
|
public class ZlmHookConfig {
|
||||||
private String hook;
|
private String hook;
|
||||||
|
private Duration delay = Duration.ofMillis(100);
|
||||||
}
|
}
|
||||||
|
@ -90,11 +90,6 @@ public class DeviceProxyService {
|
|||||||
MediaDescription mediaDescription = (MediaDescription)gb28181Description.getMediaDescriptions(true).get(0);
|
MediaDescription mediaDescription = (MediaDescription)gb28181Description.getMediaDescriptions(true).get(0);
|
||||||
boolean tcp = StringUtils.containsIgnoreCase(mediaDescription.getMedia().getProtocol(), "TCP");
|
boolean tcp = StringUtils.containsIgnoreCase(mediaDescription.getMedia().getProtocol(), "TCP");
|
||||||
zlmStreamChangeHookService.handlerMap.put(callId,()->{
|
zlmStreamChangeHookService.handlerMap.put(callId,()->{
|
||||||
try {
|
|
||||||
Thread.sleep(500);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
StartSendRtp startSendRtp = new StartSendRtp();
|
StartSendRtp startSendRtp = new StartSendRtp();
|
||||||
startSendRtp.setApp("live");
|
startSendRtp.setApp("live");
|
||||||
startSendRtp.setStream(callId);
|
startSendRtp.setStream(callId);
|
||||||
@ -132,11 +127,6 @@ public class DeviceProxyService {
|
|||||||
MediaDescription mediaDescription = (MediaDescription)gb28181Description.getMediaDescriptions(true).get(0);
|
MediaDescription mediaDescription = (MediaDescription)gb28181Description.getMediaDescriptions(true).get(0);
|
||||||
boolean tcp = StringUtils.containsIgnoreCase(mediaDescription.getMedia().getProtocol(), "TCP");
|
boolean tcp = StringUtils.containsIgnoreCase(mediaDescription.getMedia().getProtocol(), "TCP");
|
||||||
zlmStreamChangeHookService.handlerMap.put(callId,()->{
|
zlmStreamChangeHookService.handlerMap.put(callId,()->{
|
||||||
try {
|
|
||||||
Thread.sleep(500);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
StartSendRtp startSendRtp = new StartSendRtp();
|
StartSendRtp startSendRtp = new StartSendRtp();
|
||||||
startSendRtp.setApp("live");
|
startSendRtp.setApp("live");
|
||||||
startSendRtp.setStream(callId);
|
startSendRtp.setStream(callId);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package cn.skcks.docking.gb28181.mocking.service.zlm.hook;
|
package cn.skcks.docking.gb28181.mocking.service.zlm.hook;
|
||||||
|
|
||||||
|
import cn.skcks.docking.gb28181.mocking.config.sip.ZlmHookConfig;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -11,7 +13,9 @@ import java.util.concurrent.ConcurrentMap;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Data
|
@Data
|
||||||
@Service
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class ZlmStreamChangeHookService {
|
public class ZlmStreamChangeHookService {
|
||||||
|
private ZlmHookConfig zlmHookConfig;
|
||||||
public interface ZlmStreamChangeHookHandler{
|
public interface ZlmStreamChangeHookHandler{
|
||||||
void handler();
|
void handler();
|
||||||
}
|
}
|
||||||
@ -24,6 +28,13 @@ public class ZlmStreamChangeHookService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional.ofNullable(handlerMap.remove(streamId)).ifPresent(ZlmStreamChangeHookHandler::handler);
|
Optional.ofNullable(handlerMap.remove(streamId)).ifPresent((handler)->{
|
||||||
|
try {
|
||||||
|
Thread.sleep(zlmHookConfig.getDelay().toMillis());
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
handler.handler();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,7 @@ gb28181:
|
|||||||
media:
|
media:
|
||||||
local:
|
local:
|
||||||
hook: http://10.10.10.20:18182/zlm/hook
|
hook: http://10.10.10.20:18182/zlm/hook
|
||||||
|
delay: 100ms
|
||||||
ip: 10.10.10.200
|
ip: 10.10.10.200
|
||||||
url: 'http://10.10.10.200:5081'
|
url: 'http://10.10.10.200:5081'
|
||||||
# url: 'http://10.10.10.200:12580/anything/'
|
# url: 'http://10.10.10.200:12580/anything/'
|
||||||
|
Loading…
Reference in New Issue
Block a user