public Player(ConfBot config, Id id) { FfmpegProducer = new FfmpegProducer(config.GetParent().Tools.Ffmpeg, id); WebSocketPipe = new WebSocketPipe(); StallCheckPipe = new StallCheckPipe(); VolumePipe = new VolumePipe(); Volume = config.Audio.Volume.Default; EncoderPipe = new EncoderPipe(SendCodec) { Bitrate = ScaleBitrate(config.Audio.Bitrate) }; EncoderPipeHighQuality = new EncoderPipe(Codec.OpusMusic) { Bitrate = 192000 }; TimePipe = new PreciseTimedPipe { ReadBufferSize = EncoderPipe.PacketSize }; TimePipe.Initialize(EncoderPipe, id); MergePipe = new PassiveMergePipe(); SplitterPipe = new PassiveSplitterPipe(); config.Audio.Bitrate.Changed += (s, e) => EncoderPipe.Bitrate = ScaleBitrate(e.NewValue); MergePipe.Into(TimePipe).Chain <CheckActivePipe>().Chain(SplitterPipe); SplitterPipe.Chain(EncoderPipeHighQuality).Chain(WebSocketPipe); SplitterPipe.Chain(StallCheckPipe).Chain(VolumePipe).Chain(EncoderPipe); }
public Player(ConfRoot confRoot, ConfBot config, DedicatedTaskScheduler scheduler, Id id) { this.scheduler = scheduler; FfmpegProducer = new FfmpegProducer(confRoot.Tools.Ffmpeg, scheduler, id); StallCheckPipe = new StallCheckPipe(); VolumePipe = new VolumePipe(); Volume = config.Audio.Volume.Default; EncoderPipe = new EncoderPipe(SendCodec) { Bitrate = ScaleBitrate(config.Audio.Bitrate) }; TimePipe = new PreciseTimedPipe(EncoderPipe, id) { ReadBufferSize = EncoderPipe.PacketSize }; MergePipe = new PassiveMergePipe(); config.Audio.Bitrate.Changed += (s, e) => EncoderPipe.Bitrate = ScaleBitrate(e.NewValue); MergePipe.Into(TimePipe).Chain <CheckActivePipe>().Chain(StallCheckPipe).Chain(VolumePipe).Chain(EncoderPipe); }
public Ts3Client(ConfBot config) { Util.Init(out clientDbNames); Util.Init(out clientbuffer); TsFullClient = new Ts3FullClient(EventDispatchType.DoubleThread); TsFullClient.OnClientLeftView += ExtendedClientLeftView; TsFullClient.OnClientEnterView += ExtendedClientEnterView; TsFullClient.OnTextMessage += ExtendedTextMessage; TsFullClient.OnErrorEvent += TsFullClient_OnErrorEvent; TsFullClient.OnConnected += TsFullClient_OnConnected; TsFullClient.OnDisconnected += TsFullClient_OnDisconnected; int ScaleBitrate(int value) => Math.Min(Math.Max(1, value), 255) * 1000; this.config = config; this.config.Audio.Bitrate.Changed += (s, e) => encoderPipe.Bitrate = ScaleBitrate(e.NewValue); ffmpegProducer = new FfmpegProducer(config.GetParent().Tools.Ffmpeg); stallCheckPipe = new StallCheckPipe(); volumePipe = new VolumePipe(); Volume = config.Audio.Volume.Default; encoderPipe = new EncoderPipe(SendCodec) { Bitrate = ScaleBitrate(config.Audio.Bitrate) }; timePipe = new PreciseTimedPipe { ReadBufferSize = encoderPipe.PacketSize }; timePipe.Initialize(encoderPipe); TargetPipe = new CustomTargetPipe(TsFullClient); mergePipe = new PassiveMergePipe(); mergePipe.Add(ffmpegProducer); mergePipe.Into(timePipe).Chain <CheckActivePipe>().Chain(stallCheckPipe).Chain(volumePipe).Chain(encoderPipe).Chain(TargetPipe); identity = null; }
public Ts3Client(ConfBot config, Ts3FullClient tsFullClient, Id id) { this.id = id; Util.Init(out clientDbNames); Util.Init(out clientbuffer); dbIdCache = new LruCache <string, ulong>(1024); this.tsFullClient = tsFullClient; tsFullClient.OnEachTextMessage += ExtendedTextMessage; tsFullClient.OnErrorEvent += TsFullClient_OnErrorEvent; tsFullClient.OnConnected += TsFullClient_OnConnected; tsFullClient.OnDisconnected += TsFullClient_OnDisconnected; int ScaleBitrate(int value) => Util.Clamp(value, 1, 255) * 1000; this.config = config; this.config.Audio.Bitrate.Changed += (s, e) => encoderPipe.Bitrate = ScaleBitrate(e.NewValue); ffmpegProducer = new FfmpegProducer(config.GetParent().Tools.Ffmpeg, id); stallCheckPipe = new StallCheckPipe(); volumePipe = new VolumePipe(); Volume = config.Audio.Volume.Default; encoderPipe = new EncoderPipe(SendCodec) { Bitrate = ScaleBitrate(config.Audio.Bitrate) }; timePipe = new PreciseTimedPipe { ReadBufferSize = encoderPipe.PacketSize }; timePipe.Initialize(encoderPipe, id); TargetPipe = new CustomTargetPipe(tsFullClient); mergePipe = new PassiveMergePipe(); mergePipe.Add(ffmpegProducer); mergePipe.Into(timePipe).Chain <CheckActivePipe>().Chain(stallCheckPipe).Chain(volumePipe).Chain(encoderPipe).Chain(TargetPipe); identity = null; }