opentok 3.0.3 → 4.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/metrics.yml +17 -0
  3. data/.travis.yml +3 -1
  4. data/CODE_OF_CONDUCT.md +128 -0
  5. data/README.md +312 -28
  6. data/lib/opentok/archive.rb +45 -4
  7. data/lib/opentok/archives.rb +73 -5
  8. data/lib/opentok/broadcast.rb +118 -0
  9. data/lib/opentok/broadcasts.rb +149 -0
  10. data/lib/opentok/client.rb +212 -7
  11. data/lib/opentok/connections.rb +28 -0
  12. data/lib/opentok/constants.rb +1 -1
  13. data/lib/opentok/exceptions.rb +6 -0
  14. data/lib/opentok/opentok.rb +44 -10
  15. data/lib/opentok/session.rb +5 -0
  16. data/lib/opentok/signals.rb +47 -0
  17. data/lib/opentok/sip.rb +33 -0
  18. data/lib/opentok/stream.rb +46 -0
  19. data/lib/opentok/stream_list.rb +18 -0
  20. data/lib/opentok/streams.rb +79 -0
  21. data/lib/opentok/version.rb +1 -1
  22. data/opentok.gemspec +9 -8
  23. data/sample/Broadcast/Gemfile +4 -0
  24. data/sample/Broadcast/README.md +201 -0
  25. data/sample/Broadcast/broadcast_sample.rb +97 -0
  26. data/sample/Broadcast/public/css/sample.css +64 -0
  27. data/sample/Broadcast/public/js/host.js +185 -0
  28. data/sample/Broadcast/public/js/participant.js +85 -0
  29. data/sample/Broadcast/views/host.erb +82 -0
  30. data/sample/Broadcast/views/index.erb +32 -0
  31. data/sample/Broadcast/views/layout.erb +29 -0
  32. data/sample/Broadcast/views/participant.erb +27 -0
  33. data/sample/HelloWorld/public/js/helloworld.js +4 -10
  34. data/sample/HelloWorld/views/index.erb +1 -3
  35. data/spec/cassettes/OpenTok_Archives/calls_layout_on_archive_object.yml +47 -0
  36. data/spec/cassettes/OpenTok_Archives/changes_the_layout_of_an_archive.yml +38 -0
  37. data/spec/cassettes/OpenTok_Archives/http_client_errors/.yml +34 -0
  38. data/spec/cassettes/OpenTok_Archives/should_create_archives.yml +3 -1
  39. data/spec/cassettes/OpenTok_Archives/should_create_audio_only_archives.yml +3 -1
  40. data/spec/cassettes/OpenTok_Archives/should_create_custom_layout_archives.yml +50 -0
  41. data/spec/cassettes/OpenTok_Archives/should_create_hd_archives.yml +54 -0
  42. data/spec/cassettes/OpenTok_Archives/should_create_individual_archives.yml +3 -1
  43. data/spec/cassettes/OpenTok_Archives/should_create_named_archives.yml +3 -1
  44. data/spec/cassettes/OpenTok_Archives/should_delete_an_archive_by_id.yml +3 -1
  45. data/spec/cassettes/OpenTok_Archives/should_find_archives_by_id.yml +3 -1
  46. data/spec/cassettes/OpenTok_Archives/should_find_archives_with_unknown_properties.yml +3 -1
  47. data/spec/cassettes/OpenTok_Archives/should_find_expired_archives.yml +3 -1
  48. data/spec/cassettes/OpenTok_Archives/should_find_paused_archives_by_id.yml +3 -1
  49. data/spec/cassettes/OpenTok_Archives/should_stop_archives.yml +3 -1
  50. data/spec/cassettes/OpenTok_Archives/when_many_archives_are_created/should_return_all_archives.yml +3 -1
  51. data/spec/cassettes/OpenTok_Archives/when_many_archives_are_created/should_return_archives_with_an_offset.yml +3 -1
  52. data/spec/cassettes/OpenTok_Archives/when_many_archives_are_created/should_return_count_number_of_archives.yml +3 -1
  53. data/spec/cassettes/OpenTok_Archives/when_many_archives_are_created/should_return_part_of_the_archives_when_using_offset_and_count.yml +3 -1
  54. data/spec/cassettes/OpenTok_Archives/when_many_archives_are_created/should_return_session_archives.yml +3 -1
  55. data/spec/cassettes/OpenTok_Broadcasts/calls_layout_on_broadcast_object.yml +57 -0
  56. data/spec/cassettes/OpenTok_Broadcasts/changes_the_layout_of_a_broadcast.yml +38 -0
  57. data/spec/cassettes/OpenTok_Broadcasts/fetches_a_hls_broadcast_url.yml +52 -0
  58. data/spec/cassettes/OpenTok_Broadcasts/finds_a_broadcast.yml +57 -0
  59. data/spec/cassettes/OpenTok_Broadcasts/starts_a_rtmp_broadcast.yml +61 -0
  60. data/spec/cassettes/OpenTok_Broadcasts/stops_a_broadcast.yml +47 -0
  61. data/spec/cassettes/OpenTok_Connections/forces_a_connection_to_be_terminated.yml +38 -0
  62. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_always_archived_sessions.yml +3 -1
  63. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_default_sessions.yml +3 -1
  64. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_relayed_media_sessions.yml +3 -1
  65. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_relayed_media_sessions_for_invalid_media_modes.yml +3 -1
  66. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_relayed_media_sessions_with_a_location_hint.yml +3 -1
  67. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_routed_media_sessions.yml +3 -1
  68. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_routed_media_sessions_with_a_location_hint.yml +3 -1
  69. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_sessions_with_a_location_hint.yml +3 -1
  70. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/with_an_addendum_to_the_user_agent_string/should_append_the_addendum_to_the_user_agent_header.yml +3 -1
  71. data/spec/cassettes/OpenTok_Signals/receives_a_valid_response_for_a_connection.yml +39 -0
  72. data/spec/cassettes/OpenTok_Signals/receives_a_valid_response_for_all_connections.yml +39 -0
  73. data/spec/cassettes/OpenTok_Sip/receives_a_valid_response.yml +3 -1
  74. data/spec/cassettes/OpenTok_Streams/get_all_streams_information.yml +55 -0
  75. data/spec/cassettes/OpenTok_Streams/get_specific_stream_information.yml +44 -0
  76. data/spec/cassettes/OpenTok_Streams/layout_working_on_two_stream_list.yml +38 -0
  77. data/spec/opentok/archives_spec.rb +84 -1
  78. data/spec/opentok/broadcasts_spec.rb +171 -0
  79. data/spec/opentok/client_spec.rb +51 -0
  80. data/spec/opentok/connection_spec.rb +38 -0
  81. data/spec/opentok/opentok_spec.rb +21 -0
  82. data/spec/opentok/signal_spec.rb +50 -0
  83. data/spec/opentok/streams_spec.rb +75 -0
  84. data/spec/spec_helper.rb +2 -0
  85. metadata +84 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 679a364a592829ee29acad18146e680f82d2a3de
4
- data.tar.gz: 1d822425e30d6aa05e41768348fd9863b85677a4
2
+ SHA256:
3
+ metadata.gz: 55309730e5aa9927756e9003fb5745c497e3956e5fab4810a280cfcab77614fa
4
+ data.tar.gz: ed3f6dcf6577b28f762503c7d271a485d03cdf27862a358a809951d09f9747b1
5
5
  SHA512:
6
- metadata.gz: 0e0fdf3a74c811f22c535c1829eb9109ce7f8e2c45ab711796ee97a5891658aa2ab3d5625f9ddf953ddcbb27241ddb339261fec7d5321145ed012469cc896a1f
7
- data.tar.gz: '0741182e612a82221688abda4226a5138e1051a47ad5d0f8a3e59005461935a2af711ba338721d37d2a42954e4113f43733ec2cbfca0c0a0ee77d83222701319'
6
+ metadata.gz: cfecdaf4cd7eeef31be4e6fb9e2b146007c1c9305051483400d4764508066dc62f45cd74a31a4c604b50cfb79aac48310821e7bd88956513a83bdaf07a107f89
7
+ data.tar.gz: ab5b745259d82e5c79b8ad25c794e0dafe66eb3d5205909a4659bafcfa696a5160949c12841de5b87b444635e8d70517158ee73627976a33c9188d90eae37c4f
@@ -0,0 +1,17 @@
1
+ name: Aggregit
2
+
3
+ on:
4
+ schedule:
5
+ - cron: "0 0 * * *"
6
+
7
+ jobs:
8
+ recordMetrics:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: michaeljolley/aggregit@v1
12
+ with:
13
+ githubToken: ${{ secrets.GITHUB_TOKEN }}
14
+ project_id: ${{ secrets.project_id }}
15
+ private_key: ${{ secrets.private_key }}
16
+ client_email: ${{ secrets.client_email }}
17
+ firebaseDbUrl: ${{ secrets.firebaseDbUrl }}
@@ -5,11 +5,13 @@ language: ruby
5
5
  cache: bundler
6
6
  before_install: gem update bundler
7
7
  rvm:
8
- - 2.0
9
8
  - 2.1
10
9
  - 2.2
11
10
  - 2.3
12
11
  - 2.4
12
+ - 2.5
13
+ - 2.6
14
+ - 2.7
13
15
  notifications:
14
16
  slack:
15
17
  secure: agVll2R9PTPvJMcUgbvOh9eGt60zGDc8kPUwEsiQr828rCgXh/ZxD5irYDyKQg3ZsS8+f3MjFCwzU7uQALkia2pDrie9d8g8m1dt4Q5U7Qm6QecshvE0U9JwbB5Ngxaftbqyf0XEFrE7CKs7RI1BzFRpe8m+fdZgfwccX8Gb7pc=
@@ -0,0 +1,128 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ - Demonstrating empathy and kindness toward other people
21
+ - Being respectful of differing opinions, viewpoints, and experiences
22
+ - Giving and gracefully accepting constructive feedback
23
+ - Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ - Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ - The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ - Trolling, insulting or derogatory comments, and personal or political attacks
33
+ - Public or private harassment
34
+ - Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ - Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ devrel@vonage.com.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
+
121
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
+ enforcement ladder](https://github.com/mozilla/diversity).
123
+
124
+ [homepage]: https://www.contributor-covenant.org
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ https://www.contributor-covenant.org/faq. Translations are available at
128
+ https://www.contributor-covenant.org/translations.
data/README.md CHANGED
@@ -1,12 +1,18 @@
1
1
  # OpenTok Ruby SDK
2
2
 
3
- [![Build Status](https://travis-ci.org/opentok/OpenTok-Ruby-SDK.png)](https://travis-ci.org/opentok/OpenTok-Ruby-SDK)
3
+ [![Build Status](https://travis-ci.org/opentok/OpenTok-Ruby-SDK.png)](https://travis-ci.org/opentok/OpenTok-Ruby-SDK) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
4
+
5
+ <img src="https://assets.tokbox.com/img/vonage/Vonage_VideoAPI_black.svg" height="48px" alt="Tokbox is now known as Vonage" />
4
6
 
5
7
  The OpenTok Ruby SDK lets you generate
6
- [sessions](http://www.tokbox.com/opentok/tutorials/create-session/) and
7
- [tokens](http://www.tokbox.com/opentok/tutorials/create-token/) for
8
- [OpenTok](http://www.tokbox.com/) applications, and
9
- [archive](https://tokbox.com/opentok/tutorials/archiving) OpenTok sessions.
8
+ [sessions](https://tokbox.com/developer/guides/create-session/) and
9
+ [tokens](https://tokbox.com/developer/guides/create-token/) for
10
+ [OpenTok](http://www.tokbox.com/) applications. It also includes methods for
11
+ working with OpenTok [archives](https://tokbox.com/developer/guides/archiving),
12
+ working with OpenTok [live streaming
13
+ broadcasts](https://tokbox.com/developer/guides/broadcast/live-streaming/),
14
+ working with OpenTok [SIP interconnect](https://tokbox.com/developer/guides/sip),
15
+ and [disconnecting clients from sessions](https://tokbox.com/developer/guides/moderation/rest/).
10
16
 
11
17
  # Installation
12
18
 
@@ -17,7 +23,7 @@ Bundler helps manage dependencies for Ruby projects. Find more info here:
17
23
  Add this gem to your `Gemfile`:
18
24
 
19
25
  ```ruby
20
- gem "opentok", "~> 3.0.3"
26
+ gem "opentok", "~> 4.0.0"
21
27
  ```
22
28
 
23
29
  Allow bundler to install the change.
@@ -45,13 +51,35 @@ require "opentok"
45
51
  opentok = OpenTok::OpenTok.new api_key, api_secret
46
52
  ```
47
53
 
54
+ ### Initialization Options
55
+
56
+ You can specify a custom timeout value for HTTP requests when initializing a new `OpenTok::OpenTok`
57
+ object:
58
+
59
+ ```ruby
60
+ require "opentok"
61
+
62
+ opentok = OpenTok::OpenTok.new api_key, api_secret, :timeout_length => 10
63
+ ```
64
+
65
+ The value for `:timeout_length` is an integer representing the number of seconds to wait for an HTTP
66
+ request to complete. The default is set to 2 seconds.
67
+
48
68
  ## Creating Sessions
49
69
 
50
- To create an OpenTok Session, use the `OpenTok#create_session(properties)` method. The
51
- `properties` parameter is an optional Hash used to specify whether you are creating a session that
52
- uses the OpenTok Media Server and specifying a location hint. The `session_id` method of the
53
- returned `OpenTok::Session` instance is useful to get a sessionId that can be saved to a persistent
54
- store (e.g. database).
70
+ To create an OpenTok Session, use the `OpenTok#create_session(properties)` method.
71
+ The `properties` parameter is an optional Hash used to specify the following:
72
+
73
+ - Whether the session uses the [OpenTok Media
74
+ Router](https://tokbox.com/developer/guides/create-session/#media-mode),
75
+ which is required for some OpenTok features (such as archiving)
76
+
77
+ - A location hint for the OpenTok server.
78
+
79
+ - Whether the session is automatically archived.
80
+
81
+ The `session_id` method of the returned `OpenTok::Session` instance is useful to
82
+ get a sessionId that can be saved to a persistent store (such as a database).
55
83
 
56
84
  ```ruby
57
85
  # Create a session that will attempt to transmit streams directly between clients.
@@ -96,10 +124,38 @@ token = session.generate_token({
96
124
  });
97
125
  ```
98
126
 
127
+ ## Working with Streams
128
+
129
+ Use this method to get information for an OpenTok stream or for all streams in a session.
130
+ For example, you can call this method to get information about layout classes used by an
131
+ OpenTok stream.
132
+
133
+ To get information of a specific stream in a session, call
134
+ `opentok.streams.find(session_id, stream_id)`. The return object is a `Stream` object and
135
+ you can access various stream properties as shown in the following example (using RSpec notations):
136
+
137
+ ```ruby
138
+ expect(stream).to be_an_instance_of OpenTok::Stream
139
+ expect(stream.videoType).to eq 'camera'
140
+ expect(stream.layoutClassList.count).to eq 1
141
+ expect(stream.layoutClassList.first).to eq "full"
142
+ ```
143
+
144
+ To get information on all streams in a session, call `opentok.streams.all(session_id)`.
145
+ The return value is a `StreamList` object:
146
+
147
+ ```ruby
148
+ expect(all_streams).to be_an_instance_of OpenTok::StreamList
149
+ expect(all_streams.total).to eq 2
150
+ expect(all_streams[0].layoutClassList[1]).to eq "focus"
151
+ ```
152
+
99
153
  ## Working with Archives
100
154
 
101
- You can start the recording of an OpenTok Session using the `opentok.archives.create(session_id,
102
- options)` method. This will return an `OpenTok::Archive` instance. The parameter `options` is an
155
+ You can only archive sessions that use the OpenTok Media Router
156
+ (sessions with the media mode set to routed).
157
+
158
+ You can start the recording of an OpenTok Session using the `opentok.archives.create(session_id, options)` method. This will return an `OpenTok::Archive` instance. The parameter `options` is an
103
159
  optional Hash used to set the `has_audio`, `has_video`, and `name` options. Note that you can
104
160
  only start an Archive on a Session that has clients connected.
105
161
 
@@ -127,6 +183,43 @@ archive = opentok.archives.create session_id :output_mode => :individual
127
183
  The `:output_mode => :composed` setting (the default) causes all streams in the archive to be
128
184
  recorded to a single (composed) file.
129
185
 
186
+ For composed archives you can set the resolution of the archive, either "640x480" (SD, the default)
187
+ or "1280x720" (HD). The `resolution` parameter is optional and could be included in the options
188
+ hash (second argument) of the `opentok.archives.create()` method.
189
+
190
+ ```ruby
191
+ opts = {
192
+ :output_mode => :composed,
193
+ :resolution => "1280x720"
194
+ }
195
+
196
+ archive = opentok.archives.create session_id, opts
197
+ ```
198
+
199
+ To customize the initial layout of composed archives, you can use the `:layout` option.
200
+ Set this to a hash containing two keys: `:type` and `:stylesheet`. Valid values for
201
+ `:type` are "bestFit" (best fit), "custom" (custom), "horizontalPresentation"
202
+ (horizontal presentation), "pip" (picture-in-picture), and "verticalPresentation"
203
+ (vertical presentation)). If you specify a "custom" layout type, set the `:stylesheet`
204
+ key to the stylesheet (CSS). (For other layout types, do not set the `:stylesheet` key.)
205
+
206
+ ```ruby
207
+ opts = {
208
+ :output_mode => :composed,
209
+ :resolution => "1280x720",
210
+ :layout => {
211
+ :type => "custom",
212
+ :stylesheet => "stream:last-child{display: block;margin: 0;top: 0;left: 0;width: 1px;height: 1px;}stream:first-child{display: block;margin: 0;top: 0;left: 0;width: 100%;height: 100%;}"
213
+ }
214
+ }
215
+
216
+ archive = opentok.archives.create session_id, opts
217
+ ```
218
+
219
+ If you do not specify an initial layout type, the archive uses the best fit
220
+ layout type. For more information, see [Customizing the video layout for composed
221
+ archives](https://tokbox.com/developer/guides/archiving/layout-control.html).
222
+
130
223
  You can stop the recording of a started Archive using the `opentok.archives.stop_by_id(archive_id)`
131
224
  method. You can also do this using the `Archive#stop()` method.
132
225
 
@@ -175,14 +268,197 @@ Note that you can also create an automatically archived session, by passing in `
175
268
  as the `:archive_mode` property of the `options` parameter passed into the
176
269
  `OpenTok#create_session()` method (see "Creating Sessions," above).
177
270
 
271
+ You can set the [layout](https://tokbox.com/developer/rest/#change_composed_archive_layout) of an archive:
272
+
273
+ ```ruby
274
+ opts = { :type => "verticalPresentation" }
275
+ opentok.archives.layout(archive_id, opts)
276
+ ```
277
+
278
+ The hash `opts` has two entries:
279
+
280
+ - The `type` is the layout type for the archive. Valid values are "bestFit" (best fit)
281
+ "custom" (custom), "horizontalPresentation" (horizontal presentation),
282
+ "pip" (picture-in-picture), and "verticalPresentation" (vertical presentation)).
283
+
284
+ - If you specify a "custom" layout type, set the `stylesheet` property.
285
+ (For other layout types, do not set the stylesheet property.)
286
+
287
+ See [Customizing the video layout for composed archives](https://tokbox.com/developer/guides/archiving/layout-control.html)
288
+ for more details.
289
+
290
+ You can set the initial layout class for a client's streams by setting the layout option when you
291
+ create the token for the client, using the `opentok.generate_token` method. And you can also change
292
+ the layout classes of a stream as follows:
293
+
294
+ ```ruby
295
+ streams_list = {
296
+ :items => [
297
+ {
298
+ :id => "8b732909-0a06-46a2-8ea8-074e64d43422",
299
+ :layoutClassList => ["full"]
300
+ },
301
+ {
302
+ :id => "8b732909-0a06-46a2-8ea8-074e64d43423",
303
+ :layoutClassList => ["full", "focus"]
304
+ }
305
+ ]
306
+ }
307
+ response = opentok.streams.layout(session_id, streams_list)
308
+ ```
309
+
310
+ For more information on setting stream layout classes, see the
311
+ [Changing the composed archive layout classes for an OpenTok
312
+ stream](https://tokbox.com/developer/rest/#change-stream-layout-classes-composed).
313
+
314
+ Please keep in mind that the `streams.layout` method applies to archive and broadcast streams only.
315
+
178
316
  For more information on archiving, see the
179
317
  [OpenTok archiving](https://tokbox.com/opentok/tutorials/archiving/) programming guide.
180
318
 
319
+ ## Signaling
181
320
 
182
- ## Initiating a SIP call
321
+ You can send a signal using the `opentok.signals.send(session_id, connection_id, opts)` method.
322
+ If `connection_id` is nil or an empty string, then the signal is send to all valid connections in
323
+ the session.
183
324
 
184
- You can initiate a SIP call using the `opentok.sip.dial(session_id, token, sip_uri, opts)` method. This requires a SIP url. You will often need to pass options for authenticating to the SIP provider and specifying encrypted session establishment.
325
+ An example of `opts` field can be as follows:
185
326
 
327
+ ```ruby
328
+ opts = { :type => "chat",
329
+ :data => "Hello"
330
+ }
331
+ ```
332
+
333
+ The maximum length of the `type` string is 128 bytes, and it must contain only letters
334
+ (A-Z and a-z), numbers (0-9), '-', '\_', and '~'.
335
+
336
+ The `data` string must not exceed the maximum size (8 kB).
337
+
338
+ The `connection_id` and `opts` parameter are jointly optional by default. Hence you can also
339
+ use `opentok.signals.send(session_id)`
340
+
341
+ For more information on signaling, see the
342
+ [OpenTok Signaling](https://tokbox.com/developer/guides/signaling/js/) programming guide.
343
+
344
+ ## Broadcasting
345
+
346
+ You can broadcast your streams to a HLS or RTMP servers.
347
+
348
+ To successfully start broadcasting a session, at least one publishing client must be connected to
349
+ the session.
350
+
351
+ You can only have one active live streaming broadcast at a time for a session (however, having more
352
+ than one would not be useful).
353
+
354
+ The live streaming broadcast can target one HLS endpoint and up to five RTMP servers simultaneously
355
+ for a session.
356
+
357
+ You can only start live streaming for sessions that use the OpenTok Media Router (with the
358
+ media mode set to routed). You cannot use live streaming with sessions that have the media mode set
359
+ to relayed.
360
+
361
+ To create a HLS only broadcast:
362
+
363
+ ```ruby
364
+ opts = {
365
+ :outputs => {
366
+ :hls => {}
367
+ }
368
+ }
369
+ broadcast = opentok.broadcasts.create(session_id, opts)
370
+
371
+ # HLS + RTMP
372
+ opts = {
373
+ :outputs => {
374
+ :hls => {},
375
+ :rtmp => [
376
+ {
377
+ :id => "myOpentokStream",
378
+ :serverUrl => "rtmp://x.rtmp.youtube.com/live123",
379
+ :streamName => "66c9-jwuh-pquf-9x00"
380
+ }
381
+ ]
382
+ }
383
+ }
384
+ broadcast = opentok.broadcasts.create(session_id, opts)
385
+ ```
386
+
387
+ The returned Broadcast object has information about the broadcast, like id, sessionId , projectId,
388
+ createdAt, updatedAt, resolution, status, and a Hash of broadcastUrls. The broadcastUrls
389
+ consists of an HLS URL and an array of RTMP objects. The RTMP objects resembles the `rtmp` value
390
+ in `opts` in the example above.
391
+
392
+ For more information on broadcast, see the
393
+ [OpenTok Broadcast guide](https://tokbox.com/developer/rest/#start_broadcast) programming guide.
394
+
395
+ To get information about a broadcast stream
396
+
397
+ ```ruby
398
+ my_broadcast = opentok.broadcasts.find broadcast_id
399
+ ```
400
+
401
+ The Broadcast object returned has properties describing the broadcast, like id, sessionId,
402
+ projectId, createdAt, updatedAt, resolution, status, and a Hash of broadcastUrls. The broadcastUrls
403
+ consists of an HLS URL and an array of RTMP objects. The RTMP objects resembles the `rtmp` value
404
+ in `opts` in the example above.
405
+
406
+ To stop a broadcast:
407
+
408
+ ```ruby
409
+ my_broadcast = opentok.broadcasts.stop broadcast_id
410
+
411
+ # stop at a broadcast object level too
412
+ #
413
+ my_broadcast = opentok.broadcasts.find broadcast_id
414
+ ret_broadcast = my_broadcast.stop
415
+
416
+ # Both the above returned objects has the "broadcastUrls" property as a nil value and the status
417
+ # property value is "stopped"
418
+ ```
419
+
420
+ To change the layout of a broadcast dynamically
421
+
422
+ ```ruby
423
+ opentok.broadcasts.layout(started_broadcast_id, {
424
+ :type => "verticalPresentation"
425
+ })
426
+
427
+ # On an object level
428
+ my_broadcast = opentok.broadcasts.find broadcast_id
429
+ my_broadcast.layout(
430
+ :type => 'pip',
431
+ )
432
+
433
+ # the returned value is true if successful
434
+ ```
435
+
436
+ The hash above has two entries.
437
+
438
+ - The `type` is the layout type for the archive. Valid values are "bestFit" (best fit),
439
+ "custom" (custom), "horizontalPresentation" (horizontal presentation),
440
+ "pip" (picture-in-picture), and "verticalPresentation" (vertical presentation).
441
+
442
+ - If you specify a "custom" layout type, set the `stylesheet` property. (For other layout types,
443
+ do not set the stylesheet property.)
444
+
445
+ Refer to [Customizing the video layout for composed
446
+ archives](https://tokbox.com/developer/guides/archiving/layout-control.html)
447
+ for more details.
448
+
449
+ You can also change the layout of an individual stream dynamically. Refer to
450
+ [working with Streams](#working-with-streams).
451
+
452
+ ## Force disconnect
453
+
454
+ You can cause a client to be forced to disconnect from a session by using the
455
+ `opentok.connections.forceDisconnect(session_id, connection_id)` method.
456
+
457
+ ## Initiating a SIP call
458
+
459
+ You can initiate a SIP call using the `opentok.sip.dial(session_id, token, sip_uri, opts)` method.
460
+ This requires a SIP URL. You will often need to pass options for authenticating to the SIP provider
461
+ and specifying encrypted session establishment.
186
462
 
187
463
  ```ruby
188
464
  opts = { "auth" => { "username" => sip_username,
@@ -193,16 +469,16 @@ response = opentok.sip.dial(session_id, token, "sip:+15128675309@acme.pstn.examp
193
469
  ```
194
470
 
195
471
  For more information on SIP Interconnect, see the
196
- [OpenTok SIP Interconnect](https://tokbox.com/developer/guides/sip/) programming guide.
197
-
472
+ [OpenTok SIP Interconnect](https://tokbox.com/developer/guides/sip/) developer guide.
198
473
 
199
474
  # Samples
200
475
 
201
- There are two sample applications included in this repository. To get going as fast as possible, clone the whole
202
- repository and follow the Walkthroughs:
476
+ There are three sample applications included in this repository. To get going as fast as possible, clone the whole
477
+ repository and read the README in each of the sample directories:
203
478
 
204
- * [HelloWorld](sample/HelloWorld/README.md)
205
- * [Archiving](sample/Archiving/README.md)
479
+ - [HelloWorld](sample/HelloWorld/README.md)
480
+ - [Archiving](sample/Archiving/README.md)
481
+ - [Broadcast](sample/Broadcast/README.md)
206
482
 
207
483
  # Documentation
208
484
 
@@ -210,9 +486,10 @@ Reference documentation is available at
210
486
 
211
487
  # Requirements
212
488
 
213
- You need an OpenTok API key and API secret, which you can obtain at <https://dashboard.tokbox.com>.
489
+ You need an OpenTok API key and API secret, which you can obtain by logging into your
490
+ [TokBox account](https://tokbox.com/account).
214
491
 
215
- The OpenTok Ruby SDK requires Ruby 1.9.3 or greater.
492
+ The OpenTok Ruby SDK requires Ruby 2.1.0 or greater.
216
493
 
217
494
  # Release Notes
218
495
 
@@ -221,6 +498,12 @@ about each release.
221
498
 
222
499
  ## Important changes since v2.2.0
223
500
 
501
+ **Changes in v4.0.0:**
502
+
503
+ The SDK adds support for Ruby v2.7 and now requires Ruby v2.1.0 or higher.
504
+ For Ruby v2.0.0 please continue to use the OpenTok Ruby SDK v3.0.0.
505
+ For Ruby v1.9.3 please continue to use the OpenTok Ruby SDK v2.5.0.
506
+
224
507
  **Changes in v3.0.0:**
225
508
 
226
509
  The SDK now now requires Ruby v2.0.0 or higher. For Ruby v1.9.3 please continue to use the
@@ -245,15 +528,16 @@ See the reference documentation
245
528
  <http://www.tokbox.com/opentok/libraries/server/ruby/reference/index.html> and in the
246
529
  docs directory of the SDK.
247
530
 
248
-
249
531
  # Development and Contributing
250
532
 
251
533
  Interested in contributing? We :heart: pull requests! See the [Development](DEVELOPING.md) and
252
534
  [Contribution](CONTRIBUTING.md) guidelines.
253
535
 
254
- # Support
536
+ ## Getting Help
255
537
 
256
- See <https://support.tokbox.com> for all our support options.
538
+ We love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either:
257
539
 
258
- Find a bug? File it on the [Issues](https://github.com/opentok/opentok-ruby-sdk/issues) page. Hint:
259
- test cases are really helpful!
540
+ - Open an issue on this repository
541
+ - See <https://support.tokbox.com/> for support options
542
+ - Tweet at us! We're [@VonageDev on Twitter](https://twitter.com/VonageDev)
543
+ - Or [join the Vonage Developer Community Slack](https://developer.nexmo.com/community/slack)