openvibers/openvibe.live Commits

API docs: the go-live example with openvibe-sdk/live (slot, go live, WHIP publish and end) (#273)

OP OpenVibers committed 24 days ago · 24e6141ee5 · 1 file, +11 −0

Changes

ddiff --git a/public/fragments/documentation.html b/public/fragments/documentation.html
iindex 85b01b64..43db8b34 100644
---- a/public/fragments/documentation.html
++++ b/public/fragments/documentation.html
@@@ -287,6 +287,17 @@ const { stream, endpoint } = await fetch('https://openvibe.live/api/streams', {
console.log(endpoint.whipUrlBase); // POST your SDP offer here (see WebRTC tab)
</code></pre>
++<h3>The same with openvibe-sdk</h3>
++<p>In Node, <code>npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.52.0</code> and use <code>openvibe-sdk/live</code>: who is live, channels, slots, going live, the session, the content feeds and WHIP, with errors as <code>OpenVibeError</code> (<a href="https://github.com/OpenVibers/OpenVibe.SDK#readme" target="_blank" rel="noopener">SDK README</a>).</p>
++<pre><code>const { createClient } = require('openvibe-sdk');
++const { createLiveClient } = require('openvibe-sdk/live');
++const live = createLiveClient(createClient({ token: TOKEN })); // openvibe.live is found through the network registry
++
++const { managed_stream: slot } = await live.slots.create({ title: 'Robot cam', streaming_method: 'whip', category: 'Technology' });
++const { stream, endpoint } = await live.goLive(slot.id);
++const { answer, location } = await live.whip.publish(live.whip.url(slot.stream_key), offerSdp);
++// … later: await live.whip.end(location); // the last session on a stream ends it
++</code></pre>
</div>