├── .yardopts
├── lib
├── opentok
│ ├── version.rb
│ ├── constants.rb
│ ├── extensions
│ │ └── hash.rb
│ ├── stream_list.rb
│ ├── broadcast_list.rb
│ ├── archive_list.rb
│ ├── render_list.rb
│ ├── connections.rb
│ ├── stream.rb
│ ├── exceptions.rb
│ ├── signals.rb
│ ├── websocket.rb
│ ├── captions.rb
│ └── render.rb
└── opentok.rb
├── Gemfile
├── sample
├── Archiving
│ ├── Gemfile
│ ├── public
│ │ ├── img
│ │ │ ├── archiving-off.png
│ │ │ ├── archiving-on-idle.png
│ │ │ └── archiving-on-message.png
│ │ ├── css
│ │ │ └── sample.css
│ │ └── js
│ │ │ ├── participant.js
│ │ │ └── host.js
│ ├── views
│ │ ├── layout.erb
│ │ ├── index.erb
│ │ ├── participant.erb
│ │ ├── history.erb
│ │ └── host.erb
│ └── archiving_sample.rb
├── Broadcast
│ ├── Gemfile
│ ├── views
│ │ ├── participant.erb
│ │ ├── layout.erb
│ │ ├── all.erb
│ │ ├── index.erb
│ │ └── host.erb
│ ├── public
│ │ ├── css
│ │ │ └── sample.css
│ │ └── js
│ │ │ └── participant.js
│ └── broadcast_sample.rb
└── HelloWorld
│ ├── Gemfile
│ ├── views
│ └── index.erb
│ ├── hello_world.rb
│ └── public
│ └── js
│ └── helloworld.js
├── .gitignore
├── Rakefile
├── .github
└── workflows
│ ├── metrics.yml
│ └── ci.yml
├── spec
├── spec_helper.rb
├── cassettes
│ ├── OpenTok_Renders
│ │ ├── stops_an_Experience_Composer_render.yml
│ │ ├── finds_an_Experience_Composer_render.yml
│ │ ├── starts_an_Experience_Composer_render.yml
│ │ └── for_many_renders
│ │ │ ├── should_return_count_number_of_renders.yml
│ │ │ ├── should_return_part_of_the_renders_when_using_offset_and_count.yml
│ │ │ └── should_return_renders_with_an_offset.yml
│ ├── OpenTok_Archives
│ │ ├── http_client_errors
│ │ │ └── .yml
│ │ ├── should_delete_an_archive_by_id.yml
│ │ ├── changes_the_layout_of_an_archive.yml
│ │ ├── should_stop_archives.yml
│ │ ├── should_find_expired_archives.yml
│ │ ├── should_find_paused_archives_by_id.yml
│ │ ├── should_create_archives.yml
│ │ ├── should_create_an_archive_with_multi_archive_tag_value_of_nil_when_multiArchiveTag_not_specified.yml
│ │ ├── should_create_named_archives.yml
│ │ ├── adds_a_stream_to_an_archive.yml
│ │ ├── removes_a_stream_from_an_archive.yml
│ │ ├── should_create_an_archive_with_matching_multi_archive_tag_when_multiArchiveTag_is_specified.yml
│ │ ├── should_create_an_archive_with_maxBitrate_set_to_specified_max_bitrate_value.yml
│ │ ├── should_create_an_archive_with_streamMode_set_to_specified_stream_mode_value.yml
│ │ ├── should_create_an_archives_with_a_specified_multiArchiveTag.yml
│ │ ├── should_create_audio_only_archives.yml
│ │ ├── should_create_layout_archives_with_screenshare_layout_types.yml
│ │ ├── should_create_an_archive_with_quantizationParameter_set_to_specified_value.yml
│ │ ├── should_create_individual_archives.yml
│ │ ├── calls_layout_on_archive_object.yml
│ │ ├── should_find_archives_with_unknown_properties.yml
│ │ ├── should_create_hd_archives.yml
│ │ ├── should_create_custom_layout_archives.yml
│ │ ├── should_find_archives_by_id.yml
│ │ └── when_many_archives_are_created
│ │ │ ├── should_return_count_number_of_archives.yml
│ │ │ ├── should_return_archives_with_an_offset.yml
│ │ │ ├── should_return_session_archives.yml
│ │ │ └── should_return_part_of_the_archives_when_using_offset_and_count.yml
│ ├── OpenTok_Streams
│ │ ├── disables_the_mute_state_of_a_session.yml
│ │ ├── forces_the_specified_stream_to_be_muted.yml
│ │ ├── forces_all_current_and_future_streams_in_a_session_to_be_muted.yml
│ │ ├── forces_all_current_and_future_streams_in_a_session_to_be_muted_except_specified_excluded_streams.yml
│ │ ├── get_specific_stream_information.yml
│ │ ├── layout_working_on_two_stream_list.yml
│ │ └── get_all_streams_information.yml
│ ├── OpenTok_Sip
│ │ ├── _play_dtmf_to_session
│ │ │ └── returns_a_200_response_code_when_passed_a_valid_dtmf_digit_string.yml
│ │ ├── _play_dtmf_to_connection
│ │ │ └── returns_a_200_response_code_when_passed_a_valid_dtmf_digit_string.yml
│ │ └── receives_a_valid_response.yml
│ ├── OpenTok_Connections
│ │ └── forces_a_connection_to_be_terminated.yml
│ ├── OpenTok_WebSocket
│ │ ├── receives_a_valid_response.yml
│ │ └── receives_a_valid_response_with_opts.yml
│ ├── OpenTok_Broadcasts
│ │ ├── changes_the_layout_of_a_broadcast.yml
│ │ ├── stops_a_broadcast.yml
│ │ ├── adds_a_stream_to_a_broadcast.yml
│ │ ├── removes_a_stream_from_a_broadcast.yml
│ │ ├── fetches_a_hls_broadcast_url.yml
│ │ ├── starts_a_broadcast_with_a_multi_broadcast_tag_value_of_nil_when_multiBroadcastTag_not_specified.yml
│ │ ├── starts_a_broadcast_with_a_specified_multiBroadcastTag.yml
│ │ ├── starts_a_broadcast_with_a_matching_multi_broadcast_tag_value_when_multiBroadcastTag_is_specified.yml
│ │ ├── finds_a_broadcast.yml
│ │ ├── calls_layout_on_broadcast_object.yml
│ │ ├── starts_a_rtmp_broadcast.yml
│ │ └── for_many_broadcasts
│ │ │ └── should_return_count_number_of_broadcasts.yml
│ ├── OpenTok_Signals
│ │ ├── receives_a_valid_response_for_all_connections.yml
│ │ └── receives_a_valid_response_for_a_connection.yml
│ ├── OpenTok_OpenTok
│ │ └── when_initialized_properly
│ │ │ ├── _create_session
│ │ │ ├── creates_default_sessions.yml
│ │ │ ├── creates_e2ee_sessions.yml
│ │ │ ├── creates_relayed_media_sessions.yml
│ │ │ ├── creates_routed_media_sessions.yml
│ │ │ ├── creates_always_archived_sessions.yml
│ │ │ ├── creates_relayed_media_sessions_for_invalid_media_modes.yml
│ │ │ ├── creates_sessions_with_a_location_hint.yml
│ │ │ ├── creates_always_archived_sessions_with_a_set_archive_name.yml
│ │ │ ├── creates_relayed_media_sessions_with_a_location_hint.yml
│ │ │ ├── creates_routed_media_sessions_with_a_location_hint.yml
│ │ │ ├── creates_always_archived_sessions_with_a_set_archive_resolution.yml
│ │ │ └── creates_always_archived_sessions_with_a_set_archive_name_and_resolution.yml
│ │ │ └── with_an_addendum_to_the_user_agent_string
│ │ │ └── should_append_the_addendum_to_the_user_agent_header.yml
│ └── OpenTok_Captions
│ │ ├── receives_a_valid_response_when_stopping_captions.yml
│ │ ├── receives_a_valid_response_when_starting_captions.yml
│ │ └── receives_a_valid_response_when_starting_captions_with_options.yml
├── opentok
│ ├── connection_spec.rb
│ ├── websocket_spec.rb
│ ├── signal_spec.rb
│ ├── client_spec.rb
│ ├── captions_spec.rb
│ ├── sip_spec.rb
│ ├── session_spec.rb
│ └── streams_spec.rb
└── matchers
│ └── token.rb
├── LICENSE
├── opentok.gemspec
└── CONTRIBUTING.md
/.yardopts:
--------------------------------------------------------------------------------
1 | 'lib/**/*.rb' --no-private --readme doc/README.md
--------------------------------------------------------------------------------
/lib/opentok/version.rb:
--------------------------------------------------------------------------------
1 | module OpenTok
2 | # @private
3 | VERSION = '4.13.0'
4 | end
5 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source "http://rubygems.org"
2 |
3 | gem "pry"
4 |
5 | # Specify your gem's dependencies in opentok.gemspec
6 | gemspec
7 |
--------------------------------------------------------------------------------
/sample/Archiving/Gemfile:
--------------------------------------------------------------------------------
1 | source "http://rubygems.org"
2 |
3 | gem "sinatra", "~> 1.4.4"
4 | gem "opentok", :path => "../../"
5 |
--------------------------------------------------------------------------------
/sample/Broadcast/Gemfile:
--------------------------------------------------------------------------------
1 | source "http://rubygems.org"
2 |
3 | gem "sinatra", "~> 1.4.4"
4 | gem "opentok", :path => "../../"
5 |
--------------------------------------------------------------------------------
/sample/HelloWorld/Gemfile:
--------------------------------------------------------------------------------
1 | source "http://rubygems.org"
2 |
3 | gem "sinatra", "~> 1.4.4"
4 | gem "opentok", :path => "../../"
5 |
--------------------------------------------------------------------------------
/lib/opentok.rb:
--------------------------------------------------------------------------------
1 | require "opentok/opentok"
2 |
3 | # Namespace for classes and modules in the OpenTok Ruby SDK.
4 | module OpenTok
5 |
6 | end
7 |
--------------------------------------------------------------------------------
/sample/Archiving/public/img/archiving-off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentok/OpenTok-Ruby-SDK/HEAD/sample/Archiving/public/img/archiving-off.png
--------------------------------------------------------------------------------
/sample/Archiving/public/img/archiving-on-idle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentok/OpenTok-Ruby-SDK/HEAD/sample/Archiving/public/img/archiving-on-idle.png
--------------------------------------------------------------------------------
/sample/Archiving/public/img/archiving-on-message.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/opentok/OpenTok-Ruby-SDK/HEAD/sample/Archiving/public/img/archiving-on-message.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | .bundle
4 | .config
5 | .yardoc
6 | Gemfile.lock
7 | InstalledFiles
8 | _yardoc
9 | coverage
10 |
11 | lib/bundler/man
12 | pkg
13 | rdoc
14 | spec/reports
15 | test/tmp
16 | test/version_tmp
17 | tmp
18 | vendor
19 |
20 | .DS_Store
--------------------------------------------------------------------------------
/lib/opentok/constants.rb:
--------------------------------------------------------------------------------
1 | module OpenTok
2 | require "set"
3 | API_URL = "https://api.opentok.com"
4 | TOKEN_SENTINEL = "T1=="
5 | ROLES = { subscriber: "subscriber", publisher: "publisher", moderator: "moderator", publisheronly: "publisheronly" }
6 | ARCHIVE_MODES = ::Set.new([:manual, :always])
7 | AUTH_EXPIRE = 300
8 | end
9 |
--------------------------------------------------------------------------------
/lib/opentok/extensions/hash.rb:
--------------------------------------------------------------------------------
1 | module OpenTok
2 | module HashExtensions
3 | def camelize_keys!
4 | keys.each do |k|
5 | new_key = k.to_s.camelize(:lower)
6 | new_key = new_key.to_sym if k.is_a? Symbol
7 | self[new_key] = self.delete(k)
8 | end
9 | self
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/lib/opentok/stream_list.rb:
--------------------------------------------------------------------------------
1 | require "opentok/stream"
2 |
3 |
4 | module OpenTok
5 | # A class for accessing a list of Stream objects.
6 | class StreamList < Array
7 |
8 | # The total number streams.
9 | attr_reader :total
10 |
11 | # @private
12 | def initialize(json)
13 | @total = json['count']
14 | super json['items'].map { |item| Stream.new item }
15 | end
16 |
17 | end
18 | end
--------------------------------------------------------------------------------
/lib/opentok/broadcast_list.rb:
--------------------------------------------------------------------------------
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
15 |
--------------------------------------------------------------------------------
/lib/opentok/archive_list.rb:
--------------------------------------------------------------------------------
1 | require "opentok/archive"
2 |
3 | module OpenTok
4 | # A class for accessing an array of Archive objects.
5 | class ArchiveList < Array
6 |
7 | # The total number archives.
8 | attr_reader :total
9 |
10 | # @private
11 | def initialize(interface, json)
12 | @total = json['count']
13 | super json['items'].map { |item| Archive.new interface, item }
14 | end
15 |
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/lib/opentok/render_list.rb:
--------------------------------------------------------------------------------
1 | require "opentok/render"
2 |
3 | module OpenTok
4 | # A class for accessing an array of Experience Composer Render objects.
5 | class RenderList < Array
6 | # The total number of Experience Composer renders.
7 | attr_reader :total
8 |
9 | def initialize(interface, json)
10 | @total = json["count"]
11 | super json["items"].map { |item| ::OpenTok::Render.new interface, item }
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | require "bundler/gem_tasks"
2 | require "rspec/core/rake_task"
3 | require "yard"
4 |
5 | RSpec::Core::RakeTask.new(:spec)
6 |
7 | YARD::Rake::YardocTask.new do |t|
8 | # t.files = ['lib/**/*.rb', OTHER_PATHS] # optional
9 | # t.options = ['--any', '--extra', '--opts'] # optional
10 | end
11 |
12 | desc "Open an irb session preloaded with this library"
13 | task :console do
14 | sh "irb -rubygems -I lib -r opentok.rb"
15 | end
16 |
17 | task :default => :spec
18 |
--------------------------------------------------------------------------------
/.github/workflows/metrics.yml:
--------------------------------------------------------------------------------
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 }}
18 |
--------------------------------------------------------------------------------
/sample/Archiving/public/css/sample.css:
--------------------------------------------------------------------------------
1 | /* Move down content because we have a fixed navbar that is 50px tall */
2 | body {
3 | padding-top: 50px;
4 | padding-bottom: 20px;
5 | background-color: #F2F2F2;
6 | }
7 |
8 | /* Responsive: Portrait tablets and up */
9 | @media screen and (min-width: 768px) {
10 | /* Remove padding from wrapping element since we kick in the grid classes here */
11 | .body-content {
12 | padding: 0;
13 | }
14 | }
15 |
16 | #subscribers div {
17 | float: left;
18 | }
19 |
20 | .bump-me {
21 | padding-top: 40px;
22 | }
23 |
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | require "vcr"
2 | require 'webmock/rspec'
3 |
4 | VCR.configure do |c|
5 | c.cassette_library_dir = 'spec/cassettes'
6 | c.hook_into :webmock
7 | c.default_cassette_options = { :match_requests_on => [:method, :uri, :query, :body, :headers] }
8 | c.configure_rspec_metadata!
9 | end
10 |
11 | RSpec.configure do |c|
12 | # so we can use :vcr rather than :vcr => true;
13 | # in RSpec 3 this will no longer be necessary.
14 | c.treat_symbols_as_metadata_keys_with_true_values = true
15 | end
16 |
17 | RSpec::Expectations.configuration.on_potential_false_positives = :nothing
18 |
--------------------------------------------------------------------------------
/sample/HelloWorld/views/index.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
Create a broadcast
12 |
13 |
14 | Everyone who joins either the Host View or Participant View
15 | joins a single OpenTok session. The Host can click
16 | Start Broadcast and Stop Broadcast to control the live streaming
17 | broadcast of the entire session.
18 |
19 |
20 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
List of Broadcasts
32 |
33 |
34 | Click through to List of Broadcasts to see examples of using the
35 | Broadcasting REST API to list broadcasts showing status (started,
36 | stopped, available) and created at timestamp.
37 |
38 |
39 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/spec/cassettes/OpenTok_Archives/should_create_hd_archives.yml:
--------------------------------------------------------------------------------
1 | ---
2 | http_interactions:
3 | - request:
4 | method: post
5 | uri: https://api.opentok.com/v2/project/123456/archive
6 | body:
7 | encoding: UTF-8
8 | string: '{"sessionId":"SESSIONID","outputMode":"composed","resolution":"1280x720"}'
9 | headers:
10 | User-Agent:
11 | - OpenTok-Ruby-SDK/<%= version %>
12 | X-Opentok-Auth:
13 | - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14 | Content-Type:
15 | - application/json
16 | Accept-Encoding: "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
17 | Accept: "*/*"
18 | response:
19 | status:
20 | code: 200
21 | message: OK
22 | headers:
23 | Server:
24 | - nginx
25 | Date:
26 | - Fri, 21 Sep 2018 16:54:25 GMT
27 | Content-Type:
28 | - application/json
29 | Transfer-Encoding:
30 | - chunked
31 | Connection:
32 | - keep-alive
33 | body:
34 | encoding: UTF-8
35 | string: |-
36 | {
37 | "createdAt" : 1395193762293,
38 | "duration" : 0,
39 | "id" : "d7f4d2a3-da74-414d-868a-190532a835bc",
40 | "name" : "ARCHIVE NAME",
41 | "partnerId" : 123456,
42 | "reason" : "",
43 | "sessionId" : "SESSIONID",
44 | "size" : 0,
45 | "status" : "started",
46 | "url" : null,
47 | "hasAudio" : true,
48 | "hasVideo" : false,
49 | "outputMode": "composed",
50 | "resolution": "1280x720"
51 | }
52 | http_version:
53 | recorded_at: Fri, 21 Sep 2018 16:54:25 GMT
54 | recorded_with: VCR 2.8.0
55 |
--------------------------------------------------------------------------------
/spec/cassettes/OpenTok_Archives/should_create_custom_layout_archives.yml:
--------------------------------------------------------------------------------
1 | ---
2 | http_interactions:
3 | - request:
4 | method: post
5 | uri: https://api.opentok.com/v2/project/123456/archive
6 | body:
7 | encoding: UTF-8
8 | string: '{"sessionId":"SESSIONID","layout":{"type":"custom","stylesheet":"stream:last-child{display: block;margin: 0;top: 0;left: 0;width: 1px;height: 1px;}stream:first-child{display: block;margin: 0;top: 0;left: 0;width: 100%;height: 100%;}"}}'
9 | headers:
10 | User-Agent:
11 | - OpenTok-Ruby-SDK/<%= version %>
12 | X-Opentok-Auth:
13 | - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14 | Content-Type:
15 | - application/json
16 | Accept-Encoding: "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
17 | Accept: "*/*"
18 | response:
19 | status:
20 | code: 200
21 | message: OK
22 | headers:
23 | Server:
24 | - nginx
25 | Date:
26 | - Fri, 17 Jan 2020 21:15:36 GMT
27 | Content-Type:
28 | - application/json
29 | Transfer-Encoding:
30 | - chunked
31 | Connection:
32 | - keep-alive
33 | body:
34 | encoding: UTF-8
35 | string: |-
36 | {
37 | "createdAt" : 1395183243556,
38 | "duration" : 0,
39 | "id" : "30b3ebf1-ba36-4f5b-8def-6f70d9986fe9",
40 | "name" : "",
41 | "partnerId" : 123456,
42 | "reason" : "",
43 | "sessionId" : "SESSIONID",
44 | "size" : 0,
45 | "status" : "started",
46 | "url" : null
47 | }
48 | http_version:
49 | recorded_at: Fri, 17 Jan 2020 21:15:36 GMT
50 | recorded_with: VCR 5.0.0
51 |
--------------------------------------------------------------------------------
/spec/cassettes/OpenTok_Archives/should_find_archives_by_id.yml:
--------------------------------------------------------------------------------
1 | ---
2 | http_interactions:
3 | - request:
4 | method: get
5 | uri: https://api.opentok.com/v2/project/123456/archive/f6e7ee58-d6cf-4a59-896b-6d56b158ec71
6 | body:
7 | encoding: US-ASCII
8 | string: ''
9 | headers:
10 | User-Agent:
11 | - OpenTok-Ruby-SDK/<%= version %>
12 | X-Opentok-Auth:
13 | - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14 | Accept-Encoding: "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
15 | Accept: "*/*"
16 | response:
17 | status:
18 | code: 200
19 | message: OK
20 | headers:
21 | Server:
22 | - nginx
23 | Date:
24 | - Wed, 19 Mar 2014 01:49:22 GMT
25 | Content-Type:
26 | - application/json
27 | Transfer-Encoding:
28 | - chunked
29 | Connection:
30 | - keep-alive
31 | body:
32 | encoding: UTF-8
33 | string: |-
34 | {
35 | "createdAt" : 1395187836000,
36 | "duration" : 62,
37 | "id" : "f6e7ee58-d6cf-4a59-896b-6d56b158ec71",
38 | "name" : "",
39 | "partnerId" : 123456,
40 | "reason" : "",
41 | "sessionId" : "SESSIONID",
42 | "size" : 8347554,
43 | "status" : "available",
44 | "url" : "http://tokbox.com.archive2.s3.amazonaws.com/123456%2Ff6e7ee58-d6cf-4a59-896b-6d56b158ec71%2Farchive.mp4?Expires=1395194362&AWSAccessKeyId=AKIAI6LQCPIXYVWCQV6Q&Signature=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
45 | "notarealproperty" : "not a real value"
46 | }
47 | http_version:
48 | recorded_at: Wed, 19 Mar 2014 01:49:22 GMT
49 | recorded_with: VCR 2.8.0
50 |
--------------------------------------------------------------------------------
/spec/cassettes/OpenTok_Broadcasts/starts_a_broadcast_with_a_multi_broadcast_tag_value_of_nil_when_multiBroadcastTag_not_specified.yml:
--------------------------------------------------------------------------------
1 | ---
2 | http_interactions:
3 | - request:
4 | method: post
5 | uri: https://api.opentok.com/v2/project/123456/broadcast
6 | body:
7 | encoding: UTF-8
8 | string: '{"sessionId":"SESSIONID","outputs":{"hls":{}}}'
9 | headers:
10 | User-Agent:
11 | - OpenTok-Ruby-SDK/<%= version %>
12 | X-Opentok-Auth:
13 | - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14 | Content-Type:
15 | - application/json
16 | Accept-Encoding:
17 | - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18 | Accept:
19 | - "*/*"
20 | response:
21 | status:
22 | code: 200
23 | message: OK
24 | headers:
25 | Server:
26 | - nginx
27 | Date:
28 | - Mon, 03 Oct 2022 11:11:31 GMT
29 | Content-Type:
30 | - application/json; charset=utf-8
31 | Connection:
32 | - keep-alive
33 | body:
34 | encoding: UTF-8
35 | string: |-
36 | {
37 | "id":"BROADCASTID",
38 | "sessionId":"SESSIONID",
39 | "projectId":123456,
40 | "createdAt":1538086900154,
41 | "broadcastUrls":
42 | {
43 | "hls":"https://cdn-broadcast001-pdx.tokbox.com/14787/14787_b930bf08-1c9f-4c55-ab04-7d192578c057.smil/playlist.m3u8"
44 | },
45 | "updatedAt":1538086900489,
46 | "status":"started",
47 | "maxDuration":7200,
48 | "resolution":"640x480",
49 | "partnerId":100,
50 | "event":"broadcast"
51 | }
52 | recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
53 | recorded_with: VCR 6.0.0
54 |
--------------------------------------------------------------------------------
/spec/cassettes/OpenTok_Captions/receives_a_valid_response_when_stopping_captions.yml:
--------------------------------------------------------------------------------
1 | ---
2 | http_interactions:
3 | - request:
4 | method: post
5 | uri: https://api.opentok.com/v2/project/123456/captions/CAPTIONSID/stop
6 | body:
7 | encoding: UTF-8
8 | string: ''
9 | headers:
10 | User-Agent:
11 | - OpenTok-Ruby-SDK/<%= version %>
12 | X-Opentok-Auth:
13 | - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14 | Content-Type:
15 | - application/json
16 | Accept-Encoding:
17 | - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18 | Accept:
19 | - "*/*"
20 | response:
21 | status:
22 | code: 202
23 | message: Accepted
24 | headers:
25 | Date:
26 | - Tue, 05 Sep 2023 11:30:55 GMT
27 | Content-Type:
28 | - application/json; charset=utf-8
29 | Transfer-Encoding:
30 | - chunked
31 | Connection:
32 | - keep-alive
33 | Set-Cookie:
34 | - AWSALBTG=LJIybl0y9LXphBJqNdoYf94M2EQTLnT/IhYp4UD+lzvSSZfKfdshtXSXDJ+gplgMuZ+3zg7mtnQoUF7ZhM2IRiL6VYJq88ltUPP075OdNgDwWRpYLq+doFLXeee4skbljcUpgTAWkCp1MReHhYdiTO8G36cgW9hPyWE9/jIMcfhN6HzVv5Q=;
35 | Expires=Tue, 12 Sep 2023 11:30:55 GMT; Path=/
36 | - AWSALBTGCORS=LJIybl0y9LXphBJqNdoYf94M2EQTLnT/IhYp4UD+lzvSSZfKfdshtXSXDJ+gplgMuZ+3zg7mtnQoUF7ZhM2IRiL6VYJq88ltUPP075OdNgDwWRpYLq+doFLXeee4skbljcUpgTAWkCp1MReHhYdiTO8G36cgW9hPyWE9/jIMcfhN6HzVv5Q=;
37 | Expires=Tue, 12 Sep 2023 11:30:55 GMT; Path=/; SameSite=None; Secure
38 | X-Opentok-Trace:
39 | - f=unknown&s=cerberus&u=22ECEF08-1EBD-4554-BF7B-04857DE8616A
40 | body:
41 | encoding: UTF-8
42 | string: ''
43 | recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
44 | recorded_with: VCR 6.0.0
45 |
--------------------------------------------------------------------------------
/spec/cassettes/OpenTok_Broadcasts/starts_a_broadcast_with_a_specified_multiBroadcastTag.yml:
--------------------------------------------------------------------------------
1 | ---
2 | http_interactions:
3 | - request:
4 | method: post
5 | uri: https://api.opentok.com/v2/project/123456/broadcast
6 | body:
7 | encoding: UTF-8
8 | string: '{"sessionId":"SESSIONID","outputs":{"hls":{}},"multiBroadcastTag":"broadcast-1"}'
9 | headers:
10 | User-Agent:
11 | - OpenTok-Ruby-SDK/<%= version %>
12 | X-Opentok-Auth:
13 | - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14 | Content-Type:
15 | - application/json
16 | Accept-Encoding:
17 | - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18 | Accept:
19 | - "*/*"
20 | response:
21 | status:
22 | code: 200
23 | message: OK
24 | headers:
25 | Server:
26 | - nginx
27 | Date:
28 | - Wed, 07 Sep 2022 13:52:17 GMT
29 | Content-Type:
30 | - application/json
31 | Connection:
32 | - keep-alive
33 | body:
34 | encoding: UTF-8
35 | string: |-
36 | {
37 | "id":"BROADCASTID",
38 | "sessionId":"SESSIONID",
39 | "projectId":123456,
40 | "createdAt":1538086900154,
41 | "broadcastUrls":
42 | {
43 | "hls":"https://cdn-broadcast001-pdx.tokbox.com/14787/14787_b930bf08-1c9f-4c55-ab04-7d192578c057.smil/playlist.m3u8"
44 | },
45 | "updatedAt":1538086900489,
46 | "status":"started",
47 | "maxDuration":7200,
48 | "resolution":"640x480",
49 | "partnerId":100,
50 | "event":"broadcast",
51 | "multiBroadcastTag":"broadcast-1"
52 | }
53 | recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
54 | recorded_with: VCR 6.0.0
55 |
--------------------------------------------------------------------------------
/sample/Archiving/views/participant.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
Participant
10 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
Instructions
20 |
21 |
22 |
23 |
24 |
25 | | When |
26 | You will see |
27 |
28 |
29 |
30 |
31 | | Archiving is started |
32 |  |
33 |
34 |
35 | | Archiving remains on |
36 |  |
37 |
38 |
39 | | Archiving is stopped |
40 |  |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/spec/cassettes/OpenTok_Broadcasts/starts_a_broadcast_with_a_matching_multi_broadcast_tag_value_when_multiBroadcastTag_is_specified.yml:
--------------------------------------------------------------------------------
1 | ---
2 | http_interactions:
3 | - request:
4 | method: post
5 | uri: https://api.opentok.com/v2/project/123456/broadcast
6 | body:
7 | encoding: UTF-8
8 | string: '{"sessionId":"SESSIONID","outputs":{"hls":{}},"multiBroadcastTag":"broadcast-1"}'
9 | headers:
10 | User-Agent:
11 | - OpenTok-Ruby-SDK/<%= version %>
12 | X-Opentok-Auth:
13 | - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14 | Content-Type:
15 | - application/json
16 | Accept-Encoding:
17 | - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18 | Accept:
19 | - "*/*"
20 | response:
21 | status:
22 | code: 200
23 | message: OK
24 | headers:
25 | Server:
26 | - nginx
27 | Date:
28 | - Mon, 03 Oct 2022 11:11:31 GMT
29 | Content-Type:
30 | - application/json; charset=utf-8
31 | Connection:
32 | - keep-alive
33 | body:
34 | encoding: UTF-8
35 | string: |-
36 | {
37 | "id":"BROADCASTID",
38 | "sessionId":"SESSIONID",
39 | "projectId":123456,
40 | "createdAt":1538086900154,
41 | "broadcastUrls":
42 | {
43 | "hls":"https://cdn-broadcast001-pdx.tokbox.com/14787/14787_b930bf08-1c9f-4c55-ab04-7d192578c057.smil/playlist.m3u8"
44 | },
45 | "updatedAt":1538086900489,
46 | "status":"started",
47 | "maxDuration":7200,
48 | "resolution":"640x480",
49 | "partnerId":100,
50 | "event":"broadcast",
51 | "multiBroadcastTag":"broadcast-1"
52 | }
53 | recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
54 | recorded_with: VCR 6.0.0
55 |
--------------------------------------------------------------------------------
/spec/opentok/captions_spec.rb:
--------------------------------------------------------------------------------
1 | require "opentok/opentok"
2 | require "opentok/captions"
3 | require "opentok/version"
4 | require "spec_helper"
5 |
6 | describe OpenTok::Captions do
7 | before(:each) do
8 | now = Time.parse("2017-04-18 20:17:40 +1000")
9 | allow(Time).to receive(:now) { now }
10 | end
11 |
12 | let(:api_key) { "123456" }
13 | let(:api_secret) { "1234567890abcdef1234567890abcdef1234567890" }
14 | let(:session_id) { "SESSIONID" }
15 | let(:captions_id) { "CAPTIONSID" }
16 | let(:expiring_token) { "TOKENID" }
17 | let(:status_callback_url) { "https://example.com/captions/status" }
18 | let(:opentok) { OpenTok::OpenTok.new api_key, api_secret }
19 | let(:captions) { opentok.captions }
20 | subject { captions }
21 |
22 | it "receives a valid response when starting captions", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
23 | response = captions.start(session_id, expiring_token)
24 | expect(response).not_to be_nil
25 | expect(response.code).to eq(202)
26 | end
27 |
28 | it "receives a valid response when starting captions with options", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
29 | opts = { "language_code" => "en-GB",
30 | "max_duration" => 5000,
31 | "partial_captions" => false,
32 | "status_callback_url" => status_callback_url
33 | }
34 |
35 | response = captions.start(session_id, expiring_token, opts)
36 | expect(response).not_to be_nil
37 | expect(response.code).to eq(202)
38 | end
39 |
40 | it "receives a valid response when stopping captions", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
41 | response = captions.stop(captions_id)
42 | expect(response.code).to eq(202)
43 | end
44 | end
45 |
--------------------------------------------------------------------------------
/spec/cassettes/OpenTok_Captions/receives_a_valid_response_when_starting_captions.yml:
--------------------------------------------------------------------------------
1 | ---
2 | http_interactions:
3 | - request:
4 | method: post
5 | uri: https://api.opentok.com/v2/project/123456/captions
6 | body:
7 | encoding: UTF-8
8 | string: '{"sessionId":"SESSIONID","token":"TOKENID"}'
9 | headers:
10 | User-Agent:
11 | - OpenTok-Ruby-SDK/<%= version %>
12 | X-Opentok-Auth:
13 | - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14 | Content-Type:
15 | - application/json
16 | Accept-Encoding:
17 | - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18 | Accept:
19 | - "*/*"
20 | response:
21 | status:
22 | code: 202
23 | message: Accepted
24 | headers:
25 | Date:
26 | - Tue, 05 Sep 2023 11:32:49 GMT
27 | Content-Type:
28 | - application/json; charset=utf-8
29 | Transfer-Encoding:
30 | - chunked
31 | Connection:
32 | - keep-alive
33 | Set-Cookie:
34 | - AWSALBTG=V0iIksb77idvUqENJbP7kHbxorCidH5rXzTdrmAq244qBgmkoAZJ+QZE0gPn/fKjmIEtO29S43zhxzH3X5Ao8Nf/8KMvioOduANad0cg6/rMMbSKhWdxNJkcePyrYLO/6voP37Lk8LamlXqv3QK6lj9SCvA+/wyUB6CV+i1JY8XSc1ba/+s=;
35 | Expires=Tue, 12 Sep 2023 11:32:49 GMT; Path=/
36 | - AWSALBTGCORS=V0iIksb77idvUqENJbP7kHbxorCidH5rXzTdrmAq244qBgmkoAZJ+QZE0gPn/fKjmIEtO29S43zhxzH3X5Ao8Nf/8KMvioOduANad0cg6/rMMbSKhWdxNJkcePyrYLO/6voP37Lk8LamlXqv3QK6lj9SCvA+/wyUB6CV+i1JY8XSc1ba/+s=;
37 | Expires=Tue, 12 Sep 2023 11:32:49 GMT; Path=/; SameSite=None; Secure
38 | X-Opentok-Trace:
39 | - f=unknown&s=cerberus&u=B8FAC1E2-3DCE-40A9-9CC3-866750E7C7A5
40 | body:
41 | encoding: UTF-8
42 | string: '{ "captionsId": "7c0680fc-6274-4de5-a66f-d0648e8d3ac2" }'
43 | recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
44 | recorded_with: VCR 6.0.0
45 |
--------------------------------------------------------------------------------
/spec/cassettes/OpenTok_Broadcasts/finds_a_broadcast.yml:
--------------------------------------------------------------------------------
1 | ---
2 | http_interactions:
3 | - request:
4 | method: get
5 | uri: https://api.opentok.com/v2/project/123456/broadcast/13dbcc23-af92-4862-9184-74b21815a814
6 | body:
7 | encoding: US-ASCII
8 | string: ''
9 | headers:
10 | User-Agent:
11 | - OpenTok-Ruby-SDK/<%= version %>
12 | X-Opentok-Auth:
13 | - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14 | Accept-Encoding: "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
15 | Accept: "*/*"
16 | response:
17 | status:
18 | code: 200
19 | message: OK
20 | headers:
21 | Server:
22 | - nginx
23 | Date:
24 | - Fri, 28 Sep 2018 18:46:21 GMT
25 | Content-Type:
26 | - application/json
27 | Connection:
28 | - keep-alive
29 | body:
30 | encoding: UTF-8
31 | string: |-
32 | {
33 | "id":"13dbcc23-af92-4862-9184-74b21815a814",
34 | "sessionId":"SESSIONID",
35 | "projectId":123456,
36 | "createdAt":1538160235541,
37 | "broadcastUrls":{
38 | "rtmp":[
39 | {
40 | "status":"live",
41 | "id":"rubyTestStream",
42 | "serverUrl":"rtmp://x.rtmp.youtube.com/live2",
43 | "streamName":"66c9-jwuh-pquf-9x18"
44 | }
45 | ],
46 | "hls":"https://cdn-broadcast001-pdx.tokbox.com/14935/14935_77e4e8e8-0c8b-4cea-b579-0560875f7123.smil/playlist.m3u8"
47 | },
48 | "updatedAt":1538160235541,
49 | "status":"started",
50 | "maxDuration":7200,
51 | "resolution":"640x480",
52 | "partnerId":123456,
53 | "event":"broadcast"
54 | }
55 | http_version:
56 | recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
57 | recorded_with: VCR 2.8.0
58 |
--------------------------------------------------------------------------------
/spec/cassettes/OpenTok_Captions/receives_a_valid_response_when_starting_captions_with_options.yml:
--------------------------------------------------------------------------------
1 | ---
2 | http_interactions:
3 | - request:
4 | method: post
5 | uri: https://api.opentok.com/v2/project/123456/captions
6 | body:
7 | encoding: UTF-8
8 | string: '{"sessionId":"SESSIONID","token":"TOKENID","languageCode":"en-GB","maxDuration":5000,"partialCaptions":false,"statusCallbackUrl":"https://example.com/captions/status"}'
9 | headers:
10 | User-Agent:
11 | - OpenTok-Ruby-SDK/<%= version %>
12 | X-Opentok-Auth:
13 | - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14 | Content-Type:
15 | - application/json
16 | Accept-Encoding:
17 | - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18 | Accept:
19 | - "*/*"
20 | response:
21 | status:
22 | code: 202
23 | message: Accepted
24 | headers:
25 | Date:
26 | - Tue, 05 Sep 2023 12:05:23 GMT
27 | Content-Type:
28 | - application/json; charset=utf-8
29 | Transfer-Encoding:
30 | - chunked
31 | Connection:
32 | - keep-alive
33 | Set-Cookie:
34 | - AWSALBTG=Qam0XgGzqhEaBC7TB9UprWCTZ6omkQZDorQLpkU8Kb3+iSIJsINH6Rh13nWnaLryAUc08wZEEc0VAi6ZXVa5gVLE/5YeIvMT9WP8VzJLFyvQ/bMe7TIDvp/QronHO4tohNGpvrFQxCC5LElWX5JnN3sCr5WpUHqEPQr0jz9TtUmKJYIh0So=;
35 | Expires=Tue, 12 Sep 2023 12:05:23 GMT; Path=/
36 | - AWSALBTGCORS=Qam0XgGzqhEaBC7TB9UprWCTZ6omkQZDorQLpkU8Kb3+iSIJsINH6Rh13nWnaLryAUc08wZEEc0VAi6ZXVa5gVLE/5YeIvMT9WP8VzJLFyvQ/bMe7TIDvp/QronHO4tohNGpvrFQxCC5LElWX5JnN3sCr5WpUHqEPQr0jz9TtUmKJYIh0So=;
37 | Expires=Tue, 12 Sep 2023 12:05:23 GMT; Path=/; SameSite=None; Secure
38 | X-Opentok-Trace:
39 | - f=unknown&s=cerberus&u=5DB017B0-6FC7-444F-BDE9-20D3CBA7B2EA
40 | body:
41 | encoding: UTF-8
42 | string: '{ "captionsId": "7c0680fc-6274-4de5-a66f-d0648e8d3ac2" }'
43 | recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
44 | recorded_with: VCR 6.0.0
45 |
--------------------------------------------------------------------------------
/spec/cassettes/OpenTok_Broadcasts/calls_layout_on_broadcast_object.yml:
--------------------------------------------------------------------------------
1 | ---
2 | http_interactions:
3 | - request:
4 | method: get
5 | uri: https://api.opentok.com/v2/project/123456/broadcast/13dbcc23-af92-4862-9184-74b21815a814
6 | body:
7 | encoding: US-ASCII
8 | string: ''
9 | headers:
10 | User-Agent:
11 | - OpenTok-Ruby-SDK/<%= version %>
12 | X-Opentok-Auth:
13 | - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14 | Accept-Encoding: "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
15 | Accept: "*/*"
16 | response:
17 | status:
18 | code: 200
19 | message: OK
20 | headers:
21 | Server:
22 | - nginx
23 | Date:
24 | - Fri, 28 Sep 2018 20:45:36 GMT
25 | Content-Type:
26 | - application/json
27 | Connection:
28 | - keep-alive
29 | body:
30 | encoding: UTF-8
31 | string: |-
32 | {
33 | "id":"13dbcc23-af92-4862-9184-74b21815a814",
34 | "sessionId":"SESSIONID",
35 | "projectId":123456,
36 | "createdAt":1538160235541,
37 | "broadcastUrls":{
38 | "rtmp":[
39 | {
40 | "status":"live",
41 | "id":"rubyTestStream",
42 | "serverUrl":"rtmp://x.rtmp.youtube.com/live2",
43 | "streamName":"66c9-jwuh-pquf-9x18"
44 | }
45 | ],
46 | "hls":"https://cdn-broadcast001-pdx.tokbox.com/14935/14935_77e4e8e8-0c8b-4cea-b579-0560875f7123.smil/playlist.m3u8"
47 | },
48 | "updatedAt":1538160235541,
49 | "status":"started",
50 | "maxDuration":7200,
51 | "resolution":"640x480",
52 | "partnerId":123456,
53 | "event":"broadcast"
54 | }
55 | http_version:
56 | recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
57 | recorded_with: VCR 2.8.0
58 |
--------------------------------------------------------------------------------
/lib/opentok/signals.rb:
--------------------------------------------------------------------------------
1 | module OpenTok
2 | # A class for working with OpenTok signals.
3 | class Signals
4 | # @private
5 | def initialize(client)
6 | @client = client
7 | end
8 |
9 | # Sends a signal to clients connected to an OpenTok session.
10 | #
11 | # You can send a signal to all valid connections in a session or to a specific connection of
12 | # a session.
13 | #
14 | # For more information on signaling, see
15 | # {https://tokbox.com/developer/rest/#send_signal}.
16 | #
17 | # @param [String] session_id The session ID of the OpenTok session.
18 | #
19 | # @param [String] connection_id
20 | # When a connection_id is specified, only that connection recieves the signal.
21 | # Otherwise, the signal is sent to all clients connected to the session.
22 | #
23 | # @option options [String] :type This is the type of the signal. You can use this
24 | # field to group and filter signals. It is a property of the Signal object received by
25 | # the client(s).
26 | #
27 | # @option options [String] :data This is the data within the signal or the payload.
28 | # Contains the main information to be sent in the signal. It is a property of the Signal object
29 | # received by the client(s).
30 | #
31 | # @raise [ArgumentError]
32 | # One of the signal properties — data, type, session_id, or connection_id — is invalid.
33 | # @raise [OpenTokAuthenticationError]
34 | # You are not authorized to send the signal. Check your authentication credentials.
35 | # @raise [OpenTokError]
36 | # The client specified by the connection_id property is not connected to the session.
37 | # @raise [OpenTokError]
38 | # The type string exceeds the maximum length (128 bytes), or the data string exceeds
39 | # the maximum size (8 kB).
40 | def send(session_id, connectionId = "", options = {})
41 | raise ArgumentError, "session_id not provided" if session_id.to_s.empty?
42 | response = @client.signal(session_id, connectionId, options)
43 | (200..300).include? response.code
44 | end
45 |
46 | end
47 | end
--------------------------------------------------------------------------------
/lib/opentok/websocket.rb:
--------------------------------------------------------------------------------
1 | require "opentok/client"
2 |
3 | # An object that lets you work with Audio Connector WebSocket connections.
4 | module OpenTok
5 | class WebSocket
6 | # Starts an Audio Connector WebSocket connection to send audio from a Vonage Video API session to a WebSocket URI.
7 | # See the {https://tokbox.com/developer/guides/audio-connector/ OpenTok Audio Connector developer guide}.
8 | #
9 | # @example
10 | # opts = {
11 | # "streams" => ["STREAMID1", "STREAMID2"],
12 | # "headers" => {
13 | # "key1" => "val1",
14 | # "key2" => "val2"
15 | # }
16 | # }
17 | # response = opentok.websocket.connect(SESSIONID, TOKEN, "ws://service.com/wsendpoint", opts)
18 | #
19 | # @param [String] session_id (required) The OpenTok session ID that includes the OpenTok streams you want to include in
20 | # the WebSocket stream.
21 | # @param [String] token (required) The OpenTok token to be used for the Audio Connector connection to the. OpenTok session.
22 | # @param [String] websocket_uri (required) A publicly reachable WebSocket URI to be used for the destination of the audio
23 | # stream (such as "wss://service.com/ws-endpoint").
24 | # @param [Hash] opts (optional) A hash defining options for the Audio Connector WebSocket connection. For example:
25 | # @option opts [Array] :streams (optional) An array of stream IDs for the OpenTok streams you want to include in the WebSocket stream.
26 | # If you omit this property, all streams in the session will be included.
27 | # @option opts [Hash] :headers (optional) A hash of key-value pairs of headers to be sent to your WebSocket server with each message,
28 | # with a maximum length of 512 bytes.
29 | # @option opts [Boolean] :bidirectional (optional) Whether the WebSocket connection should be bidirectional.
30 | def connect(session_id, token, websocket_uri, opts = {})
31 | response = @client.connect_websocket(session_id, token, websocket_uri, opts)
32 | end
33 |
34 | def initialize(client)
35 | @client = client
36 | end
37 | end
38 | end
39 |
--------------------------------------------------------------------------------
/opentok.gemspec:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | require File.expand_path("../lib/opentok/version.rb", __FILE__)
3 |
4 | Gem::Specification.new do |spec|
5 | spec.name = "opentok"
6 | spec.version = OpenTok::VERSION
7 | spec.authors = ["Stijn Mathysen", "Karmen Blake", "Song Zheng", "Patrick Quinn-Graham", "Ankur Oberoi"]
8 | spec.email = ["stijn@skylight.be", "karmenblake@gmail.com", "song@tokbox.com", "pqg@tokbox.com", "ankur@tokbox.com"]
9 | spec.summary = %q{Ruby gem for the OpenTok API}
10 | spec.description = %q{OpenTok is an API from TokBox that enables websites to weave live group video communication into their online experience. With OpenTok you have the freedom and flexibility to create the most engaging web experience for your users. This gem lets you generate sessions and tokens for OpenTok applications. It also includes support for working with OpenTok 2.0 archives. See