Skip to content

Commit a75424d

Browse files
committed
generate legacy pipelines when specifying codec.
1 parent 1c63b56 commit a75424d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

server/internal/config/capture.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ func (s *Capture) SetV2() {
451451
enableLegacy = true
452452
}
453453

454+
modifiedVideoCodec := false
454455
if videoCodec := viper.GetString("video_codec"); videoCodec != "" {
455456
s.VideoCodec, ok = codec.ParseStr(videoCodec)
456457
if !ok || s.VideoCodec.Type != webrtc.RTPCodecTypeVideo {
@@ -459,24 +460,29 @@ func (s *Capture) SetV2() {
459460
}
460461
log.Warn().Msg("you are using v2 configuration 'NEKO_VIDEO_CODEC' which is deprecated, please use 'NEKO_CAPTURE_VIDEO_CODEC' instead")
461462
enableLegacy = true
463+
modifiedVideoCodec = true
462464
}
463465

464466
if viper.GetBool("vp8") {
465467
s.VideoCodec = codec.VP8()
466468
log.Warn().Msg("you are using deprecated config setting 'NEKO_VP8=true', use 'NEKO_CAPTURE_VIDEO_CODEC=vp8' instead")
467469
enableLegacy = true
470+
modifiedVideoCodec = true
468471
} else if viper.GetBool("vp9") {
469472
s.VideoCodec = codec.VP9()
470473
log.Warn().Msg("you are using deprecated config setting 'NEKO_VP9=true', use 'NEKO_CAPTURE_VIDEO_CODEC=vp9' instead")
471474
enableLegacy = true
475+
modifiedVideoCodec = true
472476
} else if viper.GetBool("h264") {
473477
s.VideoCodec = codec.H264()
474478
log.Warn().Msg("you are using deprecated config setting 'NEKO_H264=true', use 'NEKO_CAPTURE_VIDEO_CODEC=h264' instead")
475479
enableLegacy = true
480+
modifiedVideoCodec = true
476481
} else if viper.GetBool("av1") {
477482
s.VideoCodec = codec.AV1()
478483
log.Warn().Msg("you are using deprecated config setting 'NEKO_AV1=true', use 'NEKO_CAPTURE_VIDEO_CODEC=av1' instead")
479484
enableLegacy = true
485+
modifiedVideoCodec = true
480486
}
481487

482488
videoHWEnc := HwEncUnset
@@ -498,7 +504,7 @@ func (s *Capture) SetV2() {
498504
videoPipeline := viper.GetString("video")
499505

500506
// video pipeline
501-
if videoHWEnc != HwEncUnset || videoBitrate != 0 || videoMaxFPS != 0 || videoPipeline != "" {
507+
if modifiedVideoCodec || videoHWEnc != HwEncUnset || videoBitrate != 0 || videoMaxFPS != 0 || videoPipeline != "" {
502508
pipeline, err := NewVideoPipeline(s.VideoCodec, s.Display, videoPipeline, videoMaxFPS, videoBitrate, videoHWEnc)
503509
if err != nil {
504510
log.Warn().Err(err).Msg("unable to create video pipeline, using default")
@@ -534,6 +540,7 @@ func (s *Capture) SetV2() {
534540
enableLegacy = true
535541
}
536542

543+
modifiedAudioCodec := false
537544
if audioCodec := viper.GetString("audio_codec"); audioCodec != "" {
538545
s.AudioCodec, ok = codec.ParseStr(audioCodec)
539546
if !ok || s.AudioCodec.Type != webrtc.RTPCodecTypeAudio {
@@ -542,31 +549,36 @@ func (s *Capture) SetV2() {
542549
}
543550
log.Warn().Msg("you are using v2 configuration 'NEKO_AUDIO_CODEC' which is deprecated, please use 'NEKO_CAPTURE_AUDIO_CODEC' instead")
544551
enableLegacy = true
552+
modifiedAudioCodec = true
545553
}
546554

547555
if viper.GetBool("opus") {
548556
s.AudioCodec = codec.Opus()
549557
log.Warn().Msg("you are using deprecated config setting 'NEKO_OPUS=true', use 'NEKO_CAPTURE_AUDIO_CODEC=opus' instead")
550558
enableLegacy = true
559+
modifiedAudioCodec = true
551560
} else if viper.GetBool("g722") {
552561
s.AudioCodec = codec.G722()
553562
log.Warn().Msg("you are using deprecated config setting 'NEKO_G722=true', use 'NEKO_CAPTURE_AUDIO_CODEC=g722' instead")
554563
enableLegacy = true
564+
modifiedAudioCodec = true
555565
} else if viper.GetBool("pcmu") {
556566
s.AudioCodec = codec.PCMU()
557567
log.Warn().Msg("you are using deprecated config setting 'NEKO_PCMU=true', use 'NEKO_CAPTURE_AUDIO_CODEC=pcmu' instead")
558568
enableLegacy = true
569+
modifiedAudioCodec = true
559570
} else if viper.GetBool("pcma") {
560571
s.AudioCodec = codec.PCMA()
561572
log.Warn().Msg("you are using deprecated config setting 'NEKO_PCMA=true', use 'NEKO_CAPTURE_AUDIO_CODEC=pcma' instead")
562573
enableLegacy = true
574+
modifiedAudioCodec = true
563575
}
564576

565577
audioBitrate := viper.GetUint("audio_bitrate")
566578
audioPipeline := viper.GetString("audio")
567579

568580
// audio pipeline
569-
if audioBitrate != 0 || audioPipeline != "" {
581+
if modifiedAudioCodec || audioBitrate != 0 || audioPipeline != "" {
570582
pipeline, err := NewAudioPipeline(s.AudioCodec, s.AudioDevice, audioPipeline, audioBitrate)
571583
if err != nil {
572584
log.Warn().Err(err).Msg("unable to create audio pipeline, using default")

0 commit comments

Comments
 (0)