Riduce reload MediaMTX in live e allinea ingest mobile al preset qualità.
Evita patch recording ripetute che distruggevano i muxer HLS (500 ops) e fa encoderare 1080p/720p con codec e bitrate coerenti al wizard. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -13,30 +13,66 @@ RSpec.describe Mediamtx::PublisherSync do
|
||||
end
|
||||
let(:client) { instance_double(Mediamtx::Client) }
|
||||
let(:redis) { instance_double(Redis, get: nil, set: true, incr: 1, expire: true, del: 1) }
|
||||
let(:path_info) do
|
||||
{ "name" => session.mediamtx_path_name, "online" => true, "source" => { "type" => "rtmpConn" }, "record" => false }
|
||||
end
|
||||
|
||||
before do
|
||||
Billing::AssignPlan.call(club: club, plan_slug: "premium_full")
|
||||
allow(Mediamtx::Client).to receive(:new).and_return(client)
|
||||
allow(client).to receive_messages(list_paths: [ {
|
||||
"name" => session.mediamtx_path_name, "online" => true, "source" => { "type" => "rtmpConn" }
|
||||
} ])
|
||||
allow(Mediamtx::PublisherOnline).to receive(:path_info).and_return(path_info)
|
||||
allow(Mediamtx::PublisherOnline).to receive(:active_path?).and_return(true)
|
||||
allow_any_instance_of(described_class).to receive(:redis).and_return(redis)
|
||||
allow(client).to receive(:set_path_recording)
|
||||
end
|
||||
|
||||
it "abilita la registrazione quando il publisher è online" do
|
||||
it "abilita la registrazione quando il publisher è online e la sessione è live" do
|
||||
session.update!(status: "live")
|
||||
|
||||
described_class.new(session).call
|
||||
|
||||
expect(client).to have_received(:set_path_recording).with(session, enabled: true)
|
||||
end
|
||||
|
||||
it "disabilita la registrazione in pausa" do
|
||||
session.update!(status: "paused")
|
||||
allow(Mediamtx::PublisherOnline).to receive(:active_path?).and_return(true)
|
||||
it "non abilita la registrazione in connecting senza publisher online" do
|
||||
allow(Mediamtx::PublisherOnline).to receive(:active_path?).and_return(false)
|
||||
path_info["online"] = false
|
||||
|
||||
described_class.new(session).call
|
||||
|
||||
expect(client).to have_received(:set_path_recording).with(session, enabled: false)
|
||||
expect(client).not_to have_received(:set_path_recording)
|
||||
end
|
||||
|
||||
it "abilita la registrazione quando connecting diventa live con publisher online" do
|
||||
described_class.new(session).call
|
||||
|
||||
expect(session.reload.status).to eq("live")
|
||||
expect(client).to have_received(:set_path_recording).with(session, enabled: true)
|
||||
end
|
||||
|
||||
it "non disabilita la registrazione su reconnecting con publisher offline" do
|
||||
session.update!(status: "reconnecting")
|
||||
allow(Mediamtx::PublisherOnline).to receive(:active_path?).and_return(false)
|
||||
|
||||
described_class.new(session).call
|
||||
|
||||
expect(client).not_to have_received(:set_path_recording)
|
||||
end
|
||||
|
||||
it "non patcha la registrazione in pausa (gestita da Sessions::Pause)" do
|
||||
session.update!(status: "paused")
|
||||
|
||||
described_class.new(session).call
|
||||
|
||||
expect(client).not_to have_received(:set_path_recording)
|
||||
end
|
||||
|
||||
it "salta la patch se MediaMTX ha già lo stato record desiderato" do
|
||||
session.update!(status: "live")
|
||||
path_info["record"] = true
|
||||
|
||||
described_class.new(session).call
|
||||
|
||||
expect(client).not_to have_received(:set_path_recording)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user