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
dbec9df2
Commit
dbec9df2
authored
Jan 01, 2021
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Pion's JSON support for ICE configuration.
parent
2ec0c014
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
53 deletions
+42
-53
README
README
+1
-1
go.mod
go.mod
+1
-1
go.sum
go.sum
+7
-8
group/ice.go
group/ice.go
+30
-36
rtpconn/rtpconn.go
rtpconn/rtpconn.go
+2
-6
rtpconn/webclient.go
rtpconn/webclient.go
+1
-1
No files found.
README
View file @
dbec9df2
...
...
@@ -38,7 +38,7 @@ It should look like this:
],
"username": "username",
"credential": "password"
}
,
}
]
The port number, username and password should be the same as the ones in
...
...
go.mod
View file @
dbec9df2
...
...
@@ -8,6 +8,6 @@ require (
github.com/pion/ice/v2 v2.0.14
github.com/pion/rtcp v1.2.6
github.com/pion/rtp v1.6.2
github.com/pion/webrtc/v3 v3.0.
0
github.com/pion/webrtc/v3 v3.0.
2-0.20201230060242-921608c26b93
golang.org/x/crypto v0.0.0-20201217014255-9d1352758620
)
go.sum
View file @
dbec9df2
...
...
@@ -54,12 +54,8 @@ github.com/pion/mdns v0.0.4 h1:O4vvVqr4DGX63vzmO6Fw9vpy3lfztVWHGCQfyw0ZLSY=
github.com/pion/mdns v0.0.4/go.mod h1:R1sL0p50l42S5lJs91oNdUL58nm0QHrhxnSegr++qC0=
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=
github.com/pion/rtcp v1.2.4 h1:NT3H5LkUGgaEapvp0HGik+a+CpflRF7KTD7H+o7OWIM=
github.com/pion/rtcp v1.2.4/go.mod h1:52rMNPWFsjr39z9B9MhnkqhPLoeHTv1aN63o/42bWE0=
github.com/pion/rtcp v1.2.6 h1:1zvwBbyd0TeEuuWftrd/4d++m+/kZSeiguxU61LFWpo=
github.com/pion/rtcp v1.2.6/go.mod h1:52rMNPWFsjr39z9B9MhnkqhPLoeHTv1aN63o/42bWE0=
github.com/pion/rtp v1.6.1 h1:2Y2elcVBrahYnHKN2X7rMHX/r1R4TEBMP1LaVu/wNhk=
github.com/pion/rtp v1.6.1/go.mod h1:bDb5n+BFZxXx0Ea7E5qe+klMuqiBrP+w8XSjiWtCUko=
github.com/pion/rtp v1.6.2 h1:iGBerLX6JiDjB9NXuaPzHyxHFG9JsIEdgwTC0lp5n/U=
github.com/pion/rtp v1.6.2/go.mod h1:bDb5n+BFZxXx0Ea7E5qe+klMuqiBrP+w8XSjiWtCUko=
github.com/pion/sctp v1.7.10/go.mod h1:EhpTUQu1/lcK3xI+eriS6/96fWetHGCvBi9MSsnaBN0=
...
...
@@ -67,8 +63,8 @@ github.com/pion/sctp v1.7.11 h1:UCnj7MsobLKLuP/Hh+JMiI/6W5Bs/VF45lWKgHFjSIE=
github.com/pion/sctp v1.7.11/go.mod h1:EhpTUQu1/lcK3xI+eriS6/96fWetHGCvBi9MSsnaBN0=
github.com/pion/sdp/v3 v3.0.3 h1:gJK9hk+JFD2NGIM1nXmqNCq1DkVaIZ9dlA3u3otnkaw=
github.com/pion/sdp/v3 v3.0.3/go.mod h1:bNiSknmJE0HYBprTHXKPQ3+JjacTv5uap92ueJZKsRk=
github.com/pion/srtp/v2 v2.0.0
-rc.3 h1:1fPiK1nJlNyh235tSGgBnXrPc99wK1/D707f6ntb3qY
=
github.com/pion/srtp/v2 v2.0.0
-rc.3/go.mod h1:S6J9oY6ahAXdU3ni4nUwhWTJuBfssFjPxoB0u41TBpY
=
github.com/pion/srtp/v2 v2.0.0
h1:rS4vRR0XHakmnXkaptPaXHxRiqSPWSCrDXFl/ZWMLo0
=
github.com/pion/srtp/v2 v2.0.0
/go.mod h1:QYOU1YKWaE/NJjR2WxtDMc+AfS9So0uz0RnadqOGJO8
=
github.com/pion/stun v0.3.5 h1:uLUCBCkQby4S1cf6CGuR9QrVOKcvUwFeemaC865QHDg=
github.com/pion/stun v0.3.5/go.mod h1:gDMim+47EeEtfWogA37n6qXZS88L5V6LqFcf+DZA2UA=
github.com/pion/transport v0.8.10/go.mod h1:tBmha/UCjpum5hqTWhfAEs3CO4/tHSg0MYRhSzR+CZ8=
...
...
@@ -78,12 +74,14 @@ github.com/pion/transport v0.10.1 h1:2W+yJT+0mOQ160ThZYUx5Zp2skzshiNgxrNE9GUfhJM
github.com/pion/transport v0.10.1/go.mod h1:PBis1stIILMiis0PewDw91WJeLJkyIMcEk+DwKOzf4A=
github.com/pion/transport v0.12.0 h1:UFmOBBZkTZ3LgvLRf/NGrfWdZEubcU6zkLU3PsA9YvU=
github.com/pion/transport v0.12.0/go.mod h1:N3+vZQD9HlDP5GWkZ85LohxNsDcNgofQmyL6ojX5d8Q=
github.com/pion/transport v0.12.1 h1:6v8lxQGVZpwSICEZjhl/CCv6aErINZlrm3O5ncFXj/c=
github.com/pion/transport v0.12.1/go.mod h1:N3+vZQD9HlDP5GWkZ85LohxNsDcNgofQmyL6ojX5d8Q=
github.com/pion/turn/v2 v2.0.5 h1:iwMHqDfPEDEOFzwWKT56eFmh6DYC6o/+xnLAEzgISbA=
github.com/pion/turn/v2 v2.0.5/go.mod h1:APg43CFyt/14Uy7heYUOGWdkem/Wu4PhCO/bjyrTqMw=
github.com/pion/udp v0.1.0 h1:uGxQsNyrqG3GLINv36Ff60covYmfrLoxzwnCsIYspXI=
github.com/pion/udp v0.1.0/go.mod h1:BPELIjbwE9PRbd/zxI/KYBnbo7B6+oA6YuEaNE8lths=
github.com/pion/webrtc/v3 v3.0.
0 h1:/eTiY3NbfpKj5op8cqtCZlpTv9/yumd17YRinDNOUX0
=
github.com/pion/webrtc/v3 v3.0.
0/go.mod h1:/xwKHOAk1Y8dspJcxMwuTtxpi8t/Gzks37iB3W6hNu
M=
github.com/pion/webrtc/v3 v3.0.
2-0.20201230060242-921608c26b93 h1:lyPYvMAKRkqG5dJYa/DbwFqrWkA0QIcOkH7g+MS4OKs
=
github.com/pion/webrtc/v3 v3.0.
2-0.20201230060242-921608c26b93/go.mod h1:jq9Zm/SEnlXqCANHUr0Fk8G+j0lYznq+athpXb6kwL
M=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
...
...
@@ -129,6 +127,7 @@ golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 h1:DYfZAGf2WMFjMxbgTjaC+2HC7
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221 h1:/ZHdbVpdR/jk3g30/d4yUL0JU9kksj8+F/bnQUVLGDM=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
...
...
group/ice.go
View file @
dbec9df2
...
...
@@ -2,6 +2,7 @@ package group
import
(
"encoding/json"
"errors"
"log"
"os"
"sync/atomic"
...
...
@@ -17,16 +18,28 @@ type ICEServer struct {
CredentialType
string
`json:"credentialType,omitempty"`
}
type
RTCConfiguration
struct
{
ICEServers
[]
ICEServer
`json:"iceServers,omitempty"`
ICETransportPolicy
string
`json:"iceTransportPolicy,omitempty"`
func
getICEServer
(
server
ICEServer
)
(
webrtc
.
ICEServer
,
error
)
{
s
:=
webrtc
.
ICEServer
{
URLs
:
server
.
URLs
,
Username
:
server
.
Username
,
Credential
:
server
.
Credential
,
}
switch
server
.
CredentialType
{
case
""
,
"password"
:
s
.
CredentialType
=
webrtc
.
ICECredentialTypePassword
case
"oauth"
:
s
.
CredentialType
=
webrtc
.
ICECredentialTypeOauth
default
:
return
webrtc
.
ICEServer
{},
errors
.
New
(
"unsupported credential type"
)
}
return
s
,
nil
}
var
ICEFilename
string
var
ICERelayOnly
bool
type
iceConf
struct
{
conf
RTC
Configuration
conf
webrtc
.
Configuration
timestamp
time
.
Time
}
...
...
@@ -34,7 +47,7 @@ var iceConfiguration atomic.Value
func
updateICEConfiguration
()
*
iceConf
{
now
:=
time
.
Now
()
var
conf
RTC
Configuration
var
conf
webrtc
.
Configuration
if
ICEFilename
!=
""
{
file
,
err
:=
os
.
Open
(
ICEFilename
)
...
...
@@ -43,15 +56,24 @@ func updateICEConfiguration() *iceConf {
}
else
{
defer
file
.
Close
()
d
:=
json
.
NewDecoder
(
file
)
err
=
d
.
Decode
(
&
conf
.
ICEServers
)
var
servers
[]
ICEServer
err
=
d
.
Decode
(
&
servers
)
if
err
!=
nil
{
log
.
Printf
(
"Get ICE configuration: %v"
,
err
)
}
for
_
,
s
:=
range
servers
{
ss
,
err
:=
getICEServer
(
s
)
if
err
!=
nil
{
log
.
Printf
(
"parse ICE server: %v"
,
err
)
continue
}
conf
.
ICEServers
=
append
(
conf
.
ICEServers
,
ss
)
}
}
}
if
ICERelayOnly
{
conf
.
ICETransportPolicy
=
"relay"
conf
.
ICETransportPolicy
=
webrtc
.
ICETransportPolicyRelay
}
iceConf
:=
iceConf
{
...
...
@@ -62,7 +84,7 @@ func updateICEConfiguration() *iceConf {
return
&
iceConf
}
func
ICEConfiguration
()
*
RTC
Configuration
{
func
ICEConfiguration
()
*
webrtc
.
Configuration
{
conf
,
ok
:=
iceConfiguration
.
Load
()
.
(
*
iceConf
)
if
!
ok
||
time
.
Since
(
conf
.
timestamp
)
>
5
*
time
.
Minute
{
conf
=
updateICEConfiguration
()
...
...
@@ -72,31 +94,3 @@ func ICEConfiguration() *RTCConfiguration {
return
&
conf
.
conf
}
func
ToConfiguration
(
conf
*
RTCConfiguration
)
webrtc
.
Configuration
{
var
iceServers
[]
webrtc
.
ICEServer
for
_
,
s
:=
range
conf
.
ICEServers
{
tpe
:=
webrtc
.
ICECredentialTypePassword
if
s
.
CredentialType
==
"oauth"
{
tpe
=
webrtc
.
ICECredentialTypeOauth
}
iceServers
=
append
(
iceServers
,
webrtc
.
ICEServer
{
URLs
:
s
.
URLs
,
Username
:
s
.
Username
,
Credential
:
s
.
Credential
,
CredentialType
:
tpe
,
},
)
}
policy
:=
webrtc
.
ICETransportPolicyAll
if
conf
.
ICETransportPolicy
==
"relay"
{
policy
=
webrtc
.
ICETransportPolicyRelay
}
return
webrtc
.
Configuration
{
ICEServers
:
iceServers
,
ICETransportPolicy
:
policy
,
}
}
rtpconn/rtpconn.go
View file @
dbec9df2
...
...
@@ -138,9 +138,7 @@ type rtpDownConnection struct {
func
newDownConn
(
c
group
.
Client
,
id
string
,
remote
conn
.
Up
)
(
*
rtpDownConnection
,
error
)
{
api
:=
group
.
APIFromCodecs
(
remote
.
Codecs
())
pc
,
err
:=
api
.
NewPeerConnection
(
group
.
ToConfiguration
(
group
.
ICEConfiguration
()),
)
pc
,
err
:=
api
.
NewPeerConnection
(
*
group
.
ICEConfiguration
())
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -459,9 +457,7 @@ func pushConn(up *rtpUpConnection, g *group.Group, cs []group.Client) {
}
func
newUpConn
(
c
group
.
Client
,
id
string
,
labels
map
[
string
]
string
)
(
*
rtpUpConnection
,
error
)
{
pc
,
err
:=
c
.
Group
()
.
API
()
.
NewPeerConnection
(
group
.
ToConfiguration
(
group
.
ICEConfiguration
()),
)
pc
,
err
:=
c
.
Group
()
.
API
()
.
NewPeerConnection
(
*
group
.
ICEConfiguration
())
if
err
!=
nil
{
return
nil
,
err
}
...
...
rtpconn/webclient.go
View file @
dbec9df2
...
...
@@ -177,7 +177,7 @@ type clientMessage struct {
Candidate
*
webrtc
.
ICECandidateInit
`json:"candidate,omitempty"`
Labels
map
[
string
]
string
`json:"labels,omitempty"`
Request
rateMap
`json:"request,omitempty"`
RTCConfiguration
*
group
.
RTCConfiguration
`json:"rtcConfiguration,omitempty"`
RTCConfiguration
*
webrtc
.
Configuration
`json:"rtcConfiguration,omitempty"`
}
type
closeMessage
struct
{
...
...
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