feat: 部分修复Hdmi再次启动启动不了的bug
This commit is contained in:
parent
8396b7aaea
commit
e0ac21d141
|
@ -119,7 +119,27 @@ public class HttpHdmiVideoStreamService : BackgroundService
|
||||||
private async Task<HdmiIn?> GetOrCreateHdmiInAsync(string boardId)
|
private async Task<HdmiIn?> GetOrCreateHdmiInAsync(string boardId)
|
||||||
{
|
{
|
||||||
if (_hdmiInDict.TryGetValue(boardId, out var hdmiIn))
|
if (_hdmiInDict.TryGetValue(boardId, out var hdmiIn))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var enableResult = await hdmiIn.EnableTrans(true);
|
||||||
|
if (!enableResult.IsSuccessful)
|
||||||
|
{
|
||||||
|
logger.Error($"Failed to enable HDMI transmission for board {boardId}: {enableResult.Error}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
logger.Info($"Successfully enabled HDMI transmission for board {boardId}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.Error(ex, $"Exception occurred while enabling HDMI transmission for board {boardId}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_hdmiInDict[boardId] = hdmiIn;
|
||||||
|
_hdmiInCtsDict[boardId] = new CancellationTokenSource();
|
||||||
return hdmiIn;
|
return hdmiIn;
|
||||||
|
}
|
||||||
|
|
||||||
var db = new Database.AppDataConnection();
|
var db = new Database.AppDataConnection();
|
||||||
if (db == null)
|
if (db == null)
|
||||||
|
|
|
@ -3059,6 +3059,59 @@ export class HdmiVideoStreamClient {
|
||||||
}
|
}
|
||||||
return Promise.resolve<HdmiVideoStreamEndpoint>(null as any);
|
return Promise.resolve<HdmiVideoStreamEndpoint>(null as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disableHdmiTransmission( cancelToken?: CancelToken): Promise<FileResponse | null> {
|
||||||
|
let url_ = this.baseUrl + "/api/HdmiVideoStream/DisableHdmiTransmission";
|
||||||
|
url_ = url_.replace(/[?&]$/, "");
|
||||||
|
|
||||||
|
let options_: AxiosRequestConfig = {
|
||||||
|
responseType: "blob",
|
||||||
|
method: "POST",
|
||||||
|
url: url_,
|
||||||
|
headers: {
|
||||||
|
"Accept": "application/octet-stream"
|
||||||
|
},
|
||||||
|
cancelToken
|
||||||
|
};
|
||||||
|
|
||||||
|
return this.instance.request(options_).catch((_error: any) => {
|
||||||
|
if (isAxiosError(_error) && _error.response) {
|
||||||
|
return _error.response;
|
||||||
|
} else {
|
||||||
|
throw _error;
|
||||||
|
}
|
||||||
|
}).then((_response: AxiosResponse) => {
|
||||||
|
return this.processDisableHdmiTransmission(_response);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected processDisableHdmiTransmission(response: AxiosResponse): Promise<FileResponse | null> {
|
||||||
|
const status = response.status;
|
||||||
|
let _headers: any = {};
|
||||||
|
if (response.headers && typeof response.headers === "object") {
|
||||||
|
for (const k in response.headers) {
|
||||||
|
if (response.headers.hasOwnProperty(k)) {
|
||||||
|
_headers[k] = response.headers[k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (status === 200 || status === 206) {
|
||||||
|
const contentDisposition = response.headers ? response.headers["content-disposition"] : undefined;
|
||||||
|
let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined;
|
||||||
|
let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined;
|
||||||
|
if (fileName) {
|
||||||
|
fileName = decodeURIComponent(fileName);
|
||||||
|
} else {
|
||||||
|
fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
|
||||||
|
fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
|
||||||
|
}
|
||||||
|
return Promise.resolve({ fileName: fileName, status: status, data: new Blob([response.data], { type: response.headers["content-type"] }), headers: _headers });
|
||||||
|
} else if (status !== 200 && status !== 204) {
|
||||||
|
const _responseText = response.data;
|
||||||
|
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||||
|
}
|
||||||
|
return Promise.resolve<FileResponse | null>(null as any);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class JtagClient {
|
export class JtagClient {
|
||||||
|
|
|
@ -362,6 +362,9 @@ function stopStream() {
|
||||||
isPlaying.value = false;
|
isPlaying.value = false;
|
||||||
currentVideoSource.value = '';
|
currentVideoSource.value = '';
|
||||||
videoStatus.value = '已停止播放';
|
videoStatus.value = '已停止播放';
|
||||||
|
|
||||||
|
const client = AuthManager.createAuthenticatedHdmiVideoStreamClient();
|
||||||
|
client.disableHdmiTransmission();
|
||||||
|
|
||||||
addLog('info', '停止播放HDMI视频流');
|
addLog('info', '停止播放HDMI视频流');
|
||||||
alert?.info('已停止播放HDMI视频流');
|
alert?.info('已停止播放HDMI视频流');
|
||||||
|
|
Loading…
Reference in New Issue