Trait sunk::Streamable
source · pub trait Streamable {
fn stream(&self, client: &Client) -> Result<Vec<u8>>;
fn stream_url(&self, client: &Client) -> Result<String>;
fn download(&self, client: &Client) -> Result<Vec<u8>>;
fn download_url(&self, client: &Client) -> Result<String>;
fn encoding(&self) -> &str;
fn set_max_bit_rate(&mut self, bit_rate: usize);
fn set_transcoding(&mut self, format: &str);
}
Expand description
A trait for forms of streamable media.
Required Methods
sourcefn stream(&self, client: &Client) -> Result<Vec<u8>>
fn stream(&self, client: &Client) -> Result<Vec<u8>>
Returns the raw bytes of the media.
Supports transcoding options specified on the media beforehand. See the
struct-level documentation for available options. The Media
trait
provides setting a maximum bit rate and a target transcoding format.
The method does not provide any information about the encoding of the media without evaluating the stream itself.
sourcefn stream_url(&self, client: &Client) -> Result<String>
fn stream_url(&self, client: &Client) -> Result<String>
Returns a constructed URL for streaming.
Supports transcoding options specified on the media beforehand. See the
struct-level documentation for available options. The Media
trait
provides setting a maximum bit rate and a target transcoding format.
This would be used in conjunction with a streaming library to directly take the URI and stream it.
sourcefn download(&self, client: &Client) -> Result<Vec<u8>>
fn download(&self, client: &Client) -> Result<Vec<u8>>
Returns the raw bytes of the media.
The method does not provide any information about the encoding of the media without evaluating the stream itself.
sourcefn download_url(&self, client: &Client) -> Result<String>
fn download_url(&self, client: &Client) -> Result<String>
Returns a constructed URL for downloading the song.
sourcefn encoding(&self) -> &str
fn encoding(&self) -> &str
Returns the default encoding of the media.
A Subsonic server is able to transcode media for streaming to reduce data size (for example, it may transcode FLAC to MP3 to reduce file size, or downsample high bitrate files). Where possible, the method will return the default transcoding of the media (if enabled); otherwise, it will return the original encoding.
sourcefn set_max_bit_rate(&mut self, bit_rate: usize)
fn set_max_bit_rate(&mut self, bit_rate: usize)
Sets the maximum bitrate the media will use when streaming.
The bit rate is measured in Kbps. Higher bit rate media will be downsampled to this bit rate.
Supported values are 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320. The method will not error or panic when using a non-legal value, but the server may not provide the requested bit rate. A bit rate of 0 will disable a limit (i.e., use the original bit rate.)
sourcefn set_transcoding(&mut self, format: &str)
fn set_transcoding(&mut self, format: &str)
Sets the transcoding format the media will use when streaming.
The possible transcoding formats are those defined by the Subsonic
server as valid transcoding targets. Default values are "mp3"
,
"flv"
, "mkv"
, and "mp4"
. The special value "raw"
is additionally
supported on servers implementing version 1.9.0 of the API.
The method will not error or panic when using a non-supported format, but the server may not provide that transcoded format.