38 lines
918 B
Go

package rtsp
import (
"log"
"strings"
"time"
)
// cutURI returns the last part of the URI after "/".
func cutURI(URI string) (CutURI string) {
splitted := strings.Split(URI, "/")
return splitted[len(splitted)-1]
}
// waitPeriod waits for the next period.
func waitPeriod(period int) {
periodTD := time.Duration(period) * time.Second
now := time.Now()
nextSegment := now.Truncate(periodTD).Add(periodTD)
waitDuration := nextSegment.Sub(now)
log.Printf("waiting for start recording: %v\n", waitDuration)
time.Sleep(waitDuration)
}
// findResolution finds resolution in SDP.
func findResolution(Body []byte) string {
split := strings.Split(string(Body), "\r\n")
for _, line := range split {
if strings.Contains(line, "a=x-dimensions:") {
s, _ := strings.CutPrefix(line, "a=x-dimensions:")
resolution := strings.Join(strings.Split(s, ","), "-")
return resolution
}
}
return "resolution"
}