[+] 设备录像状态
This commit is contained in:
@@ -45,8 +45,10 @@ public class ClientStatus {
|
||||
private Boolean alarming;
|
||||
@Schema(title = "是否正在充电", description = "是否正在充电")
|
||||
private Boolean charging;
|
||||
@Schema(title = "是否正在录像", description = "是否正在录像")
|
||||
private Boolean recording;
|
||||
@Schema(title = "终端是否正在录像", description = "终端是否正在录像")
|
||||
private Boolean clientRecording;
|
||||
@Schema(title = "服务端是否正在录像", description = "服务端是否正在录像")
|
||||
private Boolean serverRecording;
|
||||
@Schema(title = "最后心跳时间", description = "最后心跳时间")
|
||||
private LocalDateTime lastHeartbeat;
|
||||
@Schema(title = "终端状态", description = "其他扩展终端状态")
|
||||
@@ -68,7 +70,7 @@ public class ClientStatus {
|
||||
this.setBattery(MapUtils.getInteger(body, Constant.BATTERY));
|
||||
this.setAlarming(MapUtils.getBoolean(body, Constant.ALARMING));
|
||||
this.setCharging(MapUtils.getBoolean(body, Constant.CHARGING));
|
||||
this.setRecording(MapUtils.getBoolean(body, Constant.RECORDING));
|
||||
this.setClientRecording(MapUtils.getBoolean(body, Constant.CLIENT_RECORDING));
|
||||
this.status(MapUtils.get(body, Constant.STATUS));
|
||||
this.config(MapUtils.get(body, Constant.CONFIG));
|
||||
this.setLastHeartbeat(LocalDateTime.now());
|
||||
|
||||
@@ -168,6 +168,7 @@ public class Recorder {
|
||||
this.thread.setDaemon(true);
|
||||
this.thread.setName("TaoyaoRecord");
|
||||
this.thread.start();
|
||||
this.updateRecordStatus(true);
|
||||
log.info("开始媒体录像:{}", this.folder);
|
||||
}
|
||||
|
||||
@@ -276,6 +277,7 @@ public class Recorder {
|
||||
this.scriptExecutor.stop("q");
|
||||
this.preview();
|
||||
this.duration();
|
||||
this.updateRecordStatus(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,5 +286,14 @@ public class Recorder {
|
||||
public void close() {
|
||||
EventPublisher.publishEvent(new RecorderCloseEvent(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新录像状态
|
||||
*
|
||||
* @param status 状态
|
||||
*/
|
||||
private void updateRecordStatus(boolean status) {
|
||||
this.clientWrapper.getClient().status().setServerRecording(status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.acgist.taoyao.boot.annotation.Description;
|
||||
import com.acgist.taoyao.boot.annotation.Protocol;
|
||||
import com.acgist.taoyao.boot.config.Constant;
|
||||
import com.acgist.taoyao.boot.model.Message;
|
||||
import com.acgist.taoyao.boot.utils.MapUtils;
|
||||
import com.acgist.taoyao.signal.client.Client;
|
||||
import com.acgist.taoyao.signal.client.ClientType;
|
||||
import com.acgist.taoyao.signal.protocol.ProtocolControlAdapter;
|
||||
@@ -46,6 +47,7 @@ public class ControlClientRecordProtocol extends ProtocolControlAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Client client, Client targetClient, Message message, Map<String, Object> body) {
|
||||
this.updateRecordStatus(targetClient, MapUtils.getBoolean(body, Constant.ENABLED));
|
||||
client.push(targetClient.request(message));
|
||||
}
|
||||
|
||||
@@ -56,7 +58,18 @@ public class ControlClientRecordProtocol extends ProtocolControlAdapter {
|
||||
* @return 执行结果
|
||||
*/
|
||||
public Message execute(String clientId, Boolean enabled) {
|
||||
this.updateRecordStatus(this.clientManager.clients(clientId), enabled);
|
||||
return this.request(clientId, this.build(Map.of(Constant.ENABLED, enabled)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置录像状态
|
||||
*
|
||||
* @param client 终端
|
||||
* @param enabled 录像状态
|
||||
*/
|
||||
private void updateRecordStatus(Client client, Boolean enabled) {
|
||||
client.status().setClientRecording(enabled);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
import com.acgist.taoyao.boot.annotation.Description;
|
||||
import com.acgist.taoyao.boot.annotation.Protocol;
|
||||
@@ -59,6 +60,7 @@ public class ControlServerRecordProtocol extends ProtocolControlAdapter implemen
|
||||
this.ffmpegProperties = ffmpegProperties;
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public void onApplicationEvent(RecorderCloseEvent event) {
|
||||
final Recorder recorder = event.getRecorder();
|
||||
|
||||
Reference in New Issue
Block a user