Add support maxwidth/maxheight settings for homekit source
This commit is contained in:
@@ -134,6 +134,8 @@ func streamHandler(rawURL string) (core.Producer, error) {
|
|||||||
client, err := homekit.Dial(rawURL, srtp.Server)
|
client, err := homekit.Dial(rawURL, srtp.Server)
|
||||||
if client != nil && rawQuery != "" {
|
if client != nil && rawQuery != "" {
|
||||||
query := streams.ParseQuery(rawQuery)
|
query := streams.ParseQuery(rawQuery)
|
||||||
|
client.MaxWidth = core.Atoi(query.Get("maxwidth"))
|
||||||
|
client.MaxHeight = core.Atoi(query.Get("maxheight"))
|
||||||
client.Bitrate = parseBitrate(query.Get("bitrate"))
|
client.Bitrate = parseBitrate(query.Get("bitrate"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,10 +67,10 @@ func audioToMedia(codecs []camera.AudioCodecConfiguration) *core.Media {
|
|||||||
return media
|
return media
|
||||||
}
|
}
|
||||||
|
|
||||||
func trackToVideo(track *core.Receiver, video0 *camera.VideoCodecConfiguration) *camera.VideoCodecConfiguration {
|
func trackToVideo(track *core.Receiver, video0 *camera.VideoCodecConfiguration, maxWidth, maxHeight int) *camera.VideoCodecConfiguration {
|
||||||
profileID := video0.CodecParams[0].ProfileID[0]
|
profileID := video0.CodecParams[0].ProfileID[0]
|
||||||
level := video0.CodecParams[0].Level[0]
|
level := video0.CodecParams[0].Level[0]
|
||||||
attrs := video0.VideoAttrs[0]
|
var attrs camera.VideoCodecAttributes
|
||||||
|
|
||||||
if track != nil {
|
if track != nil {
|
||||||
profile := h264.GetProfileLevelID(track.Codec.FmtpLine)
|
profile := h264.GetProfileLevelID(track.Codec.FmtpLine)
|
||||||
@@ -90,6 +90,9 @@ func trackToVideo(track *core.Receiver, video0 *camera.VideoCodecConfiguration)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range video0.VideoAttrs {
|
for _, s := range video0.VideoAttrs {
|
||||||
|
if (maxWidth > 0 && int(s.Width) > maxWidth) || (maxHeight > 0 && int(s.Height) > maxHeight) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if s.Width > attrs.Width || s.Height > attrs.Height {
|
if s.Width > attrs.Width || s.Height > attrs.Height {
|
||||||
attrs = s
|
attrs = s
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ type Client struct {
|
|||||||
|
|
||||||
stream *camera.Stream
|
stream *camera.Stream
|
||||||
|
|
||||||
|
MaxWidth int
|
||||||
|
MaxHeight int
|
||||||
Bitrate int // in bits/s
|
Bitrate int // in bits/s
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +117,7 @@ func (c *Client) Start() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
videoTrack := c.trackByKind(core.KindVideo)
|
videoTrack := c.trackByKind(core.KindVideo)
|
||||||
videoCodec := trackToVideo(videoTrack, &c.videoConfig.Codecs[0])
|
videoCodec := trackToVideo(videoTrack, &c.videoConfig.Codecs[0], c.MaxWidth, c.MaxHeight)
|
||||||
|
|
||||||
audioTrack := c.trackByKind(core.KindAudio)
|
audioTrack := c.trackByKind(core.KindAudio)
|
||||||
audioCodec := trackToAudio(audioTrack, &c.audioConfig.Codecs[0])
|
audioCodec := trackToAudio(audioTrack, &c.audioConfig.Codecs[0])
|
||||||
|
|||||||
Reference in New Issue
Block a user