diff --git a/go.mod b/go.mod index 78cc192..42f8459 100644 --- a/go.mod +++ b/go.mod @@ -15,10 +15,13 @@ require ( github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/ncruces/go-strftime v1.0.0 // indirect + github.com/pion/logging v0.2.4 // indirect github.com/pion/randutil v0.1.0 // indirect github.com/pion/rtcp v1.2.16 // indirect github.com/pion/rtp v1.10.0 // indirect github.com/pion/sdp/v3 v3.0.17 // indirect + github.com/pion/srtp/v3 v3.0.10 // indirect + github.com/pion/transport/v4 v4.0.1 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/sigurn/crc16 v0.0.0-20240131213347-83fcde1e29d1 // indirect github.com/sigurn/crc8 v0.0.0-20220107193325-2243fe600f9f // indirect diff --git a/go.sum b/go.sum index 21c0973..9a25c40 100644 --- a/go.sum +++ b/go.sum @@ -25,6 +25,8 @@ github.com/miekg/dns v1.1.72 h1:vhmr+TF2A3tuoGNkLDFK9zi36F2LS+hKTRW0Uf8kbzI= github.com/miekg/dns v1.1.72/go.mod h1:+EuEPhdHOsfk6Wk5TT2CzssZdqkmFhf8r+aVyDEToIs= github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w= github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= +github.com/pion/logging v0.2.4 h1:tTew+7cmQ+Mc1pTBLKH2puKsOvhm32dROumOZ655zB8= +github.com/pion/logging v0.2.4/go.mod h1:DffhXTKYdNZU+KtJ5pyQDjvOAh/GsNSyv1lbkFbe3so= github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA= github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8= github.com/pion/rtcp v1.2.16 h1:fk1B1dNW4hsI78XUCljZJlC4kZOPk67mNRuQ0fcEkSo= @@ -33,6 +35,10 @@ github.com/pion/rtp v1.10.0 h1:XN/xca4ho6ZEcijpdF2VGFbwuHUfiIMf3ew8eAAE43w= github.com/pion/rtp v1.10.0/go.mod h1:rF5nS1GqbR7H/TCpKwylzeq6yDM+MM6k+On5EgeThEM= github.com/pion/sdp/v3 v3.0.17 h1:9SfLAW/fF1XC8yRqQ3iWGzxkySxup4k4V7yN8Fs8nuo= github.com/pion/sdp/v3 v3.0.17/go.mod h1:9tyKzznud3qiweZcD86kS0ff1pGYB3VX+Bcsmkx6IXo= +github.com/pion/srtp/v3 v3.0.10 h1:tFirkpBb3XccP5VEXLi50GqXhv5SKPxqrdlhDCJlZrQ= +github.com/pion/srtp/v3 v3.0.10/go.mod h1:3mOTIB0cq9qlbn59V4ozvv9ClW/BSEbRp4cY0VtaR7M= +github.com/pion/transport/v4 v4.0.1 h1:sdROELU6BZ63Ab7FrOLn13M6YdJLY20wldXW2Cu2k8o= +github.com/pion/transport/v4 v4.0.1/go.mod h1:nEuEA4AD5lPdcIegQDpVLgNoDGreqM/YqmEx3ovP4jM= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= diff --git a/pkg/tester/worker.go b/pkg/tester/worker.go index 2916e53..0512486 100644 --- a/pkg/tester/worker.go +++ b/pkg/tester/worker.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "os/exec" + "strings" "time" "github.com/AlexxIT/go2rtc/pkg/core" @@ -50,6 +51,11 @@ func RunWorkers(s *Session, urls []string) { func testURL(s *Session, rawURL string) { defer s.AddTested() + if strings.HasPrefix(rawURL, "homekit://") { + testHomeKit(s, rawURL) + return + } + handler := GetHandler(rawURL) if handler == nil { return diff --git a/pkg/tester/worker_homekit.go b/pkg/tester/worker_homekit.go new file mode 100644 index 0000000..578c81a --- /dev/null +++ b/pkg/tester/worker_homekit.go @@ -0,0 +1,40 @@ +package tester + +import ( + "fmt" + "time" + + "github.com/AlexxIT/go2rtc/pkg/hap" +) + +// testHomeKit -- snapshot via HAP GetImage, bypasses SRTP/Producer flow +func testHomeKit(s *Session, rawURL string) { + start := time.Now() + + conn, err := hap.Dial(rawURL) + if err != nil { + return + } + defer conn.Close() + + jpeg, err := conn.GetImage(1920, 1080) + if err != nil { + return + } + + latency := time.Since(start).Milliseconds() + + r := &Result{ + Source: rawURL, + Codecs: []string{"JPEG"}, + LatencyMs: latency, + } + + if len(jpeg) > 0 { + idx := s.AddScreenshot(jpeg) + r.Screenshot = fmt.Sprintf("api/test/screenshot?id=%s&i=%d", s.ID, idx) + r.Width, r.Height = jpegSize(jpeg) + } + + s.AddResult(r) +}