From 84dc1a983fd7f25f3c0a6eaeca329e314f9b1e5a Mon Sep 17 00:00:00 2001 From: _ <> Date: Sun, 14 Nov 2021 19:31:54 +0000 Subject: [PATCH] :heavy_plus_sign: HTTP playback works, for Ogg/Vorbis only for now This is really cool. Since I own the whole I/O stack, I could also make it run over QUIC or some compressed format or anything I like. And I can probably sniff the first packet by hand to suport both Vorbis and Opus. That would cover most of my music library. --- src/decoder.rs | 56 +++++++++++----- src/main.rs | 178 +++++++++++++++++++++++++------------------------ 2 files changed, 131 insertions(+), 103 deletions(-) diff --git a/src/decoder.rs b/src/decoder.rs index c3d31dc..9cdc6fe 100644 --- a/src/decoder.rs +++ b/src/decoder.rs @@ -90,8 +90,8 @@ impl PcmBuffers { } } -pub struct Decoder { - demuxer: FfmpegDemuxer, +pub struct Decoder { + demuxer: T, decoder: DecodeContext, resampler: ResamplingContext, @@ -99,10 +99,8 @@ pub struct Decoder { dummy_frame: Option , } -impl Decoder { - pub fn new (filename: &str) -> Result { - let (demuxer, codec) = FfmpegDemuxer::new (filename)?; - +impl Decoder { + pub fn new (demuxer: T, codec: ffmpeg_next::codec::Context) -> Result { let decoder = codec.decoder ().audio ()?; let resampler = decoder.resampler ( Sample::F32 (sample::Type::Packed), @@ -228,11 +226,11 @@ impl Decoder { } } -trait Demuxer { - +pub trait Demuxer { + fn pump (&mut self) -> Result