sdp
sdp copied to clipboard
Add GetFingerprint() to SessionDescription
Summary
I need to get the fingerprint of a given sessions description.
Motivation
I authorize clients based on their fingerprints - I need a way to get the client's fingerprint so I can check if it's in my authorized fingerprints file.
Describe alternatives you've considered
I'm using regex do get the fingerprint directly from the description's string.
Additional Context
There is already WithFingerprint()
function to set the sd's fingerprint, this complements it.
fp,ok:=s.MediaDescriptions[0].Attribute("fingerprint")
fp,ok:=s.MediaDescriptions[0].Attribute("fingerprint")
Thanks!
I've tried using it instead of the regex I have now but I keep getting a !ok
. Here's my code
func GetFingerprint(sd *webrtc.SessionDescription) (string, error) {
s, err := sd.Unmarshal()
if err != nil {
return "", fmt.Errorf("Failed to unmarshal sdp: %w", err)
}
fp, ok := s.MediaDescriptions[0].Attribute("fingerprint")
if !ok {
return "", fmt.Errorf("Failed to get fingerprint from sdp")
}
...
Hey @daonb mind trying at the global level also?
pion/webrtc does that here
It might be nice to add AttributeRecursive
? This would be useful for ice as well!
Hey @daonb mind trying at the global level also? pion/webrtc does that here
It works! Thanks. I've ended up using the global level Attribute
as terminal7 has no media.
It might be nice to add
AttributeRecursive
? This would be useful for ice as well!
I'd be happy to help, but I think we should find a better name as it's not really recursive. How about CollectAttribute
?