opentok 4.3.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 +11 -0
- data/README.md +60 -38
- data/lib/opentok/archive.rb +5 -2
- data/lib/opentok/archives.rb +15 -8
- data/lib/opentok/broadcast.rb +6 -2
- data/lib/opentok/broadcasts.rb +50 -9
- data/lib/opentok/client.rb +90 -0
- data/lib/opentok/exceptions.rb +3 -1
- data/lib/opentok/opentok.rb +10 -5
- 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 +8 -10
- 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 +54 -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,14 @@
|
|
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
|
+
|
8
|
+
# 4.4.0
|
9
|
+
|
10
|
+
* Implements DVR Pause/Resume and HLS Low-Latency options for Broadcasts [#243](https://github.com/opentok/OpenTok-Ruby-SDK/pull/243)
|
11
|
+
|
1
12
|
# 4.3.0
|
2
13
|
|
3
14
|
* Fixes an issue with `activesupport` [#238](https://github.com/opentok/OpenTok-Ruby-SDK/pull/238)
|
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,23 +39,30 @@ 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
|
-
# you specify streams to be included based on calls to
|
55
|
-
#
|
56
|
-
# stream's audio, video, or both are included in the archive.
|
62
|
+
# you specify streams to be included based on calls to the {Archives#add_stream} method. You can specify whether a
|
63
|
+
# stream's audio, video, or both are included in the archive.
|
57
64
|
# In composed archives, in both automatic and manual modes, the archive composer includes streams based
|
58
|
-
# on
|
65
|
+
# on {https://tokbox.com/developer/guides/archive-broadcast-layout/#stream-prioritization-rules stream prioritization rules}.
|
59
66
|
# Important: this feature is currently available in the Standard environment only.
|
60
67
|
# @option options [Hash] :layout Specify this to assign the initial layout type for
|
61
68
|
# the archive. This applies only to composed archives. This is a hash containing three keys:
|
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,32 +37,62 @@ 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).
|
43
49
|
# The default maximum duration is 4 hours (14,400 seconds).
|
44
50
|
#
|
45
|
-
# @option options [Hash] outputs
|
51
|
+
# @option options [Hash] outputs (Required)
|
46
52
|
# This object defines the types of broadcast streams you want to start (both HLS and RTMP).
|
47
53
|
# You can include HLS, RTMP, or both as broadcast streams. If you include RTMP streaming,
|
48
54
|
# you can specify up to five target RTMP streams (or just one).
|
49
|
-
#
|
50
|
-
#
|
51
|
-
# For each RTMP , specify (<code>:serverUrl</code>) for the RTMP server URL,
|
55
|
+
#
|
56
|
+
# For multiple RTMP streams, the (<code>:rtmp</code>) property is set to an [Array] of Rtmp [Hash] objects.
|
57
|
+
# For each RTMP hash, specify (<code>:serverUrl</code>) for the RTMP server URL,
|
52
58
|
# (<code>:streamName</code>) such as the YouTube Live stream name or the Facebook stream key),
|
53
|
-
# and (optionally) (<code>:id</code>), a unique ID for the stream.
|
59
|
+
# and (optionally) (<code>:id</code>), a unique ID for the stream. If you specify an ID, it will be
|
60
|
+
# included in the (<code>broadcast_json</code>) response from the Client#start_broadcast method call,
|
61
|
+
# and is also available in the (<code>broadcast_json</code>) response from the Broadcasts#find method.
|
62
|
+
# Vonage streams the session to each RTMP URL you specify. Note that OpenTok live streaming
|
63
|
+
# supports RTMP and RTMPS.
|
64
|
+
# If you need to support only one RTMP URL, you can set a Rtmp [Hash] object (instead of an array of
|
65
|
+
# objects) for the (<code>:rtmp</code>) property value in the (<code>:outputs</code>) [Hash].
|
66
|
+
#
|
67
|
+
# For HLS, the (<code>:hls</code>) property in the (<code>:outputs</code>) [Hash] is set to a HLS [Hash]
|
68
|
+
# object. This object includes the following optional properties:
|
69
|
+
# - (<code>:dvr</code>) (Boolean). Whether to enable
|
70
|
+
# {https://tokbox.com/developer/guides/broadcast/live-streaming/#dvr DVR functionality}
|
71
|
+
# (rewinding, pausing, and resuming)
|
72
|
+
# in players that support it (true), or not (false, the default). With DVR enabled, the HLS URL will
|
73
|
+
# include a ?DVR query string appended to the end.
|
74
|
+
# - (<code>:low_latency</code>) (Boolean). Whether to enable
|
75
|
+
# {https://tokbox.com/developer/guides/broadcast/live-streaming/#low-latency low-latency mode}
|
76
|
+
# for the HLSstream.
|
77
|
+
# Some HLS players do not support low-latency mode. This feature is incompatible with DVR mode HLS
|
78
|
+
# broadcasts (both can't be set to true). This is a beta feature.
|
79
|
+
# The HLS URL is included in the (<code>broadcast_json</code>) response from the Client#start_broadcast
|
80
|
+
# method call, and is also available in the (<code>broadcast_json</code>) response from the
|
81
|
+
# Broadcasts#find method.
|
54
82
|
#
|
55
83
|
# @option options [string] resolution
|
56
|
-
# 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).
|
57
87
|
#
|
58
88
|
# @option options [String] :streamMode (Optional) Whether streams included in the broadcast are selected
|
59
89
|
# automatically ("auto", the default) or manually ("manual"). When streams are selected automatically ("auto"),
|
60
90
|
# all streams in the session can be included in the broadcast. When streams are selected manually ("manual"),
|
61
|
-
# you specify streams to be included based on calls to
|
62
|
-
# {
|
91
|
+
# you specify streams to be included based on calls to the
|
92
|
+
# {Broadcasts#add_stream} method. You can specify whether a
|
63
93
|
# stream's audio, video, or both are included in the broadcast.
|
64
94
|
# For both automatic and manual modes, the broadcast composer includes streams based
|
65
|
-
# on
|
95
|
+
# on {https://tokbox.com/developer/guides/archive-broadcast-layout/#stream-prioritization-rules stream prioritization rules}.
|
66
96
|
# Important: this feature is currently available in the Standard environment only.
|
67
97
|
#
|
68
98
|
# @return [Broadcast] The broadcast object, which includes properties defining the broadcast,
|
@@ -75,6 +105,13 @@ module OpenTok
|
|
75
105
|
def create(session_id, options = {})
|
76
106
|
raise ArgumentError, "session_id not provided" if session_id.to_s.empty?
|
77
107
|
raise ArgumentError, "options cannot be empty" if options.empty?
|
108
|
+
raise ArgumentError, "outputs property is required in options" unless options.has_key?(:outputs)
|
109
|
+
raise ArgumentError, "outputs must be a Hash" unless options[:outputs].is_a? Hash
|
110
|
+
if options[:outputs].has_key?(:hls)
|
111
|
+
dvr = options[:outputs][:hls][:dvr]
|
112
|
+
low_latency = options[:outputs][:hls][:low_latency]
|
113
|
+
raise ArgumentError, "dvr and low_latency can't both be true for HLS" if hls_dvr_and_low_latency_options_both_true?(dvr, low_latency)
|
114
|
+
end
|
78
115
|
broadcast_json = @client.start_broadcast(session_id, options)
|
79
116
|
Broadcast.new self, broadcast_json
|
80
117
|
end
|
@@ -263,5 +300,9 @@ module OpenTok
|
|
263
300
|
has_audio == false && has_video == false
|
264
301
|
end
|
265
302
|
|
303
|
+
def hls_dvr_and_low_latency_options_both_true?(dvr, low_latency)
|
304
|
+
dvr == true && low_latency == true
|
305
|
+
end
|
306
|
+
|
266
307
|
end
|
267
308
|
end
|
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
@@ -42,9 +42,9 @@ module OpenTok
|
|
42
42
|
# streams, and signal. (This is the default value if you do not specify a role.)
|
43
43
|
#
|
44
44
|
# * <code>:moderator</code> -- In addition to the privileges granted to a
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
45
|
+
# publisher, a moderator can perform moderation functions, such as forcing clients
|
46
|
+
# to disconnect, to stop publishing streams, or to mute audio in published streams. See the
|
47
|
+
# {https://tokbox.com/developer/guides/moderation/ Moderation developer guide}.
|
48
48
|
# @option options [integer] :expire_time The expiration time, in seconds since the UNIX epoch.
|
49
49
|
# Pass in 0 to use the default expiration time of 24 hours after the token creation time.
|
50
50
|
# The maximum expiration time is 30 days after the creation time.
|
@@ -77,8 +77,8 @@ module OpenTok
|
|
77
77
|
# @param [String] api_key The OpenTok API key for your
|
78
78
|
# {https://tokbox.com/account OpenTok project}.
|
79
79
|
# @param [String] api_secret Your OpenTok API key.
|
80
|
-
# @option opts [Symbol] :api_url Do not set this parameter. It is for internal use by
|
81
|
-
# @option opts [Symbol] :ua_addendum Do not set this parameter. It is for internal use by
|
80
|
+
# @option opts [Symbol] :api_url Do not set this parameter. It is for internal use by Vonage.
|
81
|
+
# @option opts [Symbol] :ua_addendum Do not set this parameter. It is for internal use by Vonage.
|
82
82
|
# @option opts [Symbol] :timeout_length Custom timeout in seconds. If not provided, defaults to 2 seconds.
|
83
83
|
def initialize(api_key, api_secret, opts={})
|
84
84
|
@api_key = api_key.to_s()
|
@@ -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
|