Fix #628: Add setting to transcode stream
This commit is contained in:
@@ -332,12 +332,19 @@ func (j *jellyfinMediaProvider) SetFavorite(params mediaprovider.RatingFavoriteP
|
||||
return err
|
||||
}
|
||||
|
||||
func (j *jellyfinMediaProvider) GetStreamURL(trackID string, forceRaw bool) (string, error) {
|
||||
return j.client.GetStreamURL(trackID)
|
||||
func (j *jellyfinMediaProvider) GetStreamURL(trackID string, transcode *mediaprovider.TranscodeSettings, forceRaw bool) (string, error) {
|
||||
var jfTranscode *jellyfin.TranscodeOptions
|
||||
if transcode != nil {
|
||||
jfTranscode = &jellyfin.TranscodeOptions{
|
||||
AudioCodec: transcode.Codec,
|
||||
AudioBitRate: uint32(transcode.BitRateKBPS * 1000),
|
||||
}
|
||||
}
|
||||
return j.client.GetStreamURL(trackID, jfTranscode)
|
||||
}
|
||||
|
||||
func (j *jellyfinMediaProvider) DownloadTrack(trackID string) (io.Reader, error) {
|
||||
url, err := j.client.GetStreamURL(trackID)
|
||||
url, err := j.client.GetStreamURL(trackID, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -184,6 +184,11 @@ type LoginResponse struct {
|
||||
IsAuthError bool
|
||||
}
|
||||
|
||||
type TranscodeSettings struct {
|
||||
Codec string
|
||||
BitRateKBPS int
|
||||
}
|
||||
|
||||
type Server interface {
|
||||
Login(username, password string) LoginResponse
|
||||
MediaProvider() MediaProvider
|
||||
@@ -234,7 +239,7 @@ type MediaProvider interface {
|
||||
|
||||
GetFavorites() (Favorites, error)
|
||||
|
||||
GetStreamURL(trackID string, forceRaw bool) (string, error)
|
||||
GetStreamURL(trackID string, transcodeSettings *TranscodeSettings, forceRaw bool) (string, error)
|
||||
|
||||
GetTopTracks(artist Artist, count int) ([]*Track, error)
|
||||
|
||||
|
||||
@@ -234,9 +234,12 @@ func (s *subsonicMediaProvider) GetSimilarTracks(artistID string, count int) ([]
|
||||
return sharedutil.MapSlice(tr, toTrack), nil
|
||||
}
|
||||
|
||||
func (s *subsonicMediaProvider) GetStreamURL(trackID string, forceRaw bool) (string, error) {
|
||||
func (s *subsonicMediaProvider) GetStreamURL(trackID string, transcode *mediaprovider.TranscodeSettings, forceRaw bool) (string, error) {
|
||||
m := make(map[string]string)
|
||||
if forceRaw {
|
||||
if transcode != nil {
|
||||
m["format"] = transcode.Codec
|
||||
m["maxBitRate"] = strconv.Itoa(transcode.BitRateKBPS)
|
||||
} else if forceRaw {
|
||||
m["format"] = "raw"
|
||||
}
|
||||
u, err := s.client.GetStreamURL(trackID, m)
|
||||
|
||||
Reference in New Issue
Block a user