From 2130980d17bd7d45fc344a55154d66d559e1a756 Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Fri, 11 Apr 2025 13:07:47 +0530 Subject: [PATCH] Add basic video support to WHIP. (#3602) Tested with eyevinn client. There are a few issues to figure out still 1. Simulcast - how? 2. For simulcast, how to know width, height so that adaptive stream can work. 3. The layer added is dummy. It works, but connection quality scoring would be incorrect (will always say excellent) without bitrate. Will need some dynamic update of `TrackInfo` based on actual stream for all of this to fit well into our system, but the simple video support works for now. --- pkg/rtc/participant.go | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index b20f9464c..da9d46fef 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -858,8 +858,7 @@ func (p *ParticipantImpl) synthesizeAddTrackRequests(offer webrtc.SessionDescrip } for _, m := range parsed.MediaDescriptions { - if !strings.EqualFold(m.MediaName.Media, "audio") { - // ONE-SHOT-SIGNALLING-MODE-TODO: support video + if !strings.EqualFold(m.MediaName.Media, "audio") && !strings.EqualFold(m.MediaName.Media, "video") { continue } @@ -886,15 +885,34 @@ func (p *ParticipantImpl) synthesizeAddTrackRequests(offer webrtc.SessionDescrip trackID = guid.New(utils.TrackPrefix) } + var ( + name string + trackSource livekit.TrackSource + trackType livekit.TrackType + ) + if strings.EqualFold(m.MediaName.Media, "audio") { + name = "synthesized-microphone" + trackSource = livekit.TrackSource_MICROPHONE + trackType = livekit.TrackType_AUDIO + } else { + name = "synthesized-camera" + trackSource = livekit.TrackSource_CAMERA + trackType = livekit.TrackType_VIDEO + } req := &livekit.AddTrackRequest{ Cid: trackID, - Name: "synthesized-microphone", - Source: livekit.TrackSource_MICROPHONE, - Type: livekit.TrackType_AUDIO, + Name: name, + Source: trackSource, + Type: trackType, DisableDtx: true, Stereo: false, Stream: "camera", } + // ONE-SHOT-SIGNALLING-MODE-TODO: support video simulcast + if strings.EqualFold(m.MediaName.Media, "video") { + // dummy layer to ensure at least one layer is available + req.Layers = []*livekit.VideoLayer{{}} + } p.AddTrack(req) } return nil