Exemple #1
0
        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);
        }
Exemple #2
0
        public E <string> Play(PlayResource res)
        {
            E <string> result;

            if (res is MediaPlayResource mres && mres.IsIcyStream)
            {
                result = FfmpegProducer.AudioStartIcy(res.PlayUri);
            }
Exemple #3
0
        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);
        }
Exemple #4
0
        public R <SongAnalyzerResult, LocalStr> Run(CancellationToken cancellationToken)
        {
            Log.Info("Started analysis for \"{0}\"", Source.AudioResource.ResourceTitle);
            Stopwatch timer = new Stopwatch();

            timer.Start();

            var resource = ResourceResolver.Load(Source.AudioResource);

            if (!resource.Ok)
            {
                return(resource.Error);
            }
            var res          = resource.Value;
            var restoredLink = ResourceResolver.RestoreLink(res.BaseData);

            if (!restoredLink.Ok)
            {
                return(restoredLink.Error);
            }

            Log.Debug("Song resolve took {0}ms", timer.ElapsedMilliseconds);

            if (!(Source.AudioResource.Gain.HasValue || Source.AudioResource.AudioType != "youtube"))
            {
                timer.Restart();

                var gain = FfmpegProducer.VolumeDetect(res.PlayUri, cancellationToken);
                res.BaseData = res.BaseData.WithGain(gain);
                Log.Debug("Song volume detect took {0}ms", timer.ElapsedMilliseconds);
            }

            return(new SongAnalyzerResult {
                Resource = res,
                RestoredLink = restoredLink
            });
        }
Exemple #5
0
 public async Task Play(PlayResource res)
 {
     if (res is MediaPlayResource mres && mres.IsIcyStream)
     {
         await FfmpegProducer.AudioStartIcy(res.PlayUri);
     }
Exemple #6
0
 public SongAnalyzerTask(QueueItem source, ResolveContext resourceResolver, FfmpegProducer ffmpegProducer)
 {
     Source           = source;
     FfmpegProducer   = ffmpegProducer;
     ResourceResolver = resourceResolver;
 }
Exemple #7
0
 public int RunVolumeDetection(string url, CancellationToken token)
 {
     return(FfmpegProducer.VolumeDetect(url, token));
 }