Browse Source

webrtc: optimize publish page for mobile devices (#2066) (#2472)

pull/2475/head
Alessandro Ros 3 years ago committed by GitHub
parent
commit
64f4185537
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 81
      internal/core/webrtc_publish_index.html

81
internal/core/webrtc_publish_index.html

@ -8,7 +8,6 @@ html, body {
margin: 0; margin: 0;
padding: 0; padding: 0;
height: 100%; height: 100%;
overflow: hidden;
} }
body { body {
display: flex; display: flex;
@ -21,11 +20,12 @@ body {
min-height: 0; min-height: 0;
} }
#controls { #controls {
height: 200px;
flex-shrink: 0; flex-shrink: 0;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
min-height: 200px;
padding: 10px;
} }
#device { #device {
flex-direction: column; flex-direction: column;
@ -35,6 +35,14 @@ body {
display: flex; display: flex;
gap: 20px; gap: 20px;
justify-content: center; justify-content: center;
flex-wrap: wrap;
}
#device > div > div {
display: flex;
gap: 20px;
}
#error-message {
text-align: center;
} }
select { select {
width: 200px; width: 200px;
@ -50,31 +58,43 @@ select {
</div> </div>
<div id="device" style="display: none;"> <div id="device" style="display: none;">
<div id="device_line"> <div id="device_line">
video device: <div>
<select id="video_device"> video device
<option value="none">none</option> <select id="video_device">
</select> <option value="none">none</option>
</select>
audio device: </div>
<select id="audio_device">
<option value="none">none</option> <div>
</select> audio device
<select id="audio_device">
<option value="none">none</option>
</select>
</div>
</div> </div>
<div id="codec_line"> <div id="codec_line">
video codec: <div>
<select id="video_codec"> video codec
</select> <select id="video_codec">
</select>
</div>
audio codec: <div>
<select id="audio_codec"> audio codec
</select> <select id="audio_codec">
</select>
</div>
</div> </div>
<div id="bitrate_line"> <div id="bitrate_line">
video bitrate (kbps): <div>
<input id="video_bitrate" type="text" value="10000" /> video bitrate (kbps)
<input id="video_bitrate" type="text" value="10000" />
</div>
audio bitrate (kbps): <div>
<input id="audio_bitrate" type="text" value="32" /> audio bitrate (kbps)
<input id="audio_bitrate" type="text" value="32" />
</div>
<div> <div>
<input id="audio_voice" type="checkbox" checked> <input id="audio_voice" type="checkbox" checked>
@ -449,13 +469,14 @@ class Transmitter {
} }
const onTransmit = (stream) => { const onTransmit = (stream) => {
state = TRANSMITTING;
render();
document.getElementById('video').srcObject = stream; document.getElementById('video').srcObject = stream;
new Transmitter(stream); new Transmitter(stream);
}; };
const onPublish = () => { const onPublish = () => {
state = TRANSMITTING;
render();
const videoId = document.getElementById('video_device').value; const videoId = document.getElementById('video_device').value;
const audioId = document.getElementById('audio_device').value; const audioId = document.getElementById('audio_device').value;
@ -483,7 +504,12 @@ const onPublish = () => {
} }
navigator.mediaDevices.getUserMedia({ video, audio }) navigator.mediaDevices.getUserMedia({ video, audio })
.then(onTransmit); .then(onTransmit)
.catch((err) => {
state = ERROR;
errorMessage = err.toString();
render();
});
} else { } else {
navigator.mediaDevices.getDisplayMedia({ navigator.mediaDevices.getDisplayMedia({
video: { video: {
@ -494,7 +520,12 @@ const onPublish = () => {
}, },
audio: false, audio: false,
}) })
.then(onTransmit); .then(onTransmit)
.catch((err) => {
state = ERROR;
errorMessage = err.toString();
render();
});
} }
}; };

Loading…
Cancel
Save