luthfiampas / Bufdio

A cross platform audio playback library for .NET with PortAudio and FFmpeg.
MIT License
7 stars 4 forks source link

Plumb through a list of key-value pair options to the ffmpeg demuxer #2

Open boolemancer opened 3 years ago

boolemancer commented 3 years ago

I stumbled across the library and it seemed like it would be pretty useful, but for my scenario, I needed a way to set some specific demuxer options (see here for examples).

To that end, I added an optional parameter when loading a file to pass a set of key-value pairs that eventually get passed to avformat_open_input, and figured I'd share the changes if you find them useful.

luthfiampas commented 3 years ago

Hello @boolemancer Thank you very much. Sorry for the late response, I've been very busy lately.

I'm okay with the demuxer options in the FFmpeg decoder. But I think, we should not explicitly declare FFmpegDecoderOptions in the AudioPlayer. Also, adding IReadOnlyDictionary<string, string> parameter in the IAudioPlayer's Load method seems little bit hackish to me, the IAudioPlayer interface should not know FFmpeg things.

Based on the current design, we have 2 solutions:

  1. User need to create custom AudioPlayer class that override CreateDecoder method
  2. Or, we can add an optional IAudioDecoder factory method, or a function that constructs and returns IAudioDecoder instance in AudioPlayer's constructor