opentok 4.1.0 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +30 -0
  3. data/.github/workflows/metrics.yml +17 -0
  4. data/CHANGES.md +153 -0
  5. data/README.md +3 -1
  6. data/lib/opentok/archive.rb +50 -3
  7. data/lib/opentok/archives.rb +104 -7
  8. data/lib/opentok/broadcast.rb +44 -1
  9. data/lib/opentok/broadcast_list.rb +14 -0
  10. data/lib/opentok/broadcasts.rb +131 -13
  11. data/lib/opentok/client.rb +161 -0
  12. data/lib/opentok/connections.rb +1 -1
  13. data/lib/opentok/constants.rb +1 -0
  14. data/lib/opentok/opentok.rb +8 -8
  15. data/lib/opentok/sip.rb +40 -2
  16. data/lib/opentok/streams.rb +50 -1
  17. data/lib/opentok/token_generator.rb +1 -0
  18. data/lib/opentok/version.rb +1 -1
  19. data/opentok.gemspec +1 -1
  20. data/sample/Broadcast/README.md +42 -0
  21. data/sample/Broadcast/broadcast_sample.rb +15 -0
  22. data/sample/Broadcast/views/all.erb +46 -0
  23. data/sample/Broadcast/views/index.erb +16 -1
  24. data/spec/cassettes/OpenTok_Archives/adds_a_stream_to_an_archive.yml +37 -0
  25. data/spec/cassettes/OpenTok_Archives/removes_a_stream_from_an_archive.yml +37 -0
  26. data/spec/cassettes/OpenTok_Archives/should_create_layout_archives_with_screenshare_layout_types.yml +50 -0
  27. data/spec/cassettes/OpenTok_Broadcasts/adds_a_stream_to_a_broadcast.yml +37 -0
  28. data/spec/cassettes/OpenTok_Broadcasts/for_many_broadcasts/should_return_all_broadcasts.yml +192 -0
  29. data/spec/cassettes/OpenTok_Broadcasts/for_many_broadcasts/should_return_broadcasts_with_an_offset.yml +117 -0
  30. data/spec/cassettes/OpenTok_Broadcasts/for_many_broadcasts/should_return_count_number_of_broadcasts.yml +92 -0
  31. data/spec/cassettes/OpenTok_Broadcasts/for_many_broadcasts/should_return_part_of_the_broadcasts_when_using_offset_and_count.yml +142 -0
  32. data/spec/cassettes/OpenTok_Broadcasts/for_many_broadcasts/should_return_session_broadcasts.yml +117 -0
  33. data/spec/cassettes/OpenTok_Broadcasts/removes_a_stream_from_a_broadcast.yml +37 -0
  34. data/spec/cassettes/OpenTok_Sip/_play_dtmf_to_connection/returns_a_200_response_code_when_passed_a_valid_dtmf_digit_string.yml +39 -0
  35. data/spec/cassettes/OpenTok_Sip/_play_dtmf_to_session/returns_a_200_response_code_when_passed_a_valid_dtmf_digit_string.yml +39 -0
  36. data/spec/cassettes/OpenTok_Sip/receives_a_valid_response.yml +2 -2
  37. data/spec/cassettes/OpenTok_Streams/disables_the_mute_state_of_a_session.yml +37 -0
  38. data/spec/cassettes/OpenTok_Streams/forces_all_current_and_future_streams_in_a_session_to_be_muted.yml +39 -0
  39. data/spec/cassettes/OpenTok_Streams/forces_all_current_and_future_streams_in_a_session_to_be_muted_except_specified_excluded_streams.yml +39 -0
  40. data/spec/cassettes/OpenTok_Streams/forces_the_specified_stream_to_be_muted.yml +39 -0
  41. data/spec/opentok/archives_spec.rb +40 -0
  42. data/spec/opentok/broadcasts_spec.rb +103 -1
  43. data/spec/opentok/connection_spec.rb +1 -1
  44. data/spec/opentok/opentok_spec.rb +6 -0
  45. data/spec/opentok/sip_spec.rb +32 -1
  46. data/spec/opentok/streams_spec.rb +21 -1
  47. metadata +42 -6
  48. data/.travis.yml +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 348ea4d3600d65e0e68b7078f4b694144c1eb03410ef46dccf2b27f235fd4c34
4
- data.tar.gz: 900521793c8e747b77b50a081a83328a004df84231a048f6f5b6e07a75d7bbbd
3
+ metadata.gz: 7f62fb97355256f1598610039ab4a80a186ddd61f3dda8b2d39f191e3c0b7341
4
+ data.tar.gz: 7bd988f8c398a851c955a04f9e450009c3617819cda0204976b45fd76a6cdc36
5
5
  SHA512:
6
- metadata.gz: ac9f2f38462314084442b364b63af518569bc1931ffd70300be797a295303648236c28cb910a88804b0d63cc110194ae30334c7ea1a4e25be7f0ccaa148c676a
7
- data.tar.gz: aa8d99ffc987557ed346c3e9188057aa3239d77f88da4d94f09cb39c4283447a27bc0e39da2fff007095a8268bf9b14aed623d7748371a0d3385fa329cb91a2f
6
+ metadata.gz: a19392b392cbdef32902fbe563313a49af146b19c7409865bf3820d81c6df4b0fd6b11e3d949f891a2565f45ac81a3b45c0e073eac2e29e58e5390826df2c38e
7
+ data.tar.gz: ca1c2d809b6488f9f3580a6eb857009e5d154f397d63541d713f96f7086f7383e1686a493929fbe4b7ddd3b6f2f9badd23ea539ddd3d2dd89a70ccde1af51a68
@@ -0,0 +1,30 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main, dev, beta ]
6
+ pull_request:
7
+ branches: [ main, dev, beta ]
8
+
9
+ jobs:
10
+ test:
11
+ strategy:
12
+ matrix:
13
+ os: [ubuntu-latest, windows-latest, macos-latest]
14
+ ruby: [2.5, 2.6, 2.7, 3.0]
15
+ exclude:
16
+ - os: windows-latest
17
+ ruby: 3.0
18
+ runs-on: ${{ matrix.os }}
19
+ steps:
20
+ - uses: actions/checkout@v2
21
+ - name: Set up Ruby
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ - name: Install dependencies
26
+ run: bundle install
27
+ - name: Run tests
28
+ run: bundle exec rake spec
29
+ env:
30
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
@@ -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 }}
data/CHANGES.md ADDED
@@ -0,0 +1,153 @@
1
+ # 4.3.0
2
+
3
+ * Fixes an issue with `activesupport` [#238](https://github.com/opentok/OpenTok-Ruby-SDK/pull/238)
4
+ * Adds Force Mute feature [#233](https://github.com/opentok/OpenTok-Ruby-SDK/pull/233) and [#237](https://github.com/opentok/OpenTok-Ruby-SDK/pull/237)
5
+ * Adds Listing Live Streaming Broadcasts feature [#236](https://github.com/opentok/OpenTok-Ruby-SDK/pull/236). Thanks [@ihors-livestorm](https://github.com/ihors-livestorm)!
6
+ * Adds Selective Stream feature [#235](https://github.com/opentok/OpenTok-Ruby-SDK/pull/235)
7
+ * Adds Dial DTMF feature [#234](https://github.com/opentok/OpenTok-Ruby-SDK/pull/234)
8
+ * Adds Observe Force Mute flag to `Sip#dial` method [#232](https://github.com/opentok/OpenTok-Ruby-SDK/pull/232)
9
+ * Updates dependency version (`rake`) [#231](https://github.com/opentok/OpenTok-Ruby-SDK/pull/231)
10
+ * Adds Video Outbound flag to `Sip#dial` method [#227](https://github.com/opentok/OpenTok-Ruby-SDK/pull/227)
11
+
12
+ # 4.2.0
13
+
14
+ * A new `screenshare_type` parameter has been added to the layout options for archives and broadcasts, and this release makes it available in the SDK: https://tokbox.com/developer/rest/
15
+
16
+ # 4.1.2 Release
17
+
18
+ Fixes an issue with custom broadcast layout [#218](https://github.com/opentok/OpenTok-Ruby-SDK/pull/218)
19
+
20
+ # 4.1.1
21
+
22
+ Patch release to address issue corrected in [#214](https://github.com/opentok/OpenTok-Ruby-SDK/pull/214)
23
+
24
+ # Release v4.1.0
25
+
26
+ Add a `timeout_length` custom parameter that allows for the specification in seconds to wait before timing out for HTTP requests.
27
+
28
+ # Release 4.0.1
29
+
30
+ * Addresses an issue with invocation of `Set` in rubies v2.5
31
+ * Updates cassettes for request header changes in HTTParty
32
+
33
+ # Release 4.0.0
34
+
35
+ * Update gems (thanks [@fidalgo](https://github.com/fidalgo))
36
+ * Adds Ruby 2.7 support
37
+ * Removes Ruby 2.0 support. (For Ruby v2.0.0 please continue to use the OpenTok Ruby SDK v3.0.0.)
38
+ * Add layout to archive create (thanks [@mjthompsgb](https://github.com/mjthompsgb))
39
+ * Broadcast sample (thanks [@IGitGotIt](https://github.com/IGitGotIt))
40
+
41
+ # Release v3.1.0
42
+
43
+ Adds the following APIs (Thanks @JayTokBox & [@normanargueta](https://github.com/normanargueta)):
44
+ - Force Disconnect
45
+ - Signaling
46
+ - Resolution Support
47
+ - Archive Layouts
48
+ - Broadcasting APIs
49
+ - Get & List streams
50
+
51
+ Updates and improves documentation! (Thanks [@jeffswartz](https://github.com/jeffswartz) )
52
+
53
+ # Release v3.0.3
54
+
55
+ Fixes internal logging and useragent issue
56
+
57
+ # Release v3.0.1
58
+
59
+ Upgraded dependency version ([#155](https://github.com/opentok/OpenTok-Ruby-SDK/pull/155))
60
+
61
+ # Release v3.0.0
62
+
63
+ Updating the version of httparty to 0.15. This is a breaking change because we require Ruby >= 2.0.0 now.
64
+
65
+
66
+ # Release v2.5.0
67
+
68
+ This updates includes the following change:
69
+
70
+ - [Add a dial method to initiate a SIP call](https://github.com/opentok/OpenTok-Ruby-SDK/pull/133)
71
+
72
+ Thanks @herestomwiththeweather!
73
+
74
+ # Release v2.4.1
75
+
76
+ This updates includes the following changes:
77
+
78
+ - [Support for the initial_layout_class_list feature of tokens](https://github.com/opentok/OpenTok-Ruby-SDK/pull/146)
79
+ - [Remove unnecessary info param from JS samples](https://github.com/opentok/OpenTok-Ruby-SDK/pull/147)
80
+
81
+ # Release v2.4.0
82
+
83
+ This updates includes the following changes:
84
+
85
+ - [Adds support for filtering archives by session ID](https://github.com/opentok/OpenTok-Ruby-SDK/pull/143)
86
+ - [Adds support for JWT `X-OPENTOK-AUTH` header, replacing the deprecated `X-TB-PARTNER-AUTH` header](https://github.com/opentok/OpenTok-Ruby-SDK/pull/134)
87
+ - [Updates the REST API endpoint URL to use `/project/` replacing the deprecated `/partner/`](https://github.com/opentok/OpenTok-Ruby-SDK/pull/129)
88
+
89
+ As well as:
90
+
91
+ - Updates JS code in samples to use latest API and best practices ([#140](https://github.com/opentok/OpenTok-Ruby-SDK/pull/140) and [#144](https://github.com/opentok/OpenTok-Ruby-SDK/pull/144))
92
+ - Removes generated HTML docs from this repo
93
+ - Updates documentation
94
+
95
+ # Release v2.4.0.beta.1
96
+
97
+ This update includes support for the `initial_layout_class_list` feature of tokens.
98
+
99
+ # Release v2.3.4
100
+
101
+ This update addresses an issue with loading the opentok gem in certain Rails based projects. (see: [#109](https://github.com/opentok/OpenTok-Ruby-SDK/issues/109), [#113](https://github.com/opentok/OpenTok-Ruby-SDK/pull/113). thanks [@LuckDragon82](https://github.com/LuckDragon82)!)
102
+
103
+ # Release v2.3.3
104
+
105
+ This release adds an internal option on the OpenTok initializer used to customize the User Agent string. ([#108](https://github.com/opentok/OpenTok-Ruby-SDK/pull/108))
106
+
107
+ # Release v2.3.2
108
+
109
+ This release fixes an issue where connection timeouts are too aggressive. It doubles the time allowed while also only counting the time it takes for TCP connect to finish, not the entire HTTP response to be received ([#106](https://github.com/opentok/OpenTok-Ruby-SDK/pull/106) thanks [@dramalho](https://github.com/dramalho))
110
+
111
+ # Release v2.3.0
112
+
113
+ New archiving features:
114
+ - Automatically archived sessions -- See the `:archive_mode` option of the `OpenTok#create_session()` method.
115
+ - Audio-only or video-only archives -- See the `:has_audio` and `:has_video` parameters of the `OpenTok#archives.create()` method.
116
+ - Individual archiving -- See the `:output_mode` parameter of the `OpenTok#archives.create()` method.
117
+ - Paused archives -- When no clients are publishing to a session being archived, its status changes to "paused". See `Archive#status`.
118
+
119
+ Other improvements:
120
+ - Adds default HTTP timeout for requests ([#78](https://github.com/opentok/OpenTok-Ruby-SDK/pull/78) thanks [@dramalho](https://github.com/dramalho))
121
+ - Fixes Archiving sample app ([#96](https://github.com/opentok/OpenTok-Ruby-SDK/pull/96) thanks [@matsubo](https://github.com/matsubo))
122
+
123
+ # Release v2.2.4
124
+
125
+ - Ruby 2.2.0 compatibility (thanks [@superacidjax](https://github.com/superacidjax)) [#80](https://github.com/opentok/OpenTok-Ruby-SDK/pull/80)
126
+ - Uses updated REST API for `archives.create` and `archives.stop_by_id` [#49](https://github.com/opentok/OpenTok-Ruby-SDK/issues/49) [#88](https://github.com/opentok/OpenTok-Ruby-SDK/issues/88)
127
+ - Adds `rake console` task for gem authors [#91](https://github.com/opentok/OpenTok-Ruby-SDK/pull/91)
128
+
129
+ # Release v2.2.3
130
+
131
+ This version fixes a bug related to users on Windows receiving an `OpenTokAuthenticationError` exception because of a bug in an older version of the `httparty` gem. See [#60](https://github.com/opentok/OpenTok-Ruby-SDK/issues/60)
132
+
133
+ # Release v2.2.2
134
+
135
+ The default setting for the `create_session()` method is to create a session with the media mode set
136
+ to relayed. In previous versions of the SDK, the default setting was to use the OpenTok Media Router
137
+ (media mode set to routed). In a relayed session, clients will attempt to send streams directly
138
+ between each other (peer-to-peer); if clients cannot connect due to firewall restrictions, the
139
+ session uses the OpenTok TURN server to relay audio-video streams.
140
+
141
+ # Release v2.2.0
142
+
143
+ This version of the SDK includes support for working with OpenTok 2.0 archives. (This API does not
144
+ work with OpenTok 1.0 archives.)
145
+
146
+ Note also that the `options` parameter of the `OpenTok.create_session()` method has a `media_mode`
147
+ property instead of a `p2p` property.
148
+
149
+ # v0.1.3
150
+
151
+ Fixes issues:
152
+
153
+ - [#48](https://github.com/opentok/OpenTok-Ruby-SDK/issues/48) - OpenTokException given invalid number or parameters
data/README.md CHANGED
@@ -1,6 +1,8 @@
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) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
3
+ ![Coverage Status](https://github.com/opentok/OpenTok-Ruby-SDK/workflows/CI/badge.svg)
4
+ [![codecov](https://codecov.io/gh/opentok/OpenTok-Ruby-SDK/branch/master/graph/badge.svg)](https://codecov.io/gh/opentok/opentok-ruby-sdk)
5
+ [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
4
6
 
5
7
  <img src="https://assets.tokbox.com/img/vonage/Vonage_VideoAPI_black.svg" height="48px" alt="Tokbox is now known as Vonage" />
6
8
 
@@ -7,7 +7,7 @@ module OpenTok
7
7
  # The time at which the archive was created, in milliseconds since the UNIX epoch.
8
8
  #
9
9
  # @attr [string] duration
10
- # The duration of the archive, in milliseconds.
10
+ # The duration of the archive, in seconds.
11
11
  #
12
12
  # @attr [string] id
13
13
  # The archive ID.
@@ -26,19 +26,26 @@ module OpenTok
26
26
  # Whether all streams in the archive are recorded to a single file (<code>:composed</code>)
27
27
  # or to individual files (<code>:individual</code>).
28
28
  #
29
- # @attr [string] partner_id
29
+ # @attr [string] projectId
30
30
  # The API key associated with the archive.
31
31
  #
32
32
  # @attr [string] reason
33
33
  # For archives with the status "stopped" or "failed", this string describes the
34
34
  # reason the archive stopped (such as "maximum duration exceeded") or failed.
35
35
  #
36
+ # @attr [string] resolution
37
+ # The resolution of the archive (either "640x480", "1280x720", "480x640", or "720x1280").
38
+ # This property is only set for composed archives.
39
+ #
36
40
  # @attr [string] session_id
37
41
  # The session ID of the OpenTok session associated with this archive.
38
42
  #
39
43
  # @attr [float] size
40
44
  # The size of the MP4 file. For archives that have not been generated, this value is set to 0.
41
45
  #
46
+ # @attr [string] streamMode
47
+ # Whether streams included in the archive are selected automatically ("auto", the default) or manually ("manual").
48
+ #
42
49
  # @attr [string] status
43
50
  # The status of the archive, which can be one of the following:
44
51
  #
@@ -99,7 +106,7 @@ module OpenTok
99
106
  # {https://tokbox.com/developer/guides/archiving/layout-control.html Customizing
100
107
  # the video layout for composed archives}.
101
108
  #
102
- # @option options [String] :type
109
+ # @option options [String] :type
103
110
  # The layout type. Set this to "bestFit", "pip", "verticalPresentation",
104
111
  # "horizontalPresentation", "focus", or "custom".
105
112
  #
@@ -136,6 +143,46 @@ module OpenTok
136
143
  @json = @interface.layout(@json['id'], opts)
137
144
  end
138
145
 
146
+ # Adds a stream to currently running composed archive that was started with the
147
+ # streamMode set to "manual". For a description of the feature, see
148
+ # {https://tokbox.com/developer/rest/#selecting-archive-streams}.
149
+ #
150
+ # @param [String] stream_id
151
+ # The ID for the stream to be added to the archive
152
+ #
153
+ # @option opts [true, false] :has_audio
154
+ # (Boolean, optional) — Whether the composed archive should include the stream's
155
+ # audio (true, the default) or not (false).
156
+ #
157
+ # @option opts [true, false] :has_video
158
+ # (Boolean, optional) — Whether the composed archive should include the stream's
159
+ # video (true, the default) or not (false).
160
+ #
161
+ # @raise [OpenTokArchiveError]
162
+ # The streamMode for the archive is not set to "manual".
163
+ #
164
+ # You can call the method repeatedly with add_stream set to the same stream ID, to
165
+ # toggle the stream's audio or video in the archive. If you set both has_audio and
166
+ # has_video to false, you will get error response.
167
+ def add_stream(stream_id, opts = {})
168
+ raise OpenTokArchiveError, "stream_mode must be manual in order to add a stream" unless @json['streamMode'] == 'manual'
169
+ @interface.add_stream(@json['id'], stream_id, opts)
170
+ end
171
+
172
+ # Removes a stream to currently running composed archive that was started with the
173
+ # streamMode set to "manual". For a description of the feature, see
174
+ # {https://tokbox.com/developer/rest/#selecting-archive-streams}.
175
+ #
176
+ # @param [String] stream_id
177
+ # The ID for the stream to be removed from the archive
178
+ #
179
+ # @raise [OpenTokArchiveError]
180
+ # The streamMode for the archive is not set to "manual".
181
+ def remove_stream(stream_id)
182
+ raise OpenTokArchiveError, "stream_mode must be manual in order to remove a stream" unless @json['streamMode'] == 'manual'
183
+ @interface.remove_stream(@json['id'], stream_id)
184
+ end
185
+
139
186
  # @private ignore
140
187
  def method_missing(method, *args, &block)
141
188
  camelized_method = method.to_s.camelize(:lower)
@@ -48,13 +48,26 @@ module OpenTok
48
48
  # default) or "1280x720" (HD). This property only applies to composed archives. If you set
49
49
  # this property and set the outputMode property to "individual", the call the method
50
50
  # results in an error.
51
+ # @option options [String] :streamMode (Optional) Whether streams included in the archive are selected
52
+ # automatically ("auto", the default) or manually ("manual"). When streams are selected automatically ("auto"),
53
+ # 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 this REST method
55
+ # { https://tokbox.com/developer/rest/#selecting-archive-streams }. You can specify whether a
56
+ # stream's audio, video, or both are included in the archive.
57
+ # In composed archives, in both automatic and manual modes, the archive composer includes streams based
58
+ # on stream prioritization rules { https://tokbox.com/developer/guides/archive-broadcast-layout/#stream-prioritization-rules }.
59
+ # Important: this feature is currently available in the Standard environment only.
51
60
  # @option options [Hash] :layout Specify this to assign the initial layout type for
52
- # the archive. This applies only to composed archives. This is a hash containing two keys:
53
- # <code>:type</code> and <code>:stylesheet<code>. Valid values for <code>:type</code> are
54
- # "bestFit" (best fit), "custom" (custom), "horizontalPresentation" (horizontal presentation),
61
+ # the archive. This applies only to composed archives. This is a hash containing three keys:
62
+ # <code>:type</code>, <code>:stylesheet<code> and <code>:screenshare_type</code>.
63
+ # Valid values for <code>:type</code> are "bestFit" (best fit), "custom" (custom),
64
+ # "horizontalPresentation" (horizontal presentation),
55
65
  # "pip" (picture-in-picture), and "verticalPresentation" (vertical presentation)).
56
66
  # If you specify a "custom" layout type, set the <code>:stylesheet</code> key to the
57
67
  # stylesheet (CSS). (For other layout types, do not set the <code>:stylesheet</code> key.)
68
+ # Valid values for <code>:screenshare_type</code> are "bestFit", "pip",
69
+ # "verticalPresentation", "horizontalPresentation". This property is optional.
70
+ # If it is specified, then the <code>:type</code> property **must** be set to "bestFit".
58
71
  # If you do not specify an initial layout type, the archive uses the best fit
59
72
  # layout type. For more information, see
60
73
  # {https://tokbox.com/developer/guides/archiving/layout-control.html Customizing
@@ -167,10 +180,10 @@ module OpenTok
167
180
  # {https://tokbox.com/developer/guides/archiving/layout-control.html Customizing
168
181
  # the video layout for composed archives}.
169
182
  #
170
- # @param [String] archive_id
183
+ # @param [String] archive_id
171
184
  # The archive ID.
172
185
  #
173
- # @option options [String] :type
186
+ # @option options [String] :type
174
187
  # The layout type. Set this to "bestFit", "pip", "verticalPresentation",
175
188
  # "horizontalPresentation", "focus", or "custom".
176
189
  #
@@ -178,6 +191,11 @@ module OpenTok
178
191
  # The stylesheet for a custom layout. Set this parameter
179
192
  # if you set <code>type</code> to <code>"custom"</code>. Otherwise, leave it undefined.
180
193
  #
194
+ # @option options [String] :screenshare_type
195
+ # The screenshare layout type. Set this to "bestFit", "pip", "verticalPresentation" or
196
+ # "horizonalPresentation". If this is defined, then the <code>type</code> parameter
197
+ # must be set to <code>"bestFit"</code>.
198
+ #
181
199
  # @raise [ArgumentError]
182
200
  # The archive_id or options parameter is empty. Or the "custom"
183
201
  # type was specified without a stylesheet option. Or a stylesheet was passed in for a
@@ -208,11 +226,90 @@ module OpenTok
208
226
  raise ArgumentError, "archive_id not provided" if archive_id.to_s.empty?
209
227
  type = options[:type]
210
228
  raise ArgumentError, "custom type must have a stylesheet" if (type.eql? "custom") && (!options.key? :stylesheet)
211
- valid_non_custom_type = ["bestFit","horizontalPresentation","pip", "verticalPresentation", ""].include? type
212
- raise ArgumentError, "type is not valid or stylesheet not needed" if !valid_non_custom_type
229
+ valid_non_custom_layouts = ["bestFit","horizontalPresentation","pip", "verticalPresentation", ""]
230
+ valid_non_custom_type = valid_non_custom_layouts.include? type
231
+ raise ArgumentError, "type is not valid" if !valid_non_custom_type && !(type.eql? "custom")
213
232
  raise ArgumentError, "type is not valid or stylesheet not needed" if valid_non_custom_type and options.key? :stylesheet
233
+ raise ArgumentError, "screenshare_type is not valid" if options[:screenshare_type] && !valid_non_custom_layouts.include?(options[:screenshare_type])
234
+ raise ArgumentError, "type must be set to 'bestFit' if screenshare_type is defined" if options[:screenshare_type] && type != 'bestFit'
214
235
  response = @client.layout_archive(archive_id, options)
215
236
  (200..300).include? response.code
216
237
  end
238
+
239
+ # Adds a stream to currently running composed archive that was started with the
240
+ # streamMode set to "manual". For a description of the feature, see
241
+ # {https://tokbox.com/developer/rest/#selecting-archive-streams}.
242
+ #
243
+ # @param [String] archive_id
244
+ # The archive ID.
245
+ #
246
+ # @param [String] stream_id
247
+ # The ID for the stream to be added to the archive
248
+ #
249
+ # @option opts [true, false] :has_audio
250
+ # (Boolean, optional) — Whether the composed archive should include the stream's
251
+ # audio (true, the default) or not (false).
252
+ #
253
+ # @option opts [true, false] :has_video
254
+ # (Boolean, optional) — Whether the composed archive should include the stream's
255
+ # video (true, the default) or not (false).
256
+ #
257
+ # You can call the method repeatedly with add_stream set to the same stream ID, to
258
+ # toggle the stream's audio or video in the archive. If you set both has_audio and
259
+ # has_video to false, you will get error response.
260
+ #
261
+ # @raise [ArgumentError]
262
+ # The archive_id parameter is empty.
263
+ #
264
+ # @raise [ArgumentError]
265
+ # The stream_id parameter is empty.
266
+ #
267
+ # @raise [ArgumentError]
268
+ # The has_audio and has_video properties of the options parameter are both set to "false"
269
+ #
270
+ def add_stream(archive_id, stream_id, options)
271
+ raise ArgumentError, "archive_id not provided" if archive_id.to_s.empty?
272
+ raise ArgumentError, "stream_id not provided" if stream_id.to_s.empty?
273
+ if options.has_key?(:has_audio) && options.has_key?(:has_video)
274
+ has_audio = options[:has_audio]
275
+ has_video = options[:has_video]
276
+ raise ArgumentError, "has_audio and has_video can't both be false" if audio_and_video_options_both_false?(has_audio, has_video)
277
+ end
278
+ options['add_stream'] = stream_id
279
+
280
+ @client.select_streams_for_archive(archive_id, options)
281
+ end
282
+
283
+ # Removes a stream from a currently running composed archive that was started with the
284
+ # streamMode set to "manual". For a description of the feature, see
285
+ # {https://tokbox.com/developer/rest/#selecting-archive-streams}.
286
+ #
287
+ # @param [String] archive_id
288
+ # The archive ID.
289
+ #
290
+ # @param [String] stream_id
291
+ # The ID for the stream to be removed from the archive
292
+ #
293
+ # @raise [ArgumentError]
294
+ # The archive_id parameter id is empty.
295
+ #
296
+ # @raise [ArgumentError]
297
+ # The stream_id parameter is empty.
298
+ #
299
+ def remove_stream(archive_id, stream_id)
300
+ raise ArgumentError, "archive_id not provided" if archive_id.to_s.empty?
301
+ raise ArgumentError, "stream_id not provided" if stream_id.to_s.empty?
302
+ options = {}
303
+ options['remove_stream'] = stream_id
304
+
305
+ @client.select_streams_for_archive(archive_id, options)
306
+ end
307
+
308
+ private
309
+
310
+ def audio_and_video_options_both_false?(has_audio, has_video)
311
+ has_audio == false && has_video == false
312
+ end
313
+
217
314
  end
218
315
  end
@@ -22,6 +22,9 @@ module OpenTok
22
22
  # @attr [string] resolution
23
23
  # The resolution of the broadcast: either "640x480" (SD, the default) or "1280x720" (HD). This property is optional.
24
24
  #
25
+ # @attr [string] streamMode
26
+ # Whether streams included in the broadcast are selected automatically ("auto", the default) or manually ("manual").
27
+ #
25
28
  # @attr [Hash] broadcastUrls is defined as follows:
26
29
  # This object defines the types of broadcast streams you want to start (both HLS and RTMP).
27
30
  # You can include HLS, RTMP, or both as broadcast streams. If you include RTMP streaming,
@@ -65,7 +68,7 @@ module OpenTok
65
68
  # For more information, see
66
69
  # {https://tokbox.com/developer/guides/broadcast/live-streaming/#configuring-video-layout-for-opentok-live-streaming-broadcasts Configuring video layout for OpenTok live streaming broadcasts}.
67
70
  #
68
- # @option options [String] :type
71
+ # @option options [String] :type
69
72
  # The layout type. Set this to "bestFit", "pip", "verticalPresentation",
70
73
  # "horizontalPresentation", "focus", or "custom".
71
74
  #
@@ -100,6 +103,46 @@ module OpenTok
100
103
  @json = @interface.layout(@json['id'], opts)
101
104
  end
102
105
 
106
+ # Adds a stream to currently running broadcast that was started with the
107
+ # streamMode set to "manual". For a description of the feature, see
108
+ # {https://tokbox.com/developer/rest/#selecting-broadcast-streams}.
109
+ #
110
+ # @param [String] stream_id
111
+ # The ID for the stream to be added to the broadcast
112
+ #
113
+ # @option opts [true, false] :has_audio
114
+ # (Boolean, optional) — Whether the broadcast should include the stream's
115
+ # audio (true, the default) or not (false).
116
+ #
117
+ # @option opts [true, false] :has_video
118
+ # (Boolean, optional) — Whether the broadcast should include the stream's
119
+ # video (true, the default) or not (false).
120
+ #
121
+ # @raise [OpenTokBroadcastError]
122
+ # The streamMode for the broadcast is not set to "manual".
123
+ #
124
+ # You can call the method repeatedly with add_stream set to the same stream ID, to
125
+ # toggle the stream's audio or video in the broadcast. If you set both has_audio and
126
+ # has_video to false, you will get error response.
127
+ def add_stream(stream_id, opts = {})
128
+ raise OpenTokBroadcastError, "stream_mode must be manual in order to add a stream" unless @json['streamMode'] == 'manual'
129
+ @interface.add_stream(@json['id'], stream_id, opts)
130
+ end
131
+
132
+ # Removes a stream to currently running broadcast that was started with the
133
+ # streamMode set to "manual". For a description of the feature, see
134
+ # {https://tokbox.com/developer/rest/#selecting-broadcast-streams}.
135
+ #
136
+ # @param [String] stream_id
137
+ # The ID for the stream to be removed from the broadcast
138
+ #
139
+ # @raise [OpenTokBroadcastError]
140
+ # The streamMode for the broadcast is not set to "manual".
141
+ def remove_stream(stream_id)
142
+ raise OpenTokBroadcastError, "stream_mode must be manual in order to add a stream" unless @json['streamMode'] == 'manual'
143
+ @interface.remove_stream(@json['id'], stream_id)
144
+ end
145
+
103
146
  # @private ignore
104
147
  def method_missing(method, *args, &block)
105
148
  camelized_method = method.to_s.camelize(:lower)
@@ -0,0 +1,14 @@
1
+ require "opentok/broadcast"
2
+
3
+ module OpenTok
4
+ # A class for accessing an array of Broadcast objects.
5
+ class BroadcastList < Array
6
+ # The total number of broadcasts.
7
+ attr_reader :total
8
+
9
+ def initialize(interface, json)
10
+ @total = json["count"]
11
+ super json["items"].map { |item| ::OpenTok::Broadcast.new interface, item }
12
+ end
13
+ end
14
+ end