mirror of
https://github.com/bjdgyc/anylink.git
synced 2025-08-08 11:10:14 +08:00
添加 github.com/pion/dtls 代码
This commit is contained in:
38
dtls-2.0.9/util.go
Normal file
38
dtls-2.0.9/util.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package dtls
|
||||
|
||||
func findMatchingSRTPProfile(a, b []SRTPProtectionProfile) (SRTPProtectionProfile, bool) {
|
||||
for _, aProfile := range a {
|
||||
for _, bProfile := range b {
|
||||
if aProfile == bProfile {
|
||||
return aProfile, true
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0, false
|
||||
}
|
||||
|
||||
func findMatchingCipherSuite(a, b []CipherSuite) (CipherSuite, bool) { //nolint
|
||||
for _, aSuite := range a {
|
||||
for _, bSuite := range b {
|
||||
if aSuite.ID() == bSuite.ID() {
|
||||
return aSuite, true
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func splitBytes(bytes []byte, splitLen int) [][]byte {
|
||||
splitBytes := make([][]byte, 0)
|
||||
numBytes := len(bytes)
|
||||
for i := 0; i < numBytes; i += splitLen {
|
||||
j := i + splitLen
|
||||
if j > numBytes {
|
||||
j = numBytes
|
||||
}
|
||||
|
||||
splitBytes = append(splitBytes, bytes[i:j])
|
||||
}
|
||||
|
||||
return splitBytes
|
||||
}
|
Reference in New Issue
Block a user