serenity-rs / songbird

An async Rust library for the Discord voice API
ISC License
381 stars 108 forks source link

Get aux_metadata from a TrackHandle #209

Closed freehelpdesk closed 7 months ago

freehelpdesk commented 7 months ago

Songbird version: 0.4.0

Rust version (rustc -V): 1.75-nightly

Serenity/Twilight version: Serenity 0.12.0, Poise 0.6.0

Output of ffmpeg -version, yt-dlp --version (if relevant): ...

Description: Is there an ability to get AuxMetadata from a track handle if applicable? While migrating a bot from an older version of Songbird, my custom audio inputs were destroyed and there is not no way to keep the information in the queue for later use with a queue list command. I am currently working with a Float PCM stream, and obtain given metadata though an API endpoint.

From the docs that i've seen, there appears to be no way of doing this with the current default queue implementation. ...

FelixMcFelix commented 7 months ago

You can solve this by attaching metadata to the track handle's typemap when creating a trackhandle -- see https://docs.rs/songbird/latest/songbird/tracks/struct.TrackHandle.html#method.typemap

The reason you can't necessarily do this natively is that while we could put a &Input into View, it's then deceptively easy to fire off and block on a (possibly long-running) aux_metadata call in a time-sensitive context. The flip side of 'why don't we always add this' is because not all Inputs have AuxMetadata, and not all users will care for the resource wastage at scale.

(apologies for typos/sloppy typing, responding from my phone)

freehelpdesk commented 7 months ago

Oh neat! I didn't see that method before. Thank you for your amazing support.