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
Hide 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
(
"errors"
...
...
@@ -19,7 +19,9 @@ import (
"sfu/group"
)
type
diskClient
struct
{
var
Directory
string
type
Client
struct
{
group
*
group
.
Group
id
string
...
...
@@ -42,31 +44,31 @@ func newId() string {
return
s
}
func
New
DiskClient
(
g
*
group
.
Group
)
*
disk
Client
{
return
&
disk
Client
{
group
:
g
,
id
:
newId
()}
func
New
(
g
*
group
.
Group
)
*
Client
{
return
&
Client
{
group
:
g
,
id
:
newId
()}
}
func
(
client
*
disk
Client
)
Group
()
*
group
.
Group
{
func
(
client
*
Client
)
Group
()
*
group
.
Group
{
return
client
.
group
}
func
(
client
*
disk
Client
)
Id
()
string
{
func
(
client
*
Client
)
Id
()
string
{
return
client
.
id
}
func
(
client
*
disk
Client
)
Credentials
()
group
.
ClientCredentials
{
func
(
client
*
Client
)
Credentials
()
group
.
ClientCredentials
{
return
group
.
ClientCredentials
{
"RECORDING"
,
""
}
}
func
(
client
*
disk
Client
)
SetPermissions
(
perms
group
.
ClientPermissions
)
{
func
(
client
*
Client
)
SetPermissions
(
perms
group
.
ClientPermissions
)
{
return
}
func
(
client
*
disk
Client
)
PushClient
(
id
,
username
string
,
add
bool
)
error
{
func
(
client
*
Client
)
PushClient
(
id
,
username
string
,
add
bool
)
error
{
return
nil
}
func
(
client
*
disk
Client
)
Close
()
error
{
func
(
client
*
Client
)
Close
()
error
{
client
.
mu
.
Lock
()
defer
client
.
mu
.
Unlock
()
...
...
@@ -78,13 +80,13 @@ func (client *diskClient) Close() error {
return
nil
}
func
(
client
*
disk
Client
)
kick
(
message
string
)
error
{
func
(
client
*
Client
)
kick
(
message
string
)
error
{
err
:=
client
.
Close
()
group
.
DelClient
(
client
)
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
()
defer
client
.
mu
.
Unlock
()
...
...
@@ -102,7 +104,7 @@ func (client *diskClient) PushConn(id string, up conn.Up, tracks []conn.UpTrack,
return
nil
}
directory
:=
filepath
.
Join
(
recordingsDir
,
client
.
group
.
Name
())
directory
:=
filepath
.
Join
(
Directory
,
client
.
group
.
Name
())
err
:=
os
.
MkdirAll
(
directory
,
0700
)
if
err
!=
nil
{
return
err
...
...
sfu.go
View file @
813d89b6
...
...
@@ -15,13 +15,13 @@ import (
"runtime/pprof"
"syscall"
"sfu/disk"
"sfu/group"
)
var
httpAddr
string
var
staticRoot
string
var
dataDir
string
var
recordingsDir
string
func
main
()
{
var
cpuprofile
,
memprofile
,
mutexprofile
string
...
...
@@ -33,7 +33,7 @@ func main() {
"data `directory`"
)
flag
.
StringVar
(
&
group
.
Directory
,
"groups"
,
"./groups/"
,
"group description `directory`"
)
flag
.
StringVar
(
&
recordingsDir
,
"recordings"
,
"./recordings/"
,
flag
.
StringVar
(
&
disk
.
Directory
,
"recordings"
,
"./recordings/"
,
"recordings `directory`"
)
flag
.
StringVar
(
&
cpuprofile
,
"cpuprofile"
,
""
,
"store CPU profile in `file`"
)
...
...
webclient.go
View file @
813d89b6
...
...
@@ -18,6 +18,7 @@ import (
"github.com/pion/webrtc/v3"
"sfu/conn"
"sfu/disk"
"sfu/estimator"
"sfu/group"
)
...
...
@@ -1037,12 +1038,12 @@ func handleClientMessage(c *webClient, m clientMessage) error {
return
c
.
error
(
group
.
UserError
(
"not authorised"
))
}
for
_
,
cc
:=
range
c
.
group
.
GetClients
(
c
)
{
_
,
ok
:=
cc
.
(
*
diskClient
)
_
,
ok
:=
cc
.
(
*
disk
.
Client
)
if
ok
{
return
c
.
error
(
group
.
UserError
(
"already recording"
))
}
}
disk
:=
NewDiskClient
(
c
.
group
)
disk
:=
disk
.
New
(
c
.
group
)
_
,
err
:=
group
.
AddClient
(
c
.
group
.
Name
(),
disk
)
if
err
!=
nil
{
disk
.
Close
()
...
...
@@ -1054,7 +1055,7 @@ func handleClientMessage(c *webClient, m clientMessage) error {
return
c
.
error
(
group
.
UserError
(
"not authorised"
))
}
for
_
,
cc
:=
range
c
.
group
.
GetClients
(
c
)
{
disk
,
ok
:=
cc
.
(
*
diskClient
)
disk
,
ok
:=
cc
.
(
*
disk
.
Client
)
if
ok
{
disk
.
Close
()
group
.
DelClient
(
disk
)
...
...
webserver.go
View file @
813d89b6
...
...
@@ -19,6 +19,7 @@ import (
"github.com/gorilla/websocket"
"sfu/disk"
"sfu/group"
)
...
...
@@ -324,7 +325,7 @@ func recordingsHandler(w http.ResponseWriter, r *http.Request) {
return
}
f
,
err
:=
os
.
Open
(
filepath
.
Join
(
recordingsDir
,
pth
))
f
,
err
:=
os
.
Open
(
filepath
.
Join
(
disk
.
Directory
,
pth
))
if
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
notFound
(
w
)
...
...
@@ -391,7 +392,7 @@ func handleGroupAction(w http.ResponseWriter, r *http.Request, group string) {
return
}
err
:=
os
.
Remove
(
filepath
.
Join
(
recordingsDir
,
group
+
"/"
+
filename
),
filepath
.
Join
(
disk
.
Directory
,
group
+
"/"
+
filename
),
)
if
err
!=
nil
{
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