Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
galene
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
galene
Commits
ca6020a2
Commit
ca6020a2
authored
Jan 12, 2021
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement filters.
No user interface yet.
parent
e7d7c2dd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
2 deletions
+85
-2
static/galene.js
static/galene.js
+85
-2
No files found.
static/galene.js
View file @
ca6020a2
...
...
@@ -83,6 +83,7 @@ function getUserPass() {
* @property {boolean} [activityDetection]
* @property {Array.<number>} [resolution]
* @property {boolean} [blackboardMode]
* @property {string} [filter]
*/
/** @type{settings} */
...
...
@@ -777,6 +778,70 @@ async function setMaxVideoThroughput(c, bps) {
}
}
/**
* @constructor
*/
function
Filter
(
stream
,
f
)
{
/** @type {MediaStream} */
this
.
input
=
stream
;
/** @type {(this: Filter, src: HTMLElement, dest: HTMLCanvasElement) => void} */
this
.
f
=
f
;
/** @type {HTMLVideoElement} */
this
.
video
=
document
.
createElement
(
'
video
'
);
/** @type {HTMLCanvasElement} */
this
.
canvas
=
document
.
createElement
(
'
canvas
'
);
/** @type {MediaStream} */
this
.
captureStream
=
null
;
/** @type {MediaStream} */
this
.
outputStream
=
null
;
/** @type {number} */
this
.
timer
=
null
;
/** @ts-ignore */
this
.
captureStream
=
this
.
canvas
.
captureStream
(
0
);
this
.
outputStream
=
new
MediaStream
();
this
.
outputStream
.
addTrack
(
this
.
captureStream
.
getTracks
()[
0
]);
this
.
input
.
getTracks
().
forEach
(
t
=>
{
t
.
onended
=
e
=>
this
.
stop
();
if
(
t
.
kind
!=
'
video
'
)
this
.
outputStream
.
addTrack
(
t
);
});
this
.
video
.
srcObject
=
stream
;
this
.
video
.
muted
=
true
;
this
.
video
.
play
();
this
.
timer
=
setInterval
(()
=>
this
.
draw
(),
1000
/
30
);
}
Filter
.
prototype
.
draw
=
function
()
{
this
.
canvas
.
width
=
this
.
video
.
videoWidth
;
this
.
canvas
.
height
=
this
.
video
.
videoHeight
;
this
.
f
(
this
.
video
,
this
.
canvas
);
/** @ts-ignore */
this
.
captureStream
.
getTracks
()[
0
].
requestFrame
();
};
Filter
.
prototype
.
stop
=
function
()
{
if
(
!
this
.
timer
)
return
;
this
.
captureStream
.
getTracks
()[
0
].
stop
();
clearTimeout
(
this
.
timer
);
this
.
timer
=
null
;
};
let
filters
=
{
'
mirror-h
'
:
(
video
,
canvas
)
=>
{
let
ctx
=
canvas
.
getContext
(
'
2d
'
);
ctx
.
scale
(
-
1
,
1
);
ctx
.
drawImage
(
video
,
-
video
.
videoWidth
,
0
);
},
'
mirror-v
'
:
(
video
,
canvas
)
=>
{
let
ctx
=
canvas
.
getContext
(
'
2d
'
);
ctx
.
scale
(
1
,
-
1
);
ctx
.
drawImage
(
video
,
0
,
-
video
.
videoHeight
);
},
};
function
isSafari
()
{
let
ua
=
navigator
.
userAgent
.
toLowerCase
();
return
ua
.
indexOf
(
'
safari
'
)
>=
0
&&
ua
.
indexOf
(
'
chrome
'
)
<
0
;
...
...
@@ -791,6 +856,14 @@ async function addLocalMedia(id) {
let
audio
=
settings
.
audio
?
{
deviceId
:
settings
.
audio
}
:
false
;
let
video
=
settings
.
video
?
{
deviceId
:
settings
.
video
}
:
false
;
let
filter
=
null
;
if
(
settings
.
filter
)
{
filter
=
filters
[
settings
.
filter
];
if
(
!
filter
)
{
displayWarning
(
`Unknown filter
${
filter
}
`
);
}
}
if
(
video
)
{
let
resolution
=
settings
.
resolution
;
if
(
resolution
)
{
...
...
@@ -830,9 +903,18 @@ async function addLocalMedia(id) {
let
c
=
newUpStream
(
id
);
c
.
kind
=
'
local
'
;
c
.
stream
=
stream
;
if
(
filter
)
{
let
f
=
new
Filter
(
stream
,
filter
);
c
.
stream
=
f
.
outputStream
;
c
.
onclose
=
function
()
{
f
.
stop
();
}
}
else
{
c
.
stream
=
stream
;
}
let
mute
=
getSettings
().
localMute
;
stream
.
getTracks
().
forEach
(
t
=>
{
c
.
stream
.
getTracks
().
forEach
(
t
=>
{
c
.
labels
[
t
.
id
]
=
t
.
kind
;
if
(
t
.
kind
==
'
audio
'
)
{
if
(
mute
)
...
...
@@ -972,6 +1054,7 @@ function stopUpMedia(c) {
try
{
t
.
stop
();
}
catch
(
e
)
{
console
.
warn
(
e
);
}
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment