Skip to content

Commit

Permalink
Fix utest fail. v5.13.14
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Jan 18, 2024
1 parent 2aab57a commit d059f19
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 76 deletions.
68 changes: 3 additions & 65 deletions ui/src/pages/ScenarioCamera.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default function ScenarioCamera() {
const [activeKey, setActiveKey] = React.useState();
const [secrets, setSecrets] = React.useState();
const handleError = useErrorHandler();
const language = useSrsLanguage();

React.useEffect(() => {
axios.post('/terraform/v1/ffmpeg/camera/secret', {
Expand Down Expand Up @@ -113,7 +112,7 @@ function ScenarioCameraImpl({defaultActiveKey, defaultSecrets}) {
refreshStreams();
const timer = setInterval(() => refreshStreams(), 10 * 1000);
return () => clearInterval(timer);
}, [handleError]);
}, [t, handleError]);

const updateSecrets = React.useCallback((e, action, platform, server, secret, enabled, custom, label, files, extraAudio, onSuccess) => {
e.preventDefault();
Expand All @@ -136,7 +135,7 @@ function ScenarioCameraImpl({defaultActiveKey, defaultSecrets}) {
} finally {
new Promise(resolve => setTimeout(resolve, 3000)).then(() => setSubmiting(false));
}
}, [handleError, setSubmiting]);
}, [t, handleError, setSubmiting]);

return (
<Accordion defaultActiveKey={defaultActiveKey}>
Expand Down Expand Up @@ -464,7 +463,7 @@ function CameraStreamSelector({platform, cameraFiles, setCameraFiles}) {
} finally {
setSubmiting(false);
}
}, [inputStream, handleError, platform, setCameraFiles, setSubmiting]);
}, [t, inputStream, handleError, platform, setCameraFiles, setSubmiting]);

return (<>
<Form.Control as="div">
Expand All @@ -483,67 +482,6 @@ function CameraStreamSelector({platform, cameraFiles, setCameraFiles}) {
</>);
}

function CameraStreamSelectorEn({platform, cameraFiles, setCameraFiles}) {
const handleError = useErrorHandler();
const [inputStream, setInputStream] = React.useState(cameraFiles?.length ? cameraFiles[0].target : '');
const [submiting, setSubmiting] = React.useState();

const checkStreamUrl = React.useCallback(async () => {
if (!inputStream) return alert('Please input stream URL');
const isHTTP = inputStream.startsWith('http://') || inputStream.startsWith('https://');
if (!inputStream.startsWith('rtmp://') && !inputStream.startsWith('rtsp://') && !isHTTP) return alert('The stream must be rtmp/http/https/rtsp');
if (isHTTP && inputStream.indexOf('.flv') < 0 && inputStream.indexOf('.m3u8') < 0) return alert('The HTTP stream must be http-flv/hls');

setSubmiting(true);
try {
const res = await new Promise((resolve, reject) => {
axios.post(`/terraform/v1/ffmpeg/camera/stream-url`, {
url: inputStream,
}, {
headers: Token.loadBearerHeader(),
}).then(res => {
resolve(res);
}).catch(reject);
});

await new Promise((resolve, reject) => {
console.log(`Check stream url ok,${JSON.stringify(res.data.data)}`);
const streamObj = res.data.data;
const files = [{name: streamObj.name, size: 0, uuid: streamObj.uuid, target: streamObj.target, type: "stream"}];
axios.post('/terraform/v1/ffmpeg/camera/source', {
platform, files,
}, {
headers: Token.loadBearerHeader(),
}).then(res => {
console.log(`Setup the virtual live stream ok,${JSON.stringify(res.data.data)}`);
setCameraFiles(res.data.data.files);
resolve();
}).catch(reject);
});
} catch (e) {
handleError(e);
} finally {
setSubmiting(false);
}
}, [inputStream, handleError, platform, setCameraFiles, setSubmiting]);

return (<>
<Form.Control as="div">
{!cameraFiles?.length && <>
<Row>
<Col>
<Form.Control type="text" defaultValue={inputStream} placeholder="please input stream URL" onChange={e => setInputStream(e.target.value)} />
</Col>
<Col xs="auto">
<Button variant="primary" disabled={submiting} onClick={checkStreamUrl}>Submit</Button>
</Col>
</Row></>
}
{cameraFiles?.length && <CameraFileList files={cameraFiles} onChangeFiles={(e) => setCameraFiles(null)}/>}
</Form.Control>
</>)
}

function CameraFileFormatInfo({file}) {
const f = file;
if (!f?.format) return <></>;
Expand Down
6 changes: 2 additions & 4 deletions ui/src/pages/ScenarioForward.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import React from "react";
import {Token} from "../utils";
import axios from "axios";
import moment from "moment";
import {TutorialsButton, useTutorials} from "../components/TutorialsButton";
import {useErrorHandler} from "react-error-boundary";
import {useSrsLanguage} from "../components/LanguageSwitch";
import {useTranslation} from "react-i18next";
Expand All @@ -18,7 +17,6 @@ export default function ScenarioForward() {
const [activeKey, setActiveKey] = React.useState();
const [secrets, setSecrets] = React.useState();
const handleError = useErrorHandler();
const language = useSrsLanguage();

React.useEffect(() => {
axios.post('/terraform/v1/ffmpeg/forward/secret', {
Expand Down Expand Up @@ -100,7 +98,7 @@ function ScenarioForwardImpl({defaultActiveKey, defaultSecrets}) {
refreshStreams();
const timer = setInterval(() => refreshStreams(), 10 * 1000);
return () => clearInterval(timer);
}, [handleError, setForwards]);
}, [t, handleError, setForwards]);

const updateSecrets = React.useCallback((e, action, platform, server, secret, enabled, custom, label, onSuccess) => {
e.preventDefault();
Expand All @@ -121,7 +119,7 @@ function ScenarioForwardImpl({defaultActiveKey, defaultSecrets}) {
} finally {
new Promise(resolve => setTimeout(resolve, 3000)).then(() => setSubmiting(false));
}
}, [handleError, setSubmiting]);
}, [t, handleError, setSubmiting]);

return (
<Accordion defaultActiveKey={[defaultActiveKey]} alwaysOpen>
Expand Down
3 changes: 2 additions & 1 deletion ui/src/pages/ScenarioLiveRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//
import React from "react";
import {useSrsLanguage} from "../components/LanguageSwitch";
import {Accordion, Button, Card, Form, Nav, Tab, Table, Tabs} from "react-bootstrap";
import {Accordion, Button, Card, Form, Nav, Table} from "react-bootstrap";
import {useTranslation} from "react-i18next";
import axios from "axios";
import {Clipboard, Token} from "../utils";
Expand Down Expand Up @@ -292,6 +292,7 @@ function ScenarioLiveRoomManager({roomId, setRoomId}) {
<Accordion.Item eventKey="2">
<Accordion.Header>{t('lr.room.ai')}</Accordion.Header>
<Accordion.Body>
On the way...
</Accordion.Body>
</Accordion.Item>
</Accordion>
Expand Down
11 changes: 5 additions & 6 deletions ui/src/pages/ScenarioVLive.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {useSrsLanguage} from "../components/LanguageSwitch";
import FileUploader from "../components/FileUploader";
import {useTranslation} from "react-i18next";
import {SrsErrorBoundary} from "../components/SrsErrorBoundary";
import {TutorialsButton, useTutorials} from "../components/TutorialsButton";

export default function ScenarioVLive() {
const [init, setInit] = React.useState();
Expand Down Expand Up @@ -111,7 +110,7 @@ function ScenarioVLiveImpl({defaultActiveKey, defaultSecrets}) {
refreshStreams();
const timer = setInterval(() => refreshStreams(), 10 * 1000);
return () => clearInterval(timer);
}, [handleError]);
}, [t, handleError]);

const updateSecrets = React.useCallback((e, action, platform, server, secret, enabled, custom, label, files, onSuccess) => {
e.preventDefault();
Expand All @@ -133,7 +132,7 @@ function ScenarioVLiveImpl({defaultActiveKey, defaultSecrets}) {
} finally {
new Promise(resolve => setTimeout(resolve, 3000)).then(() => setSubmiting(false));
}
}, [handleError, setSubmiting]);
}, [t, handleError, setSubmiting]);

return (
<Accordion defaultActiveKey={defaultActiveKey}>
Expand Down Expand Up @@ -481,7 +480,7 @@ function VLiveStreamSelector({platform, vLiveFiles, setVLiveFiles}) {
} finally {
setSubmiting(false);
}
}, [inputStream, handleError, platform, setVLiveFiles, setSubmiting]);
}, [t, inputStream, handleError, platform, setVLiveFiles, setSubmiting]);

return (<>
<Form.Control as="div">
Expand Down Expand Up @@ -530,7 +529,7 @@ function VLiveFileSelector({platform, vLiveFiles, setVLiveFiles}) {
setVLiveFiles(res.data.data.files);
}).catch(handleError);
}).catch(handleError);
}, [inputFile, handleError, platform, setVLiveFiles]);
}, [t, inputFile, handleError, platform, setVLiveFiles]);

return (<>
<Form.Control as="div">
Expand Down Expand Up @@ -565,7 +564,7 @@ function VLiveFileUploader({platform, vLiveFiles, setVLiveFiles}) {
console.log(`${t('plat.tool.upload3')}, ${JSON.stringify(res.data.data)}`);
setFiles(res.data.data.files);
}).catch(handleError);
}, [handleError]);
}, [t, handleError]);

return (<>
<Form.Control as='div'>
Expand Down

0 comments on commit d059f19

Please sign in to comment.