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
cf6c1203
Commit
cf6c1203
authored
Jan 12, 2021
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better typing for filters, allow filters to skip frames.
parent
a5b57976
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
+17
-9
static/galene.js
static/galene.js
+17
-9
No files found.
static/galene.js
View file @
cf6c1203
...
@@ -779,12 +779,14 @@ async function setMaxVideoThroughput(c, bps) {
...
@@ -779,12 +779,14 @@ async function setMaxVideoThroughput(c, bps) {
}
}
/**
/**
* @param {MediaStream} stream
* @param {(this: Filter, src: CanvasImageSource, dest: HTMLCanvasElement) => boolean} f
* @constructor
* @constructor
*/
*/
function
Filter
(
stream
,
f
)
{
function
Filter
(
stream
,
f
)
{
/** @type {MediaStream} */
/** @type {MediaStream} */
this
.
inputStream
=
stream
;
this
.
inputStream
=
stream
;
/** @type {(this: Filter, src:
HTMLElement, dest: HTMLCanvasElement) => void
} */
/** @type {(this: Filter, src:
CanvasImageSource, dest: HTMLCanvasElement) => boolean
} */
this
.
f
=
f
;
this
.
f
=
f
;
/** @type {number} */
/** @type {number} */
this
.
frameRate
=
30
;
this
.
frameRate
=
30
;
...
@@ -801,7 +803,6 @@ function Filter(stream, f) {
...
@@ -801,7 +803,6 @@ function Filter(stream, f) {
/** @type {number} */
/** @type {number} */
this
.
count
=
0
;
this
.
count
=
0
;
//this.input.getTracks().forEach(t => console.log(t.getSettings()));
/** @ts-ignore */
/** @ts-ignore */
this
.
captureStream
=
this
.
canvas
.
captureStream
(
0
);
this
.
captureStream
=
this
.
canvas
.
captureStream
(
0
);
...
@@ -838,9 +839,11 @@ Filter.prototype.draw = function() {
...
@@ -838,9 +839,11 @@ Filter.prototype.draw = function() {
this
.
canvas
.
width
=
this
.
video
.
videoWidth
;
this
.
canvas
.
width
=
this
.
video
.
videoWidth
;
this
.
canvas
.
height
=
this
.
video
.
videoHeight
;
this
.
canvas
.
height
=
this
.
video
.
videoHeight
;
this
.
f
(
this
.
video
,
this
.
canvas
);
let
ok
=
this
.
f
.
call
(
this
,
this
.
video
,
this
.
canvas
);
/** @ts-ignore */
if
(
ok
)
{
this
.
captureStream
.
getTracks
()[
0
].
requestFrame
();
/** @ts-ignore */
this
.
captureStream
.
getTracks
()[
0
].
requestFrame
();
}
};
};
Filter
.
prototype
.
stop
=
function
()
{
Filter
.
prototype
.
stop
=
function
()
{
...
@@ -851,16 +854,21 @@ Filter.prototype.stop = function() {
...
@@ -851,16 +854,21 @@ Filter.prototype.stop = function() {
this
.
timer
=
null
;
this
.
timer
=
null
;
};
};
/**
* @type {Object.<string, ((this: Filter, src: CanvasImageSource, dest: HTMLCanvasElement) => boolean)>}
*/
let
filters
=
{
let
filters
=
{
'
mirror-h
'
:
(
video
,
canvas
)
=>
{
'
mirror-h
'
:
function
(
video
,
canvas
)
{
let
ctx
=
canvas
.
getContext
(
'
2d
'
);
let
ctx
=
canvas
.
getContext
(
'
2d
'
);
ctx
.
scale
(
-
1
,
1
);
ctx
.
scale
(
-
1
,
1
);
ctx
.
drawImage
(
video
,
-
video
.
videoWidth
,
0
);
ctx
.
drawImage
(
video
,
-
canvas
.
width
,
0
);
return
true
;
},
},
'
mirror-v
'
:
(
video
,
canvas
)
=>
{
'
mirror-v
'
:
function
(
video
,
canvas
)
{
let
ctx
=
canvas
.
getContext
(
'
2d
'
);
let
ctx
=
canvas
.
getContext
(
'
2d
'
);
ctx
.
scale
(
1
,
-
1
);
ctx
.
scale
(
1
,
-
1
);
ctx
.
drawImage
(
video
,
0
,
-
video
.
videoHeight
);
ctx
.
drawImage
(
video
,
0
,
-
canvas
.
height
);
return
true
;
},
},
};
};
...
...
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