Class: LiveKit::EgressServiceClient
- Inherits:
-
Twirp::Client
- Object
- Twirp::Client
- LiveKit::EgressServiceClient
- Includes:
- AuthMixin
- Defined in:
- lib/livekit/egress_service_client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_secret ⇒ Object
Returns the value of attribute api_secret.
Instance Method Summary collapse
-
#initialize(base_url, api_key: nil, api_secret: nil) ⇒ EgressServiceClient
constructor
A new instance of EgressServiceClient.
-
#list_egress(room_name: nil, egress_id: nil, active: false) ⇒ Object
list all egress or only egress for a room.
- #start_participant_egress(room_name, identity, output, screen_share: false, preset: nil, advanced: nil) ⇒ Object
- #start_room_composite_egress(room_name, output, preset: nil, advanced: nil, custom_base_url: nil, layout: nil, audio_only: false, video_only: false) ⇒ Object
- #start_track_composite_egress(room_name, output, audio_track_id: nil, video_track_id: nil, preset: nil, advanced: nil) ⇒ Object
- #start_track_egress(room_name, output, track_id) ⇒ Object
- #start_web_egress(url, output, preset: nil, advanced: nil, audio_only: false, video_only: false, await_start_signal: false) ⇒ Object
- #stop_egress(egress_id) ⇒ Object
- #update_layout(egress_id, layout) ⇒ Object
- #update_stream(egress_id, add_output_urls: [], remove_output_urls: []) ⇒ Object
Methods included from AuthMixin
Constructor Details
#initialize(base_url, api_key: nil, api_secret: nil) ⇒ EgressServiceClient
Returns a new instance of EgressServiceClient.
11 12 13 14 15 |
# File 'lib/livekit/egress_service_client.rb', line 11 def initialize(base_url, api_key: nil, api_secret: nil) super(File.join(to_http_url(base_url), "/twirp")) @api_key = api_key @api_secret = api_secret end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
9 10 11 |
# File 'lib/livekit/egress_service_client.rb', line 9 def api_key @api_key end |
#api_secret ⇒ Object
Returns the value of attribute api_secret.
9 10 11 |
# File 'lib/livekit/egress_service_client.rb', line 9 def api_secret @api_secret end |
Instance Method Details
#list_egress(room_name: nil, egress_id: nil, active: false) ⇒ Object
list all egress or only egress for a room
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/livekit/egress_service_client.rb', line 186 def list_egress( room_name: nil, egress_id: nil, active: false ) self.rpc( :ListEgress, Proto::ListEgressRequest.new( room_name: room_name, active: active, egress_id: egress_id, ), headers: auth_header(roomRecord: true), ) end |
#start_participant_egress(room_name, identity, output, screen_share: false, preset: nil, advanced: nil) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/livekit/egress_service_client.rb', line 51 def start_participant_egress( room_name, identity, # EncodedFileOutput, SegmentedFileOutput, StreamOutput, ImageOutput, or array containing up to one of each output, # true to record the participant's screenshare and screenshare_audio track screen_share: false, # EncodingOptionsPreset, only one of preset or advanced could be set preset: nil, # EncodingOptions, only one of preset or advanced could be set advanced: nil ) request = Proto::ParticipantEgressRequest.new( room_name: room_name, identity: identity, screen_share: screen_share, preset: preset, advanced: advanced, ) self.set_output(request, output) self.rpc( :StartParticipantEgress, request, headers: auth_header(roomRecord: true), ) end |
#start_room_composite_egress(room_name, output, preset: nil, advanced: nil, custom_base_url: nil, layout: nil, audio_only: false, video_only: false) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/livekit/egress_service_client.rb', line 17 def start_room_composite_egress( room_name, # EncodedFileOutput, SegmentedFileOutput, StreamOutput, ImageOutput or array containing up to one of each output, # EncodingOptionsPreset, only one of preset or advanced could be set preset: nil, # EncodingOptions, only one of preset or advanced could be set advanced: nil, # egress template url, otherwise uses default templates custom_base_url: nil, # egress layout layout: nil, # true to record only audio audio_only: false, # true to record only video video_only: false ) request = Proto::RoomCompositeEgressRequest.new( room_name: room_name, preset: preset, advanced: advanced, layout: layout, custom_base_url: custom_base_url, audio_only: audio_only, video_only: video_only, ) self.set_output(request, output) self.rpc( :StartRoomCompositeEgress, request, headers: auth_header(roomRecord: true), ) end |
#start_track_composite_egress(room_name, output, audio_track_id: nil, video_track_id: nil, preset: nil, advanced: nil) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/livekit/egress_service_client.rb', line 78 def start_track_composite_egress( room_name, # EncodedFileOutput, SegmentedFileOutput, StreamOutput, ImageOutput, or array containing up to one of each output, # TrackID of an audio track audio_track_id: nil, # TrackID of a video track video_track_id: nil, # EncodingOptionsPreset, only one of preset or advanced could be set preset: nil, # EncodingOptions, only one of preset or advanced could be set advanced: nil ) request = Proto::TrackCompositeEgressRequest.new( room_name: room_name, preset: preset, advanced: advanced, audio_track_id: audio_track_id, video_track_id: video_track_id, ) self.set_output(request, output) self.rpc( :StartTrackCompositeEgress, request, headers: auth_header(roomRecord: true), ) end |
#start_track_egress(room_name, output, track_id) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/livekit/egress_service_client.rb', line 106 def start_track_egress( room_name, # either a DirectFileOutput - egress to storage or string - egress to WebSocket URL output, track_id ) request = Proto::TrackEgressRequest.new( room_name: room_name, track_id: track_id, ) if output.filepath request.file = output else request.websocket_url = output end self.rpc( :StartTrackEgress, request, headers: auth_header(roomRecord: true), ) end |
#start_web_egress(url, output, preset: nil, advanced: nil, audio_only: false, video_only: false, await_start_signal: false) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/livekit/egress_service_client.rb', line 128 def start_web_egress( url, # EncodedFileOutput, SegmentedFileOutput, StreamOutput, ImageOutput, or array containing up to one of each output, # EncodingOptionsPreset, only one of preset or advanced could be set preset: nil, # EncodingOptions, only one of preset or advanced could be set advanced: nil, # true to record only audio audio_only: false, # true to record only video video_only: false, # true to await START_RECORDING chrome log await_start_signal: false ) request = Proto::WebEgressRequest.new( url: url, preset: preset, advanced: advanced, audio_only: audio_only, video_only: video_only, await_start_signal: await_start_signal, ) self.set_output(request, output) self.rpc( :StartWebEgress, request, headers: auth_header(roomRecord: true), ) end |
#stop_egress(egress_id) ⇒ Object
202 203 204 205 206 207 208 |
# File 'lib/livekit/egress_service_client.rb', line 202 def stop_egress(egress_id) self.rpc( :StopEgress, Proto::StopEgressRequest.new(egress_id: egress_id), headers: auth_header(roomRecord: true), ) end |
#update_layout(egress_id, layout) ⇒ Object
159 160 161 162 163 164 165 166 167 168 |
# File 'lib/livekit/egress_service_client.rb', line 159 def update_layout(egress_id, layout) self.rpc( :UpdateLayout, Proto::UpdateLayoutRequest.new( egress_id: egress_id, layout: layout, ), headers: auth_header(roomRecord: true), ) end |
#update_stream(egress_id, add_output_urls: [], remove_output_urls: []) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/livekit/egress_service_client.rb', line 170 def update_stream(egress_id, add_output_urls: [], remove_output_urls: [] ) self.rpc( :UpdateStream, Proto::UpdateStreamRequest.new( egress_id: egress_id, add_output_urls: add_output_urls, remove_output_urls: remove_output_urls, ), headers: auth_header(roomRecord: true), ) end |