Class: LiveKit::IngressServiceClient

Inherits:
Twirp::Client
  • Object
show all
Includes:
AuthMixin
Defined in:
lib/livekit/ingress_service_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AuthMixin

#auth_header

Constructor Details

#initialize(base_url, api_key: nil, api_secret: nil) ⇒ IngressServiceClient

Returns a new instance of IngressServiceClient.



11
12
13
14
15
# File 'lib/livekit/ingress_service_client.rb', line 11

def initialize(base_url, api_key: nil, api_secret: nil)
  super(File.join(Utils.to_http_url(base_url), "/twirp"))
  @api_key = api_key
  @api_secret = api_secret
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



9
10
11
# File 'lib/livekit/ingress_service_client.rb', line 9

def api_key
  @api_key
end

#api_secretObject

Returns the value of attribute api_secret.



9
10
11
# File 'lib/livekit/ingress_service_client.rb', line 9

def api_secret
  @api_secret
end

Instance Method Details

#create_ingress(input_type, name: nil, room_name: nil, participant_identity: nil, participant_name: nil, audio: nil, video: nil, bypass_transcoding: nil, enable_transcoding: nil, url: nil) ⇒ 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
50
51
52
53
54
55
56
# File 'lib/livekit/ingress_service_client.rb', line 17

def create_ingress(
  input_type,
  # optional, name to identify the ingress
  name: nil,
  # optional, you can attach to a room at a later time
  room_name: nil,
  # optional, identity of participant to publish as
  participant_identity: nil,
  # optional, display name of participant
  participant_name: nil,
  # optional, LiveKit::Proto::IngressAudioOptions
  audio: nil,
  # optional, LiveKit::Proto::IngressVideoOptions
  video: nil,
  # optional, whether to forward input media unprocessed, for WHIP only [deprecated]
  bypass_transcoding: nil,
  # optional, whether to enable transcoding or forward the input media directly.
  # Transcoding is required for all input types except WHIP. For WHIP, the default is to not transcode.
  enable_transcoding: nil,
  # optional, needed for ingresses of type URL, provides the URL to fetch media from
  url: nil
)
  request = Proto::CreateIngressRequest.new(
    input_type: input_type,
    name: name,
    room_name: room_name,
    participant_identity: participant_identity,
    participant_name: participant_name,
    audio: audio,
    video: video,
    bypass_transcoding: bypass_transcoding,
    enable_transcoding: enable_transcoding,
    url: url,
  )
  self.rpc(
    :CreateIngress,
    request,
    headers:auth_header(video_grant: VideoGrant.new(ingressAdmin: true)),
  )
end

#delete_ingress(ingress_id) ⇒ Object



113
114
115
116
117
118
119
120
121
122
# File 'lib/livekit/ingress_service_client.rb', line 113

def delete_ingress(ingress_id)
  request = Proto::DeleteIngressRequest.new(
    ingress_id: ingress_id
  )
  self.rpc(
    :DeleteIngress,
    request,
    headers:auth_header(video_grant: VideoGrant.new(ingressAdmin: true)),
  )
end

#list_ingress(room_name: nil, ingress_id: nil) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/livekit/ingress_service_client.rb', line 96

def list_ingress(
  # optional, filter by room name
  room_name: nil,
  # optional, list by ingress id
  ingress_id: nil
)
  request = Proto::ListIngressRequest.new(
    room_name: room_name,
    ingress_id: ingress_id,
  )
  self.rpc(
    :ListIngress,
    request,
    headers:auth_header(video_grant: VideoGrant.new(ingressAdmin: true)),
  )
end

#update_ingress(ingress_id, name: nil, room_name: nil, participant_identity: nil, participant_name: nil, audio: nil, video: nil, bypass_transcoding: nil, enable_transcoding: nil) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/livekit/ingress_service_client.rb', line 58

def update_ingress(
  ingress_id,
  # optional, name to identify the ingress
  name: nil,
  # optional, you can attach to a room at a later time
  room_name: nil,
  # optional, identity of participant to publish as
  participant_identity: nil,
  # optional, display name of participant
  participant_name: nil,
  # optional, LiveKit::Proto::IngressAudioOptions
  audio: nil,
  # optional, LiveKit::Proto::IngressVideoOptions
  video: nil,
  # optional, whether to forward input media unprocessed, for WHIP only
  bypass_transcoding: nil,
  # optional, whether to enable transcoding or forward the input media directly.
  # Transcoding is required for all input types except WHIP. For WHIP, the default is to not transcode.
  enable_transcoding: nil
)
  request = Proto::UpdateIngressRequest.new(
    ingress_id: ingress_id,
    name: name,
    room_name: room_name,
    participant_identity: participant_identity,
    participant_name: participant_name,
    audio: audio,
    video: video,
    bypass_transcoding: bypass_transcoding,
    enable_transcoding: enable_transcoding,
  )
  self.rpc(
    :UpdateIngress,
    request,
    headers:auth_header(video_grant: VideoGrant.new(ingressAdmin: true)),
  )
end