Class: Vonage::Video
- Inherits:
-
Namespace
- Object
- Namespace
- Vonage::Video
show all
- Defined in:
- lib/vonage/video.rb
Defined Under Namespace
Classes: Archives, Broadcasts, Captions, Moderation, Renders, SIP, Signals, Streams, WebSocket
Instance Method Summary
collapse
Instance Method Details
82
83
84
|
# File 'lib/vonage/video.rb', line 82
def archives
@archives ||= Archives.new(@config)
end
|
88
89
90
|
# File 'lib/vonage/video.rb', line 88
def broadcasts
@broadcasts ||= Broadcasts.new(@config)
end
|
112
113
114
|
# File 'lib/vonage/video.rb', line 112
def captions
@captions ||= Captions.new(@config)
end
|
#create_session(**params) ⇒ Response
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/vonage/video.rb', line 31
def create_session(**params)
request_params = params.clone
request_params[:archive_mode] ||= 'manual'
media_mode = request_params.delete(:media_mode) || 'routed'
if media_mode == 'relayed' && request_params[:archive_mode] == 'manual'
request_params['p2p.preference'] = 'enabled'
else
request_params['p2p.preference'] = 'disabled'
end
response = request('/session/create', params: camelcase(request_params), type: Post)
public_response_data = {
session_id: response.entity.first.session_id,
archive_mode: request_params[:archive_mode],
media_mode: media_mode,
location: request_params[:location]
}
entity = Entity.new(public_response_data)
response.class.new(entity, response.http_response)
end
|
#generate_client_token(session_id:, scope: 'session.connect', role: 'publisher', **params) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/vonage/video.rb', line 56
def generate_client_token(session_id:, scope: 'session.connect', role: 'publisher', **params)
valid_roles = %w[publisher subscriber moderator publisheronly]
raise ArgumentError, "Invalid role: #{role}" unless valid_roles.include?(role)
claims = {
application_id: @config.application_id,
scope: scope,
session_id: session_id,
role: role,
initial_layout_class_list: '',
sub: 'video',
acl: {
paths: {'/session/**' => {}}
}
}
claims[:data] = params[:data] if params[:data]
claims[:initial_layout_class_list] = params[:initial_layout_class_list].join(' ') if params[:initial_layout_class_list]
claims[:exp] = params[:expire_time].to_i if params[:expire_time]
JWT.generate(claims, @config.private_key)
end
|
94
95
96
|
# File 'lib/vonage/video.rb', line 94
def moderation
@moderation ||= Moderation.new(@config)
end
|
118
119
120
|
# File 'lib/vonage/video.rb', line 118
def renders
@renders ||= Renders.new(@config)
end
|
100
101
102
|
# File 'lib/vonage/video.rb', line 100
def signals
@signals ||= Signals.new(@config)
end
|
106
107
108
|
# File 'lib/vonage/video.rb', line 106
def streams
@streams ||= Streams.new(@config)
end
|
124
125
126
|
# File 'lib/vonage/video.rb', line 124
def web_socket
@web_socket ||= WebSocket.new(@config)
end
|