feat: 前端添加切换摄像头功能

This commit is contained in:
2025-07-21 17:24:22 +08:00
parent d1c9710afe
commit e872f24936
3 changed files with 246 additions and 164 deletions

View File

@@ -68,7 +68,7 @@ export class VideoStreamClient {
* 获取 HTTP 视频流信息
* @return 流信息
*/
getStreamInfo(): Promise<any> {
getStreamInfo(): Promise<StreamInfoResult> {
let url_ = this.baseUrl + "/api/VideoStream/StreamInfo";
url_ = url_.replace(/[?&]$/, "");
@@ -84,15 +84,14 @@ export class VideoStreamClient {
});
}
protected processGetStreamInfo(response: Response): Promise<any> {
protected processGetStreamInfo(response: Response): Promise<StreamInfoResult> {
const status = response.status;
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200) {
return response.text().then((_responseText) => {
let result200: any = null;
let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
result200 = resultData200 !== undefined ? resultData200 : <any>null;
result200 = StreamInfoResult.fromJS(resultData200);
return result200;
});
} else if (status === 500) {
@@ -107,7 +106,7 @@ export class VideoStreamClient {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<any>(null as any);
return Promise.resolve<StreamInfoResult>(null as any);
}
/**
@@ -4673,6 +4672,88 @@ export interface IException {
stackTrace?: string | undefined;
}
/** 视频流信息结构体 */
export class StreamInfoResult implements IStreamInfoResult {
/** TODO: */
frameRate!: number;
/** TODO: */
frameWidth!: number;
/** TODO: */
frameHeight!: number;
/** TODO: */
format!: string;
/** TODO: */
htmlUrl!: string;
/** TODO: */
mjpegUrl!: string;
/** TODO: */
snapshotUrl!: string;
/** TODO: */
usbCameraUrl!: string;
constructor(data?: IStreamInfoResult) {
if (data) {
for (var property in data) {
if (data.hasOwnProperty(property))
(<any>this)[property] = (<any>data)[property];
}
}
}
init(_data?: any) {
if (_data) {
this.frameRate = _data["frameRate"];
this.frameWidth = _data["frameWidth"];
this.frameHeight = _data["frameHeight"];
this.format = _data["format"];
this.htmlUrl = _data["htmlUrl"];
this.mjpegUrl = _data["mjpegUrl"];
this.snapshotUrl = _data["snapshotUrl"];
this.usbCameraUrl = _data["usbCameraUrl"];
}
}
static fromJS(data: any): StreamInfoResult {
data = typeof data === 'object' ? data : {};
let result = new StreamInfoResult();
result.init(data);
return result;
}
toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
data["frameRate"] = this.frameRate;
data["frameWidth"] = this.frameWidth;
data["frameHeight"] = this.frameHeight;
data["format"] = this.format;
data["htmlUrl"] = this.htmlUrl;
data["mjpegUrl"] = this.mjpegUrl;
data["snapshotUrl"] = this.snapshotUrl;
data["usbCameraUrl"] = this.usbCameraUrl;
return data;
}
}
/** 视频流信息结构体 */
export interface IStreamInfoResult {
/** TODO: */
frameRate: number;
/** TODO: */
frameWidth: number;
/** TODO: */
frameHeight: number;
/** TODO: */
format: string;
/** TODO: */
htmlUrl: string;
/** TODO: */
mjpegUrl: string;
/** TODO: */
snapshotUrl: string;
/** TODO: */
usbCameraUrl: string;
}
/** 摄像头配置请求模型 */
export class CameraConfigRequest implements ICameraConfigRequest {
/** 摄像头地址 */