From 6288c2a57f153c5f1565d21c291dd93739584c10 Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Sat, 2 Sep 2023 07:39:16 +0300 Subject: [PATCH] Add MJPEG support to HomeKit client --- pkg/homekit/client.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pkg/homekit/client.go b/pkg/homekit/client.go index 3d691067..e161a801 100644 --- a/pkg/homekit/client.go +++ b/pkg/homekit/client.go @@ -95,6 +95,17 @@ func (c *Client) GetMedias() []*core.Media { c.SDP = fmt.Sprintf("%+v\n%+v", c.videoConfig, c.audioConfig) c.Medias = []*core.Media{ + { + Kind: core.KindVideo, + Direction: core.DirectionRecvonly, + Codecs: []*core.Codec{ + { + Name: core.CodecJPEG, + ClockRate: 90000, + PayloadType: core.PayloadTypeRAW, + }, + }, + }, videoToMedia(c.videoConfig.Codecs), audioToMedia(c.audioConfig.Codecs), } @@ -164,8 +175,12 @@ func (c *Client) Start() error { func (c *Client) Stop() error { _ = c.SuperProducer.Close() - c.srtp.DelSession(c.videoSession) - c.srtp.DelSession(c.audioSession) + if c.videoSession != nil { + c.srtp.DelSession(c.videoSession) + } + if c.audioSession != nil { + c.srtp.DelSession(c.audioSession) + } return c.hap.Close() }