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 )
4
+ [ ![ codecov] ( https://codecov.io/gh/opentok/OpenTok-Ruby-SDK/branch/master/graph/badge.svg )] ( https://codecov.io/gh/opentok/opentok-ruby-sdk )
5
5
[ ![ Contributor Covenant] ( https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg )] ( CODE_OF_CONDUCT.md )
6
6
7
7
<img src =" https://assets.tokbox.com/img/vonage/Vonage_VideoAPI_black.svg " height =" 48px " alt =" Tokbox is now known as Vonage " />
8
8
9
- The OpenTok Ruby SDK lets you generate
10
- [ sessions] ( https://tokbox.com/developer/guides/create-session/ ) and
11
- [ tokens] ( https://tokbox.com/developer/guides/create-token/ ) for
12
- [ OpenTok] ( http://www.tokbox.com/ ) applications. It also includes methods for
13
- working with OpenTok [ archives] ( https://tokbox.com/developer/guides/archiving ) ,
14
- working with OpenTok [ live streaming
15
- broadcasts] ( https://tokbox.com/developer/guides/broadcast/live-streaming/ ) ,
16
- working with OpenTok [ SIP interconnect] ( https://tokbox.com/developer/guides/sip ) ,
17
- and [ disconnecting clients from sessions] ( https://tokbox.com/developer/guides/moderation/rest/ ) .
9
+ The OpenTok Ruby SDK provides methods for:
18
10
19
- # Installation
11
+ * Generating [ sessions] ( https://tokbox.com/developer/guides/create-session/ ) and
12
+ [ tokens] ( https://tokbox.com/developer/guides/create-token/ ) for
13
+ [ OpenTok] ( https://www.vonage.com/communications-apis/video/ ) applications
14
+ * Working with OpenTok [ archives] ( https://tokbox.com/developer/guides/archiving )
15
+ * Working with OpenTok [ live streaming broadcasts] ( https://tokbox.com/developer/guides/broadcast/live-streaming/ )
16
+ * Working with OpenTok [ SIP interconnect] ( https://tokbox.com/developer/guides/sip )
17
+ * [ Sending signals to clients connected to a session] ( https://tokbox.com/developer/guides/signaling/ )
18
+ * [ Disconnecting clients from sessions] ( https://tokbox.com/developer/guides/moderation/rest/ )
19
+ * [ Forcing clients in a session to disconnect or mute published audio] ( https://tokbox.com/developer/guides/moderation/ )
20
+ * Working with OpenTok [ Experience Composers] ( https://tokbox.com/developer/guides/experience-composer )
20
21
21
- ## Bundler (recommended):
22
+ ## Installation
23
+
24
+ ### Bundler (recommended):
22
25
23
26
Bundler helps manage dependencies for Ruby projects. Find more info here: < http://bundler.io >
24
27
@@ -34,15 +37,15 @@ Allow bundler to install the change.
34
37
$ bundle install
35
38
```
36
39
37
- ## RubyGems:
40
+ ### RubyGems:
38
41
39
42
```
40
43
$ gem install opentok
41
44
```
42
45
43
- # Usage
46
+ ## Usage
44
47
45
- ## Initializing
48
+ ### Initializing
46
49
47
50
Load the gem at the top of any file where it will be used. Then initialize an ` OpenTok::OpenTok `
48
51
object with your OpenTok API key and API secret.
@@ -53,7 +56,7 @@ require "opentok"
53
56
opentok = OpenTok ::OpenTok .new api_key, api_secret
54
57
```
55
58
56
- ### Initialization Options
59
+ #### Initialization Options
57
60
58
61
You can specify a custom timeout value for HTTP requests when initializing a new ` OpenTok::OpenTok `
59
62
object:
@@ -67,7 +70,7 @@ opentok = OpenTok::OpenTok.new api_key, api_secret, :timeout_length => 10
67
70
The value for ` :timeout_length ` is an integer representing the number of seconds to wait for an HTTP
68
71
request to complete. The default is set to 2 seconds.
69
72
70
- ## Creating Sessions
73
+ ### Creating Sessions
71
74
72
75
To create an OpenTok Session, use the ` OpenTok#create_session(properties) ` method.
73
76
The ` properties ` parameter is an optional Hash used to specify the following:
@@ -101,7 +104,7 @@ session = opentok.create_session :archive_mode => :always, :media_mode => :route
101
104
session_id = session.session_id
102
105
```
103
106
104
- ## Generating Tokens
107
+ ### Generating Tokens
105
108
106
109
Once a Session is created, you can start generating Tokens for clients to use when connecting to it.
107
110
You can generate a token either by calling the ` opentok.generate_token(session_id, options) ` method,
@@ -111,7 +114,7 @@ the Token. For layout control in archives and broadcasts, the initial layout cla
111
114
published from connections using this token can be set as well.
112
115
113
116
``` ruby
114
- # Generate a Token from just a session_id (fetched from a database)
117
+ # # Generate a Token from just a session_id (fetched from a database)
115
118
token = opentok.generate_token session_id
116
119
117
120
# Generate a Token by calling the method on the Session (returned from createSession)
@@ -126,7 +129,7 @@ token = session.generate_token({
126
129
});
127
130
```
128
131
129
- ## Working with Streams
132
+ ### Working with Streams
130
133
131
134
Use this method to get information for an OpenTok stream or for all streams in a session.
132
135
For example, you can call this method to get information about layout classes used by an
@@ -152,7 +155,7 @@ expect(all_streams.total).to eq 2
152
155
expect(all_streams[0 ].layoutClassList[1 ]).to eq " focus"
153
156
```
154
157
155
- ## Working with Archives
158
+ ### Working with Archives
156
159
157
160
You can only archive sessions that use the OpenTok Media Router
158
161
(sessions with the media mode set to routed).
@@ -185,8 +188,7 @@ archive = opentok.archives.create session_id :output_mode => :individual
185
188
The ` :output_mode => :composed ` setting (the default) causes all streams in the archive to be
186
189
recorded to a single (composed) file.
187
190
188
- For composed archives you can set the resolution of the archive, either "640x480" (SD, the default)
189
- or "1280x720" (HD). The ` resolution ` parameter is optional and could be included in the options
191
+ For composed archives you can set the resolution of the archive, either "640x480" (SD landscape, the default), "1280x720" (HD landscape), "1920x1080" (FHD landscape), "480x640" (SD portrait), "720x1280" (HD portrait), or "1080x1920" (FHD portrait).. The ` resolution ` parameter is optional and could be included in the options
190
192
hash (second argument) of the ` opentok.archives.create() ` method.
191
193
192
194
``` ruby
@@ -316,9 +318,9 @@ stream](https://tokbox.com/developer/rest/#change-stream-layout-classes-composed
316
318
Please keep in mind that the ` streams.layout ` method applies to archive and broadcast streams only.
317
319
318
320
For more information on archiving, see the
319
- [ OpenTok archiving] ( https://tokbox.com/opentok/tutorials/ archiving/) programming guide.
321
+ [ OpenTok archiving] ( /developer/guides/ archiving/) developer guide.
320
322
321
- ## Signaling
323
+ ### Signaling
322
324
323
325
You can send a signal using the ` opentok.signals.send(session_id, connection_id, opts) ` method.
324
326
If ` connection_id ` is nil or an empty string, then the signal is send to all valid connections in
@@ -343,16 +345,13 @@ use `opentok.signals.send(session_id)`
343
345
For more information on signaling, see the
344
346
[ OpenTok Signaling] ( https://tokbox.com/developer/guides/signaling/js/ ) programming guide.
345
347
346
- ## Broadcasting
348
+ ### Broadcasting
347
349
348
350
You can broadcast your streams to a HLS or RTMP servers.
349
351
350
352
To successfully start broadcasting a session, at least one publishing client must be connected to
351
353
the session.
352
354
353
- You can only have one active live streaming broadcast at a time for a session (however, having more
354
- than one would not be useful).
355
-
356
355
The live streaming broadcast can target one HLS endpoint and up to five RTMP servers simultaneously
357
356
for a session.
358
357
@@ -451,12 +450,25 @@ for more details.
451
450
You can also change the layout of an individual stream dynamically. Refer to
452
451
[ working with Streams] ( #working-with-streams ) .
453
452
454
- ## Force disconnect
453
+ ### Force disconnect
455
454
456
455
You can cause a client to be forced to disconnect from a session by using the
457
456
` opentok.connections.forceDisconnect(session_id, connection_id) ` method.
458
457
459
- ## Initiating a SIP call
458
+ ### Forcing clients in a session to mute published audio
459
+
460
+ You can force the publisher of a specific stream to stop publishing audio using the
461
+ ` opentok.streams.force_mute(session_id, stream_id) ` method.
462
+
463
+ You can force the publisher of all streams in a session (except for an optional list of streams)
464
+ to stop publishing audio using the ` opentok.streams.force_mute_all(session_id, opts) `
465
+ method. You can then disable the mute state of the session by calling the
466
+ ` opentok.streams.disable_force_mute(session_id) ` method.
467
+
468
+ For more information, see
469
+ [ Muting the audio of streams in a session] ( https://tokbox.com/developer/guides/moderation/#force_mute ) .
470
+
471
+ ### Initiating a SIP call
460
472
461
473
You can initiate a SIP call using the ` opentok.sip.dial(session_id, token, sip_uri, opts) ` method.
462
474
This requires a SIP URL. You will often need to pass options for authenticating to the SIP provider
@@ -473,7 +485,17 @@ response = opentok.sip.dial(session_id, token, "sip:
[email protected]
473
485
For more information on SIP Interconnect, see the
474
486
[ OpenTok SIP Interconnect] ( https://tokbox.com/developer/guides/sip/ ) developer guide.
475
487
476
- # Samples
488
+ ### Working with Experience Composers
489
+
490
+ You can start an [ Experience Composer] ( https://tokbox.com/developer/guides/experience-composer )
491
+ by calling the ` opentok.renders.start(session_id, options) ` method.
492
+
493
+ You can stop an Experience Composer by calling the ` opentok.renders.stop(render_id, options) ` method.
494
+
495
+ You can get information about Experience Composers by calling the ` opentok.renders.find(render_id) `
496
+ and ` opentok.renders.list(options) ` methods.
497
+
498
+ ## Samples
477
499
478
500
There are three sample applications included in this repository. To get going as fast as possible, clone the whole
479
501
repository and read the README in each of the sample directories:
@@ -482,23 +504,23 @@ repository and read the README in each of the sample directories:
482
504
- [ Archiving] ( sample/Archiving/README.md )
483
505
- [ Broadcast] ( sample/Broadcast/README.md )
484
506
485
- # Documentation
507
+ ## Documentation
486
508
487
509
Reference documentation is available at < http://www.tokbox.com//opentok/libraries/server/ruby/reference/index.html > .
488
510
489
- # Requirements
511
+ ## Requirements
490
512
491
513
You need an OpenTok API key and API secret, which you can obtain by logging into your
492
514
[ Vonage Video API account] ( https://tokbox.com/account ) .
493
515
494
516
The OpenTok Ruby SDK requires Ruby 2.1.0 or greater.
495
517
496
- # Release Notes
518
+ ## Release Notes
497
519
498
520
See the [ Releases] ( https://github.com/opentok/opentok-ruby-sdk/releases ) page for details
499
521
about each release.
500
522
501
- ## Important changes since v2.2.0
523
+ ### Important changes since v2.2.0
502
524
503
525
** Changes in v4.0.0:**
504
526
@@ -530,7 +552,7 @@ See the reference documentation
530
552
< http://www.tokbox.com/opentok/libraries/server/ruby/reference/index.html > and in the
531
553
docs directory of the SDK.
532
554
533
- # Development and Contributing
555
+ ## Development and Contributing
534
556
535
557
Interested in contributing? We :heart : pull requests! See the [ Development] ( DEVELOPING.md ) and
536
558
[ Contribution] ( CONTRIBUTING.md ) guidelines.
0 commit comments