Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't link audio to image bins #642

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/gstreamer/bin.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type Bin struct {
latency uint64

linkFunc func() error
shouldLink func(string) bool
eosFunc func() bool
getSrcPad func(string) *gst.Pad
getSinkPad func(string) *gst.Pad
Expand Down Expand Up @@ -317,6 +318,13 @@ func (b *Bin) SetLinkFunc(f func() error) {
b.linkFunc = f
}

func (b *Bin) SetShouldLink(f func(string) bool) {
b.mu.Lock()
defer b.mu.Unlock()

b.shouldLink = f
}

// Set a custom linking function which returns a pad for the named src bin
func (b *Bin) SetGetSrcPad(f func(srcName string) *gst.Pad) {
b.mu.Lock()
Expand Down Expand Up @@ -484,6 +492,10 @@ func (b *Bin) queueLinkPeersLocked(src, sink *Bin) error {
srcName := src.bin.GetName()
sinkName := sink.bin.GetName()

if (src.shouldLink != nil && !src.shouldLink(sinkName)) || (sink.shouldLink != nil && !sink.shouldLink(srcName)) {
return nil
}

queueName := fmt.Sprintf("%s_%s_queue", srcName, sinkName)
queue, err := BuildQueue(queueName, b.latency, true)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions pkg/pipeline/builder/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ func BuildImageBin(c *config.ImageConfig, pipeline *gstreamer.Pipeline, p *confi
return queue.GetStaticPad("sink")
}
})
b.SetShouldLink(func(srcBin string) bool {
return srcBin != "audio"
})

videoRate, err := gst.NewElement("videorate")
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion test/multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
func (r *Runner) runMultipleTest(
t *testing.T,
req *rpc.StartEgressRequest,
file, stream, segments bool,
file, stream, segments, images bool,
filenameSuffix livekit.SegmentedFileSuffix,
) {
egressID := r.startEgress(t, req)
Expand Down Expand Up @@ -65,4 +65,7 @@ func (r *Runner) runMultipleTest(
if segments {
r.verifySegments(t, p, filenameSuffix, res, false)
}
if images {
r.verifyImages(t, p, 0, res)
}
}
2 changes: 1 addition & 1 deletion test/participant.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func (r *Runner) testParticipantMulti(t *testing.T) {
},
}

r.runMultipleTest(t, req, true, true, false, livekit.SegmentedFileSuffix_INDEX)
r.runMultipleTest(t, req, true, true, false, false, livekit.SegmentedFileSuffix_INDEX)
},
)

Expand Down
9 changes: 6 additions & 3 deletions test/room_composite.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,16 @@ func (r *Runner) testRoomCompositeMulti(t *testing.T) {
FileType: livekit.EncodedFileType_MP4,
Filepath: r.getFilePath("rc_multiple_{time}"),
}},
StreamOutputs: []*livekit.StreamOutput{{
Protocol: livekit.StreamProtocol_RTMP,
ImageOutputs: []*livekit.ImageOutput{{
CaptureInterval: 10,
Width: 1280,
Height: 720,
FilenamePrefix: r.getFilePath("rc_image"),
}},
},
},
}

r.runMultipleTest(t, req, true, true, false, livekit.SegmentedFileSuffix_TIMESTAMP)
r.runMultipleTest(t, req, true, false, false, true, livekit.SegmentedFileSuffix_TIMESTAMP)
})
}
2 changes: 1 addition & 1 deletion test/track_composite.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func (r *Runner) testTrackCompositeMulti(t *testing.T) {
},
}

r.runMultipleTest(t, req, false, true, true, livekit.SegmentedFileSuffix_INDEX)
r.runMultipleTest(t, req, false, true, true, false, livekit.SegmentedFileSuffix_INDEX)
},
)
}
2 changes: 1 addition & 1 deletion test/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,6 @@ func (r *Runner) testWebMulti(t *testing.T) {
},
}

r.runMultipleTest(t, req, true, false, true, livekit.SegmentedFileSuffix_INDEX)
r.runMultipleTest(t, req, true, false, true, false, livekit.SegmentedFileSuffix_INDEX)
})
}
Loading