Skip to content
Snippets Groups Projects
Commit e11db8f8 authored by Greg Fodor's avatar Greg Fodor
Browse files

Refactor fake webrtc:// scheme into hubs://client/<client id>/video

parent 6ed4af3f
No related branches found
No related tags found
No related merge requests found
......@@ -86,10 +86,10 @@ async function createVideoEl(src) {
videoEl.loop = true;
videoEl.crossOrigin = "anonymous";
if (!src.startsWith("webrtc://")) {
if (!src.startsWith("hubs://")) {
videoEl.src = src;
} else {
const streamClientId = src.substring(9);
const streamClientId = src.substring(7).split("/")[1]; // /clients/<client id>/video is only URL for now
const stream = await NAF.connection.adapter.getMediaStream(streamClientId, "video");
videoEl.srcObject = new MediaStream(stream.getVideoTracks());
}
......@@ -327,7 +327,7 @@ AFRAME.registerComponent("media-video", {
return;
}
if (!src.startsWith("webrtc://")) {
if (!src.startsWith("hubs://")) {
// TODO FF error here if binding mediastream: The captured HTMLMediaElement is playing a MediaStream. Applying volume or mute status is not currently supported -- not an issue since we have no audio atm in shared video.
texture.audioSource = this.el.sceneEl.audioListener.context.createMediaElementSource(texture.image);
......
......@@ -22,7 +22,7 @@ function b64EncodeUnicode(str) {
}
export const proxiedUrlFor = (url, index) => {
if (url.startsWith("webrtc://")) return url;
if (!(url.startsWith("http:") || url.startsWith("https:"))) return url;
// farspark doesn't know how to read '=' base64 padding characters
const base64Url = b64EncodeUnicode(url).replace(/=+$/g, "");
......@@ -46,7 +46,7 @@ export const resolveUrl = async (url, index) => {
};
export const guessContentType = url => {
if (url.startsWith("webrtc://")) return "video/webrtc";
if (url.startsWith("hubs://") && url.endsWith("/video")) return "video/vnd.hubs-webrtc";
const extension = new URL(url).pathname.split(".").pop();
return commonKnownContentTypes[extension];
};
......@@ -128,9 +128,8 @@ export const addMedia = (src, template, contentOrigin, resolve = false, resize =
.catch(() => {
entity.setAttribute("media-loader", { src: "error" });
});
}
if (src instanceof MediaStream) {
entity.setAttribute("media-loader", { src: `webrtc://${NAF.clientId}` });
} else if (src instanceof MediaStream) {
entity.setAttribute("media-loader", { src: `hubs://clients/${NAF.clientId}/video` });
}
if (contentOrigin) {
......
......@@ -22,8 +22,8 @@ export default function pinnedEntityToGltf(el) {
if (components["media-loader"]) {
const mediaSrc = components["media-loader"].data.src;
if (mediaSrc.startsWith("webrtc://")) {
// Do not persist webrtc media shares
if (mediaSrc.startsWith("hubs://") && mediaSrc.endsWith("/video")) {
// Do not persist hubs client video urls
return null;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment