opentok 4.2.0 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +3 -3
- data/CHANGES.md +153 -0
- data/lib/opentok/archive.rb +49 -2
- data/lib/opentok/archives.rb +89 -4
- data/lib/opentok/broadcast.rb +44 -1
- data/lib/opentok/broadcast_list.rb +14 -0
- data/lib/opentok/broadcasts.rb +109 -6
- data/lib/opentok/client.rb +161 -0
- data/lib/opentok/connections.rb +1 -1
- data/lib/opentok/constants.rb +1 -0
- data/lib/opentok/opentok.rb +7 -7
- data/lib/opentok/sip.rb +40 -2
- data/lib/opentok/streams.rb +50 -1
- data/lib/opentok/token_generator.rb +1 -0
- data/lib/opentok/version.rb +1 -1
- data/opentok.gemspec +1 -1
- data/sample/Broadcast/README.md +42 -0
- data/sample/Broadcast/broadcast_sample.rb +15 -0
- data/sample/Broadcast/views/all.erb +46 -0
- data/sample/Broadcast/views/index.erb +16 -1
- data/spec/cassettes/OpenTok_Archives/adds_a_stream_to_an_archive.yml +37 -0
- data/spec/cassettes/OpenTok_Archives/removes_a_stream_from_an_archive.yml +37 -0
- data/spec/cassettes/OpenTok_Broadcasts/adds_a_stream_to_a_broadcast.yml +37 -0
- data/spec/cassettes/OpenTok_Broadcasts/for_many_broadcasts/should_return_all_broadcasts.yml +192 -0
- data/spec/cassettes/OpenTok_Broadcasts/for_many_broadcasts/should_return_broadcasts_with_an_offset.yml +117 -0
- data/spec/cassettes/OpenTok_Broadcasts/for_many_broadcasts/should_return_count_number_of_broadcasts.yml +92 -0
- data/spec/cassettes/OpenTok_Broadcasts/for_many_broadcasts/should_return_part_of_the_broadcasts_when_using_offset_and_count.yml +142 -0
- data/spec/cassettes/OpenTok_Broadcasts/for_many_broadcasts/should_return_session_broadcasts.yml +117 -0
- data/spec/cassettes/OpenTok_Broadcasts/removes_a_stream_from_a_broadcast.yml +37 -0
- data/spec/cassettes/OpenTok_Sip/_play_dtmf_to_connection/returns_a_200_response_code_when_passed_a_valid_dtmf_digit_string.yml +39 -0
- data/spec/cassettes/OpenTok_Sip/_play_dtmf_to_session/returns_a_200_response_code_when_passed_a_valid_dtmf_digit_string.yml +39 -0
- data/spec/cassettes/OpenTok_Sip/receives_a_valid_response.yml +2 -2
- data/spec/cassettes/OpenTok_Streams/disables_the_mute_state_of_a_session.yml +37 -0
- data/spec/cassettes/OpenTok_Streams/forces_all_current_and_future_streams_in_a_session_to_be_muted.yml +39 -0
- data/spec/cassettes/OpenTok_Streams/forces_all_current_and_future_streams_in_a_session_to_be_muted_except_specified_excluded_streams.yml +39 -0
- data/spec/cassettes/OpenTok_Streams/forces_the_specified_stream_to_be_muted.yml +39 -0
- data/spec/opentok/archives_spec.rb +11 -0
- data/spec/opentok/broadcasts_spec.rb +50 -3
- data/spec/opentok/connection_spec.rb +1 -1
- data/spec/opentok/sip_spec.rb +32 -1
- data/spec/opentok/streams_spec.rb +21 -1
- metadata +38 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f62fb97355256f1598610039ab4a80a186ddd61f3dda8b2d39f191e3c0b7341
|
4
|
+
data.tar.gz: 7bd988f8c398a851c955a04f9e450009c3617819cda0204976b45fd76a6cdc36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a19392b392cbdef32902fbe563313a49af146b19c7409865bf3820d81c6df4b0fd6b11e3d949f891a2565f45ac81a3b45c0e073eac2e29e58e5390826df2c38e
|
7
|
+
data.tar.gz: ca1c2d809b6488f9f3580a6eb857009e5d154f397d63541d713f96f7086f7383e1686a493929fbe4b7ddd3b6f2f9badd23ea539ddd3d2dd89a70ccde1af51a68
|
data/.github/workflows/ci.yml
CHANGED
@@ -2,9 +2,9 @@ name: CI
|
|
2
2
|
|
3
3
|
on:
|
4
4
|
push:
|
5
|
-
branches: [
|
5
|
+
branches: [ main, dev, beta ]
|
6
6
|
pull_request:
|
7
|
-
branches: [
|
7
|
+
branches: [ main, dev, beta ]
|
8
8
|
|
9
9
|
jobs:
|
10
10
|
test:
|
@@ -27,4 +27,4 @@ jobs:
|
|
27
27
|
- name: Run tests
|
28
28
|
run: bundle exec rake spec
|
29
29
|
env:
|
30
|
-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
30
|
+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
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/lib/opentok/archive.rb
CHANGED
@@ -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]
|
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)
|
data/lib/opentok/archives.rb
CHANGED
@@ -48,10 +48,19 @@ 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
61
|
# the archive. This applies only to composed archives. This is a hash containing three keys:
|
53
|
-
# <code>:type</code>, <code>:stylesheet<code> and <code>:screenshare_type</code>.
|
54
|
-
# Valid values for <code>:type</code> are "bestFit" (best fit), "custom" (custom),
|
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),
|
55
64
|
# "horizontalPresentation" (horizontal presentation),
|
56
65
|
# "pip" (picture-in-picture), and "verticalPresentation" (vertical presentation)).
|
57
66
|
# If you specify a "custom" layout type, set the <code>:stylesheet</code> key to the
|
@@ -171,10 +180,10 @@ module OpenTok
|
|
171
180
|
# {https://tokbox.com/developer/guides/archiving/layout-control.html Customizing
|
172
181
|
# the video layout for composed archives}.
|
173
182
|
#
|
174
|
-
# @param [String] archive_id
|
183
|
+
# @param [String] archive_id
|
175
184
|
# The archive ID.
|
176
185
|
#
|
177
|
-
# @option options [String] :type
|
186
|
+
# @option options [String] :type
|
178
187
|
# The layout type. Set this to "bestFit", "pip", "verticalPresentation",
|
179
188
|
# "horizontalPresentation", "focus", or "custom".
|
180
189
|
#
|
@@ -226,5 +235,81 @@ module OpenTok
|
|
226
235
|
response = @client.layout_archive(archive_id, options)
|
227
236
|
(200..300).include? response.code
|
228
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
|
+
|
229
314
|
end
|
230
315
|
end
|
data/lib/opentok/broadcast.rb
CHANGED
@@ -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
|
data/lib/opentok/broadcasts.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "opentok/client"
|
2
2
|
require "opentok/broadcast"
|
3
|
-
|
3
|
+
require "opentok/broadcast_list"
|
4
4
|
|
5
5
|
module OpenTok
|
6
6
|
# A class for working with OpenTok live streaming broadcasts.
|
@@ -25,8 +25,8 @@ module OpenTok
|
|
25
25
|
#
|
26
26
|
# @option options [Hash] :layout Specify this to assign the initial layout type for
|
27
27
|
# the broadcast. This is a hash containing three keys:
|
28
|
-
# <code>:type</code>, <code>:stylesheet<code> and <code>:screenshare_type</code>.
|
29
|
-
# Valid values for <code>:type</code> are "bestFit" (best fit), "custom" (custom),
|
28
|
+
# <code>:type</code>, <code>:stylesheet<code> and <code>:screenshare_type</code>.
|
29
|
+
# Valid values for <code>:type</code> are "bestFit" (best fit), "custom" (custom),
|
30
30
|
# "horizontalPresentation" (horizontal presentation),
|
31
31
|
# "pip" (picture-in-picture), and "verticalPresentation" (vertical presentation)).
|
32
32
|
# If you specify a "custom" layout type, set the <code>:stylesheet</code> key to the
|
@@ -40,7 +40,7 @@ module OpenTok
|
|
40
40
|
# @option options [int] maxDuration
|
41
41
|
# The maximum duration for the broadcast, in seconds. The broadcast will automatically stop when
|
42
42
|
# the maximum duration is reached. You can set the maximum duration to a value from 60 (60 seconds) to 36000 (10 hours).
|
43
|
-
# The default maximum duration is
|
43
|
+
# The default maximum duration is 4 hours (14,400 seconds).
|
44
44
|
#
|
45
45
|
# @option options [Hash] outputs
|
46
46
|
# This object defines the types of broadcast streams you want to start (both HLS and RTMP).
|
@@ -55,11 +55,21 @@ module OpenTok
|
|
55
55
|
# @option options [string] resolution
|
56
56
|
# The resolution of the broadcast: either "640x480" (SD, the default) or "1280x720" (HD).
|
57
57
|
#
|
58
|
+
# @option options [String] :streamMode (Optional) Whether streams included in the broadcast are selected
|
59
|
+
# automatically ("auto", the default) or manually ("manual"). When streams are selected automatically ("auto"),
|
60
|
+
# 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 this REST method
|
62
|
+
# { https://tokbox.com/developer/rest/#selecting-broadcast-streams }. You can specify whether a
|
63
|
+
# stream's audio, video, or both are included in the broadcast.
|
64
|
+
# For both automatic and manual modes, the broadcast composer includes streams based
|
65
|
+
# on stream prioritization rules { https://tokbox.com/developer/guides/archive-broadcast-layout/#stream-prioritization-rules }.
|
66
|
+
# Important: this feature is currently available in the Standard environment only.
|
67
|
+
#
|
58
68
|
# @return [Broadcast] The broadcast object, which includes properties defining the broadcast,
|
59
69
|
# including the broadcast ID.
|
60
70
|
#
|
61
71
|
# @raise [OpenTokBroadcastError] The broadcast could not be started. The request was invalid or broadcast already started
|
62
|
-
# @raise [OpenTokAuthenticationError] Authentication failed while starting an
|
72
|
+
# @raise [OpenTokAuthenticationError] Authentication failed while starting an broadcast.
|
63
73
|
# Invalid API key.
|
64
74
|
# @raise [OpenTokError] OpenTok server error.
|
65
75
|
def create(session_id, options = {})
|
@@ -85,6 +95,25 @@ module OpenTok
|
|
85
95
|
Broadcast.new self, broadcast_json
|
86
96
|
end
|
87
97
|
|
98
|
+
# Returns a BroadcastList, which is an array of broadcasts that are completed and in-progress,
|
99
|
+
# for your API key.
|
100
|
+
#
|
101
|
+
# @param [Hash] options A hash with keys defining which range of broadcasts to retrieve.
|
102
|
+
# @option options [integer] :offset Optional. The index offset of the first broadcast. 0 is offset
|
103
|
+
# of the most recently started broadcast. 1 is the offset of the broadcast that started prior to
|
104
|
+
# the most recent broadcast. If you do not specify an offset, 0 is used.
|
105
|
+
# @option options [integer] :count Optional. The number of broadcasts to be returned. The maximum
|
106
|
+
# number of broadcasts returned is 1000.
|
107
|
+
# @option options [String] :session_id Optional. The session ID that broadcasts belong to.
|
108
|
+
# https://tokbox.com/developer/rest/#list_broadcasts
|
109
|
+
#
|
110
|
+
# @return [BroadcastList] An BroadcastList object, which is an array of Broadcast objects.
|
111
|
+
def all(options = {})
|
112
|
+
raise ArgumentError, "Limit is invalid" unless options[:count].nil? || (0..1000).include?(options[:count])
|
113
|
+
|
114
|
+
broadcast_list_json = @client.list_broadcasts(options[:offset], options[:count], options[:sessionId])
|
115
|
+
BroadcastList.new self, broadcast_list_json
|
116
|
+
end
|
88
117
|
|
89
118
|
# Stops an OpenTok broadcast
|
90
119
|
#
|
@@ -111,7 +140,7 @@ module OpenTok
|
|
111
140
|
# @param [String] broadcast_id
|
112
141
|
# The broadcast ID.
|
113
142
|
#
|
114
|
-
# @option options [String] :type
|
143
|
+
# @option options [String] :type
|
115
144
|
# The layout type. Set this to "bestFit", "pip", "verticalPresentation",
|
116
145
|
# "horizontalPresentation", "focus", or "custom".
|
117
146
|
#
|
@@ -159,6 +188,80 @@ module OpenTok
|
|
159
188
|
(200..300).include? response.code
|
160
189
|
end
|
161
190
|
|
191
|
+
# Adds a stream to currently running broadcast that was started with the
|
192
|
+
# streamMode set to "manual". For a description of the feature, see
|
193
|
+
# {https://tokbox.com/developer/rest/#selecting-broadcast-streams}.
|
194
|
+
#
|
195
|
+
# @param [String] broadcast_id
|
196
|
+
# The broadcast ID.
|
197
|
+
#
|
198
|
+
# @param [String] stream_id
|
199
|
+
# The ID for the stream to be added to the broadcast
|
200
|
+
#
|
201
|
+
# @option opts [true, false] :has_audio
|
202
|
+
# (Boolean, optional) — Whether the broadcast should include the stream's
|
203
|
+
# audio (true, the default) or not (false).
|
204
|
+
#
|
205
|
+
# @option opts [true, false] :has_video
|
206
|
+
# (Boolean, optional) — Whether the broadcast should include the stream's
|
207
|
+
# video (true, the default) or not (false).
|
208
|
+
#
|
209
|
+
# You can call the method repeatedly with add_stream set to the same stream ID, to
|
210
|
+
# toggle the stream's audio or video in the broadcast. If you set both has_audio and
|
211
|
+
# has_video to false, you will get error response.
|
212
|
+
#
|
213
|
+
# @raise [ArgumentError]
|
214
|
+
# The broadcast_id parameter is empty.
|
215
|
+
#
|
216
|
+
# @raise [ArgumentError]
|
217
|
+
# The stream_id parameter is empty.
|
218
|
+
#
|
219
|
+
# @raise [ArgumentError]
|
220
|
+
# The has_audio and has_video properties of the options parameter are both set to "false"
|
221
|
+
#
|
222
|
+
def add_stream(broadcast_id, stream_id, options)
|
223
|
+
raise ArgumentError, "broadcast_id not provided" if broadcast_id.to_s.empty?
|
224
|
+
raise ArgumentError, "stream_id not provided" if stream_id.to_s.empty?
|
225
|
+
if options.has_key?(:has_audio) && options.has_key?(:has_video)
|
226
|
+
has_audio = options[:has_audio]
|
227
|
+
has_video = options[:has_video]
|
228
|
+
raise ArgumentError, "has_audio and has_video can't both be false" if audio_and_video_options_both_false?(has_audio, has_video)
|
229
|
+
end
|
230
|
+
options['add_stream'] = stream_id
|
231
|
+
|
232
|
+
@client.select_streams_for_broadcast(broadcast_id, options)
|
233
|
+
end
|
234
|
+
|
235
|
+
# Removes a stream from a currently running broadcast that was started with the
|
236
|
+
# streamMode set to "manual". For a description of the feature, see
|
237
|
+
# {https://tokbox.com/developer/rest/#selecting-broadcast-streams}.
|
238
|
+
#
|
239
|
+
# @param [String] broadcast_id
|
240
|
+
# The broadcast ID.
|
241
|
+
#
|
242
|
+
# @param [String] stream_id
|
243
|
+
# The ID for the stream to be removed from the broadcast
|
244
|
+
#
|
245
|
+
# @raise [ArgumentError]
|
246
|
+
# The broadcast_id parameter id is empty.
|
247
|
+
#
|
248
|
+
# @raise [ArgumentError]
|
249
|
+
# The stream_id parameter is empty.
|
250
|
+
#
|
251
|
+
def remove_stream(broadcast_id, stream_id)
|
252
|
+
raise ArgumentError, "broadcast_id not provided" if broadcast_id.to_s.empty?
|
253
|
+
raise ArgumentError, "stream_id not provided" if stream_id.to_s.empty?
|
254
|
+
options = {}
|
255
|
+
options['remove_stream'] = stream_id
|
256
|
+
|
257
|
+
@client.select_streams_for_broadcast(broadcast_id, options)
|
258
|
+
end
|
259
|
+
|
260
|
+
private
|
261
|
+
|
262
|
+
def audio_and_video_options_both_false?(has_audio, has_video)
|
263
|
+
has_audio == false && has_video == false
|
264
|
+
end
|
162
265
|
|
163
266
|
end
|
164
267
|
end
|