opentok 4.4.0 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +7 -0
- data/README.md +59 -37
- data/lib/opentok/archive.rb +5 -2
- data/lib/opentok/archives.rb +13 -5
- data/lib/opentok/broadcast.rb +6 -2
- data/lib/opentok/broadcasts.rb +9 -1
- data/lib/opentok/client.rb +90 -0
- data/lib/opentok/exceptions.rb +3 -1
- data/lib/opentok/opentok.rb +5 -0
- data/lib/opentok/render.rb +78 -0
- data/lib/opentok/render_list.rb +14 -0
- data/lib/opentok/renders.rb +101 -0
- data/lib/opentok/session.rb +4 -4
- data/lib/opentok/streams.rb +1 -1
- data/lib/opentok/version.rb +1 -1
- data/spec/cassettes/OpenTok_Archives/should_create_an_archive_with_matching_multi_archive_tag_when_multiArchiveTag_is_specified.yml +50 -0
- data/spec/cassettes/OpenTok_Archives/should_create_an_archive_with_multi_archive_tag_value_of_nil_when_multiArchiveTag_not_specified.yml +49 -0
- data/spec/cassettes/OpenTok_Archives/should_create_an_archives_with_a_specified_multiArchiveTag.yml +52 -0
- data/spec/cassettes/OpenTok_Broadcasts/starts_a_broadcast_with_a_matching_multi_broadcast_tag_value_when_multiBroadcastTag_is_specified.yml +54 -0
- data/spec/cassettes/OpenTok_Broadcasts/starts_a_broadcast_with_a_multi_broadcast_tag_value_of_nil_when_multiBroadcastTag_not_specified.yml +53 -0
- data/spec/cassettes/OpenTok_Broadcasts/starts_a_broadcast_with_a_specified_multiBroadcastTag.yml +54 -0
- data/spec/cassettes/OpenTok_Renders/finds_an_Experience_Composer_render.yml +46 -0
- data/spec/cassettes/OpenTok_Renders/for_many_renders/should_return_all_renders.yml +108 -0
- data/spec/cassettes/OpenTok_Renders/for_many_renders/should_return_count_number_of_renders.yml +63 -0
- data/spec/cassettes/OpenTok_Renders/for_many_renders/should_return_part_of_the_renders_when_using_offset_and_count.yml +63 -0
- data/spec/cassettes/OpenTok_Renders/for_many_renders/should_return_renders_with_an_offset.yml +74 -0
- data/spec/cassettes/OpenTok_Renders/starts_an_Experience_Composer_render.yml +48 -0
- data/spec/cassettes/OpenTok_Renders/stops_an_Experience_Composer_render.yml +28 -0
- data/spec/opentok/archives_spec.rb +21 -0
- data/spec/opentok/broadcasts_spec.rb +38 -0
- data/spec/opentok/renders_spec.rb +142 -0
- metadata +34 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d767275da666c054e01f40a08a9b24bf1d0adff6fffdd143dad116ac532109eb
|
4
|
+
data.tar.gz: 8911e707e50e47683bfbf95e1a7851a28b292a9febcccec14f6a65088bec1cde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12062c3280ec988533f1ec136471d9e07cb88a30c0d2c5e6176a668ec130f718669f826e74daed353347ef4bd61240269efb3e22563751305202ec7bd6398fee
|
7
|
+
data.tar.gz: 17d32a6034e7ef78c6bbdd92e39ad5cbb64a13f72bd2ca21140884528d5702f754044c79f7933ca61709a7b6ce20c80225e2bbac32cb2db1ed92a689aec88d12
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# 4.5.0
|
2
|
+
|
3
|
+
* Adds support for multiple archives and records feature [#248](https://github.com/opentok/OpenTok-Ruby-SDK/pull/248)
|
4
|
+
* Adds Experience Composer functionality [#249](https://github.com/opentok/OpenTok-Ruby-SDK/pull/249)
|
5
|
+
* Updates code comments to make explicit support for 1080p resolution for Archive and Broadcast [#246](https://github.com/opentok/OpenTok-Ruby-SDK/pull/246)
|
6
|
+
* Updates various other documentation/code comments [#250](https://github.com/opentok/OpenTok-Ruby-SDK/pull/250)
|
7
|
+
|
1
8
|
# 4.4.0
|
2
9
|
|
3
10
|
* Implements DVR Pause/Resume and HLS Low-Latency options for Broadcasts [#243](https://github.com/opentok/OpenTok-Ruby-SDK/pull/243)
|
data/README.md
CHANGED
@@ -1,24 +1,27 @@
|
|
1
1
|
# OpenTok Ruby SDK
|
2
2
|
|
3
3
|

|
4
|
-
[](https://codecov.io/gh/opentok/opentok-ruby-sdk)
|
4
|
+
[](https://codecov.io/gh/opentok/opentok-ruby-sdk)
|
5
5
|
[](CODE_OF_CONDUCT.md)
|
6
6
|
|
7
7
|
<img src="https://assets.tokbox.com/img/vonage/Vonage_VideoAPI_black.svg" height="48px" alt="Tokbox is now known as Vonage" />
|
8
8
|
|
9
|
-
The OpenTok Ruby SDK
|
10
|
-
[sessions](https://tokbox.com/developer/guides/create-session/) and
|
11
|
-
[tokens](https://tokbox.com/developer/guides/create-token/) for
|
12
|
-
[OpenTok](http://www.tokbox.com/) applications. It also includes methods for
|
13
|
-
working with OpenTok [archives](https://tokbox.com/developer/guides/archiving),
|
14
|
-
working with OpenTok [live streaming
|
15
|
-
broadcasts](https://tokbox.com/developer/guides/broadcast/live-streaming/),
|
16
|
-
working with OpenTok [SIP interconnect](https://tokbox.com/developer/guides/sip),
|
17
|
-
and [disconnecting clients from sessions](https://tokbox.com/developer/guides/moderation/rest/).
|
9
|
+
The OpenTok Ruby SDK provides methods for:
|
18
10
|
|
19
|
-
|
11
|
+
* Generating [sessions](https://tokbox.com/developer/guides/create-session/) and
|
12
|
+
[tokens](https://tokbox.com/developer/guides/create-token/) for
|
13
|
+
[OpenTok](https://www.vonage.com/communications-apis/video/) applications
|
14
|
+
* Working with OpenTok [archives](https://tokbox.com/developer/guides/archiving)
|
15
|
+
* Working with OpenTok [live streaming broadcasts](https://tokbox.com/developer/guides/broadcast/live-streaming/)
|
16
|
+
* Working with OpenTok [SIP interconnect](https://tokbox.com/developer/guides/sip)
|
17
|
+
* [Sending signals to clients connected to a session](https://tokbox.com/developer/guides/signaling/)
|
18
|
+
* [Disconnecting clients from sessions](https://tokbox.com/developer/guides/moderation/rest/)
|
19
|
+
* [Forcing clients in a session to disconnect or mute published audio](https://tokbox.com/developer/guides/moderation/)
|
20
|
+
* Working with OpenTok [Experience Composers](https://tokbox.com/developer/guides/experience-composer)
|
20
21
|
|
21
|
-
##
|
22
|
+
## Installation
|
23
|
+
|
24
|
+
### Bundler (recommended):
|
22
25
|
|
23
26
|
Bundler helps manage dependencies for Ruby projects. Find more info here: <http://bundler.io>
|
24
27
|
|
@@ -34,15 +37,15 @@ Allow bundler to install the change.
|
|
34
37
|
$ bundle install
|
35
38
|
```
|
36
39
|
|
37
|
-
|
40
|
+
### RubyGems:
|
38
41
|
|
39
42
|
```
|
40
43
|
$ gem install opentok
|
41
44
|
```
|
42
45
|
|
43
|
-
|
46
|
+
## Usage
|
44
47
|
|
45
|
-
|
48
|
+
### Initializing
|
46
49
|
|
47
50
|
Load the gem at the top of any file where it will be used. Then initialize an `OpenTok::OpenTok`
|
48
51
|
object with your OpenTok API key and API secret.
|
@@ -53,7 +56,7 @@ require "opentok"
|
|
53
56
|
opentok = OpenTok::OpenTok.new api_key, api_secret
|
54
57
|
```
|
55
58
|
|
56
|
-
|
59
|
+
#### Initialization Options
|
57
60
|
|
58
61
|
You can specify a custom timeout value for HTTP requests when initializing a new `OpenTok::OpenTok`
|
59
62
|
object:
|
@@ -67,7 +70,7 @@ opentok = OpenTok::OpenTok.new api_key, api_secret, :timeout_length => 10
|
|
67
70
|
The value for `:timeout_length` is an integer representing the number of seconds to wait for an HTTP
|
68
71
|
request to complete. The default is set to 2 seconds.
|
69
72
|
|
70
|
-
|
73
|
+
### Creating Sessions
|
71
74
|
|
72
75
|
To create an OpenTok Session, use the `OpenTok#create_session(properties)` method.
|
73
76
|
The `properties` parameter is an optional Hash used to specify the following:
|
@@ -101,7 +104,7 @@ session = opentok.create_session :archive_mode => :always, :media_mode => :route
|
|
101
104
|
session_id = session.session_id
|
102
105
|
```
|
103
106
|
|
104
|
-
|
107
|
+
### Generating Tokens
|
105
108
|
|
106
109
|
Once a Session is created, you can start generating Tokens for clients to use when connecting to it.
|
107
110
|
You can generate a token either by calling the `opentok.generate_token(session_id, options)` method,
|
@@ -111,7 +114,7 @@ the Token. For layout control in archives and broadcasts, the initial layout cla
|
|
111
114
|
published from connections using this token can be set as well.
|
112
115
|
|
113
116
|
```ruby
|
114
|
-
|
117
|
+
## Generate a Token from just a session_id (fetched from a database)
|
115
118
|
token = opentok.generate_token session_id
|
116
119
|
|
117
120
|
# Generate a Token by calling the method on the Session (returned from createSession)
|
@@ -126,7 +129,7 @@ token = session.generate_token({
|
|
126
129
|
});
|
127
130
|
```
|
128
131
|
|
129
|
-
|
132
|
+
### Working with Streams
|
130
133
|
|
131
134
|
Use this method to get information for an OpenTok stream or for all streams in a session.
|
132
135
|
For example, you can call this method to get information about layout classes used by an
|
@@ -152,7 +155,7 @@ expect(all_streams.total).to eq 2
|
|
152
155
|
expect(all_streams[0].layoutClassList[1]).to eq "focus"
|
153
156
|
```
|
154
157
|
|
155
|
-
|
158
|
+
### Working with Archives
|
156
159
|
|
157
160
|
You can only archive sessions that use the OpenTok Media Router
|
158
161
|
(sessions with the media mode set to routed).
|
@@ -185,8 +188,7 @@ archive = opentok.archives.create session_id :output_mode => :individual
|
|
185
188
|
The `:output_mode => :composed` setting (the default) causes all streams in the archive to be
|
186
189
|
recorded to a single (composed) file.
|
187
190
|
|
188
|
-
For composed archives you can set the resolution of the archive, either "640x480" (SD, the default)
|
189
|
-
or "1280x720" (HD). The `resolution` parameter is optional and could be included in the options
|
191
|
+
For composed archives you can set the resolution of the archive, either "640x480" (SD landscape, the default), "1280x720" (HD landscape), "1920x1080" (FHD landscape), "480x640" (SD portrait), "720x1280" (HD portrait), or "1080x1920" (FHD portrait).. The `resolution` parameter is optional and could be included in the options
|
190
192
|
hash (second argument) of the `opentok.archives.create()` method.
|
191
193
|
|
192
194
|
```ruby
|
@@ -316,9 +318,9 @@ stream](https://tokbox.com/developer/rest/#change-stream-layout-classes-composed
|
|
316
318
|
Please keep in mind that the `streams.layout` method applies to archive and broadcast streams only.
|
317
319
|
|
318
320
|
For more information on archiving, see the
|
319
|
-
[OpenTok archiving](
|
321
|
+
[OpenTok archiving](/developer/guides/archiving/) developer guide.
|
320
322
|
|
321
|
-
|
323
|
+
### Signaling
|
322
324
|
|
323
325
|
You can send a signal using the `opentok.signals.send(session_id, connection_id, opts)` method.
|
324
326
|
If `connection_id` is nil or an empty string, then the signal is send to all valid connections in
|
@@ -343,16 +345,13 @@ use `opentok.signals.send(session_id)`
|
|
343
345
|
For more information on signaling, see the
|
344
346
|
[OpenTok Signaling](https://tokbox.com/developer/guides/signaling/js/) programming guide.
|
345
347
|
|
346
|
-
|
348
|
+
### Broadcasting
|
347
349
|
|
348
350
|
You can broadcast your streams to a HLS or RTMP servers.
|
349
351
|
|
350
352
|
To successfully start broadcasting a session, at least one publishing client must be connected to
|
351
353
|
the session.
|
352
354
|
|
353
|
-
You can only have one active live streaming broadcast at a time for a session (however, having more
|
354
|
-
than one would not be useful).
|
355
|
-
|
356
355
|
The live streaming broadcast can target one HLS endpoint and up to five RTMP servers simultaneously
|
357
356
|
for a session.
|
358
357
|
|
@@ -451,12 +450,25 @@ for more details.
|
|
451
450
|
You can also change the layout of an individual stream dynamically. Refer to
|
452
451
|
[working with Streams](#working-with-streams).
|
453
452
|
|
454
|
-
|
453
|
+
### Force disconnect
|
455
454
|
|
456
455
|
You can cause a client to be forced to disconnect from a session by using the
|
457
456
|
`opentok.connections.forceDisconnect(session_id, connection_id)` method.
|
458
457
|
|
459
|
-
|
458
|
+
### Forcing clients in a session to mute published audio
|
459
|
+
|
460
|
+
You can force the publisher of a specific stream to stop publishing audio using the
|
461
|
+
`opentok.streams.force_mute(session_id, stream_id)` method.
|
462
|
+
|
463
|
+
You can force the publisher of all streams in a session (except for an optional list of streams)
|
464
|
+
to stop publishing audio using the `opentok.streams.force_mute_all(session_id, opts)`
|
465
|
+
method. You can then disable the mute state of the session by calling the
|
466
|
+
`opentok.streams.disable_force_mute(session_id)` method.
|
467
|
+
|
468
|
+
For more information, see
|
469
|
+
[Muting the audio of streams in a session](https://tokbox.com/developer/guides/moderation/#force_mute).
|
470
|
+
|
471
|
+
### Initiating a SIP call
|
460
472
|
|
461
473
|
You can initiate a SIP call using the `opentok.sip.dial(session_id, token, sip_uri, opts)` method.
|
462
474
|
This requires a SIP URL. You will often need to pass options for authenticating to the SIP provider
|
@@ -473,7 +485,17 @@ response = opentok.sip.dial(session_id, token, "sip:+15128675309@acme.pstn.examp
|
|
473
485
|
For more information on SIP Interconnect, see the
|
474
486
|
[OpenTok SIP Interconnect](https://tokbox.com/developer/guides/sip/) developer guide.
|
475
487
|
|
476
|
-
|
488
|
+
### Working with Experience Composers
|
489
|
+
|
490
|
+
You can start an [Experience Composer](https://tokbox.com/developer/guides/experience-composer)
|
491
|
+
by calling the `opentok.renders.start(session_id, options)` method.
|
492
|
+
|
493
|
+
You can stop an Experience Composer by calling the `opentok.renders.stop(render_id, options)` method.
|
494
|
+
|
495
|
+
You can get information about Experience Composers by calling the `opentok.renders.find(render_id)`
|
496
|
+
and `opentok.renders.list(options)` methods.
|
497
|
+
|
498
|
+
## Samples
|
477
499
|
|
478
500
|
There are three sample applications included in this repository. To get going as fast as possible, clone the whole
|
479
501
|
repository and read the README in each of the sample directories:
|
@@ -482,23 +504,23 @@ repository and read the README in each of the sample directories:
|
|
482
504
|
- [Archiving](sample/Archiving/README.md)
|
483
505
|
- [Broadcast](sample/Broadcast/README.md)
|
484
506
|
|
485
|
-
|
507
|
+
## Documentation
|
486
508
|
|
487
509
|
Reference documentation is available at <http://www.tokbox.com//opentok/libraries/server/ruby/reference/index.html>.
|
488
510
|
|
489
|
-
|
511
|
+
## Requirements
|
490
512
|
|
491
513
|
You need an OpenTok API key and API secret, which you can obtain by logging into your
|
492
514
|
[Vonage Video API account](https://tokbox.com/account).
|
493
515
|
|
494
516
|
The OpenTok Ruby SDK requires Ruby 2.1.0 or greater.
|
495
517
|
|
496
|
-
|
518
|
+
## Release Notes
|
497
519
|
|
498
520
|
See the [Releases](https://github.com/opentok/opentok-ruby-sdk/releases) page for details
|
499
521
|
about each release.
|
500
522
|
|
501
|
-
|
523
|
+
### Important changes since v2.2.0
|
502
524
|
|
503
525
|
**Changes in v4.0.0:**
|
504
526
|
|
@@ -530,7 +552,7 @@ See the reference documentation
|
|
530
552
|
<http://www.tokbox.com/opentok/libraries/server/ruby/reference/index.html> and in the
|
531
553
|
docs directory of the SDK.
|
532
554
|
|
533
|
-
|
555
|
+
## Development and Contributing
|
534
556
|
|
535
557
|
Interested in contributing? We :heart: pull requests! See the [Development](DEVELOPING.md) and
|
536
558
|
[Contribution](CONTRIBUTING.md) guidelines.
|
data/lib/opentok/archive.rb
CHANGED
@@ -34,7 +34,9 @@ module OpenTok
|
|
34
34
|
# reason the archive stopped (such as "maximum duration exceeded") or failed.
|
35
35
|
#
|
36
36
|
# @attr [string] resolution
|
37
|
-
# The resolution of the archive
|
37
|
+
# The resolution of the archive, either "640x480" (SD landscape, the default), "1280x720" (HD landscape),
|
38
|
+
# "1920x1080" (FHD landscape), "480x640" (SD portrait), "720x1280" (HD portrait), or "1080x1920" (FHD portrait).
|
39
|
+
# You may want to use a portrait aspect ratio for archives that include video streams from mobile devices (which often use the portrait aspect ratio).
|
38
40
|
# This property is only set for composed archives.
|
39
41
|
#
|
40
42
|
# @attr [string] session_id
|
@@ -70,12 +72,13 @@ module OpenTok
|
|
70
72
|
# set to null. The download URL is obfuscated, and the file is only available from the URL for
|
71
73
|
# 10 minutes. To generate a new URL, call the Archive.listArchives() or OpenTok.getArchive() method.
|
72
74
|
class Archive
|
73
|
-
|
75
|
+
attr_reader :multi_archive_tag
|
74
76
|
# @private
|
75
77
|
def initialize(interface, json)
|
76
78
|
@interface = interface
|
77
79
|
# TODO: validate json fits schema
|
78
80
|
@json = json
|
81
|
+
@multi_archive_tag = @json['multiArchiveTag']
|
79
82
|
end
|
80
83
|
|
81
84
|
# A JSON-encoded string representation of the archive.
|
data/lib/opentok/archives.rb
CHANGED
@@ -39,20 +39,28 @@ module OpenTok
|
|
39
39
|
# (a video track is included). If you set both <code>has_audio</code> and
|
40
40
|
# <code>has_video</code> to <code>false</code>, the call to the <code>create()</code>
|
41
41
|
# method results in an error.
|
42
|
+
# @option options [String] :multiArchiveTag (Optional) Set this to support recording multiple archives for the same session simultaneously.
|
43
|
+
# Set this to a unique string for each simultaneous archive of an ongoing session. You must also set this option when manually starting an archive
|
44
|
+
# that is {https://tokbox.com/developer/guides/archiving/#automatic automatically archived}. Note that the `multiArchiveTag` value is not included
|
45
|
+
# in the response for the methods to {https://tokbox.com/developer/rest/#listing_archives list archives} and
|
46
|
+
# {https://tokbox.com/developer/rest/#retrieve_archive_info retrieve archive information}. If you do not specify a unique `multiArchiveTag`,
|
47
|
+
# you can only record one archive at a time for a given session.
|
48
|
+
# {https://tokbox.com/developer/guides/archiving/#simultaneous-archives See Simultaneous archives}.
|
42
49
|
# @option options [String] :output_mode Whether all streams in the archive are recorded
|
43
50
|
# to a single file (<code>:composed</code>, the default) or to individual files
|
44
51
|
# (<code>:individual</code>). For more information on archiving and the archive file
|
45
52
|
# formats, see the {https://tokbox.com/opentok/tutorials/archiving OpenTok archiving}
|
46
53
|
# programming guide.
|
47
|
-
# @option options [String] :resolution The resolution of the archive, either "640x480" (SD,
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
54
|
+
# @option options [String] :resolution The resolution of the archive, either "640x480" (SD landscape,
|
55
|
+
# the default), "1280x720" (HD landscape), "1920x1080" (FHD landscape), "480x640" (SD portrait), "720x1280"
|
56
|
+
# (HD portrait), or "1080x1920" (FHD portrait). This property only applies to composed archives. If you set
|
57
|
+
# this property and set the outputMode property to "individual", a call to the method
|
58
|
+
# results in an error.
|
51
59
|
# @option options [String] :streamMode (Optional) Whether streams included in the archive are selected
|
52
60
|
# automatically ("auto", the default) or manually ("manual"). When streams are selected automatically ("auto"),
|
53
61
|
# all streams in the session can be included in the archive. When streams are selected manually ("manual"),
|
54
62
|
# you specify streams to be included based on calls to the {Archives#add_stream} method. You can specify whether a
|
55
|
-
# stream's audio, video, or both are included in the archive.
|
63
|
+
# stream's audio, video, or both are included in the archive.
|
56
64
|
# In composed archives, in both automatic and manual modes, the archive composer includes streams based
|
57
65
|
# on {https://tokbox.com/developer/guides/archive-broadcast-layout/#stream-prioritization-rules stream prioritization rules}.
|
58
66
|
# Important: this feature is currently available in the Standard environment only.
|
data/lib/opentok/broadcast.rb
CHANGED
@@ -20,7 +20,10 @@ module OpenTok
|
|
20
20
|
# For this start method, this timestamp matches the createdAt timestamp.
|
21
21
|
#
|
22
22
|
# @attr [string] resolution
|
23
|
-
# The resolution of the broadcast: either "640x480" (SD, the default)
|
23
|
+
# The resolution of the broadcast: either "640x480" (SD landscape, the default), "1280x720" (HD landscape),
|
24
|
+
# "1920x1080" (FHD landscape), "480x640" (SD portrait), "720x1280" (HD portrait), or "1080x1920" (FHD portrait).
|
25
|
+
# You may want to use a portrait aspect ratio for broadcasts that include video streams from mobile devices (which often use the portrait aspect ratio).
|
26
|
+
# This property is optional.
|
24
27
|
#
|
25
28
|
# @attr [string] streamMode
|
26
29
|
# Whether streams included in the broadcast are selected automatically ("auto", the default) or manually ("manual").
|
@@ -43,12 +46,13 @@ module OpenTok
|
|
43
46
|
# * "offline" -- The OpenTok platform could not connect to the remote RTMP server. This is due to an unreachable server or an error in the RTMP handshake. Causes include rejected RTMP connections, non-existing RTMP applications, rejected stream names, authentication errors, etc. Check that the server is online, and that you have provided the correct server URL and stream name.
|
44
47
|
# * "error" -- There is an error in the OpenTok platform.
|
45
48
|
class Broadcast
|
46
|
-
|
49
|
+
attr_reader :multi_broadcast_tag
|
47
50
|
# @private
|
48
51
|
def initialize(interface, json)
|
49
52
|
@interface = interface
|
50
53
|
# TODO: validate json fits schema
|
51
54
|
@json = json
|
55
|
+
@multi_broadcast_tag = @json['multiBroadcastTag']
|
52
56
|
end
|
53
57
|
|
54
58
|
# A JSON-encoded string representation of the broadcast.
|
data/lib/opentok/broadcasts.rb
CHANGED
@@ -37,6 +37,12 @@ module OpenTok
|
|
37
37
|
# If you do not specify an initial layout type, the broadcast uses the best fit
|
38
38
|
# layout type.
|
39
39
|
#
|
40
|
+
# @option options [String] :multiBroadcastTag (Optional) Set this to support multiple broadcasts for the same session simultaneously.
|
41
|
+
# Set this to a unique string for each simultaneous broadcast of an ongoing session. Note that the `multiBroadcastTag` value is *not* included
|
42
|
+
# in the response for the methods to {https://tokbox.com/developer/rest/#list_broadcasts list live streaming broadcasts} and
|
43
|
+
# {https://tokbox.com/developer/rest/#get_info_broadcast get information about a live streaming broadcast}.
|
44
|
+
# {https://tokbox.com/developer/guides/broadcast/live-streaming#simultaneous-broadcasts See Simultaneous broadcasts}.
|
45
|
+
#
|
40
46
|
# @option options [int] maxDuration
|
41
47
|
# The maximum duration for the broadcast, in seconds. The broadcast will automatically stop when
|
42
48
|
# the maximum duration is reached. You can set the maximum duration to a value from 60 (60 seconds) to 36000 (10 hours).
|
@@ -75,7 +81,9 @@ module OpenTok
|
|
75
81
|
# Broadcasts#find method.
|
76
82
|
#
|
77
83
|
# @option options [string] resolution
|
78
|
-
# The resolution of the broadcast: either "640x480" (SD, the default)
|
84
|
+
# The resolution of the broadcast: either "640x480" (SD landscape, the default), "1280x720" (HD landscape),
|
85
|
+
# "1920x1080" (FHD landscape), "480x640" (SD portrait), "720x1280" (HD portrait), or "1080x1920"
|
86
|
+
# (FHD portrait).
|
79
87
|
#
|
80
88
|
# @option options [String] :streamMode (Optional) Whether streams included in the broadcast are selected
|
81
89
|
# automatically ("auto", the default) or manually ("manual"). When streams are selected automatically ("auto"),
|
data/lib/opentok/client.rb
CHANGED
@@ -554,5 +554,95 @@ module OpenTok
|
|
554
554
|
raise OpenTokError, "Failed to connect to OpenTok. Response code: #{e.message}"
|
555
555
|
end
|
556
556
|
|
557
|
+
def start_render(session_id, opts)
|
558
|
+
opts.extend(HashExtensions)
|
559
|
+
body = { :sessionId => session_id }.merge(opts.camelize_keys!)
|
560
|
+
response = self.class.post("/v2/project/#{@api_key}/render", {
|
561
|
+
:body => body.to_json,
|
562
|
+
:headers => generate_headers("Content-Type" => "application/json")
|
563
|
+
})
|
564
|
+
case response.code
|
565
|
+
when 202
|
566
|
+
response
|
567
|
+
when 400
|
568
|
+
raise OpenTokRenderError, "The render could not be started. The request was invalid."
|
569
|
+
when 403
|
570
|
+
raise OpenTokAuthenticationError, "Authentication failed while starting a render. API Key: #{@api_key}"
|
571
|
+
when 500
|
572
|
+
raise OpenTokError, "OpenTok server error."
|
573
|
+
else
|
574
|
+
raise OpenTokRenderError, "The render could not be started"
|
575
|
+
end
|
576
|
+
rescue StandardError => e
|
577
|
+
raise OpenTokError, "Failed to connect to OpenTok. Response code: #{e.message}"
|
578
|
+
end
|
579
|
+
|
580
|
+
def get_render(render_id)
|
581
|
+
response = self.class.get("/v2/project/#{@api_key}/render/#{render_id}", {
|
582
|
+
:headers => generate_headers
|
583
|
+
})
|
584
|
+
case response.code
|
585
|
+
when 200
|
586
|
+
response
|
587
|
+
when 400
|
588
|
+
raise OpenTokRenderError, "The request was invalid."
|
589
|
+
when 403
|
590
|
+
raise OpenTokAuthenticationError, "Authentication failed while getting a render. API Key: #{@api_key}"
|
591
|
+
when 404
|
592
|
+
raise OpenTokRenderError, "No matching render found (with the specified ID)"
|
593
|
+
when 500
|
594
|
+
raise OpenTokError, "OpenTok server error."
|
595
|
+
else
|
596
|
+
raise OpenTokRenderError, "Could not fetch render information."
|
597
|
+
end
|
598
|
+
rescue StandardError => e
|
599
|
+
raise OpenTokError, "Failed to connect to OpenTok. Response code: #{e.message}"
|
600
|
+
end
|
601
|
+
|
602
|
+
def stop_render(render_id)
|
603
|
+
response = self.class.delete("/v2/project/#{@api_key}/render/#{render_id}", {
|
604
|
+
:headers => generate_headers
|
605
|
+
})
|
606
|
+
case response.code
|
607
|
+
when 204
|
608
|
+
response
|
609
|
+
when 400
|
610
|
+
raise OpenTokRenderError, "The request was invalid."
|
611
|
+
when 403
|
612
|
+
raise OpenTokAuthenticationError, "Authentication failed while stopping a render. API Key: #{@api_key}"
|
613
|
+
when 404
|
614
|
+
raise OpenTokRenderError, "No matching render found (with the specified ID) or it is already stopped"
|
615
|
+
when 500
|
616
|
+
raise OpenTokError, "OpenTok server error."
|
617
|
+
else
|
618
|
+
raise OpenTokRenderError, "The render could not be stopped."
|
619
|
+
end
|
620
|
+
rescue StandardError => e
|
621
|
+
raise OpenTokError, "Failed to connect to OpenTok. Response code: #{e.message}"
|
622
|
+
end
|
623
|
+
|
624
|
+
def list_renders(offset, count)
|
625
|
+
query = Hash.new
|
626
|
+
query[:offset] = offset unless offset.nil?
|
627
|
+
query[:count] = count unless count.nil?
|
628
|
+
response = self.class.get("/v2/project/#{@api_key}/render", {
|
629
|
+
:query => query.empty? ? nil : query,
|
630
|
+
:headers => generate_headers,
|
631
|
+
})
|
632
|
+
case response.code
|
633
|
+
when 200
|
634
|
+
response
|
635
|
+
when 403
|
636
|
+
raise OpenTokAuthenticationError,
|
637
|
+
"Authentication failed while retrieving renders. API Key: #{@api_key}"
|
638
|
+
when 500
|
639
|
+
raise OpenTokError, "OpenTok server error."
|
640
|
+
else
|
641
|
+
raise OpenTokRenderError, "The renders could not be retrieved."
|
642
|
+
end
|
643
|
+
rescue StandardError => e
|
644
|
+
raise OpenTokError, "Failed to connect to OpenTok. Response code: #{e.message}"
|
645
|
+
end
|
646
|
+
|
557
647
|
end
|
558
648
|
end
|
data/lib/opentok/exceptions.rb
CHANGED
@@ -14,5 +14,7 @@ module OpenTok
|
|
14
14
|
class OpenTokStreamLayoutError < OpenTokError; end
|
15
15
|
# Defines errors raised when you perform Broadcast operations.
|
16
16
|
class OpenTokBroadcastError < OpenTokError; end
|
17
|
-
|
17
|
+
# Defines errors raised when you perform Experience Composer render operations.
|
18
|
+
class OpenTokRenderError < OpenTokError; end
|
19
|
+
|
18
20
|
end
|
data/lib/opentok/opentok.rb
CHANGED
@@ -192,6 +192,11 @@ module OpenTok
|
|
192
192
|
@broadcasts ||= Broadcasts.new client
|
193
193
|
end
|
194
194
|
|
195
|
+
# A Renders object, which lets you work with OpenTok Experience Composer renders.
|
196
|
+
def renders
|
197
|
+
@renders ||= Renders.new client
|
198
|
+
end
|
199
|
+
|
195
200
|
# A Sip object, which lets you use the OpenTok SIP gateway.
|
196
201
|
def sip
|
197
202
|
@sip ||= Sip.new client
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require "active_support/inflector"
|
2
|
+
|
3
|
+
module OpenTok
|
4
|
+
# Represents an Experience Composer render of an OpenTok session.
|
5
|
+
# See {https://tokbox.com/developer/guides/experience-composer/ Experience Composer}.
|
6
|
+
#
|
7
|
+
# @attr [string] id
|
8
|
+
# The unique ID for the Experience Composer.
|
9
|
+
#
|
10
|
+
# @attr [string] session_id
|
11
|
+
# The session ID of the OpenTok session associated with this render.
|
12
|
+
#
|
13
|
+
# @attr [string] project_id
|
14
|
+
# The API key associated with the render.
|
15
|
+
#
|
16
|
+
# @attr [int] created_at
|
17
|
+
# The time the Experience Composer started, expressed in milliseconds since the Unix epoch.
|
18
|
+
#
|
19
|
+
# @attr [int] updated_at
|
20
|
+
# The UNIX timestamp when the Experience Composer status was last updated.
|
21
|
+
#
|
22
|
+
# @attr [string] url
|
23
|
+
# A publicly reachable URL controlled by the customer and capable of generating the content to be rendered without user intervention.
|
24
|
+
#
|
25
|
+
# @attr [string] resolution
|
26
|
+
# The resolution of the Experience Composer (either "640x480", "480x640", "1280x720", "720x1280", "1920x1080", or "1080x1920").
|
27
|
+
#
|
28
|
+
# @attr [string] status
|
29
|
+
# The status of the Experience Composer. Poll frequently to check status updates. This property set to one of the following:
|
30
|
+
# - "starting" — The Vonage Video API platform is in the process of connecting to the remote application at the URL provided. This is the initial state.
|
31
|
+
# - "started" — The Vonage Video API platform has successfully connected to the remote application server, and is publishing the web view to an OpenTok stream.
|
32
|
+
# - "stopped" — The Experience Composer has stopped.
|
33
|
+
# - "failed" — An error occurred and the Experience Composer could not proceed. It may occur at startup if the OpenTok server cannot connect to the remote
|
34
|
+
# application server or republish the stream. It may also occur at any point during the process due to an error in the Vonage Video API platform.
|
35
|
+
#
|
36
|
+
# @attr [string] reason
|
37
|
+
# The reason field is only available when the status is either "stopped" or "failed". If the status is stopped, the reason field will contain either
|
38
|
+
# "Max Duration Exceeded" or "Stop Requested." If the status is failed, the reason will contain a more specific error message.
|
39
|
+
#
|
40
|
+
# @attr [string] streamId
|
41
|
+
# The ID of the composed stream being published. The streamId is not available when the status is "starting" and may not be available when the status is "failed".
|
42
|
+
class Render
|
43
|
+
|
44
|
+
# @private
|
45
|
+
def initialize(interface, json)
|
46
|
+
@interface = interface
|
47
|
+
# TODO: validate json fits schema
|
48
|
+
@json = json
|
49
|
+
end
|
50
|
+
|
51
|
+
# A JSON-encoded string representation of the Experience Composer render.
|
52
|
+
def to_json
|
53
|
+
@json.to_json
|
54
|
+
end
|
55
|
+
|
56
|
+
# Stops the OpenTok Experience Composer render.
|
57
|
+
def stop
|
58
|
+
# TODO: validate returned json fits schema
|
59
|
+
@json = @interface.stop @json['id']
|
60
|
+
end
|
61
|
+
|
62
|
+
# Gets info about the OpenTok Experience Composer render.
|
63
|
+
def info
|
64
|
+
# TODO: validate returned json fits schema
|
65
|
+
@json = @interface.find @json['id']
|
66
|
+
end
|
67
|
+
|
68
|
+
# @private ignore
|
69
|
+
def method_missing(method, *args, &block)
|
70
|
+
camelized_method = method.to_s.camelize(:lower)
|
71
|
+
if @json.has_key? camelized_method and args.empty?
|
72
|
+
@json[camelized_method]
|
73
|
+
else
|
74
|
+
super method, *args, &block
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "opentok/render"
|
2
|
+
|
3
|
+
module OpenTok
|
4
|
+
# A class for accessing an array of Experience Composer Render objects.
|
5
|
+
class RenderList < Array
|
6
|
+
# The total number of Experience Composer renders.
|
7
|
+
attr_reader :total
|
8
|
+
|
9
|
+
def initialize(interface, json)
|
10
|
+
@total = json["count"]
|
11
|
+
super json["items"].map { |item| ::OpenTok::Render.new interface, item }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|