Skip to content

Commit 3f94dee

Browse files
committed
server-sdk-ruby: add unified start_egress convenience method
server-sdk-ruby's EgressServiceClient exposes a unified start_egress that calls the Egress.StartEgress Twirp RPC with the v2 StartEgressRequest.
1 parent b3b89d3 commit 3f94dee

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

lib/livekit/egress_service_client.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,44 @@ def start_web_egress(
178178
)
179179
end
180180

181+
def start_egress(
182+
room_name: nil,
183+
# source, only one of template, web or media could be set
184+
# TemplateSource
185+
template: nil,
186+
# WebSource
187+
web: nil,
188+
# MediaSource
189+
media: nil,
190+
# EncodingOptionsPreset, only one of preset or advanced could be set
191+
preset: nil,
192+
# EncodingOptions, only one of preset or advanced could be set
193+
advanced: nil,
194+
# an Output or array of Output
195+
outputs: nil,
196+
# StorageConfig, default storage for outputs that don't set their own
197+
storage: nil,
198+
# list of extra webhooks to call for this request
199+
webhooks: nil
200+
)
201+
request = Proto::StartEgressRequest.new(
202+
room_name: room_name,
203+
template: template,
204+
web: web,
205+
media: media,
206+
preset: preset,
207+
advanced: advanced,
208+
outputs: outputs.nil? ? nil : Array(outputs),
209+
storage: storage,
210+
webhooks: webhooks,
211+
)
212+
rpc!(
213+
:StartEgress,
214+
request,
215+
headers:auth_header(video_grant: VideoGrant.new(roomRecord: true)),
216+
)
217+
end
218+
181219
def update_layout(egress_id, layout)
182220
rpc!(
183221
:UpdateLayout,

spec/api/livekit_api_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ def mock!(client, directives)
8989
api.egress.start_track_composite_egress('test-room', mp4.call,
9090
audio_track_id: 'TR_audio1', video_track_id: 'TR_video1')
9191
api.egress.start_track_egress('test-room', PB::DirectFileOutput.new(filepath: 'track.mp4'), 'TR_video1')
92+
api.egress.start_egress(
93+
room_name: 'test-room',
94+
media: PB::MediaSource.new(video_track_id: 'TR_video1'),
95+
outputs: PB::Output.new(
96+
file: PB::FileOutput.new(file_type: PB::EncodedFileType::MP4, filepath: 'out.mp4')
97+
),
98+
preset: PB::EncodingOptionsPreset::H264_1080P_30
99+
)
92100
api.egress.update_layout('EG_abc123', 'speaker')
93101
api.egress.update_stream('EG_abc123', add_output_urls: ['rtmps://b.example.com/live/key'],
94102
remove_output_urls: ['rtmps://a.example.com/live/key'])

0 commit comments

Comments
 (0)