Fix HLS browser in prod e stabilizza broadcast RTMP su iOS.
Il proxy Rails gestisce il redirect MediaMTX su /live/match_* e riscrive le playlist; edge nginx reindirizza /live/ sotto /hls/. Su iOS, SessionBuilder HaishinKit, pipeline mixer corretta e refresh token. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
36
backend/spec/requests/hls_proxy_spec.rb
Normal file
36
backend/spec/requests/hls_proxy_spec.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe "HLS proxy", type: :request do
|
||||
let(:mediamtx_hls) { "http://mediamtx.test:8888" }
|
||||
let(:playlist) do
|
||||
<<~M3U8
|
||||
#EXTM3U
|
||||
#EXT-X-VERSION:3
|
||||
#EXT-X-TARGETDURATION:1
|
||||
#EXTINF:1.0,
|
||||
/live/match_#{session_id}/segment0.ts
|
||||
M3U8
|
||||
end
|
||||
let(:session_id) { "cc7e90b2-c672-4401-b5d3-51fdcdc7a214" }
|
||||
|
||||
before do
|
||||
allow(MatchLiveTv).to receive(:mediamtx_hls_url).and_return(mediamtx_hls)
|
||||
end
|
||||
|
||||
describe "GET /live/match_:session_id/*" do
|
||||
it "proxies MediaMTX redirect and rewrites playlist paths to /hls/" do
|
||||
stub_request(:get, "#{mediamtx_hls}/live/match_#{session_id}/index.m3u8")
|
||||
.to_return(status: 302, headers: { "Location" => "/live/match_#{session_id}/index.m3u8?cookieCheck=1" })
|
||||
stub_request(:get, "#{mediamtx_hls}/live/match_#{session_id}/index.m3u8?cookieCheck=1")
|
||||
.to_return(status: 200, body: playlist, headers: { "Content-Type" => "application/vnd.apple.mpegurl" })
|
||||
|
||||
get "/live/match_#{session_id}/index.m3u8"
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(response.body).to include("/hls/live/match_#{session_id}/segment0.ts")
|
||||
expect(response.body).not_to include("/live/match_#{session_id}/segment0.ts")
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user