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
dc34350d
Commit
dc34350d
authored
Dec 20, 2023
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Complete parsing of WHIP candidates.
parent
be2d3ab4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
15 deletions
+24
-15
rtpconn/whipclient.go
rtpconn/whipclient.go
+1
-11
webserver/whip.go
webserver/whip.go
+23
-4
No files found.
rtpconn/whipclient.go
View file @
dc34350d
...
...
@@ -193,17 +193,7 @@ func (c *WhipClient) gotOffer(ctx context.Context, offer []byte) ([]byte, error)
return
[]
byte
(
conn
.
pc
.
CurrentLocalDescription
()
.
SDP
),
nil
}
func
(
c
*
WhipClient
)
GotICECandidate
(
candidate
,
ufrag
[]
byte
)
error
{
zero
:=
uint16
(
0
)
init
:=
webrtc
.
ICECandidateInit
{
Candidate
:
string
(
candidate
),
SDPMLineIndex
:
&
zero
,
}
if
ufrag
!=
nil
{
u
:=
string
(
ufrag
)
init
.
UsernameFragment
=
&
u
}
func
(
c
*
WhipClient
)
GotICECandidate
(
init
webrtc
.
ICECandidateInit
)
error
{
c
.
mu
.
Lock
()
defer
c
.
mu
.
Unlock
()
if
c
.
connection
==
nil
{
...
...
webserver/whip.go
View file @
dc34350d
...
...
@@ -316,18 +316,37 @@ func whipResourceHandler(w http.ResponseWriter, r *http.Request) {
// RFC 8840
lines
:=
bytes
.
Split
(
body
,
[]
byte
{
'\n'
})
var
ufrag
[]
byte
mLineIndex
:=
-
1
var
mid
,
ufrag
[]
byte
for
_
,
l
:=
range
lines
{
l
=
bytes
.
TrimRight
(
l
,
"
\r
"
)
if
bytes
.
HasPrefix
(
l
,
[]
byte
(
"a=ice-ufrag:"
))
{
ufrag
=
l
[
len
(
"a=ice-ufrag:"
)
:
]
}
else
if
bytes
.
HasPrefix
(
l
,
[]
byte
(
"m="
))
{
mLineIndex
++
mid
=
nil
}
else
if
bytes
.
HasPrefix
(
l
,
[]
byte
(
"a=mid:"
))
{
mid
=
l
[
len
(
"a=mid:"
)
:
]
}
else
if
bytes
.
HasPrefix
(
l
,
[]
byte
(
"a=candidate:"
))
{
err
:=
c
.
GotICECandidate
(
l
[
2
:
],
ufrag
)
init
:=
webrtc
.
ICECandidateInit
{
Candidate
:
string
(
l
[
2
:
]),
}
if
len
(
mid
)
>
0
{
s
:=
string
(
mid
)
init
.
SDPMid
=
&
s
}
if
mLineIndex
>=
0
{
i
:=
uint16
(
mLineIndex
)
init
.
SDPMLineIndex
=
&
i
}
if
len
(
ufrag
)
>
0
{
s
:=
string
(
ufrag
)
init
.
UsernameFragment
=
&
s
}
err
:=
c
.
GotICECandidate
(
init
)
if
err
!=
nil
{
log
.
Printf
(
"WHIP candidate: %v"
,
err
)
}
}
else
if
bytes
.
Equal
(
l
,
[]
byte
(
"a=end-of-candidates"
))
{
c
.
GotICECandidate
(
nil
,
ufrag
)
}
}
w
.
WriteHeader
(
http
.
StatusNoContent
)
...
...
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