opentok 4.1.2 → 4.4.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 +30 -0
- data/CHANGES.md +157 -0
- data/README.md +4 -2
- data/lib/opentok/archive.rb +50 -3
- data/lib/opentok/archives.rb +102 -6
- data/lib/opentok/broadcast.rb +44 -1
- data/lib/opentok/broadcast_list.rb +14 -0
- data/lib/opentok/broadcasts.rb +168 -17
- 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 +9 -9
- data/lib/opentok/sip.rb +40 -2
- data/lib/opentok/streams.rb +48 -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_Archives/should_create_layout_archives_with_screenshare_layout_types.yml +50 -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 +40 -0
- data/spec/opentok/broadcasts_spec.rb +96 -2
- 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 +41 -6
- data/.travis.yml +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6c9c87f306480694d35b2f47c92bc20b65686061fb610c3d5d1d4f9cf863b81
|
4
|
+
data.tar.gz: 6e92e0db27f27fa7468235345dc69eb52a0e694fbddfe75e0ac75d9801537f09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dc075e65d9723382a4b0b421d72326dda3268d9eaf4b1c23aea4ccb35d7b66291182dd9c38cb96b9b66f2de9212715920d39a5fa5b6e1e7d12d187818edcc2b
|
7
|
+
data.tar.gz: 5d829c2f208d314ac37f923cef98993e69307a13418ea359e5685ece36f80320949fe500fe24f499cd86eab1cbfd293c9151cd8908c11492a2e01db3eecf2609
|
@@ -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 }}
|
data/CHANGES.md
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
# 4.4.0
|
2
|
+
|
3
|
+
* Implements DVR Pause/Resume and HLS Low-Latency options for Broadcasts [#243](https://github.com/opentok/OpenTok-Ruby-SDK/pull/243)
|
4
|
+
|
5
|
+
# 4.3.0
|
6
|
+
|
7
|
+
* Fixes an issue with `activesupport` [#238](https://github.com/opentok/OpenTok-Ruby-SDK/pull/238)
|
8
|
+
* 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)
|
9
|
+
* Adds Listing Live Streaming Broadcasts feature [#236](https://github.com/opentok/OpenTok-Ruby-SDK/pull/236). Thanks [@ihors-livestorm](https://github.com/ihors-livestorm)!
|
10
|
+
* Adds Selective Stream feature [#235](https://github.com/opentok/OpenTok-Ruby-SDK/pull/235)
|
11
|
+
* Adds Dial DTMF feature [#234](https://github.com/opentok/OpenTok-Ruby-SDK/pull/234)
|
12
|
+
* Adds Observe Force Mute flag to `Sip#dial` method [#232](https://github.com/opentok/OpenTok-Ruby-SDK/pull/232)
|
13
|
+
* Updates dependency version (`rake`) [#231](https://github.com/opentok/OpenTok-Ruby-SDK/pull/231)
|
14
|
+
* Adds Video Outbound flag to `Sip#dial` method [#227](https://github.com/opentok/OpenTok-Ruby-SDK/pull/227)
|
15
|
+
|
16
|
+
# 4.2.0
|
17
|
+
|
18
|
+
* 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/
|
19
|
+
|
20
|
+
# 4.1.2 Release
|
21
|
+
|
22
|
+
Fixes an issue with custom broadcast layout [#218](https://github.com/opentok/OpenTok-Ruby-SDK/pull/218)
|
23
|
+
|
24
|
+
# 4.1.1
|
25
|
+
|
26
|
+
Patch release to address issue corrected in [#214](https://github.com/opentok/OpenTok-Ruby-SDK/pull/214)
|
27
|
+
|
28
|
+
# Release v4.1.0
|
29
|
+
|
30
|
+
Add a `timeout_length` custom parameter that allows for the specification in seconds to wait before timing out for HTTP requests.
|
31
|
+
|
32
|
+
# Release 4.0.1
|
33
|
+
|
34
|
+
* Addresses an issue with invocation of `Set` in rubies v2.5
|
35
|
+
* Updates cassettes for request header changes in HTTParty
|
36
|
+
|
37
|
+
# Release 4.0.0
|
38
|
+
|
39
|
+
* Update gems (thanks [@fidalgo](https://github.com/fidalgo))
|
40
|
+
* Adds Ruby 2.7 support
|
41
|
+
* Removes Ruby 2.0 support. (For Ruby v2.0.0 please continue to use the OpenTok Ruby SDK v3.0.0.)
|
42
|
+
* Add layout to archive create (thanks [@mjthompsgb](https://github.com/mjthompsgb))
|
43
|
+
* Broadcast sample (thanks [@IGitGotIt](https://github.com/IGitGotIt))
|
44
|
+
|
45
|
+
# Release v3.1.0
|
46
|
+
|
47
|
+
Adds the following APIs (Thanks @JayTokBox & [@normanargueta](https://github.com/normanargueta)):
|
48
|
+
- Force Disconnect
|
49
|
+
- Signaling
|
50
|
+
- Resolution Support
|
51
|
+
- Archive Layouts
|
52
|
+
- Broadcasting APIs
|
53
|
+
- Get & List streams
|
54
|
+
|
55
|
+
Updates and improves documentation! (Thanks [@jeffswartz](https://github.com/jeffswartz) )
|
56
|
+
|
57
|
+
# Release v3.0.3
|
58
|
+
|
59
|
+
Fixes internal logging and useragent issue
|
60
|
+
|
61
|
+
# Release v3.0.1
|
62
|
+
|
63
|
+
Upgraded dependency version ([#155](https://github.com/opentok/OpenTok-Ruby-SDK/pull/155))
|
64
|
+
|
65
|
+
# Release v3.0.0
|
66
|
+
|
67
|
+
Updating the version of httparty to 0.15. This is a breaking change because we require Ruby >= 2.0.0 now.
|
68
|
+
|
69
|
+
|
70
|
+
# Release v2.5.0
|
71
|
+
|
72
|
+
This updates includes the following change:
|
73
|
+
|
74
|
+
- [Add a dial method to initiate a SIP call](https://github.com/opentok/OpenTok-Ruby-SDK/pull/133)
|
75
|
+
|
76
|
+
Thanks @herestomwiththeweather!
|
77
|
+
|
78
|
+
# Release v2.4.1
|
79
|
+
|
80
|
+
This updates includes the following changes:
|
81
|
+
|
82
|
+
- [Support for the initial_layout_class_list feature of tokens](https://github.com/opentok/OpenTok-Ruby-SDK/pull/146)
|
83
|
+
- [Remove unnecessary info param from JS samples](https://github.com/opentok/OpenTok-Ruby-SDK/pull/147)
|
84
|
+
|
85
|
+
# Release v2.4.0
|
86
|
+
|
87
|
+
This updates includes the following changes:
|
88
|
+
|
89
|
+
- [Adds support for filtering archives by session ID](https://github.com/opentok/OpenTok-Ruby-SDK/pull/143)
|
90
|
+
- [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)
|
91
|
+
- [Updates the REST API endpoint URL to use `/project/` replacing the deprecated `/partner/`](https://github.com/opentok/OpenTok-Ruby-SDK/pull/129)
|
92
|
+
|
93
|
+
As well as:
|
94
|
+
|
95
|
+
- 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))
|
96
|
+
- Removes generated HTML docs from this repo
|
97
|
+
- Updates documentation
|
98
|
+
|
99
|
+
# Release v2.4.0.beta.1
|
100
|
+
|
101
|
+
This update includes support for the `initial_layout_class_list` feature of tokens.
|
102
|
+
|
103
|
+
# Release v2.3.4
|
104
|
+
|
105
|
+
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)!)
|
106
|
+
|
107
|
+
# Release v2.3.3
|
108
|
+
|
109
|
+
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))
|
110
|
+
|
111
|
+
# Release v2.3.2
|
112
|
+
|
113
|
+
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))
|
114
|
+
|
115
|
+
# Release v2.3.0
|
116
|
+
|
117
|
+
New archiving features:
|
118
|
+
- Automatically archived sessions -- See the `:archive_mode` option of the `OpenTok#create_session()` method.
|
119
|
+
- Audio-only or video-only archives -- See the `:has_audio` and `:has_video` parameters of the `OpenTok#archives.create()` method.
|
120
|
+
- Individual archiving -- See the `:output_mode` parameter of the `OpenTok#archives.create()` method.
|
121
|
+
- Paused archives -- When no clients are publishing to a session being archived, its status changes to "paused". See `Archive#status`.
|
122
|
+
|
123
|
+
Other improvements:
|
124
|
+
- Adds default HTTP timeout for requests ([#78](https://github.com/opentok/OpenTok-Ruby-SDK/pull/78) thanks [@dramalho](https://github.com/dramalho))
|
125
|
+
- Fixes Archiving sample app ([#96](https://github.com/opentok/OpenTok-Ruby-SDK/pull/96) thanks [@matsubo](https://github.com/matsubo))
|
126
|
+
|
127
|
+
# Release v2.2.4
|
128
|
+
|
129
|
+
- Ruby 2.2.0 compatibility (thanks [@superacidjax](https://github.com/superacidjax)) [#80](https://github.com/opentok/OpenTok-Ruby-SDK/pull/80)
|
130
|
+
- 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)
|
131
|
+
- Adds `rake console` task for gem authors [#91](https://github.com/opentok/OpenTok-Ruby-SDK/pull/91)
|
132
|
+
|
133
|
+
# Release v2.2.3
|
134
|
+
|
135
|
+
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)
|
136
|
+
|
137
|
+
# Release v2.2.2
|
138
|
+
|
139
|
+
The default setting for the `create_session()` method is to create a session with the media mode set
|
140
|
+
to relayed. In previous versions of the SDK, the default setting was to use the OpenTok Media Router
|
141
|
+
(media mode set to routed). In a relayed session, clients will attempt to send streams directly
|
142
|
+
between each other (peer-to-peer); if clients cannot connect due to firewall restrictions, the
|
143
|
+
session uses the OpenTok TURN server to relay audio-video streams.
|
144
|
+
|
145
|
+
# Release v2.2.0
|
146
|
+
|
147
|
+
This version of the SDK includes support for working with OpenTok 2.0 archives. (This API does not
|
148
|
+
work with OpenTok 1.0 archives.)
|
149
|
+
|
150
|
+
Note also that the `options` parameter of the `OpenTok.create_session()` method has a `media_mode`
|
151
|
+
property instead of a `p2p` property.
|
152
|
+
|
153
|
+
# v0.1.3
|
154
|
+
|
155
|
+
Fixes issues:
|
156
|
+
|
157
|
+
- [#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
|
-
|
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
|
|
@@ -487,7 +489,7 @@ Reference documentation is available at <http://www.tokbox.com//opentok/librarie
|
|
487
489
|
# Requirements
|
488
490
|
|
489
491
|
You need an OpenTok API key and API secret, which you can obtain by logging into your
|
490
|
-
[
|
492
|
+
[Vonage Video API account](https://tokbox.com/account).
|
491
493
|
|
492
494
|
The OpenTok Ruby SDK requires Ruby 2.1.0 or greater.
|
493
495
|
|
data/lib/opentok/archive.rb
CHANGED
@@ -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
|
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]
|
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,13 +48,25 @@ 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 the {Archives#add_stream} method. You can specify whether a
|
55
|
+
# stream's audio, video, or both are included in the archive.
|
56
|
+
# In composed archives, in both automatic and manual modes, the archive composer includes streams based
|
57
|
+
# on {https://tokbox.com/developer/guides/archive-broadcast-layout/#stream-prioritization-rules stream prioritization rules}.
|
58
|
+
# Important: this feature is currently available in the Standard environment only.
|
51
59
|
# @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
|
53
|
-
# <code>:type</code
|
54
|
-
# "bestFit" (best fit), "custom" (custom),
|
60
|
+
# the archive. This applies only to composed archives. This is a hash containing three keys:
|
61
|
+
# <code>:type</code>, <code>:stylesheet<code> and <code>:screenshare_type</code>.
|
62
|
+
# Valid values for <code>:type</code> are "bestFit" (best fit), "custom" (custom),
|
63
|
+
# "horizontalPresentation" (horizontal presentation),
|
55
64
|
# "pip" (picture-in-picture), and "verticalPresentation" (vertical presentation)).
|
56
65
|
# If you specify a "custom" layout type, set the <code>:stylesheet</code> key to the
|
57
66
|
# stylesheet (CSS). (For other layout types, do not set the <code>:stylesheet</code> key.)
|
67
|
+
# Valid values for <code>:screenshare_type</code> are "bestFit", "pip",
|
68
|
+
# "verticalPresentation", "horizontalPresentation". This property is optional.
|
69
|
+
# If it is specified, then the <code>:type</code> property **must** be set to "bestFit".
|
58
70
|
# If you do not specify an initial layout type, the archive uses the best fit
|
59
71
|
# layout type. For more information, see
|
60
72
|
# {https://tokbox.com/developer/guides/archiving/layout-control.html Customizing
|
@@ -167,10 +179,10 @@ module OpenTok
|
|
167
179
|
# {https://tokbox.com/developer/guides/archiving/layout-control.html Customizing
|
168
180
|
# the video layout for composed archives}.
|
169
181
|
#
|
170
|
-
# @param [String] archive_id
|
182
|
+
# @param [String] archive_id
|
171
183
|
# The archive ID.
|
172
184
|
#
|
173
|
-
# @option options [String] :type
|
185
|
+
# @option options [String] :type
|
174
186
|
# The layout type. Set this to "bestFit", "pip", "verticalPresentation",
|
175
187
|
# "horizontalPresentation", "focus", or "custom".
|
176
188
|
#
|
@@ -178,6 +190,11 @@ module OpenTok
|
|
178
190
|
# The stylesheet for a custom layout. Set this parameter
|
179
191
|
# if you set <code>type</code> to <code>"custom"</code>. Otherwise, leave it undefined.
|
180
192
|
#
|
193
|
+
# @option options [String] :screenshare_type
|
194
|
+
# The screenshare layout type. Set this to "bestFit", "pip", "verticalPresentation" or
|
195
|
+
# "horizonalPresentation". If this is defined, then the <code>type</code> parameter
|
196
|
+
# must be set to <code>"bestFit"</code>.
|
197
|
+
#
|
181
198
|
# @raise [ArgumentError]
|
182
199
|
# The archive_id or options parameter is empty. Or the "custom"
|
183
200
|
# type was specified without a stylesheet option. Or a stylesheet was passed in for a
|
@@ -208,11 +225,90 @@ module OpenTok
|
|
208
225
|
raise ArgumentError, "archive_id not provided" if archive_id.to_s.empty?
|
209
226
|
type = options[:type]
|
210
227
|
raise ArgumentError, "custom type must have a stylesheet" if (type.eql? "custom") && (!options.key? :stylesheet)
|
211
|
-
|
228
|
+
valid_non_custom_layouts = ["bestFit","horizontalPresentation","pip", "verticalPresentation", ""]
|
229
|
+
valid_non_custom_type = valid_non_custom_layouts.include? type
|
212
230
|
raise ArgumentError, "type is not valid" if !valid_non_custom_type && !(type.eql? "custom")
|
213
231
|
raise ArgumentError, "type is not valid or stylesheet not needed" if valid_non_custom_type and options.key? :stylesheet
|
232
|
+
raise ArgumentError, "screenshare_type is not valid" if options[:screenshare_type] && !valid_non_custom_layouts.include?(options[:screenshare_type])
|
233
|
+
raise ArgumentError, "type must be set to 'bestFit' if screenshare_type is defined" if options[:screenshare_type] && type != 'bestFit'
|
214
234
|
response = @client.layout_archive(archive_id, options)
|
215
235
|
(200..300).include? response.code
|
216
236
|
end
|
237
|
+
|
238
|
+
# Adds a stream to currently running composed archive that was started with the
|
239
|
+
# streamMode set to "manual". For a description of the feature, see
|
240
|
+
# {https://tokbox.com/developer/rest/#selecting-archive-streams}.
|
241
|
+
#
|
242
|
+
# @param [String] archive_id
|
243
|
+
# The archive ID.
|
244
|
+
#
|
245
|
+
# @param [String] stream_id
|
246
|
+
# The ID for the stream to be added to the archive
|
247
|
+
#
|
248
|
+
# @option opts [true, false] :has_audio
|
249
|
+
# (Boolean, optional) — Whether the composed archive should include the stream's
|
250
|
+
# audio (true, the default) or not (false).
|
251
|
+
#
|
252
|
+
# @option opts [true, false] :has_video
|
253
|
+
# (Boolean, optional) — Whether the composed archive should include the stream's
|
254
|
+
# video (true, the default) or not (false).
|
255
|
+
#
|
256
|
+
# You can call the method repeatedly with add_stream set to the same stream ID, to
|
257
|
+
# toggle the stream's audio or video in the archive. If you set both has_audio and
|
258
|
+
# has_video to false, you will get error response.
|
259
|
+
#
|
260
|
+
# @raise [ArgumentError]
|
261
|
+
# The archive_id parameter is empty.
|
262
|
+
#
|
263
|
+
# @raise [ArgumentError]
|
264
|
+
# The stream_id parameter is empty.
|
265
|
+
#
|
266
|
+
# @raise [ArgumentError]
|
267
|
+
# The has_audio and has_video properties of the options parameter are both set to "false"
|
268
|
+
#
|
269
|
+
def add_stream(archive_id, stream_id, options)
|
270
|
+
raise ArgumentError, "archive_id not provided" if archive_id.to_s.empty?
|
271
|
+
raise ArgumentError, "stream_id not provided" if stream_id.to_s.empty?
|
272
|
+
if options.has_key?(:has_audio) && options.has_key?(:has_video)
|
273
|
+
has_audio = options[:has_audio]
|
274
|
+
has_video = options[:has_video]
|
275
|
+
raise ArgumentError, "has_audio and has_video can't both be false" if audio_and_video_options_both_false?(has_audio, has_video)
|
276
|
+
end
|
277
|
+
options['add_stream'] = stream_id
|
278
|
+
|
279
|
+
@client.select_streams_for_archive(archive_id, options)
|
280
|
+
end
|
281
|
+
|
282
|
+
# Removes a stream from a currently running composed archive that was started with the
|
283
|
+
# streamMode set to "manual". For a description of the feature, see
|
284
|
+
# {https://tokbox.com/developer/rest/#selecting-archive-streams}.
|
285
|
+
#
|
286
|
+
# @param [String] archive_id
|
287
|
+
# The archive ID.
|
288
|
+
#
|
289
|
+
# @param [String] stream_id
|
290
|
+
# The ID for the stream to be removed from the archive
|
291
|
+
#
|
292
|
+
# @raise [ArgumentError]
|
293
|
+
# The archive_id parameter id is empty.
|
294
|
+
#
|
295
|
+
# @raise [ArgumentError]
|
296
|
+
# The stream_id parameter is empty.
|
297
|
+
#
|
298
|
+
def remove_stream(archive_id, stream_id)
|
299
|
+
raise ArgumentError, "archive_id not provided" if archive_id.to_s.empty?
|
300
|
+
raise ArgumentError, "stream_id not provided" if stream_id.to_s.empty?
|
301
|
+
options = {}
|
302
|
+
options['remove_stream'] = stream_id
|
303
|
+
|
304
|
+
@client.select_streams_for_archive(archive_id, options)
|
305
|
+
end
|
306
|
+
|
307
|
+
private
|
308
|
+
|
309
|
+
def audio_and_video_options_both_false?(has_audio, has_video)
|
310
|
+
has_audio == false && has_video == false
|
311
|
+
end
|
312
|
+
|
217
313
|
end
|
218
314
|
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
|