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) ⇒ Object
list all egress or only egress for a room.
- #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) ⇒ 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.
10 11 12 13 14 |
# File 'lib/livekit/egress_service_client.rb', line 10 def initialize(base_url, api_key: nil, api_secret: nil) super(File.join(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.
8 9 10 |
# File 'lib/livekit/egress_service_client.rb', line 8 def api_key @api_key end |
#api_secret ⇒ Object
Returns the value of attribute api_secret.
8 9 10 |
# File 'lib/livekit/egress_service_client.rb', line 8 def api_secret @api_secret end |
Instance Method Details
#list_egress(room_name: nil) ⇒ Object
list all egress or only egress for a room
155 156 157 158 159 160 161 |
# File 'lib/livekit/egress_service_client.rb', line 155 def list_egress(room_name: nil) self.rpc( :ListEgress, Proto::ListEgressRequest.new(room_name: room_name), 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
16 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 |
# File 'lib/livekit/egress_service_client.rb', line 16 def start_room_composite_egress( room_name, # EncodedFileOutput, SegmentedFileOutput, StreamOutput, 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
50 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 50 def start_track_composite_egress( room_name, # EncodedFileOutput, SegmentedFileOutput, StreamOutput, 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
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/livekit/egress_service_client.rb', line 78 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) ⇒ Object
100 101 102 103 104 105 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 100 def start_web_egress( url, # EncodedFileOutput, SegmentedFileOutput, StreamOutput, 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 ) request = Proto::WebEgressRequest.new( url: url, preset: preset, advanced: advanced, audio_only: audio_only, video_only: video_only, ) self.set_output(request, output) self.rpc( :StartWebEgress, request, headers: auth_header(roomRecord: true), ) end |
#stop_egress(egress_id) ⇒ Object
163 164 165 166 167 168 169 |
# File 'lib/livekit/egress_service_client.rb', line 163 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
128 129 130 131 132 133 134 135 136 137 |
# File 'lib/livekit/egress_service_client.rb', line 128 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
139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/livekit/egress_service_client.rb', line 139 def update_stream(egress_id, add_output_urls: [], remove_output_urls: [] ) self.rpc( :UpdateStream, Proto::UpdateStreamRequest.new( egress_id: egress_id, add_output_urls: Google::Protobuf::RepeatedField.new(:string, add_output_urls.to_a), remove_output_urls: Google::Protobuf::RepeatedField.new(:string, remove_output_urls.to_a), ), headers: auth_header(roomRecord: true), ) end |