@uniai-fe/uds-templates 0.6.2 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/cctv/apis/server.ts
CHANGED
|
@@ -224,16 +224,6 @@ export async function getServerCctvToken({
|
|
|
224
224
|
token: "",
|
|
225
225
|
};
|
|
226
226
|
|
|
227
|
-
const BODY_PRESET: API_Req_CctvRtcTokenOrigin = {
|
|
228
|
-
site: "company_id",
|
|
229
|
-
username: "harim",
|
|
230
|
-
password: "harim",
|
|
231
|
-
action: "read",
|
|
232
|
-
path: "cam_id",
|
|
233
|
-
ttl_seconds: 3600,
|
|
234
|
-
kid: "streaming-auth-1",
|
|
235
|
-
};
|
|
236
|
-
|
|
237
227
|
if (!reqBody || !reqBody.username || !reqBody.company_id || !reqBody.cam_id) {
|
|
238
228
|
nextAPILog("POST", routeUrl, query_url, { reqBody });
|
|
239
229
|
return {
|
|
@@ -257,11 +247,13 @@ export async function getServerCctvToken({
|
|
|
257
247
|
|
|
258
248
|
// 토큰 요청 payload 구성
|
|
259
249
|
const bodyData: API_Req_CctvRtcTokenOrigin = {
|
|
260
|
-
...BODY_PRESET,
|
|
261
250
|
site,
|
|
262
251
|
username,
|
|
263
252
|
password,
|
|
253
|
+
action: "read",
|
|
264
254
|
path,
|
|
255
|
+
ttl_seconds: 3600,
|
|
256
|
+
kid: "streaming-auth-1",
|
|
265
257
|
};
|
|
266
258
|
|
|
267
259
|
nextAPILog("POST", routeUrl, query_url, { bodyData });
|
|
@@ -58,11 +58,13 @@ export function useCctvRtcStreamRegistry(): CctvRtcStreamRegistry {
|
|
|
58
58
|
* @property {string} [listUrl] company-list API 요청 경로
|
|
59
59
|
* @property {string} [tokenUrl] token API 요청 경로
|
|
60
60
|
* @property {string} [username] CCTV 조회시 권한 확인을 위한 계정명
|
|
61
|
+
* @property {string} [whepUsername] WHEP endpoint username 덮어쓰기 값
|
|
61
62
|
* @property {ContextExtension} [defaultValues] 서비스 확장 context 기본값
|
|
62
63
|
* @property {React.ReactNode} children
|
|
63
64
|
*/
|
|
64
65
|
export default function CCTVProvider<ContextExtension extends object = object>({
|
|
65
66
|
username,
|
|
67
|
+
whepUsername,
|
|
66
68
|
company_id,
|
|
67
69
|
cam_id,
|
|
68
70
|
listUrl,
|
|
@@ -83,6 +85,7 @@ export default function CCTVProvider<ContextExtension extends object = object>({
|
|
|
83
85
|
...defaultValues,
|
|
84
86
|
...CCTV_CONTEXT_DEFAULT_VALUES,
|
|
85
87
|
username,
|
|
88
|
+
whepUsername,
|
|
86
89
|
company_id,
|
|
87
90
|
cam_id,
|
|
88
91
|
} as DefaultValues<CctvContext<ContextExtension>>;
|
|
@@ -122,15 +122,18 @@ export function useCctvRtcStream({
|
|
|
122
122
|
const [isStreaming, setStreaming] = useState(false);
|
|
123
123
|
const [hasConnected, setHasConnected] = useState(false);
|
|
124
124
|
|
|
125
|
-
// react-hook-form 컨텍스트에서 username
|
|
125
|
+
// react-hook-form 컨텍스트에서 token username과 WHEP username override를 추적한다.
|
|
126
126
|
const { control } = useFormContext();
|
|
127
|
-
const
|
|
127
|
+
const tokenUsername = useWatch({ control, name: "username" });
|
|
128
|
+
const whepUsername = useWatch({ control, name: "whepUsername" });
|
|
129
|
+
const endpointUsername =
|
|
130
|
+
whepUsername === undefined ? tokenUsername : whepUsername;
|
|
128
131
|
|
|
129
132
|
// 카메라/회사/사용자 정보를 토대로 WHEP 토큰을 발급받는다.
|
|
130
133
|
const tokenQuery = useQueryCctvRtcToken({
|
|
131
134
|
company_id: cam?.company_id ?? "",
|
|
132
135
|
cam_id: cam?.cam_id ?? "",
|
|
133
|
-
username,
|
|
136
|
+
username: tokenUsername,
|
|
134
137
|
url: tokenUrl ?? contextTokenUrl,
|
|
135
138
|
});
|
|
136
139
|
|
|
@@ -141,16 +144,18 @@ export function useCctvRtcStream({
|
|
|
141
144
|
// 카메라의 RTC 엔드포인트와 사용자명을 조합해 실제 WHEP endpoint를 계산한다.
|
|
142
145
|
const endpoint = useMemo(() => {
|
|
143
146
|
if (!cam?.cam_rtc) return undefined;
|
|
144
|
-
const query =
|
|
147
|
+
const query = endpointUsername
|
|
148
|
+
? `?username=${encodeURIComponent(endpointUsername)}`
|
|
149
|
+
: "";
|
|
145
150
|
return `${cam.cam_rtc.replace(/\/$/, "")}/whep${query}`;
|
|
146
|
-
}, [cam?.cam_rtc,
|
|
151
|
+
}, [cam?.cam_rtc, endpointUsername]);
|
|
147
152
|
|
|
148
153
|
const streamKeyCandidate = useMemo(() => {
|
|
149
154
|
if (!cam?.cam_id || !cam.cam_online || !endpoint || !tokenQuery.data?.token)
|
|
150
155
|
return "";
|
|
151
156
|
|
|
152
157
|
return [
|
|
153
|
-
|
|
158
|
+
tokenUsername,
|
|
154
159
|
cam.company_id,
|
|
155
160
|
cam.cam_id,
|
|
156
161
|
endpoint,
|
|
@@ -163,14 +168,14 @@ export function useCctvRtcStream({
|
|
|
163
168
|
endpoint,
|
|
164
169
|
tokenQuery.data?.token,
|
|
165
170
|
tokenQuery.dataUpdatedAt,
|
|
166
|
-
|
|
171
|
+
tokenUsername,
|
|
167
172
|
]);
|
|
168
173
|
|
|
169
174
|
const streamIdentityKey = useMemo(() => {
|
|
170
175
|
if (!cam?.cam_id || !endpoint) return "";
|
|
171
176
|
|
|
172
|
-
return [
|
|
173
|
-
}, [cam?.cam_id, cam?.company_id, endpoint,
|
|
177
|
+
return [tokenUsername, cam.company_id, cam.cam_id, endpoint].join("|");
|
|
178
|
+
}, [cam?.cam_id, cam?.company_id, endpoint, tokenUsername]);
|
|
174
179
|
|
|
175
180
|
useEffect(() => {
|
|
176
181
|
setHasConnected(false);
|
|
@@ -60,6 +60,7 @@ export interface CctvApiUrlContext {
|
|
|
60
60
|
* @property {string} [company_id] 선택된 업체 id코드
|
|
61
61
|
* @property {string} [cam_id] 선택된 카메라 id코드
|
|
62
62
|
* @property {string} username CCTV 조회시 권한 확인을 위한 계정명
|
|
63
|
+
* @property {string} [whepUsername] WHEP endpoint username 덮어쓰기 값
|
|
63
64
|
* @property {string} [search] 검색 키워드 (입력값)
|
|
64
65
|
* @property {string} [filter] 검색 키워드 (필터값)
|
|
65
66
|
* @property {API_Res_CctvCompanyGroup[]} rawData 원본 데이터 배열
|
|
@@ -71,6 +72,10 @@ export interface CctvBaseContext extends CctvSelectedContext {
|
|
|
71
72
|
* CCTV 조회시 권한 확인을 위한 계정명
|
|
72
73
|
*/
|
|
73
74
|
username: string;
|
|
75
|
+
/**
|
|
76
|
+
* WHEP endpoint username 덮어쓰기 값
|
|
77
|
+
*/
|
|
78
|
+
whepUsername?: string;
|
|
74
79
|
/**
|
|
75
80
|
* 검색 키워드 (입력값)
|
|
76
81
|
*/
|
|
@@ -100,6 +105,7 @@ export interface CctvBaseContext extends CctvSelectedContext {
|
|
|
100
105
|
* @property {string} [company_id] 선택된 업체 id코드
|
|
101
106
|
* @property {string} [cam_id] 선택된 카메라 id코드
|
|
102
107
|
* @property {string} username CCTV 조회시 권한 확인을 위한 계정명
|
|
108
|
+
* @property {string} [whepUsername] WHEP endpoint username 덮어쓰기 값
|
|
103
109
|
* @property {string} search 검색 키워드 입력값
|
|
104
110
|
* @property {string} filter 검색 키워드 필터값
|
|
105
111
|
* @property {API_Res_CctvCompanyGroup[]} rawData 원본 데이터 배열
|
|
@@ -117,6 +123,7 @@ export type CctvContext<ContextExtension extends object = object> =
|
|
|
117
123
|
* @property {string} [listUrl] company-list API 요청 경로
|
|
118
124
|
* @property {string} [tokenUrl] token API 요청 경로
|
|
119
125
|
* @property {string} [username] CCTV 조회시 권한 확인을 위한 계정명
|
|
126
|
+
* @property {string} [whepUsername] WHEP endpoint username 덮어쓰기 값
|
|
120
127
|
* @property {ContextExtension} [defaultValues] 서비스 확장 context 기본값
|
|
121
128
|
* @property {React.ReactNode} children
|
|
122
129
|
*/
|
|
@@ -127,6 +134,10 @@ export type CctvProviderProps<ContextExtension extends object = object> =
|
|
|
127
134
|
* CCTV 조회시 권한 확인을 위한 계정명
|
|
128
135
|
*/
|
|
129
136
|
username?: string;
|
|
137
|
+
/**
|
|
138
|
+
* WHEP endpoint username 덮어쓰기 값
|
|
139
|
+
*/
|
|
140
|
+
whepUsername?: string;
|
|
130
141
|
/**
|
|
131
142
|
* 서비스 확장 context 기본값
|
|
132
143
|
*/
|