Add support two channel PCM family audio #580

This commit is contained in:
Alexey Khit
2023-08-21 15:34:53 +03:00
parent 69a3a30a0e
commit bf248c49c3
3 changed files with 14 additions and 9 deletions
+6 -1
View File
@@ -130,8 +130,13 @@ func (c *Consumer) AddTrack(media *core.Media, _ *core.Codec, track *core.Receiv
}
case core.CodecOpus, core.CodecMP3: // no changes
case core.CodecPCMA, core.CodecPCMU, core.CodecPCM, core.CodecPCML:
handler.Handler = pcm.FLACEncoder(track.Codec, handler.Handler)
codec.Name = core.CodecFLAC
if codec.Channels == 2 {
// hacky way for support two channels audio
codec.Channels = 1
codec.ClockRate *= 2
}
handler.Handler = pcm.FLACEncoder(track.Codec.Name, codec.ClockRate, handler.Handler)
default:
handler.Handler = nil