From 923c22d399aec1b3dbad8e4597d04ceb49fe49a9 Mon Sep 17 00:00:00 2001 From: golgetahir Date: Wed, 12 Mar 2025 00:45:38 +0300 Subject: [PATCH 1/6] Implement WHEP playback and add test page --- src/main/webapp/WEB-INF/web.xml | 21 +++++ src/main/webapp/whep.html | 160 ++++++++++++++++++++++++++++++++ 2 files changed, 181 insertions(+) create mode 100644 src/main/webapp/whep.html diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index ce42eb27..a2ef311d 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -182,6 +182,27 @@ /whip/* + + whep-serlvet + + org.glassfish.jersey.servlet.ServletContainer + + + jersey.config.server.provider.packages + io.antmedia.whep + + + jersey.config.server.provider.classnames + org.glassfish.jersey.media.multipart.MultiPartFeature + + + true + 1 + + + whep-serlvet + /whep/* + jersey-serlvet diff --git a/src/main/webapp/whep.html b/src/main/webapp/whep.html new file mode 100644 index 00000000..9fd8bca6 --- /dev/null +++ b/src/main/webapp/whep.html @@ -0,0 +1,160 @@ + + + + WHEP Test + + + + +

WHEP Test Player

+ + +
+ + + +
+ + + + \ No newline at end of file From 60a587ca9280efc5a1f1dc0e69080f3338b0a265 Mon Sep 17 00:00:00 2001 From: golgetahir Date: Sun, 16 Mar 2025 22:33:03 +0100 Subject: [PATCH 2/6] Update whep.html in ietf standards --- src/main/webapp/whep.html | 102 ++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 59 deletions(-) diff --git a/src/main/webapp/whep.html b/src/main/webapp/whep.html index 9fd8bca6..4fae428f 100644 --- a/src/main/webapp/whep.html +++ b/src/main/webapp/whep.html @@ -47,84 +47,68 @@

WHEP Test Player

pc.addTransceiver('audio', {direction: 'recvonly'}); pc.addTransceiver('video', {direction: 'recvonly'}); - sendWhepStart(); - - async function sendWhepStart() { - try { - console.log("Sending Whep start"); - const response = await fetch(`http://localhost:5080/LiveApp/whep/${streamId}`); - - if (!response.ok) { - throw new Error(`HTTP error! status: ${response.status}`); - } - - console.log("Whep start is successfully sent, answer is: ", response); - - // Get the ETag header which contains the session ID - const eTag = response.headers.get('ETag'); - whepSession = { pc, streamId, eTag }; + // Create an offer + const offer = await pc.createOffer(); + await pc.setLocalDescription(offer); - console.log("Whep start is successfully sent, eTag is: ", eTag); - - const sdp = await response.text(); - console.log("Whep start is successfully sent, sdp is: ", sdp); - - const remoteDesc = new RTCSessionDescription({ - type: 'offer', // In WHEP, the server sends an offer - sdp: sdp - }); - - await pc.setRemoteDescription(remoteDesc); - - const answer = await pc.createAnswer(); - - await pc.setLocalDescription(answer); - - await new Promise((resolve) => { - if (pc.iceGatheringState === 'complete') { - resolve(); - } else { - pc.addEventListener('icegatheringstatechange', function onStateChange() { + console.log("Offer created: ", offer); + console.log("Offer local description: ", pc.localDescription); + console.log("*********************12313131231313 *********************"); + + // Wait for ICE gathering to complete + await new Promise((resolve) => { + if (pc.iceGatheringState === 'complete') { + resolve(); + } else { + pc.addEventListener('icegatheringstatechange', function onStateChange() { if (pc.iceGatheringState === 'complete') { pc.removeEventListener('icegatheringstatechange', onStateChange); resolve(); } - }); - } }); - - await sendWhepAnswer(pc.localDescription.sdp, eTag); - - } catch (error) { - console.error('Error sending WHEP start:', error); } - } + }); + + sendWhepOffer(); - async function sendWhepAnswer(sdp, eTag) { + async function sendWhepOffer() { try { - const response = await fetch(`http://localhost:5080/LiveApp/whep/${streamId}/${eTag}`, { + console.log("Sending Whep offer"); + + // Send the offer to the server in a single POST request + const response = await fetch(`http://localhost:5080/LiveApp/whep/${streamId}`, { method: 'POST', headers: { - 'Content-Type': 'application/sdp', + 'Content-Type': 'application/sdp' }, - body: sdp + body: pc.localDescription.sdp }); - if (!response.ok) { + if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } + + console.log("Whep offer was successfully sent"); - // Get the SDP answer - const answerSDP = await response.text(); - - // Set the remote description - const answer = new RTCSessionDescription({ + // Get the ETag header which contains the session ID + const eTag = response.headers.get('ETag'); + whepSession = { pc, streamId, eTag }; + + console.log("ETag received: ", eTag); + + // Get the SDP answer from the response + const answerSdp = await response.text(); + console.log("Answer SDP received: ", answerSdp); + + // Create and set the remote description with the answer from the server + const remoteDesc = new RTCSessionDescription({ type: 'answer', - sdp: answerSDP + sdp: answerSdp }); - - //await pc.setRemoteDescription(answer); + + await pc.setRemoteDescription(remoteDesc); console.log('WHEP connection established'); + } catch (error) { console.error('Error establishing WHEP connection:', error); } @@ -138,7 +122,7 @@

WHEP Test Player

if (whepSession) { try { // Send DELETE request to terminate the session - await fetch(`/whep/${whepSession.streamId}/${whepSession.eTag}`, { + await fetch(`http://localhost:5080/LiveApp/whep/${whepSession.streamId}/${whepSession.eTag}`, { method: 'DELETE' }); From 02ecde3434b5fc4e9296376b320e2a91b0068a30 Mon Sep 17 00:00:00 2001 From: golgetahir Date: Tue, 25 Mar 2025 21:11:15 +0300 Subject: [PATCH 3/6] Make whep player better looking --- src/main/webapp/whep.html | 73 ++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 13 deletions(-) diff --git a/src/main/webapp/whep.html b/src/main/webapp/whep.html index 4fae428f..f5ecfd88 100644 --- a/src/main/webapp/whep.html +++ b/src/main/webapp/whep.html @@ -1,20 +1,53 @@ - - + + - WHEP Test + WHEP Player + - + + + + -

WHEP Test Player

- - -
- - - +
+
+
+

+ WebRTC Samples > WHEP Player +

+
+
+ +
+
+
+ +
+ +
+
+ +
+ +
+ + +
+
+ +
- + + + + + + - +