Upstream sync
This commit is contained in:
@@ -5,6 +5,7 @@ RSpec.describe MuxLiveStream, type: :model do
|
||||
let(:broadcast_2) { create(:broadcast, :with_stream, skip_create_callback: true, name: "My Broadcast") }
|
||||
let(:live_stream_data) { OpenStruct.new(data: OpenStruct.new(id: "stream_id", stream_key: "stream_key")) }
|
||||
let(:live_stream_playback_data) { OpenStruct.new(data: OpenStruct.new(id: "playback_id")) }
|
||||
let(:live_stream_simulcast_data) { OpenStruct.new(data: OpenStruct.new(id: "simulcast_id")) }
|
||||
|
||||
it "creates live stream and live stream playback URL" do
|
||||
allow_any_instance_of(MuxRuby::LiveStreamsApi).to receive(:create_live_stream).and_return(live_stream_data)
|
||||
@@ -85,4 +86,51 @@ RSpec.describe MuxLiveStream, type: :model do
|
||||
expect(request).to have_received(:test=).with(false)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#create_simulcast" do
|
||||
it "creates a simulcast for the live stream" do
|
||||
allow(ENV).to receive(:[]).with("MUX_REDUCED_LATENCY_ENABLED").and_return("true")
|
||||
allow(ENV).to receive(:[]).with("MUX_TEST_MODE_DISABLED").and_return("true")
|
||||
request = instance_double(MuxRuby::CreateLiveStreamRequest)
|
||||
destination = double(url: "http://test.com/rmtp", key: "123abc")
|
||||
allow(request).to receive(:reduced_latency=)
|
||||
allow(request).to receive(:new_asset_settings=)
|
||||
allow(request).to receive(:playback_policy=)
|
||||
allow(request).to receive(:test=)
|
||||
allow(MuxRuby::CreateLiveStreamRequest).to receive(:new).and_return(request)
|
||||
allow_any_instance_of(MuxRuby::LiveStreamsApi).to receive(:create_live_stream).and_return(live_stream_data)
|
||||
allow_any_instance_of(MuxRuby::LiveStreamsApi).to receive(:create_live_stream_playback_id).and_return(live_stream_playback_data)
|
||||
allow_any_instance_of(MuxRuby::LiveStreamsApi).to receive(:create_live_stream_simulcast_target).and_return(live_stream_simulcast_data)
|
||||
allow(MillicastDestination).to receive(:create).and_return(destination)
|
||||
|
||||
live_stream = MuxLiveStream.create_with_simulcast
|
||||
|
||||
expect(live_stream.id).to eq "stream_id"
|
||||
expect(live_stream.simulcast_id).to eq "simulcast_id"
|
||||
expect(live_stream.simulcast_destination).to eq destination
|
||||
end
|
||||
|
||||
context "when test mode is enabled" do
|
||||
it "does not create a simulcast" do
|
||||
allow(ENV).to receive(:[]).with("MUX_TEST_MODE_DISABLED").and_return(nil)
|
||||
allow(ENV).to receive(:[]).with("MUX_REDUCED_LATENCY_ENABLED").and_return("true")
|
||||
request = instance_double(MuxRuby::CreateLiveStreamRequest)
|
||||
destination = double(url: "http://test.com/rmtp", key: "123abc")
|
||||
allow(request).to receive(:reduced_latency=)
|
||||
allow(request).to receive(:new_asset_settings=)
|
||||
allow(request).to receive(:playback_policy=)
|
||||
allow(request).to receive(:test=)
|
||||
allow(MuxRuby::CreateLiveStreamRequest).to receive(:new).and_return(request)
|
||||
allow_any_instance_of(MuxRuby::LiveStreamsApi).to receive(:create_live_stream).and_return(live_stream_data)
|
||||
allow_any_instance_of(MuxRuby::LiveStreamsApi).to receive(:create_live_stream_playback_id).and_return(live_stream_playback_data)
|
||||
allow(MillicastDestination).to receive(:create).and_return(destination)
|
||||
|
||||
live_stream = MuxLiveStream.create_with_simulcast
|
||||
|
||||
expect(live_stream.id).to eq "stream_id"
|
||||
expect(live_stream.simulcast_id).to be_nil
|
||||
expect(live_stream.simulcast_destination).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user