opentok 3.0.3 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/metrics.yml +17 -0
  3. data/.travis.yml +3 -1
  4. data/CODE_OF_CONDUCT.md +128 -0
  5. data/README.md +312 -28
  6. data/lib/opentok/archive.rb +45 -4
  7. data/lib/opentok/archives.rb +73 -5
  8. data/lib/opentok/broadcast.rb +118 -0
  9. data/lib/opentok/broadcasts.rb +149 -0
  10. data/lib/opentok/client.rb +212 -7
  11. data/lib/opentok/connections.rb +28 -0
  12. data/lib/opentok/constants.rb +1 -1
  13. data/lib/opentok/exceptions.rb +6 -0
  14. data/lib/opentok/opentok.rb +44 -10
  15. data/lib/opentok/session.rb +5 -0
  16. data/lib/opentok/signals.rb +47 -0
  17. data/lib/opentok/sip.rb +33 -0
  18. data/lib/opentok/stream.rb +46 -0
  19. data/lib/opentok/stream_list.rb +18 -0
  20. data/lib/opentok/streams.rb +79 -0
  21. data/lib/opentok/version.rb +1 -1
  22. data/opentok.gemspec +9 -8
  23. data/sample/Broadcast/Gemfile +4 -0
  24. data/sample/Broadcast/README.md +201 -0
  25. data/sample/Broadcast/broadcast_sample.rb +97 -0
  26. data/sample/Broadcast/public/css/sample.css +64 -0
  27. data/sample/Broadcast/public/js/host.js +185 -0
  28. data/sample/Broadcast/public/js/participant.js +85 -0
  29. data/sample/Broadcast/views/host.erb +82 -0
  30. data/sample/Broadcast/views/index.erb +32 -0
  31. data/sample/Broadcast/views/layout.erb +29 -0
  32. data/sample/Broadcast/views/participant.erb +27 -0
  33. data/sample/HelloWorld/public/js/helloworld.js +4 -10
  34. data/sample/HelloWorld/views/index.erb +1 -3
  35. data/spec/cassettes/OpenTok_Archives/calls_layout_on_archive_object.yml +47 -0
  36. data/spec/cassettes/OpenTok_Archives/changes_the_layout_of_an_archive.yml +38 -0
  37. data/spec/cassettes/OpenTok_Archives/http_client_errors/.yml +34 -0
  38. data/spec/cassettes/OpenTok_Archives/should_create_archives.yml +3 -1
  39. data/spec/cassettes/OpenTok_Archives/should_create_audio_only_archives.yml +3 -1
  40. data/spec/cassettes/OpenTok_Archives/should_create_custom_layout_archives.yml +50 -0
  41. data/spec/cassettes/OpenTok_Archives/should_create_hd_archives.yml +54 -0
  42. data/spec/cassettes/OpenTok_Archives/should_create_individual_archives.yml +3 -1
  43. data/spec/cassettes/OpenTok_Archives/should_create_named_archives.yml +3 -1
  44. data/spec/cassettes/OpenTok_Archives/should_delete_an_archive_by_id.yml +3 -1
  45. data/spec/cassettes/OpenTok_Archives/should_find_archives_by_id.yml +3 -1
  46. data/spec/cassettes/OpenTok_Archives/should_find_archives_with_unknown_properties.yml +3 -1
  47. data/spec/cassettes/OpenTok_Archives/should_find_expired_archives.yml +3 -1
  48. data/spec/cassettes/OpenTok_Archives/should_find_paused_archives_by_id.yml +3 -1
  49. data/spec/cassettes/OpenTok_Archives/should_stop_archives.yml +3 -1
  50. data/spec/cassettes/OpenTok_Archives/when_many_archives_are_created/should_return_all_archives.yml +3 -1
  51. data/spec/cassettes/OpenTok_Archives/when_many_archives_are_created/should_return_archives_with_an_offset.yml +3 -1
  52. data/spec/cassettes/OpenTok_Archives/when_many_archives_are_created/should_return_count_number_of_archives.yml +3 -1
  53. data/spec/cassettes/OpenTok_Archives/when_many_archives_are_created/should_return_part_of_the_archives_when_using_offset_and_count.yml +3 -1
  54. data/spec/cassettes/OpenTok_Archives/when_many_archives_are_created/should_return_session_archives.yml +3 -1
  55. data/spec/cassettes/OpenTok_Broadcasts/calls_layout_on_broadcast_object.yml +57 -0
  56. data/spec/cassettes/OpenTok_Broadcasts/changes_the_layout_of_a_broadcast.yml +38 -0
  57. data/spec/cassettes/OpenTok_Broadcasts/fetches_a_hls_broadcast_url.yml +52 -0
  58. data/spec/cassettes/OpenTok_Broadcasts/finds_a_broadcast.yml +57 -0
  59. data/spec/cassettes/OpenTok_Broadcasts/starts_a_rtmp_broadcast.yml +61 -0
  60. data/spec/cassettes/OpenTok_Broadcasts/stops_a_broadcast.yml +47 -0
  61. data/spec/cassettes/OpenTok_Connections/forces_a_connection_to_be_terminated.yml +38 -0
  62. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_always_archived_sessions.yml +3 -1
  63. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_default_sessions.yml +3 -1
  64. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_relayed_media_sessions.yml +3 -1
  65. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_relayed_media_sessions_for_invalid_media_modes.yml +3 -1
  66. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_relayed_media_sessions_with_a_location_hint.yml +3 -1
  67. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_routed_media_sessions.yml +3 -1
  68. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_routed_media_sessions_with_a_location_hint.yml +3 -1
  69. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_sessions_with_a_location_hint.yml +3 -1
  70. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/with_an_addendum_to_the_user_agent_string/should_append_the_addendum_to_the_user_agent_header.yml +3 -1
  71. data/spec/cassettes/OpenTok_Signals/receives_a_valid_response_for_a_connection.yml +39 -0
  72. data/spec/cassettes/OpenTok_Signals/receives_a_valid_response_for_all_connections.yml +39 -0
  73. data/spec/cassettes/OpenTok_Sip/receives_a_valid_response.yml +3 -1
  74. data/spec/cassettes/OpenTok_Streams/get_all_streams_information.yml +55 -0
  75. data/spec/cassettes/OpenTok_Streams/get_specific_stream_information.yml +44 -0
  76. data/spec/cassettes/OpenTok_Streams/layout_working_on_two_stream_list.yml +38 -0
  77. data/spec/opentok/archives_spec.rb +84 -1
  78. data/spec/opentok/broadcasts_spec.rb +171 -0
  79. data/spec/opentok/client_spec.rb +51 -0
  80. data/spec/opentok/connection_spec.rb +38 -0
  81. data/spec/opentok/opentok_spec.rb +21 -0
  82. data/spec/opentok/signal_spec.rb +50 -0
  83. data/spec/opentok/streams_spec.rb +75 -0
  84. data/spec/spec_helper.rb +2 -0
  85. metadata +84 -22
@@ -10,7 +10,9 @@ http_interactions:
10
10
  User-Agent:
11
11
  - OpenTok-Ruby-SDK/<%= version %>
12
12
  X-Opentok-Auth:
13
- - eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImlzdCI6InByb2plY3QifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.Oh_JHhtEUKK1pPV4s6neXJj_RXI8EcEpJRRpG_2c9U0
13
+ - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14
+ Accept-Encoding: "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
15
+ Accept: "*/*"
14
16
  response:
15
17
  status:
16
18
  code: 200
@@ -10,7 +10,9 @@ http_interactions:
10
10
  User-Agent:
11
11
  - OpenTok-Ruby-SDK/<%= version %>
12
12
  X-Opentok-Auth:
13
- - eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImlzdCI6InByb2plY3QifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.Oh_JHhtEUKK1pPV4s6neXJj_RXI8EcEpJRRpG_2c9U0
13
+ - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14
+ Accept-Encoding: "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
15
+ Accept: "*/*"
14
16
  response:
15
17
  status:
16
18
  code: 200
@@ -10,7 +10,9 @@ http_interactions:
10
10
  User-Agent:
11
11
  - OpenTok-Ruby-SDK/<%= version %>
12
12
  X-Opentok-Auth:
13
- - eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImlzdCI6InByb2plY3QifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.Oh_JHhtEUKK1pPV4s6neXJj_RXI8EcEpJRRpG_2c9U0
13
+ - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14
+ Accept-Encoding: "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
15
+ Accept: "*/*"
14
16
  response:
15
17
  status:
16
18
  code: 200
@@ -10,7 +10,9 @@ http_interactions:
10
10
  User-Agent:
11
11
  - OpenTok-Ruby-SDK/<%= version %>
12
12
  X-Opentok-Auth:
13
- - eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImlzdCI6InByb2plY3QifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.Oh_JHhtEUKK1pPV4s6neXJj_RXI8EcEpJRRpG_2c9U0
13
+ - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14
+ Accept-Encoding: "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
15
+ Accept: "*/*"
14
16
  response:
15
17
  status:
16
18
  code: 200
@@ -10,7 +10,9 @@ http_interactions:
10
10
  User-Agent:
11
11
  - OpenTok-Ruby-SDK/<%= version %>
12
12
  X-Opentok-Auth:
13
- - eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImlzdCI6InByb2plY3QifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.Oh_JHhtEUKK1pPV4s6neXJj_RXI8EcEpJRRpG_2c9U0
13
+ - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14
+ Accept-Encoding: "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
15
+ Accept: "*/*"
14
16
  response:
15
17
  status:
16
18
  code: 200
@@ -10,7 +10,9 @@ http_interactions:
10
10
  User-Agent:
11
11
  - OpenTok-Ruby-SDK/<%= version %>
12
12
  X-Opentok-Auth:
13
- - eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImlzdCI6InByb2plY3QifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.Oh_JHhtEUKK1pPV4s6neXJj_RXI8EcEpJRRpG_2c9U0
13
+ - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14
+ Accept-Encoding: "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
15
+ Accept: "*/*"
14
16
  response:
15
17
  status:
16
18
  code: 200
@@ -10,7 +10,9 @@ http_interactions:
10
10
  User-Agent:
11
11
  - OpenTok-Ruby-SDK/<%= version %> BOOYAH
12
12
  X-Opentok-Auth:
13
- - eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImlzdCI6InByb2plY3QifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.Oh_JHhtEUKK1pPV4s6neXJj_RXI8EcEpJRRpG_2c9U0
13
+ - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14
+ Accept-Encoding: "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
15
+ Accept: "*/*"
14
16
  response:
15
17
  status:
16
18
  code: 200
@@ -0,0 +1,39 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.opentok.com/v2/project/123456/session/SESSIONID/connection/CONNID/signal
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"type":"chat","data":"Hello"}'
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: 204
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Tue, 28 Aug 2018 22:01:54 GMT
27
+ Content-Type:
28
+ - application/xml
29
+ Connection:
30
+ - keep-alive
31
+ Content-Length:
32
+ - '177'
33
+ body:
34
+ encoding: UTF-8
35
+ string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><errorPayload><code>-1</code><message>Issuer
36
+ not found</message><description>Issuer not found</description></errorPayload>
37
+ http_version:
38
+ recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
39
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,39 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.opentok.com/v2/project/123456/session/SESSIONID/signal
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"type":"chat","data":"Hello"}'
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: 204
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Tue, 28 Aug 2018 21:31:02 GMT
27
+ Content-Type:
28
+ - application/xml
29
+ Connection:
30
+ - keep-alive
31
+ Content-Length:
32
+ - '177'
33
+ body:
34
+ encoding: UTF-8
35
+ string: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><errorPayload><code>-1</code><message>Issuer
36
+ not found</message><description>Issuer not found</description></errorPayload>
37
+ http_version:
38
+ recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
39
+ recorded_with: VCR 2.8.0
@@ -10,9 +10,11 @@ http_interactions:
10
10
  User-Agent:
11
11
  - OpenTok-Ruby-SDK/<%= version %>
12
12
  X-Opentok-Auth:
13
- - eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImlzdCI6InByb2plY3QifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.Oh_JHhtEUKK1pPV4s6neXJj_RXI8EcEpJRRpG_2c9U0
13
+ - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14
14
  Content-Type:
15
15
  - application/json
16
+ Accept-Encoding: "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
17
+ Accept: "*/*"
16
18
  response:
17
19
  status:
18
20
  code: 200
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.opentok.com/v2/project/123456/session/SESSIONID/stream
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
+ 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
+ - Mon, 24 Sep 2018 20:41:24 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Connection:
30
+ - keep-alive
31
+ Content-Length:
32
+ - '73'
33
+ body:
34
+ encoding: UTF-8
35
+ string: |-
36
+ {
37
+ "count": 2,
38
+ "items": [
39
+ {
40
+ "id": "1234356-0a06-46a2-8ea8-074e64d43422",
41
+ "videoType": "camera",
42
+ "name": "",
43
+ "layoutClassList": ["full", "focus"]
44
+ },
45
+ {
46
+ "id": "8b732909-0a06-46a2-8ea8-074e64d43422",
47
+ "videoType": "screen",
48
+ "name": "",
49
+ "layoutClassList": ["full"]
50
+ }
51
+ ]
52
+ }
53
+ http_version:
54
+ recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
55
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.opentok.com/v2/project/123456/session/SESSIONID/stream/STREAMID
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
+ 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
+ - Mon, 24 Sep 2018 20:41:24 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Connection:
30
+ - keep-alive
31
+ Content-Length:
32
+ - '0'
33
+ body:
34
+ encoding: UTF-8
35
+ string: |-
36
+ {
37
+ "id": "8b732909-0a06-46a2-8ea8-074e64d43422",
38
+ "videoType": "camera",
39
+ "name": "",
40
+ "layoutClassList": ["full"]
41
+ }
42
+ http_version:
43
+ recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
44
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: put
5
+ uri: https://api.opentok.com/v2/project/123456/session/SESSIONID/stream
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"items":[{"id":"8b732909-0a06-46a2-8ea8-074e64d43422","layoutClassList":["full"]},{"id":"8b732909-0a06-46a2-8ea8-074e64d43423","layoutClassList":["full","focus"]}]}'
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
+ - Wed, 26 Sep 2018 22:48:29 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Connection:
30
+ - keep-alive
31
+ Content-Length:
32
+ - '73'
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"code":-1,"message":"Issuer not found","description":"Issuer not found"}'
36
+ http_version:
37
+ recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
38
+ recorded_with: VCR 2.8.0
@@ -57,6 +57,16 @@ describe OpenTok::Archives do
57
57
  expect(archive.output_mode).to eq :individual
58
58
  end
59
59
 
60
+ it "should create custom layout archives", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}" } } do
61
+ custom_layout = {
62
+ :type => "custom",
63
+ :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%;}"
64
+ }
65
+ archive = archives.create session_id, :layout => custom_layout
66
+ expect(archive).to be_an_instance_of OpenTok::Archive
67
+ expect(archive.session_id).to eq session_id
68
+ end
69
+
60
70
  it "should stop archives", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}" } } do
61
71
  archive = archives.stop_by_id started_archive_id
62
72
  expect(archive).to be_an_instance_of OpenTok::Archive
@@ -78,7 +88,7 @@ describe OpenTok::Archives do
78
88
 
79
89
  it "should delete an archive by id", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}" } } do
80
90
  success = archives.delete_by_id deletable_archive_id
81
- expect(success).to be_true
91
+ expect(success).to be_truthy
82
92
  # expect(archive.status).to eq ""
83
93
  end
84
94
 
@@ -93,6 +103,79 @@ describe OpenTok::Archives do
93
103
  expect(archive).to be_an_instance_of OpenTok::Archive
94
104
  end
95
105
 
106
+ it "should create hd archives", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}" } } do
107
+ archive = archives.create session_id, { :output_mode => :composed, :resolution => "1280x720" }
108
+ expect(archive).to be_an_instance_of OpenTok::Archive
109
+ expect(archive.session_id).to eq session_id
110
+ expect(archive.output_mode).to eq :composed
111
+ expect(archive.resolution).to eq "1280x720"
112
+ end
113
+
114
+ it "should create archives throws exception", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}" } } do
115
+ opts = {
116
+ :output_mode => :individual,
117
+ :resolution => "1280x720"
118
+ }
119
+
120
+ expect { archives.create session_id, opts }.to raise_exception
121
+ end
122
+
123
+ it "raise an error if layout options are empty" do
124
+ expect {
125
+ archives.layout(started_archive_id, {})
126
+ }.to raise_error(ArgumentError)
127
+ end
128
+
129
+ it "raise an error if archive id is not provided" do
130
+ expect {
131
+ archives.layout("", {
132
+ type: "custom",
133
+ stylesheet: "the layout stylesheet (only used with type == custom)"
134
+ })
135
+ }.to raise_error(ArgumentError)
136
+ end
137
+
138
+ it "raise an error if custom type has no style sheet" do
139
+ expect {
140
+ archives.layout(started_archive_id, {
141
+ type: "custom",
142
+ })
143
+ }.to raise_error(ArgumentError)
144
+ end
145
+
146
+ it "raise an error if non-custom type has style sheet" do
147
+ expect {
148
+ archives.layout(started_archive_id, {
149
+ type: "pip",
150
+ stylesheet: "the layout stylesheet (only used with type == custom)"
151
+ })
152
+ }.to raise_error(ArgumentError)
153
+ end
154
+
155
+ it "raise an error if invalid layout type" do
156
+ expect {
157
+ archives.layout(started_archive_id, {
158
+ type: "pip1"
159
+ })
160
+ }.to raise_error(ArgumentError)
161
+ end
162
+ it "calls layout on archive object", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}" } } do
163
+ archive = archives.find findable_archive_id
164
+ expect(archive).to be_an_instance_of OpenTok::Archive
165
+ expect(archive.id).to eq findable_archive_id
166
+ expect {
167
+ archive.layout(
168
+ type: 'pip1',
169
+ )
170
+ }.to raise_error(ArgumentError)
171
+ end
172
+ it "changes the layout of an archive", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}" } } do
173
+ response = archives.layout(started_archive_id, {
174
+ type: "pip"
175
+ })
176
+ expect(response).not_to be_nil
177
+ end
178
+
96
179
  # TODO: context "with a session that has no participants" do
97
180
  # let(:session_id) { "" }
98
181
  # it "should refuse to create archives with appropriate error" do
@@ -0,0 +1,171 @@
1
+ require "opentok/broadcast"
2
+ require "opentok/broadcasts"
3
+ require "opentok/opentok"
4
+ require "opentok/version"
5
+ require "spec_helper"
6
+
7
+ describe OpenTok::Broadcasts do
8
+ before(:each) do
9
+ now = Time.parse("2017-04-18 20:17:40 +1000")
10
+ allow(Time).to receive(:now) { now }
11
+ end
12
+
13
+ let(:api_key) { "123456" }
14
+ let(:api_secret) { "1234567890abcdef1234567890abcdef1234567890" }
15
+ let(:session_id) { "SESSIONID" }
16
+ let(:broadcast_id) { "BROADCASTID" }
17
+ let(:started_broadcast_id) { "13dbcc23-af92-4862-9184-74b21815a814" }
18
+ let(:opentok) { OpenTok::OpenTok.new api_key, api_secret }
19
+ let(:broadcast) { opentok.broadcasts }
20
+
21
+ subject { broadcast }
22
+
23
+ it 'raise an error on empty sessionId' do
24
+ opts = {
25
+ :outputs => {
26
+ :hls => {}
27
+ }
28
+ }
29
+ expect {
30
+ broadcast.create('', opts)
31
+ }.to raise_error(ArgumentError)
32
+ end
33
+ it 'raise an error on nil sessionId' do
34
+ opts = {
35
+ :outputs => {
36
+ :hls => {}
37
+ }
38
+ }
39
+ expect {
40
+ broadcast.create(nil, opts)
41
+ }.to raise_error(ArgumentError)
42
+ end
43
+ it 'raise an error on empty options' do
44
+ expect {
45
+ broadcast.create(nil, {})
46
+ }.to raise_error(ArgumentError)
47
+ end
48
+ it 'fetches a hls broadcast url', :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
49
+ opts = {
50
+ :outputs => {
51
+ :hls => {}
52
+ }
53
+ }
54
+ b_hls = broadcast.create(session_id, opts)
55
+ expect(b_hls).to be_an_instance_of OpenTok::Broadcast
56
+ expect(b_hls.id).to eq broadcast_id
57
+ expect(b_hls.broadcastUrls['hls']).to eq "https://cdn-broadcast001-pdx.tokbox.com/14787/14787_b930bf08-1c9f-4c55-ab04-7d192578c057.smil/playlist.m3u8"
58
+ end
59
+
60
+ it 'starts a rtmp broadcast', :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
61
+ opts = {
62
+ :outputs => {
63
+ :hls => {},
64
+ :rtmp => [
65
+ {
66
+ :id => "rubyTestStream",
67
+ :serverUrl => "rtmp://x.rtmp.youtube.com/live2",
68
+ :streamName => "66c9-jwuh-pquf-9x18"
69
+ }
70
+ ]
71
+ }
72
+ }
73
+ b_rtmp = broadcast.create(session_id, opts)
74
+ expect(b_rtmp).to be_an_instance_of OpenTok::Broadcast
75
+ expect(b_rtmp.id).to eq broadcast_id
76
+ expect(b_rtmp.broadcastUrls["rtmp"][0]["serverUrl"]).to eq "rtmp://x.rtmp.youtube.com/live2"
77
+ expect(b_rtmp.broadcastUrls["rtmp"].count).to eq 1
78
+ end
79
+
80
+ it 'finds a broadcast', :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
81
+ b = broadcast.find started_broadcast_id
82
+ expect(b).to be_an_instance_of OpenTok::Broadcast
83
+ expect(b.id).to eq started_broadcast_id
84
+ expect(b.broadcastUrls["rtmp"][0]["serverUrl"]).to eq "rtmp://x.rtmp.youtube.com/live2"
85
+ expect(b.broadcastUrls["rtmp"].count).to eq 1
86
+ end
87
+ it 'raise an error on empty broadcastId in find' do
88
+ expect {
89
+ broadcast.find("")
90
+ }.to raise_error(ArgumentError)
91
+ end
92
+ it 'raise an error on nil broadcastId in find' do
93
+ expect {
94
+ broadcast.find(nil)
95
+ }.to raise_error(ArgumentError)
96
+ end
97
+ it 'raise an error on empty broadcastId stop' do
98
+ expect {
99
+ broadcast.stop("")
100
+ }.to raise_error(ArgumentError)
101
+ end
102
+ it 'raise an error on nil broadcastId stop' do
103
+ expect {
104
+ broadcast.stop(nil)
105
+ }.to raise_error(ArgumentError)
106
+ end
107
+ it 'stops a broadcast', :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
108
+ b = broadcast.stop(started_broadcast_id)
109
+ expect(b).to be_an_instance_of OpenTok::Broadcast
110
+ expect(b.id).to eq started_broadcast_id
111
+ expect(b.broadcastUrls).to be_nil
112
+ expect(b.status).to eq "stopped"
113
+ end
114
+
115
+ it "raise an error if layout options are empty" do
116
+ expect {
117
+ broadcast.layout(started_broadcast_id, {})
118
+ }.to raise_error(ArgumentError)
119
+ end
120
+
121
+ it "raise an error if broadcast id is not provided" do
122
+ expect {
123
+ broadcast.layout("", {
124
+ type: "custom",
125
+ stylesheet: "the layout stylesheet (only used with type == custom)"
126
+ })
127
+ }.to raise_error(ArgumentError)
128
+ end
129
+
130
+ it "raise an error if custom type has no style sheet" do
131
+ expect {
132
+ broadcast.layout(started_broadcast_id, {
133
+ type: "custom",
134
+ })
135
+ }.to raise_error(ArgumentError)
136
+ end
137
+
138
+ it "raise an error if non-custom type has style sheet" do
139
+ expect {
140
+ broadcast.layout(started_broadcast_id, {
141
+ type: "pip",
142
+ stylesheet: "the layout stylesheet (only used with type == custom)"
143
+ })
144
+ }.to raise_error(ArgumentError)
145
+ end
146
+
147
+ it "raise an error if invalid layout type" do
148
+ expect {
149
+ broadcast.layout(started_broadcast_id, {
150
+ type: "pip1"
151
+ })
152
+ }.to raise_error(ArgumentError)
153
+ end
154
+ it "calls layout on broadcast object", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}" } } do
155
+ b = broadcast.find started_broadcast_id
156
+ expect(b).to be_an_instance_of OpenTok::Broadcast
157
+ expect(b.id).to eq started_broadcast_id
158
+ expect {
159
+ b.layout(
160
+ :type => 'pip1',
161
+ )
162
+ }.to raise_error(ArgumentError)
163
+ end
164
+ it "changes the layout of a broadcast", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}" } } do
165
+ response = broadcast.layout(started_broadcast_id, {
166
+ :type => "verticalPresentation"
167
+ })
168
+ expect(response).not_to be_nil
169
+ end
170
+
171
+ end