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
813d89b6
Commit
813d89b6
authored
Sep 13, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move disk writer to its own package.
parent
c6087233
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
20 deletions
+24
-20
disk/disk.go
disk/disk.go
+15
-13
sfu.go
sfu.go
+2
-2
webclient.go
webclient.go
+4
-3
webserver.go
webserver.go
+3
-2
No files found.
disk.go
→
disk
/disk
.go
View file @
813d89b6
package
main
package
disk
import
(
import
(
"errors"
"errors"
...
@@ -19,7 +19,9 @@ import (
...
@@ -19,7 +19,9 @@ import (
"sfu/group"
"sfu/group"
)
)
type
diskClient
struct
{
var
Directory
string
type
Client
struct
{
group
*
group
.
Group
group
*
group
.
Group
id
string
id
string
...
@@ -42,31 +44,31 @@ func newId() string {
...
@@ -42,31 +44,31 @@ func newId() string {
return
s
return
s
}
}
func
New
DiskClient
(
g
*
group
.
Group
)
*
disk
Client
{
func
New
(
g
*
group
.
Group
)
*
Client
{
return
&
disk
Client
{
group
:
g
,
id
:
newId
()}
return
&
Client
{
group
:
g
,
id
:
newId
()}
}
}
func
(
client
*
disk
Client
)
Group
()
*
group
.
Group
{
func
(
client
*
Client
)
Group
()
*
group
.
Group
{
return
client
.
group
return
client
.
group
}
}
func
(
client
*
disk
Client
)
Id
()
string
{
func
(
client
*
Client
)
Id
()
string
{
return
client
.
id
return
client
.
id
}
}
func
(
client
*
disk
Client
)
Credentials
()
group
.
ClientCredentials
{
func
(
client
*
Client
)
Credentials
()
group
.
ClientCredentials
{
return
group
.
ClientCredentials
{
"RECORDING"
,
""
}
return
group
.
ClientCredentials
{
"RECORDING"
,
""
}
}
}
func
(
client
*
disk
Client
)
SetPermissions
(
perms
group
.
ClientPermissions
)
{
func
(
client
*
Client
)
SetPermissions
(
perms
group
.
ClientPermissions
)
{
return
return
}
}
func
(
client
*
disk
Client
)
PushClient
(
id
,
username
string
,
add
bool
)
error
{
func
(
client
*
Client
)
PushClient
(
id
,
username
string
,
add
bool
)
error
{
return
nil
return
nil
}
}
func
(
client
*
disk
Client
)
Close
()
error
{
func
(
client
*
Client
)
Close
()
error
{
client
.
mu
.
Lock
()
client
.
mu
.
Lock
()
defer
client
.
mu
.
Unlock
()
defer
client
.
mu
.
Unlock
()
...
@@ -78,13 +80,13 @@ func (client *diskClient) Close() error {
...
@@ -78,13 +80,13 @@ func (client *diskClient) Close() error {
return
nil
return
nil
}
}
func
(
client
*
disk
Client
)
kick
(
message
string
)
error
{
func
(
client
*
Client
)
kick
(
message
string
)
error
{
err
:=
client
.
Close
()
err
:=
client
.
Close
()
group
.
DelClient
(
client
)
group
.
DelClient
(
client
)
return
err
return
err
}
}
func
(
client
*
disk
Client
)
PushConn
(
id
string
,
up
conn
.
Up
,
tracks
[]
conn
.
UpTrack
,
label
string
)
error
{
func
(
client
*
Client
)
PushConn
(
id
string
,
up
conn
.
Up
,
tracks
[]
conn
.
UpTrack
,
label
string
)
error
{
client
.
mu
.
Lock
()
client
.
mu
.
Lock
()
defer
client
.
mu
.
Unlock
()
defer
client
.
mu
.
Unlock
()
...
@@ -102,7 +104,7 @@ func (client *diskClient) PushConn(id string, up conn.Up, tracks []conn.UpTrack,
...
@@ -102,7 +104,7 @@ func (client *diskClient) PushConn(id string, up conn.Up, tracks []conn.UpTrack,
return
nil
return
nil
}
}
directory
:=
filepath
.
Join
(
recordingsDir
,
client
.
group
.
Name
())
directory
:=
filepath
.
Join
(
Directory
,
client
.
group
.
Name
())
err
:=
os
.
MkdirAll
(
directory
,
0700
)
err
:=
os
.
MkdirAll
(
directory
,
0700
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
sfu.go
View file @
813d89b6
...
@@ -15,13 +15,13 @@ import (
...
@@ -15,13 +15,13 @@ import (
"runtime/pprof"
"runtime/pprof"
"syscall"
"syscall"
"sfu/disk"
"sfu/group"
"sfu/group"
)
)
var
httpAddr
string
var
httpAddr
string
var
staticRoot
string
var
staticRoot
string
var
dataDir
string
var
dataDir
string
var
recordingsDir
string
func
main
()
{
func
main
()
{
var
cpuprofile
,
memprofile
,
mutexprofile
string
var
cpuprofile
,
memprofile
,
mutexprofile
string
...
@@ -33,7 +33,7 @@ func main() {
...
@@ -33,7 +33,7 @@ func main() {
"data `directory`"
)
"data `directory`"
)
flag
.
StringVar
(
&
group
.
Directory
,
"groups"
,
"./groups/"
,
flag
.
StringVar
(
&
group
.
Directory
,
"groups"
,
"./groups/"
,
"group description `directory`"
)
"group description `directory`"
)
flag
.
StringVar
(
&
recordingsDir
,
"recordings"
,
"./recordings/"
,
flag
.
StringVar
(
&
disk
.
Directory
,
"recordings"
,
"./recordings/"
,
"recordings `directory`"
)
"recordings `directory`"
)
flag
.
StringVar
(
&
cpuprofile
,
"cpuprofile"
,
""
,
flag
.
StringVar
(
&
cpuprofile
,
"cpuprofile"
,
""
,
"store CPU profile in `file`"
)
"store CPU profile in `file`"
)
...
...
webclient.go
View file @
813d89b6
...
@@ -18,6 +18,7 @@ import (
...
@@ -18,6 +18,7 @@ import (
"github.com/pion/webrtc/v3"
"github.com/pion/webrtc/v3"
"sfu/conn"
"sfu/conn"
"sfu/disk"
"sfu/estimator"
"sfu/estimator"
"sfu/group"
"sfu/group"
)
)
...
@@ -1037,12 +1038,12 @@ func handleClientMessage(c *webClient, m clientMessage) error {
...
@@ -1037,12 +1038,12 @@ func handleClientMessage(c *webClient, m clientMessage) error {
return
c
.
error
(
group
.
UserError
(
"not authorised"
))
return
c
.
error
(
group
.
UserError
(
"not authorised"
))
}
}
for
_
,
cc
:=
range
c
.
group
.
GetClients
(
c
)
{
for
_
,
cc
:=
range
c
.
group
.
GetClients
(
c
)
{
_
,
ok
:=
cc
.
(
*
diskClient
)
_
,
ok
:=
cc
.
(
*
disk
.
Client
)
if
ok
{
if
ok
{
return
c
.
error
(
group
.
UserError
(
"already recording"
))
return
c
.
error
(
group
.
UserError
(
"already recording"
))
}
}
}
}
disk
:=
NewDiskClient
(
c
.
group
)
disk
:=
disk
.
New
(
c
.
group
)
_
,
err
:=
group
.
AddClient
(
c
.
group
.
Name
(),
disk
)
_
,
err
:=
group
.
AddClient
(
c
.
group
.
Name
(),
disk
)
if
err
!=
nil
{
if
err
!=
nil
{
disk
.
Close
()
disk
.
Close
()
...
@@ -1054,7 +1055,7 @@ func handleClientMessage(c *webClient, m clientMessage) error {
...
@@ -1054,7 +1055,7 @@ func handleClientMessage(c *webClient, m clientMessage) error {
return
c
.
error
(
group
.
UserError
(
"not authorised"
))
return
c
.
error
(
group
.
UserError
(
"not authorised"
))
}
}
for
_
,
cc
:=
range
c
.
group
.
GetClients
(
c
)
{
for
_
,
cc
:=
range
c
.
group
.
GetClients
(
c
)
{
disk
,
ok
:=
cc
.
(
*
diskClient
)
disk
,
ok
:=
cc
.
(
*
disk
.
Client
)
if
ok
{
if
ok
{
disk
.
Close
()
disk
.
Close
()
group
.
DelClient
(
disk
)
group
.
DelClient
(
disk
)
...
...
webserver.go
View file @
813d89b6
...
@@ -19,6 +19,7 @@ import (
...
@@ -19,6 +19,7 @@ import (
"github.com/gorilla/websocket"
"github.com/gorilla/websocket"
"sfu/disk"
"sfu/group"
"sfu/group"
)
)
...
@@ -324,7 +325,7 @@ func recordingsHandler(w http.ResponseWriter, r *http.Request) {
...
@@ -324,7 +325,7 @@ func recordingsHandler(w http.ResponseWriter, r *http.Request) {
return
return
}
}
f
,
err
:=
os
.
Open
(
filepath
.
Join
(
recordingsDir
,
pth
))
f
,
err
:=
os
.
Open
(
filepath
.
Join
(
disk
.
Directory
,
pth
))
if
err
!=
nil
{
if
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
if
os
.
IsNotExist
(
err
)
{
notFound
(
w
)
notFound
(
w
)
...
@@ -391,7 +392,7 @@ func handleGroupAction(w http.ResponseWriter, r *http.Request, group string) {
...
@@ -391,7 +392,7 @@ func handleGroupAction(w http.ResponseWriter, r *http.Request, group string) {
return
return
}
}
err
:=
os
.
Remove
(
err
:=
os
.
Remove
(
filepath
.
Join
(
recordingsDir
,
group
+
"/"
+
filename
),
filepath
.
Join
(
disk
.
Directory
,
group
+
"/"
+
filename
),
)
)
if
err
!=
nil
{
if
err
!=
nil
{
if
os
.
IsPermission
(
err
)
{
if
os
.
IsPermission
(
err
)
{
...
...
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