util.go 761 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package dtls
  2. func findMatchingSRTPProfile(a, b []SRTPProtectionProfile) (SRTPProtectionProfile, bool) {
  3. for _, aProfile := range a {
  4. for _, bProfile := range b {
  5. if aProfile == bProfile {
  6. return aProfile, true
  7. }
  8. }
  9. }
  10. return 0, false
  11. }
  12. func findMatchingCipherSuite(a, b []CipherSuite) (CipherSuite, bool) {
  13. for _, aSuite := range a {
  14. for _, bSuite := range b {
  15. if aSuite.ID() == bSuite.ID() {
  16. return aSuite, true
  17. }
  18. }
  19. }
  20. return nil, false
  21. }
  22. func splitBytes(bytes []byte, splitLen int) [][]byte {
  23. splitBytes := make([][]byte, 0)
  24. numBytes := len(bytes)
  25. for i := 0; i < numBytes; i += splitLen {
  26. j := i + splitLen
  27. if j > numBytes {
  28. j = numBytes
  29. }
  30. splitBytes = append(splitBytes, bytes[i:j])
  31. }
  32. return splitBytes
  33. }