Skip to content

Commit

Permalink
stream to openfire
Browse files Browse the repository at this point in the history
update orinayo client
  • Loading branch information
deleolajide committed Jan 1, 2025
1 parent bede508 commit 68394f6
Show file tree
Hide file tree
Showing 29 changed files with 945 additions and 112 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
70 changes: 70 additions & 0 deletions classes/jsp/audio-publisher.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<!--
This example demonstrates how to publish a stream without libraries or dependencies.
-->

<html>
<head>
<title>publisher</title>
<script src="./js/stophe.min.js"></script>
</head>

<body>
<button onclick="window.publishStream()"> Publish Stream </button>

<h3> Video </h3>
<audio id="audioPlayer" autoplay muted controls style="width: 500"> </audio>

<h3> Connection State </h3>
<div id="connectionState"></div> <br />
</body>

<script>
window.publishStream = async () => {
window.connection = new Strophe.Connection(location.protocol.replace("http", "ws") + "//" + location.host + "/ws/");

window.connection.connect(location.hostname, null, async function (status) {
console.debug("XMPPConnection.connect", status);

if (status === Strophe.Status.CONNECTED) {
window.connection.send($pres());

let mediaOptions = {audio: true, video: false}

let peerConnection = new RTCPeerConnection();

peerConnection.oniceconnectionstatechange = () => {
document.getElementById('connectionState').innerText = peerConnection.iceConnectionState;
}

const stream = await navigator.mediaDevices.getUserMedia(mediaOptions);
document.getElementById('audioPlayer').srcObject = stream;

stream.getTracks().forEach(t => {
if (t.kind === 'audio') {
peerConnection.addTransceiver(t, {direction: 'sendonly'})
}
})

const offer = await peerConnection.createOffer();
peerConnection.setLocalDescription(offer);

window.connection.sendIQ($iq({type: 'set', to: window.connection.domain}).c('whip', {xmlns: 'urn:xmpp:whip:0'}).c('sdp', offer.sdp),
function (res) {
const answer = res.querySelector('sdp').innerHTML;
peerConnection.setRemoteDescription({sdp: answer, type: 'answer'});
console.debug('whip answer', answer);

}, function (err) {
console.warn('whip failed', err);
}
);
}
else

if (status === Strophe.Status.DISCONNECTED) {

}
});
}
</script>
</html>
77 changes: 77 additions & 0 deletions classes/jsp/audio-watcher.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<!--
This example demonstrates how to watch a stream without libraries or dependencies.
With this HTML you can add a 'Broadcast Box Player' to any site you want
-->

<html>
<head>
<title>audio-watcher</title>
<script src="./js/stophe.min.js"></script>
</head>

<body>
<b> Stream Key </b> <input type="text" id="streamKey" /> <br />
<button onclick="window.watchStream()"> Watch Stream </button>

<h3> Audio </h3>
<audio id="audioPlayer" autoplay controls style="width: 500"> </audio>

<h3> Connection State </h3>
<div id="connectionState"></div> <br />
</body>

<script>
window.watchStream = () => {
window.connection = new Strophe.Connection(location.protocol.replace("http", "ws") + "//" + location.host + "/ws/");

window.connection.connect(location.hostname, null, function (status) {
console.debug("XMPPConnection.connect", status);

if (status === Strophe.Status.CONNECTED) {
window.connection.send($pres());

setTimeout(() => {
const streamKey = document.getElementById('streamKey').value

if (streamKey === '') {
return window.alert('Stream Key must not be empty')
}

let peerConnection = new RTCPeerConnection()
peerConnection.addTransceiver('audio', { direction: 'recvonly' })

peerConnection.ontrack = function (event) {
document.getElementById('audioPlayer').srcObject = event.streams[0]
}

peerConnection.oniceconnectionstatechange = () => {
document.getElementById('connectionState').innerText = peerConnection.iceConnectionState;
}

peerConnection.createOffer().then(offer => {
peerConnection.setLocalDescription(offer);
console.debug('whep offer', offer.sdp);

window.connection.sendIQ($iq({type: 'set', to: window.connection.domain}).c('whep', {id: streamKey, xmlns: 'urn:xmpp:whep:0'}).c('sdp', offer.sdp),
function (res) {
console.debug('whep response', res);
const answer = res.querySelector('sdp').innerHTML;
peerConnection.setRemoteDescription({sdp: answer, type: 'answer'});
console.debug('whep answer', answer);

}, function (err) {
console.warn('whep failed', err);
}
);
})
});
}
else

if (status === Strophe.Status.DISCONNECTED) {

}
});
}
</script>
</html>
6 changes: 5 additions & 1 deletion classes/jsp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<fluent-button appearance="accent" title='Display song lyrics' id="show_lyrics">Lyrics</fluent-button>
<fluent-button appearance="accent" title='Save all settings as a registration (1-7)' id="save_reg">Save</fluent-button>
<fluent-button appearance="accent" title='Record performance as video or audio file' style="display: none;" id="record_song">Record</fluent-button>
<fluent-button appearance="accent" title='Stream performance to hosted server' style="display: none;" id="stream_song">Start Stream</fluent-button>
<fluent-button appearance="accent" title='Refresh application for new settings to take effect' id="reset_app">Refresh</fluent-button>
</center><div>
<div id="sequencer2" style="margin:10px">
Expand Down Expand Up @@ -99,6 +100,9 @@
</tr>
</table>
</div>
<div id="lavagenie" style="display:none;">
<div><center><h3>Lava Genie Ready</h3></center></div>
</div>
</td>
</tr>
<tr><td><b>Song Sequence</b></td><td><select id="songSequence" type="text" class="form-control input"></select></td><td></td></tr>
Expand Down Expand Up @@ -133,7 +137,7 @@
<script src='./js/0253_Acoustic_Guitar_sf2_file.js'></script>
<script src='./js/0341_Aspirin_sf2_file.js'></script>
<script src='./js/0260_JCLive_sf2_file.js'></script>
<script src="./assets/pedalboard.js" type="module"></script>
<script src="./assets/pedalboard.js" type="module"></script>
<script src="./js/basic-pitch.js"></script>
<script src="./js/tonal.min.js"></script>
<script src="./js/stream-deck.js"></script>
Expand Down
1 change: 1 addition & 0 deletions classes/jsp/js/audio_looper.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function AudioLooper(styleType) {

this.gainNode.connect(this.audioContext.destination);
if (recorderDestination) this.gainNode.connect(recorderDestination);
if (streamDestination) this.gainNode.connect(streamDestination);
this.source.connect(this.gainNode);

try {
Expand Down
2 changes: 1 addition & 1 deletion classes/jsp/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const createOrinAyoWindow = () => {
chrome.windows.create(data, async (win) => {
//await chrome.offscreen.closeDocument();
chrome.storage.local.set({orinAyoWin: win.id});
chrome.windows.update(win.id, {width: 1060, height: 1040});
chrome.windows.update(win.id, {width: 1090, height: 1040});
});
}

Expand Down
Loading

0 comments on commit 68394f6

Please sign in to comment.