From b989e3dff576b618ee9cd881968e295a8e5aaf39 Mon Sep 17 00:00:00 2001 From: Steve Seguin Date: Mon, 13 Dec 2021 07:46:17 -0500 Subject: [PATCH] battery status and other fixes --- codecs.html | 55 ++++-- index.html | 56 +++--- lib.js | 492 +++++++++++++++++++++++++++++++++++++++++----------- main.css | 33 ++++ main.js | 118 ++++++++++++- webrtc.js | 2 +- 6 files changed, 615 insertions(+), 141 deletions(-) diff --git a/codecs.html b/codecs.html index c96333e..62caa7c 100644 --- a/codecs.html +++ b/codecs.html @@ -16,7 +16,16 @@ function getSupportedMimeTypes(media, types, codecs) { mimeType+';codecs:"'+codec.toUpperCase()+', '+codec2.toUpperCase()+'"' ].forEach(variation => { if (isSupported(variation)){ - supported.push(variation); + try { + options.mimeType = variation; + new MediaRecorder(stream, options); + + mediaSource.addSourceBuffer(variation); + + supported.push(variation); + } catch(e){ + console.error(e); + } } })); }); @@ -26,26 +35,46 @@ function getSupportedMimeTypes(media, types, codecs) { return supported; }; -// Usage ------------------ + +var options = {}; +options.videoBitsPerSecond = parseInt(2500 * 1024); const videoTypes = ["webm", "ogg", "mp4", "x-matroska"]; const audioTypes = ["webm", "ogg", "mp3", "x-matroska"]; const codecs = ["vp9", "vp9.0", "vp8", "vp8.0", "avc1", "av1", "h265", "h.265", "h264", "h.264"] -const acodecs = ["opus"]; - -const supportedVideos = getSupportedMimeTypes("video", videoTypes, codecs); -const supportedAudios = getSupportedMimeTypes("audio", audioTypes, codecs); - -console.log('-- Top supported Video : ', supportedVideos[0]) -console.log('-- Top supported Audio : ', supportedAudios[0]) -console.log('-- All supported Videos : ', supportedVideos) -console.log('-- All supported Audios : ', supportedAudios) +const acodecs = ["opus", "pcm", "aac", "mpeg", "mp4a", "mp3", "vorbis"]; document.getElementById("output").innerHTML= ""; +var supportedVideos = null; +var supportedAudios = null; +// Usage ------------------ +var stream = null; +var mediaSource = new MediaSource(); -for (var i=0;i"; +var video = document.createElement("video"); +video.autoplay = true; +video.muted = false; +video.setAttribute("playsinline",""); +video.src = URL.createObjectURL(mediaSource); + +mediaSource.addEventListener('sourceopen', sourceOpen); +console.log("1"); +function sourceOpen(e) { + console.log("2"); + navigator.mediaDevices.getUserMedia({audio:true,video:true}).then(function(s) { + stream = s; + + supportedVideos = getSupportedMimeTypes("video", videoTypes, codecs); + supportedAudios = getSupportedMimeTypes("audio", audioTypes, codecs); + + for (var i=0;i"; + } + }).catch(function(err) { + /* handle the error */ + }); } + //for (var i=0;i"; //} diff --git a/index.html b/index.html index 742e814..9f56cd5 100644 --- a/index.html +++ b/index.html @@ -67,7 +67,7 @@ - +