diff --git a/backend/media/media.go b/backend/media/media.go index e92aa66..2ebc7a1 100644 --- a/backend/media/media.go +++ b/backend/media/media.go @@ -140,10 +140,11 @@ func (c *Service) streamMediaIdentifier(w http.ResponseWriter, r *http.Request, // streamUpstreamPath is the CarrierNode request path for a stream. CarrierNode answers with a live // H.264 copy when the query carries quality (a height) and start (seconds), which is how browsers get -// containers they cannot decode. Those two parameters are the only ones forwarded. +// containers they cannot decode, and with an MP3 copy of an audio file when it carries format=mp3. +// Those parameters are the only ones forwarded. func streamUpstreamPath(upstream string, query url.Values) string { forward := url.Values{} - for _, key := range []string{"quality", "start"} { + for _, key := range []string{"quality", "start", "format"} { if value := strings.TrimSpace(query.Get(key)); value != "" { forward.Set(key, value) } diff --git a/backend/media/media_test.go b/backend/media/media_test.go index b71a5c0..4a8e0e3 100644 --- a/backend/media/media_test.go +++ b/backend/media/media_test.go @@ -136,6 +136,7 @@ func TestStreamUpstreamPathForwardsOnlyLiveTranscodeOptions(t *testing.T) { {"blank options are dropped", url.Values{"quality": {" "}, "start": {""}}, "/media/Videos/clip.mp4"}, {"quality and start are forwarded", url.Values{"mediaKey": {"abc"}, "quality": {"1080"}, "start": {" 12.5 "}}, "/media/Videos/clip.mp4?quality=1080&start=12.5"}, {"quality alone", url.Values{"quality": {"720"}}, "/media/Videos/clip.mp4?quality=720"}, + {"format is forwarded for audio copies", url.Values{"mediaKey": {"abc"}, "format": {"mp3"}}, "/media/Videos/clip.mp4?format=mp3"}, } { if got := streamUpstreamPath("Videos/clip.mp4", tc.query); got != tc.want { t.Errorf("%s: streamUpstreamPath() = %q, want %q", tc.name, got, tc.want)