Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sfu
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
Alain Takoudjou
sfu
Commits
3167c217
Commit
3167c217
authored
4 years ago
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement playing of local files.
parent
2c17157e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
8 deletions
+57
-8
static/sfu.html
static/sfu.html
+5
-0
static/sfu.js
static/sfu.js
+51
-7
webserver/webserver.go
webserver/webserver.go
+1
-1
No files found.
static/sfu.html
View file @
3167c217
...
@@ -191,6 +191,11 @@
...
@@ -191,6 +191,11 @@
<form>
<form>
<input
id=
"activitybox"
type=
"checkbox"
>
Activity detection
</input>
<input
id=
"activitybox"
type=
"checkbox"
>
Activity detection
</input>
</form>
</form>
<form>
<label
for=
"fileinput"
>
Play local file:
</label>
<input
type=
"file"
id=
"fileinput"
accept=
"audio/*,video/*"
multiple
></input>
</form>
</fieldset>
</fieldset>
</div>
</div>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
static/sfu.js
View file @
3167c217
...
@@ -524,6 +524,13 @@ getInputElement('activitybox').onchange = function(e) {
...
@@ -524,6 +524,13 @@ getInputElement('activitybox').onchange = function(e) {
}
}
}
}
getInputElement
(
'
fileinput
'
).
onchange
=
function
(
e
)
{
let
input
=
/** @type{HTMLInputElement} */
(
this
);
let
files
=
input
.
files
;
for
(
let
i
=
0
;
i
<
files
.
length
;
i
++
)
addFileMedia
(
files
[
i
]);
}
/**
/**
* @this {Stream}
* @this {Stream}
* @param {Object<string,any>} stats
* @param {Object<string,any>} stats
...
@@ -866,6 +873,36 @@ async function addShareMedia() {
...
@@ -866,6 +873,36 @@ async function addShareMedia() {
setButtonsVisibility
()
setButtonsVisibility
()
}
}
/**
* @param {File} file
*/
async
function
addFileMedia
(
file
)
{
if
(
!
getUserPass
())
return
;
let
url
=
URL
.
createObjectURL
(
file
);
let
video
=
document
.
createElement
(
'
video
'
);
video
.
src
=
url
;
/** @ts-ignore */
let
stream
=
video
.
captureStream
();
let
c
=
newUpStream
();
c
.
kind
=
'
video
'
;
c
.
stream
=
stream
;
stream
.
onaddtrack
=
function
(
e
)
{
let
t
=
e
.
track
;
c
.
pc
.
addTrack
(
t
,
stream
);
t
.
onended
=
e
=>
{
delUpMedia
(
c
);
}
c
.
labels
[
t
.
id
]
=
t
.
kind
;
c
.
onstats
=
gotUpStats
;
c
.
setStatsInterval
(
2000
);
};
setMedia
(
c
,
true
,
video
);
video
.
play
();
}
/**
/**
* @param {Stream} c
* @param {Stream} c
*/
*/
...
@@ -947,8 +984,9 @@ function muteLocalTracks(mute) {
...
@@ -947,8 +984,9 @@ function muteLocalTracks(mute) {
/**
/**
* @param {Stream} c
* @param {Stream} c
* @param {boolean} isUp
* @param {boolean} isUp
* @param {HTMLVideoElement} [video]
*/
*/
function
setMedia
(
c
,
isUp
)
{
function
setMedia
(
c
,
isUp
,
video
)
{
let
peersdiv
=
document
.
getElementById
(
'
peers
'
);
let
peersdiv
=
document
.
getElementById
(
'
peers
'
);
let
settings
=
getSettings
();
let
settings
=
getSettings
();
let
local_media
;
let
local_media
;
...
@@ -970,15 +1008,19 @@ function setMedia(c, isUp) {
...
@@ -970,15 +1008,19 @@ function setMedia(c, isUp) {
let
media
=
/** @type {HTMLVideoElement} */
let
media
=
/** @type {HTMLVideoElement} */
(
document
.
getElementById
(
'
media-
'
+
c
.
id
));
(
document
.
getElementById
(
'
media-
'
+
c
.
id
));
if
(
!
media
)
{
if
(
!
media
)
{
if
(
video
)
{
media
=
video
;
}
else
{
media
=
document
.
createElement
(
'
video
'
);
media
=
document
.
createElement
(
'
video
'
);
media
.
id
=
'
media-
'
+
c
.
id
;
media
.
controls
=
false
;
if
(
isUp
)
media
.
muted
=
true
;
}
media
.
classList
.
add
(
'
media
'
);
media
.
classList
.
add
(
'
media
'
);
media
.
autoplay
=
true
;
media
.
autoplay
=
true
;
/** @ts-ignore */
/** @ts-ignore */
media
.
playsinline
=
true
;
media
.
playsinline
=
true
;
media
.
controls
=
false
;
media
.
id
=
'
media-
'
+
c
.
id
;
if
(
isUp
)
media
.
muted
=
true
;
div
.
appendChild
(
media
);
div
.
appendChild
(
media
);
}
}
...
@@ -1024,7 +1066,9 @@ function setMedia(c, isUp) {
...
@@ -1024,7 +1066,9 @@ function setMedia(c, isUp) {
camera
.
remove
();
camera
.
remove
();
}
}
if
(
!
video
)
media
.
srcObject
=
c
.
stream
;
media
.
srcObject
=
c
.
stream
;
setLabel
(
c
);
setLabel
(
c
);
setMediaStatus
(
c
);
setMediaStatus
(
c
);
...
...
This diff is collapsed.
Click to expand it.
webserver/webserver.go
View file @
3167c217
...
@@ -78,7 +78,7 @@ func Serve(address string, dataDir string) error {
...
@@ -78,7 +78,7 @@ func Serve(address string, dataDir string) error {
func
mungeHeader
(
w
http
.
ResponseWriter
)
{
func
mungeHeader
(
w
http
.
ResponseWriter
)
{
w
.
Header
()
.
Add
(
"Content-Security-Policy"
,
w
.
Header
()
.
Add
(
"Content-Security-Policy"
,
"connect-src ws: wss: 'self'; img-src data: 'self'; default-src 'self'"
)
"connect-src ws: wss: 'self'; img-src data: 'self';
media-src blob: 'self';
default-src 'self'"
)
}
}
func
notFound
(
w
http
.
ResponseWriter
)
{
func
notFound
(
w
http
.
ResponseWriter
)
{
...
...
This diff is collapsed.
Click to expand it.
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