restreamer-ui-v2/scripts/test-whip-post.js
Cesar Mendivil 00e98a19b3 feat: add InternalWHIP component and associated tests
- Implemented the InternalWHIP component for managing WHIP server configurations.
- Added functionality to load live WHIP state from Core and handle OBS URL generation.
- Included polling for active streams and notifying parent components of state changes.
- Created comprehensive tests for the InternalWHIP component covering various scenarios including fallback mechanisms and state changes.

test: add integration tests for WHIP source component

- Developed end-to-end tests for the InternalWHIP component to verify its behavior under different configurations.
- Ensured that the component correctly handles the loading of WHIP state, displays appropriate messages, and emits the correct onChange events.

test: add Settings WHIP configuration tests

- Implemented tests for the WHIP settings tab to validate loading and saving of WHIP configurations.
- Verified that the correct values are sent back to the Core when the user saves changes.
- Ensured that the UI reflects the current state of the WHIP configuration after Core restarts or changes.
2026-03-14 12:27:53 -07:00

59 lines
2.1 KiB
JavaScript

'use strict';
const https = require('https');
const { IngressClient, IngressInput } = require('/home/xesar/WebstormProjects/restreamer-ui-v2/node_modules/livekit-server-sdk');
const LK_API_KEY = 'APIBTqTGxf9htMK';
const LK_API_SECRET = '0dOHWPffwneaPg7OYpe4PeAes21zLJfeYJB9cKzSTtXW';
const LK_HTTP_URL = 'https://livekit-server.nextream.sytes.net';
const CADDY_HOST = 'djmaster.nextream.sytes.net';
const sdp = [
'v=0', 'o=- 0 0 IN IP4 127.0.0.1', 's=-', 't=0 0',
'm=video 9 UDP/TLS/RTP/SAVPF 96',
'c=IN IP4 0.0.0.0',
'a=sendonly', 'a=rtpmap:96 H264/90000', 'a=mid:0',
].join('\r\n') + '\r\n';
function post(path, extraHeaders) {
return new Promise((resolve, reject) => {
const req = https.request({
hostname: CADDY_HOST, path, method: 'POST',
headers: {
'Content-Type': 'application/sdp',
'Content-Length': Buffer.byteLength(sdp),
...extraHeaders,
},
rejectUnauthorized: false, timeout: 10000,
}, (r) => {
let d = '';
r.on('data', (c) => (d += c));
r.on('end', () => resolve({ status: r.statusCode, body: d.slice(0, 200) }));
});
req.on('error', reject);
req.on('timeout', () => { req.destroy(); reject(new Error('timeout')); });
req.write(sdp);
req.end();
});
}
(async () => {
const client = new IngressClient(LK_HTTP_URL, LK_API_KEY, LK_API_SECRET);
const ingress = await client.createIngress(IngressInput.WHIP_INPUT, {
name: 'test-whip-post', roomName: 'test', participantIdentity: 'obs', participantName: 'OBS',
});
console.log('stream_key :', ingress.streamKey);
console.log('ingress.url:', ingress.url);
console.log('\n[A] POST /w/<stream_key> (stream_key in URL path)');
const a = await post('/w/' + ingress.streamKey, {});
console.log(' status:', a.status, '| body:', a.body);
console.log('\n[B] POST /w (Authorization: Bearer <stream_key>)');
const b = await post('/w', { Authorization: 'Bearer ' + ingress.streamKey });
console.log(' status:', b.status, '| body:', b.body);
await client.deleteIngress(ingress.ingressId).catch(() => {});
console.log('\nIngress eliminado');
})().catch((e) => { console.error(e.message); process.exit(1); });