ruby_rabbitmq_janus 1.2.2 → 1.2.3.pre.53

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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +31 -28
  3. data/config/requests/peer/offer.json +2 -2
  4. data/lib/rrj/errors/init.rb +1 -1
  5. data/lib/rrj/errors/rabbit/rabbit.rb +14 -0
  6. data/lib/rrj/info.rb +15 -1
  7. data/lib/rrj/init.rb +12 -4
  8. data/lib/rrj/janus/processus/event.rb +4 -1
  9. data/lib/rrj/janus/processus/keepalive.rb +19 -13
  10. data/lib/rrj/janus/transactions/admin.rb +10 -4
  11. data/lib/rrj/janus/transactions/handle.rb +8 -3
  12. data/lib/rrj/janus/transactions/transaction.rb +14 -13
  13. data/lib/rrj/rabbit/publish/admin.rb +1 -1
  14. data/lib/rrj/rabbit/publish/exclusive.rb +8 -1
  15. data/lib/rrj/rabbit/publish/non_exclusive.rb +1 -1
  16. data/lib/rrj/rabbit/publish/publisher.rb +3 -1
  17. data/lib/rrj/tools/config.rb +2 -0
  18. data/lib/rrj/tools/replaces/standard.rb +1 -1
  19. data/lib/rrj/tools/replaces/type.rb +10 -0
  20. data/spec/fixtures/config/requests/admin/handle_info.json +3 -0
  21. data/spec/fixtures/config/requests/admin/handles.json +3 -0
  22. data/spec/fixtures/config/requests/admin/log_level.json +3 -0
  23. data/spec/fixtures/config/requests/admin/sessions.json +3 -0
  24. data/spec/fixtures/config/requests/base/attach.json +3 -0
  25. data/spec/fixtures/config/requests/base/create.json +4 -0
  26. data/spec/fixtures/config/requests/base/destroy.json +3 -0
  27. data/spec/fixtures/config/requests/base/detach.json +3 -0
  28. data/spec/fixtures/config/requests/base/info.json +3 -0
  29. data/spec/fixtures/config/requests/base/keepalive.json +3 -0
  30. data/spec/fixtures/config/requests/peer/answer.json +3 -0
  31. data/spec/fixtures/config/requests/peer/offer.json +3 -0
  32. data/spec/fixtures/config/requests/peer/trickle.json +3 -0
  33. data/spec/request/peer/request_offer_spec.rb +3 -5
  34. data/spec/rrj/rrj_config_spec.rb +1 -1
  35. data/spec/rrj/rrj_spec.rb +36 -10
  36. data/spec/support/examples_config.rb +6 -0
  37. data/spec/support/{examples.rb → examples_request.rb} +17 -0
  38. data/spec/support/schemas/request/peer/answer.json +2 -4
  39. data/spec/support/schemas/request/peer/offer.json +2 -4
  40. metadata +22 -14
  41. data/spec/request/peer/request_answer_spec.rb +0 -66
  42. data/spec/support/examples_peer.rb +0 -18
  43. data/spec/support/schemas/request/channel/create.json +0 -39
  44. data/spec/support/schemas/request/channel/destroy.json +0 -39
  45. data/spec/support/schemas/request/channel/exist.json +0 -41
  46. data/spec/support/schemas/request/channel/list.json +0 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66f20d8377739e714f7694bb0a5094501c89f41d
4
- data.tar.gz: a655ab4468aaf165bbe4aba9391cf1df7010e0aa
3
+ metadata.gz: 86a3d4ef09913351f9fa9de8f78c7966cddbfa58
4
+ data.tar.gz: e67eb734e40d2c9709ec2e49c696ca9799212bb6
5
5
  SHA512:
6
- metadata.gz: b9e11959cda823b1bac8d167ac04d61cfa6a789de29cb7d42a2375bd1f5a19850eac643ef975e55a59e1d98fda94673ad108a4c7feb2851d7211c0b46197f0c2
7
- data.tar.gz: 86a773c15454746076dfa43b5c49d15b00c37ad0cf0ef07b399c8f9124bc808c80dd180d23646669cb99cb58548af8871989e28ab4dda8c34239a0012324a034
6
+ metadata.gz: 0168717d3cb9d059ab7af70c079a9bd912cc2d6b0edcdcbd1e9433980127b5874a8ce0cc6ba269134607047e010aabf48932fcc96f0c6dd5f357b3719ba9ad65
7
+ data.tar.gz: af44f0c6e01d69e5f551d19134f36b1d4d6196c62764533b0f99e4b994041084ba336a5375c72992832b8fbea72da03698be335a8cb1e9fc327a9b59cddc5475
data/README.md CHANGED
@@ -6,11 +6,11 @@
6
6
 
7
7
  Ruby Gem for Janus WebRTC Gateway integration using RabbitMQ message queue
8
8
 
9
- This gem is used to communicate to a server Janus through RabbitMQ software (
10
- Message-oriented middleware). It waiting a messages to Rails API who send to RabbitMQ
11
- server in a queue for janus server. janus processes a message and send to RabbitMQ server
12
- in a queue for gem. Once the received message is decoded and returned through the Rails API.
13
-
9
+ This gem is used to communicate to a server Janus through RabbitMQ software
10
+ (Message-oriented middleware). It waiting a messages to Rails API who send to
11
+ RabbitMQ server in a queue for janus server. janus processes a message and send
12
+ to RabbitMQ server in a queue for gem. Once the received message is decoded
13
+ and returned through the Rails API.
14
14
 
15
15
  This gem is product by [Dazzl.tv](http://dazzl.tv)
16
16
 
@@ -48,17 +48,11 @@ Use generator for complete installation :
48
48
  ```ruby
49
49
  rails g -h
50
50
  RubyRabbitmqJanus:
51
- ruby_rabbitmq_janus:configuration
52
- # Generate a custom configuration file.
53
-
54
- ruby_rabbitmq_janus:default_request
55
- # Copy base request file sending to janus in application. It's necessary if you want add your request.
56
-
57
- ruby_rabbitmq_janus:initializer
58
- # Generate a initializer to this gem for rails application.
59
-
60
- ruby_rabbitmq_janus:create_request
61
- # Create an request to json format for RubyRabbitmqJanus transaction.
51
+ ruby_rabbitmq_janus:configuration # Generate a custom configuration file.
52
+ ruby_rabbitmq_janus:create_request # Create an request to json format for RubyRabbitmqJanus transaction.
53
+ ruby_rabbitmq_janus:default_request # Copy base request file sending to janus in application.
54
+ ruby_rabbitmq_janus:initializer # Generate a initializer to this gem for rails application.
55
+ ruby_rabbitmq_janus:install # Install RubyRabbitmqJanus in your Rails application
62
56
  ```
63
57
 
64
58
  #### Requests
@@ -90,18 +84,27 @@ rabbitmq and use plugin echotest for janus server.
90
84
 
91
85
  Use tags for rspec :
92
86
 
93
- | type | name |
94
- | --------------- | --------------- |
95
- | request | attach |
96
- | | create |
97
- | | detach |
98
- | | info |
99
- | | test |
100
- | level | base |
101
- | | admin |
102
- | config | rabbit |
103
- | | log |
104
- | | config |
87
+ | Describe | Type | Name |
88
+ | ------------------------------------------------------------- | --------------- | --------------- |
89
+ | **Internaly function** | config | |
90
+ | Use bunny gem | | rabbit |
91
+ | Test log functions | | log |
92
+ | Test configuration function | | config |
93
+ | Test Gem contains CONSTANTS | | describe |
94
+ | **Level request sending to janus (admin monitor API or classic)** | level | |
95
+ | Request with no admin right. | | base |
96
+ | Request with admin right in Janus application. | | admin |
97
+ | **Request JSON sending to Rabbitmq -> Janus** | request | |
98
+ | Test request attach type | | attach |
99
+ | Test request type create | | create |
100
+ | Test request type detach | | detach |
101
+ | Test request type info | | info |
102
+ | Test request type test | | test |
103
+
104
+ Example usage rspec with tags :
105
+ ```ruby
106
+ rspec --tag --name:config --tag level:base
107
+ ```
105
108
 
106
109
  ## Upgrade
107
110
 
@@ -4,8 +4,8 @@
4
4
  "handle_id": "<number>",
5
5
  "transaction": "<string>",
6
6
  "body": {
7
- "audio": "true",
8
- "video": "true"
7
+ "audio": true,
8
+ "video": true
9
9
  },
10
10
  "jsep": {
11
11
  "type": "offer",
@@ -15,7 +15,7 @@ module RubyRabbitmqJanus
15
15
  end
16
16
 
17
17
  # Define an exception if gem dont initialize correctly
18
- class InstaciateGemFailed < RRJ
18
+ class InstanciateGemFailed < RRJ
19
19
  # Initialize a error for instanciate class. It's a fatal error
20
20
  # @param [String] message Text returning in raise
21
21
  def initialize(message)
@@ -11,5 +11,19 @@ module RubyRabbitmqJanus
11
11
  super message, :fatal
12
12
  end
13
13
  end
14
+
15
+ # Execpetion primary for Rabbit class
16
+ class Rabbit < RRJError
17
+ def initialize(message)
18
+ super "[Rabbit]#{message}", :fatal
19
+ end
20
+ end
21
+
22
+ # Send exception when publish a message to rabbitmq failed
23
+ class RabbitPublishMessage < Rabbit
24
+ def initialize(message, request)
25
+ super "[Publish] #{message} -- #{request}"
26
+ end
27
+ end
14
28
  end
15
29
  end
data/lib/rrj/info.rb CHANGED
@@ -1,9 +1,23 @@
1
1
  # frozen_string_literal: true
2
+ # :reek:TooManyConstants
3
+
2
4
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
3
5
  # Define constant to gem.
4
6
  module RubyRabbitmqJanus
5
7
  # Define version to gem
6
- VERSION = '1.2.2'
8
+ VERSION = '1.2.3'
9
+
10
+ # Name to gem
11
+ GEM_NAME = 'ruby_rabbitmq_janus'
12
+
13
+ # Authors
14
+ AUTHORS = ['VAILLANT Jeremy'].freeze
15
+
16
+ # Emails
17
+ EMAILS = ['jeremy@dazzl.tv'].freeze
18
+
19
+ # Licence
20
+ LICENSE = 'MIT'
7
21
 
8
22
  # Define a summary description to gem
9
23
  SUMMARY = 'Ruby RabbitMQ Janus'
data/lib/rrj/init.rb CHANGED
@@ -87,7 +87,7 @@ module RubyRabbitmqJanus
87
87
  #
88
88
  # @example Sending an message create
89
89
  # RubyRabbitmqJanus::RRJ.new.message_session('base::create')
90
- # n#=> {"janus":"server_info","name":"Janus WebRTC Gateway" ... }
90
+ # #=> {"janus":"server_info","name":"Janus WebRTC Gateway" ... }
91
91
  #
92
92
  # @return [RubyRabbitmqJanus::Janus::Responses::Standard]
93
93
  # Give an object response to janus server
@@ -202,7 +202,7 @@ module RubyRabbitmqJanus
202
202
  #
203
203
  # @since 1.0.0
204
204
  def handle_message_simple(type, options = { 'replace' => {}, 'add' => {} })
205
- @transaction = Janus::Transactions::Handle.new(@session,
205
+ @transaction = Janus::Transactions::Handle.new(session?(options),
206
206
  false,
207
207
  handle?(options))
208
208
  @transaction.connect { message_handle(type, options) }
@@ -218,9 +218,17 @@ module RubyRabbitmqJanus
218
218
  { 'session_id' => @session } unless option.key?('session_id')
219
219
  end
220
220
 
221
+ def session?(options)
222
+ return_value(options, 'session_id', @session)
223
+ end
224
+
221
225
  def handle?(options)
222
- replace = options['replace']
223
- replace.key?('handle_id') ? replace['handle_id'] : 0
226
+ return_value(options, 'handle_id', 0)
227
+ end
228
+
229
+ def return_value(opt, key, value)
230
+ replace = opt['replace']
231
+ replace.key?(key) ? replace[key] : value
224
232
  end
225
233
  end
226
234
  end
@@ -16,7 +16,10 @@ module RubyRabbitmqJanus
16
16
 
17
17
  # Create a thred for execute a block code in a thread
18
18
  #
19
- # @yield Send to publisher the actions when a Janus event is received
19
+ # @param [Proc] block Block code for execute action when queue
20
+ # standard 'from-janus' receive a message.
21
+ #
22
+ # @return [Thread] It's a thread who listen queue and execute action
20
23
  def run(&block)
21
24
  thread.join
22
25
  Thread.new do
@@ -14,7 +14,7 @@ module RubyRabbitmqJanus
14
14
 
15
15
  # Create a thread
16
16
  def initialize
17
- @response = @publish = nil
17
+ @response = @publisher = nil
18
18
  super
19
19
  end
20
20
 
@@ -30,24 +30,30 @@ module RubyRabbitmqJanus
30
30
 
31
31
  def transaction_running
32
32
  @response = Janus::Responses::Standard.new(create_session)
33
- lock.synchronize do
34
- condition.signal
35
- end
36
- loop_session(Tools::Config.instance.ttl)
33
+ synchronize
34
+ create_loop_session
35
+ rescue => error
36
+ raise Errors::KeepaliveLoopSession, error
37
+ end
38
+
39
+ def synchronize
40
+ lock.synchronize { condition.signal }
41
+ end
42
+
43
+ def create_loop_session
44
+ loop { loop_session(Tools::Config.instance.ttl) }
37
45
  end
38
46
 
39
47
  def loop_session(time_to_live)
40
- loop do
41
- sleep time_to_live
42
- @publish.send_a_message(message_keepalive)
43
- end
44
- rescue => error
45
- raise Errors::KeepaliveLoopSession, error
48
+ sleep time_to_live
49
+ @publisher.publish(message_keepalive)
50
+ Tools::Log.instance.info "Keepalive for #{running_session}"
46
51
  end
47
52
 
48
53
  def create_session
49
- @publish = Rabbit::Publisher::PublishExclusive.new(rabbit.channel, '')
50
- @publish.send_a_message(Janus::Messages::Standard.new('base::create'))
54
+ @publisher = Rabbit::Publisher::PublishExclusive.new(rabbit.channel,
55
+ '')
56
+ @publisher.publish(Janus::Messages::Standard.new('base::create'))
51
57
  rescue => error
52
58
  raise Errors::KeepaliveCreateSession, error
53
59
  end
@@ -8,6 +8,13 @@ module RubyRabbitmqJanus
8
8
  # This class work with janus and send a series of message
9
9
  class Admin < Handle
10
10
  # Publish an message in handle
11
+ #
12
+ # @param [String] type
13
+ # Given a type to request. JSON request writing in 'config/requests/'
14
+ # @param [Hash] options Replace/add element to request
15
+ #
16
+ # @return [Janus::Response::Standard] a response to message pusblishing
17
+ # in queue Admin API
11
18
  def publish_message_handle(type, options)
12
19
  opts = {
13
20
  'session_id' => session,
@@ -15,8 +22,7 @@ module RubyRabbitmqJanus
15
22
  'admin_secret' => admin_secret
16
23
  }
17
24
  msg = Janus::Messages::Admin.new(type, opts.merge!(options))
18
- publisher = publish.send_a_message(msg)
19
- Janus::Responses::Standard.new(read_response(publisher))
25
+ Janus::Responses::Standard.new(read_response(publisher.publish(msg)))
20
26
  end
21
27
 
22
28
  private
@@ -24,13 +30,13 @@ module RubyRabbitmqJanus
24
30
  # Define queue used for admin message
25
31
  def choose_queue
26
32
  chan = rabbit.channel
27
- @publish = Rabbit::Publisher::PublisherAdmin.new(chan)
33
+ @publisher = Rabbit::Publisher::PublisherAdmin.new(chan)
28
34
  end
29
35
 
30
36
  # Override method for publishing an message and reading a response
31
37
  def send_a_message
32
38
  Tools::Log.instance.info 'Publish a message ...'
33
- Janus::Responses::Standard.new(publish.send_a_message(yield))
39
+ Janus::Responses::Standard.new(publisher.publish(yield))
34
40
  end
35
41
 
36
42
  # Read a admin pass in configuration file to this gem
@@ -33,11 +33,16 @@ module RubyRabbitmqJanus
33
33
  end
34
34
 
35
35
  # Publish an message in handle
36
+ #
37
+ # @param [String] type Request file used
38
+ # @param [Hash] options Replace/add element in request
39
+ #
40
+ # @return [Janus::Responses::Standard] Response to message sending
36
41
  def publish_message_handle(type, options)
37
42
  opts = { 'session_id' => session, 'handle_id' => handle }
38
43
  msg = Janus::Messages::Standard.new(type, opts.merge!(options))
39
- publisher = publish.send_a_message(msg)
40
- Janus::Responses::Standard.new(read_response(publisher))
44
+ response = read_response(publisher.publish(msg))
45
+ Janus::Responses::Standard.new(response)
41
46
  end
42
47
 
43
48
  private
@@ -61,7 +66,7 @@ module RubyRabbitmqJanus
61
66
  def read_response_exclusive
62
67
  chan = rabbit.channel
63
68
  tmp_publish = Rabbit::Publisher::PublishExclusive.new(chan, '')
64
- tmp_publish.send_a_message(yield)
69
+ tmp_publish.publish(yield)
65
70
  end
66
71
  end
67
72
  end
@@ -16,32 +16,33 @@ module RubyRabbitmqJanus
16
16
  def initialize(session)
17
17
  @rabbit = Rabbit::Connect.new
18
18
  @session = session
19
- @publish = @exclusive = nil
19
+ @publisher = @exclusive = nil
20
20
  rescue => error
21
21
  raise Errors::JanusTransaction, error
22
22
  end
23
23
 
24
24
  private
25
25
 
26
- attr_reader :rabbit, :session, :response, :handle, :publish, :exclusive
26
+ attr_reader :rabbit, :session, :response, :handle, :publisher,
27
+ :exclusive
27
28
 
28
29
  def choose_queue
29
30
  chan = @rabbit.channel
30
- @publish = if @exclusive
31
- Tools::Log.instance.debug \
32
- 'Choose an queue Exclusive : ampq.gen-xxx'
33
- Rabbit::Publisher::PublishExclusive.new(chan, '')
34
- else
35
- Tools::Log.instance.debug \
36
- 'Choose an queue non Exclusive : to-janus'
37
- Rabbit::Publisher::PublishNonExclusive.new(chan)
38
- end
31
+ @publisher = if @exclusive
32
+ Tools::Log.instance.debug \
33
+ 'Choose an queue Exclusive : ampq.gen-xxx'
34
+ Rabbit::Publisher::PublishExclusive.new(chan, '')
35
+ else
36
+ Tools::Log.instance.debug \
37
+ 'Choose an queue non Exclusive : to-janus'
38
+ Rabbit::Publisher::PublishNonExclusive.new(chan)
39
+ end
39
40
  end
40
41
 
41
42
  def send_a_message
42
43
  Tools::Log.instance.info 'Publish a message ...'
43
- publish = @publish.send_a_message(yield)
44
- Janus::Responses::Standard.new(read_response(publish))
44
+ response = read_response(@publisher.publish(yield))
45
+ Janus::Responses::Standard.new(response)
45
46
  end
46
47
 
47
48
  def read_response(publish)
@@ -14,7 +14,7 @@ module RubyRabbitmqJanus
14
14
  end
15
15
 
16
16
  # Send an message to queue and waiting a response
17
- def send_a_message(request)
17
+ def publish(request)
18
18
  super(request)
19
19
  return_response
20
20
  end
@@ -4,8 +4,15 @@ module RubyRabbitmqJanus
4
4
  module Rabbit
5
5
  module Publisher
6
6
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
7
+ # # Publish message
8
+ #
9
+ # Publish message in queue exclusive. Bunny create automaticaly a name for
10
+ # this queue. The queue name like to 'amq.gen-1A456DGVHDVUS'.
7
11
  class PublishExclusive < Publisher
8
12
  # Initialize an queue exclusive and generated automaticaly by bunny
13
+ #
14
+ # @param [String] exchange Exchange used for the transaction
15
+ # @param [String] name_queue Name to queue exclusive
9
16
  def initialize(exchange, name_queue)
10
17
  @reply = exchange.queue(name_queue, exclusive: true)
11
18
  super(exchange)
@@ -13,7 +20,7 @@ module RubyRabbitmqJanus
13
20
  end
14
21
 
15
22
  # Send an message to queue and waiting a response
16
- def send_a_message(request)
23
+ def publish(request)
17
24
  super(request)
18
25
  return_response
19
26
  end
@@ -14,7 +14,7 @@ module RubyRabbitmqJanus
14
14
  end
15
15
 
16
16
  # Send an message to queue
17
- def send_a_message(request)
17
+ def publish(request)
18
18
  super(request)
19
19
  end
20
20
 
@@ -18,11 +18,13 @@ module RubyRabbitmqJanus
18
18
  end
19
19
 
20
20
  # Publish an message in queue
21
- def send_a_message(request)
21
+ def publish(request)
22
22
  Tools::Log.instance.info "Send request type : #{request.type}"
23
23
  @message = request
24
24
  @exchange.publish(@message.to_json,
25
25
  request.options.merge!(reply_to: queue_name))
26
+ rescue => error
27
+ raise Errors::RabbitPublishMessage, error, request
26
28
  end
27
29
 
28
30
  private
@@ -9,6 +9,8 @@ module RubyRabbitmqJanus
9
9
  #
10
10
  # @!attribute [r] options
11
11
  # @return [Hash] Return all options to configured in config file.
12
+ # @!attribute [r] configuration
13
+ # @return [String] Path to configuration file used
12
14
  class Config
13
15
  include Singleton
14
16
 
@@ -32,7 +32,7 @@ module RubyRabbitmqJanus
32
32
 
33
33
  # Replace sdp in request
34
34
  def replace_sdp
35
- request['jsep']['sdp'] = opts['replace']['sdp']
35
+ request['jsep']['sdp'] = opts['replace']['sdp'].gsub("\n", "\r\n")
36
36
  rescue => message
37
37
  Tools::Log.instance.warn "Error sdp replace : #{message}"
38
38
  end
@@ -17,6 +17,7 @@ module RubyRabbitmqJanus
17
17
  case @request[key]
18
18
  when '<string>' then convert_to_type_string
19
19
  when '<number>' then convert_to_type_number
20
+ when '<boolean>' then convert_to_type_boolean
20
21
  end
21
22
  end
22
23
 
@@ -31,6 +32,15 @@ module RubyRabbitmqJanus
31
32
  def convert_to_type_number
32
33
  @data.to_i
33
34
  end
35
+
36
+ # Convert a data to Boolean type
37
+ def convert_to_type_boolean
38
+ if @data.casecmp('TRUE')
39
+ true
40
+ elsif @data.casecmp('FALSE')
41
+ false
42
+ end
43
+ end
34
44
  end
35
45
  end
36
46
  end
@@ -0,0 +1,3 @@
1
+ {
2
+ "error": "Request is False !!"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "error": "Request is False !!"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "error": "Request is False !!"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "error": "Request is False !!"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "error": "Request is False !!"
3
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "janus": "create",
3
+ "transaction": "<string>"
4
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "error": "Request is False !!"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "error": "Request is False !!"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "error": "Request is False !!"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "error": "Request is False !!"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "error": "Request is False !!"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "error": "Request is False !!"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "error": "Request is False !!"
3
+ }
@@ -2,13 +2,13 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe 'RubyRabbitmqJanus::RRJ -- message type offer', broken: true do
5
+ describe 'RubyRabbitmqJanus::RRJ -- message type offer' do
6
6
  before(:example) do
7
7
  sdp = <<END
8
8
  v=0
9
9
  o=- 7041456084360858977 2 IN IP4 127.0.0.1
10
10
  s=-
11
- t=0 0
11
+ t=0 0
12
12
  a=group:BUNDLE audio video
13
13
  a=msid-semantic: WMS 2jKToeOlpzKTn7anwnHOJmzFyhvEYt1kpcMY
14
14
  m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 126
@@ -94,12 +94,10 @@ a=ssrc:258141567 mslabel:2jKToeOlpzKTn7anwnHOJmzFyhvEYt1kpcMY
94
94
  a=ssrc:258141567 label:25d58816-114a-41d2-aa08-1039e09f942f
95
95
  END
96
96
  @type = 'peer::offer'
97
- @options = { 'replace' => { 'sdp' => sdp }, 'add' => {} }
97
+ @options = { 'replace' => { 'sdp' => sdp.to_s }, 'add' => {} }
98
98
  end
99
99
 
100
100
  describe '#message_handle', type: :request, level: :peer, name: :offer do
101
- let(:sdp) { 'v=0\r\no=[..more sdp stuff..]' }
102
-
103
101
  context 'when queue is exclusive' do
104
102
  it_behaves_like 'message_handle should match json schema'
105
103
  end
@@ -21,7 +21,7 @@ describe RubyRabbitmqJanus::Tools::Config, type: :config, name: :config do
21
21
  expect(@cfg.plugin_at).to be_a(String)
22
22
  end
23
23
 
24
- it 'When janus/plugins/0 defualt value is lading' do
24
+ it 'When janus/plugins/0 default value is loading' do
25
25
  expect(@cfg.plugin_at).to eq 'janus.plugin.echotest'
26
26
  end
27
27
 
data/spec/rrj/rrj_spec.rb CHANGED
@@ -3,23 +3,49 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe 'RubyRabbitmqJanus::RRJ', type: :config, name: :describe do
6
- it 'Has a version number' do
7
- expect(RubyRabbitmqJanus::VERSION).not_to be nil
6
+ context 'Has a version number' do
7
+ let(:data) { RubyRabbitmqJanus::VERSION }
8
+ it_behaves_like 'constant is', String
8
9
  end
9
10
 
10
- it 'Has a description' do
11
- expect(RubyRabbitmqJanus::DESCRIPTION).not_to be nil
11
+ context 'Has a name' do
12
+ let(:data) { RubyRabbitmqJanus::GEM_NAME }
13
+ it_behaves_like 'constant is', String
12
14
  end
13
15
 
14
- it 'Has a summary description' do
15
- expect(RubyRabbitmqJanus::SUMMARY).not_to be nil
16
+ context 'Has a author' do
17
+ let(:data) { RubyRabbitmqJanus::AUTHORS }
18
+ it_behaves_like 'constant is', Array
16
19
  end
17
20
 
18
- it 'Has a homepage' do
19
- expect(RubyRabbitmqJanus::HOMEPAGE).not_to be nil
21
+ context 'Has a email' do
22
+ let(:data) { RubyRabbitmqJanus::EMAILS }
23
+ it_behaves_like 'constant is', Array
20
24
  end
21
25
 
22
- it 'Has a post install message' do
23
- expect(RubyRabbitmqJanus::POST_INSTALL).not_to be nil
26
+ context 'Has a license' do
27
+ let(:data) { RubyRabbitmqJanus::LICENSE }
28
+ it_behaves_like 'constant is', String
29
+ it { expect('../../LICENSE').to be_an_existing_file }
30
+ end
31
+
32
+ context 'Has a description' do
33
+ let(:data) { RubyRabbitmqJanus::DESCRIPTION }
34
+ it_behaves_like 'constant is', String
35
+ end
36
+
37
+ context 'Has a summary description' do
38
+ let(:data) { RubyRabbitmqJanus::SUMMARY }
39
+ it_behaves_like 'constant is', String
40
+ end
41
+
42
+ context 'Has a homepage' do
43
+ let(:data) { RubyRabbitmqJanus::HOMEPAGE }
44
+ it_behaves_like 'constant is', String
45
+ end
46
+
47
+ context 'Has a post install message' do
48
+ let(:data) { RubyRabbitmqJanus::POST_INSTALL }
49
+ it_behaves_like 'constant is', String
24
50
  end
25
51
  end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ shared_examples 'constant is' do |type|
4
+ it { expect(data).not_to be nil }
5
+ it { expect(data).to be_kind_of(type) }
6
+ end
@@ -78,3 +78,20 @@ shared_examples 'message_admin should match json schema' do
78
78
  expect(message.to_json).to match_json_schema(@type)
79
79
  end
80
80
  end
81
+
82
+ # Simple request
83
+ shared_examples 'peer message_simple should match json empty' do
84
+ let(:message) { @gateway.message_simple(@type) }
85
+
86
+ it 'should match JSON empty' do
87
+ expect(message.to_json).to eq('{}')
88
+ end
89
+ end
90
+
91
+ shared_examples 'peer message_simple should match json schema' do
92
+ let(:message) { @gateway.message_simple(@type, true) }
93
+
94
+ it do
95
+ expect(message.to_json).to match_json_schema(@type)
96
+ end
97
+ end
@@ -3,13 +3,11 @@
3
3
  "properties": {
4
4
  "janus": { "type": "string", "pattern": "ack" },
5
5
  "transaction": { "type": "string" },
6
- "session_id": { "type": "integer" },
7
- "handle_id": { "type": "integer" }
6
+ "session_id": { "type": "integer" }
8
7
  },
9
8
  "required": [
10
9
  "janus",
11
10
  "transaction",
12
- "session_id",
13
- "handle_id"
11
+ "session_id"
14
12
  ]
15
13
  }
@@ -3,13 +3,11 @@
3
3
  "properties": {
4
4
  "janus": { "type": "string", "pattern": "ack" },
5
5
  "transaction": { "type": "string" },
6
- "session_id": { "type": "integer" },
7
- "handle_id": { "type": "integer" }
6
+ "session_id": { "type": "integer" }
8
7
  },
9
8
  "required": [
10
9
  "janus",
11
10
  "transaction",
12
- "session_id",
13
- "handle_id"
11
+ "session_id"
14
12
  ]
15
13
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_rabbitmq_janus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3.pre.53
5
5
  platform: ruby
6
6
  authors:
7
7
  - VAILLANT Jeremy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-16 00:00:00.000000000 Z
11
+ date: 2017-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '12.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '12.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -285,7 +285,7 @@ description: |
285
285
  to RabbitMQ server in a queue for gem. Once the received message is decoded and
286
286
  returned through the Rails API.
287
287
  email:
288
- - jeremy.vaillant@dazzl.tv
288
+ - jeremy@dazzl.tv
289
289
  executables: []
290
290
  extensions: []
291
291
  extra_rdoc_files: []
@@ -359,6 +359,19 @@ files:
359
359
  - lib/rrj/tools/requests.rb
360
360
  - lib/rrj/tools/tools.rb
361
361
  - lib/ruby_rabbitmq_janus.rb
362
+ - spec/fixtures/config/requests/admin/handle_info.json
363
+ - spec/fixtures/config/requests/admin/handles.json
364
+ - spec/fixtures/config/requests/admin/log_level.json
365
+ - spec/fixtures/config/requests/admin/sessions.json
366
+ - spec/fixtures/config/requests/base/attach.json
367
+ - spec/fixtures/config/requests/base/create.json
368
+ - spec/fixtures/config/requests/base/destroy.json
369
+ - spec/fixtures/config/requests/base/detach.json
370
+ - spec/fixtures/config/requests/base/info.json
371
+ - spec/fixtures/config/requests/base/keepalive.json
372
+ - spec/fixtures/config/requests/peer/answer.json
373
+ - spec/fixtures/config/requests/peer/offer.json
374
+ - spec/fixtures/config/requests/peer/trickle.json
362
375
  - spec/request/admin/request_handle_info_spec.rb
363
376
  - spec/request/admin/request_sessions_spec.rb
364
377
  - spec/request/base/request_attach_spec.rb
@@ -367,7 +380,6 @@ files:
367
380
  - spec/request/base/request_detach_spec.rb
368
381
  - spec/request/base/request_info_spec.rb
369
382
  - spec/request/base/request_keepalive_spec.rb
370
- - spec/request/peer/request_answer_spec.rb
371
383
  - spec/request/peer/request_offer_spec.rb
372
384
  - spec/request/peer/request_trickle_spec.rb
373
385
  - spec/rrj/rrj_config_spec.rb
@@ -376,8 +388,8 @@ files:
376
388
  - spec/rrj/rrj_spec.rb
377
389
  - spec/spec_helper.rb
378
390
  - spec/support/aruba.rb
379
- - spec/support/examples.rb
380
- - spec/support/examples_peer.rb
391
+ - spec/support/examples_config.rb
392
+ - spec/support/examples_request.rb
381
393
  - spec/support/schemas/config/config.json
382
394
  - spec/support/schemas/config/rabbit.json
383
395
  - spec/support/schemas/request/admin/handle_info.json
@@ -388,10 +400,6 @@ files:
388
400
  - spec/support/schemas/request/base/detach.json
389
401
  - spec/support/schemas/request/base/info.json
390
402
  - spec/support/schemas/request/base/keepalive.json
391
- - spec/support/schemas/request/channel/create.json
392
- - spec/support/schemas/request/channel/destroy.json
393
- - spec/support/schemas/request/channel/exist.json
394
- - spec/support/schemas/request/channel/list.json
395
403
  - spec/support/schemas/request/peer/answer.json
396
404
  - spec/support/schemas/request/peer/offer.json
397
405
  - spec/support/schemas/request/peer/trickle.json
@@ -427,9 +435,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
427
435
  version: '0'
428
436
  required_rubygems_version: !ruby/object:Gem::Requirement
429
437
  requirements:
430
- - - ">="
438
+ - - ">"
431
439
  - !ruby/object:Gem::Version
432
- version: '0'
440
+ version: 1.3.1
433
441
  requirements: []
434
442
  rubyforge_project:
435
443
  rubygems_version: 2.5.1
@@ -1,66 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe 'RubyRabbitmqJanus::RRJ -- message type answer', broken: true do
6
- before(:example) do
7
- sdp = <<END
8
- v=0
9
- o=- 7041456084360858977 2 IN IP4 127.0.0.1
10
- s=-
11
- t=0 0
12
- a=group:BUNDLE audio video
13
- a=msid-semantic: WMS 2jKToeOlpzKTn7anwnHOJmzFyhvEYt1kpcMY
14
- m=audio 9 UDP/TLS/RTP/SAVPF 111
15
- c=IN IP4 0.0.0.0
16
- a=rtcp:9 IN IP4 0.0.0.0
17
- a=ice-ufrag:T9QI
18
- a=ice-pwd:s9YvfGuavTZN0Lqc53JNInEP
19
- a=fingerprint:sha-256 6D:ED:BC:93:AC:EC:C2:29:03:7D:6A:60:9F:D3:F5:A1:6D:1A:38:CE:F0:C0:EC:C8:5D:87:19:19:BE:0F:89:BB
20
- a=setup:actpass
21
- a=mid:audio
22
- a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
23
- a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
24
- a=sendonly
25
- a=rtcp-mux
26
- a=rtpmap:111 opus/48000/2
27
- a=rtcp-fb:111 transport-cc
28
- a=fmtp:111 minptime=10;useinbandfec=1
29
- m=video 9 UDP/TLS/RTP/SAVPF 100
30
- c=IN IP4 0.0.0.0
31
- a=rtcp:9 IN IP4 0.0.0.0
32
- a=ice-ufrag:T9QI
33
- a=ice-pwd:s9YvfGuavTZN0Lqc53JNInEP
34
- a=fingerprint:sha-256 6D:ED:BC:93:AC:EC:C2:29:03:7D:6A:60:9F:D3:F5:A1:6D:1A:38:CE:F0:C0:EC:C8:5D:87:19:19:BE:0F:89:BB
35
- a=setup:actpass
36
- a=mid:video
37
- a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
38
- a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
39
- a=extmap:4 urn:3gpp:video-orientation
40
- a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
41
- a=sendonly
42
- a=rtcp-mux
43
- a=rtcp-rsize
44
- a=rtpmap:100 VP8/90000
45
- a=rtcp-fb:100 ccm fir
46
- a=rtcp-fb:100 nack
47
- a=rtcp-fb:100 nack pli
48
- a=rtcp-fb:100 goog-remb
49
- a=rtcp-fb:100 transport-cc
50
- END
51
- @type = 'peer::answer'
52
- @options = { 'replace' => { 'sdp' => sdp }, 'add' => {} }
53
- end
54
-
55
- describe '#message_handle', type: :request, level: :peer, name: :answer do
56
- context 'when queue is exclusive' do
57
- it_behaves_like 'message_handle should match json schema'
58
- end
59
-
60
- context 'when queue is not exclusive' do
61
- it_behaves_like 'message_handle should match json empty'
62
- end
63
- end
64
-
65
- after(:example) { @gateway.handle_message_simple('base::detach') }
66
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Simple request
4
- shared_examples 'peer message_simple should match json empty' do
5
- let(:message) { @gateway.message_simple(@type) }
6
-
7
- it 'should match JSON empty' do
8
- expect(message.to_json).to eq('{}')
9
- end
10
- end
11
-
12
- shared_examples 'peer message_simple should match json schema' do
13
- let(:message) { @gateway.message_simple(@type, true) }
14
-
15
- it do
16
- expect(message.to_json).to match_json_schema(@type)
17
- end
18
- end
@@ -1,39 +0,0 @@
1
- {
2
- "type": "object",
3
- "properties": {
4
- "janus": { "type": "string", "pattern": "success" },
5
- "session_id": { "type": "integer" },
6
- "transaction": { "type": "string" },
7
- "sender": { "type": "integer" },
8
- "plugindata": {
9
- "type": "hash",
10
- "properties": {
11
- "data": {
12
- "type": "hash",
13
- "properties": {
14
- "videocontrol": { "type": "string", "pattern": "created" },
15
- "channel": { "type": "integer"}
16
- },
17
- "required": [
18
- "videocontrol",
19
- "channel"
20
- ]
21
- },
22
- "plugin": {
23
- "type": "string"
24
- }
25
- },
26
- "required": [
27
- "plugin",
28
- "data"
29
- ]
30
- }
31
- },
32
- "required": [
33
- "janus",
34
- "session_id",
35
- "sender",
36
- "transaction",
37
- "plugindata"
38
- ]
39
- }
@@ -1,39 +0,0 @@
1
- {
2
- "type": "object",
3
- "properties": {
4
- "janus": { "type": "string", "pattern": "success" },
5
- "session_id": { "type": "integer" },
6
- "transaction": { "type": "string" },
7
- "sender": { "type": "integer" },
8
- "plugindata": {
9
- "type": "hash",
10
- "properties": {
11
- "data": {
12
- "type": "hash",
13
- "properties": {
14
- "videocontrol": { "type": "string", "pattern": "destroyed" },
15
- "channel": { "type": "integer"}
16
- },
17
- "required": [
18
- "videocontrol",
19
- "channel"
20
- ]
21
- },
22
- "plugin": {
23
- "type": "string"
24
- }
25
- },
26
- "required": [
27
- "data",
28
- "plugin"
29
- ]
30
- }
31
- },
32
- "required": [
33
- "janus",
34
- "session_id",
35
- "sender",
36
- "transaction",
37
- "plugindata"
38
- ]
39
- }
@@ -1,41 +0,0 @@
1
- {
2
- "type": "object",
3
- "properties": {
4
- "janus": { "type": "string", "pattern": "success" },
5
- "session_id": { "type": "integer" },
6
- "transaction": { "type": "string" },
7
- "sender": { "type": "integer" },
8
- "plugindata": {
9
- "type": "hash",
10
- "properties": {
11
- "data": {
12
- "type": "hash",
13
- "properties": {
14
- "videocontrol": { "type": "string", "pattern": "success" },
15
- "channel": { "type": "integer"},
16
- "exists": { "type": "boolean" }
17
- },
18
- "required": [
19
- "videocontrol",
20
- "channel",
21
- "exists"
22
- ]
23
- },
24
- "plugin": {
25
- "type": "string"
26
- }
27
- },
28
- "required": [
29
- "plugin",
30
- "data"
31
- ]
32
- }
33
- },
34
- "required": [
35
- "janus",
36
- "session_id",
37
- "sender",
38
- "transaction",
39
- "plugindata"
40
- ]
41
- }
@@ -1,37 +0,0 @@
1
- {
2
- "type": "object",
3
- "properties": {
4
- "janus": { "type": "string", "pattern": "success" },
5
- "session_id": { "type": "integer" },
6
- "transaction": { "type": "string" },
7
- "sender": { "type": "integer" },
8
- "plugindata": {
9
- "type": "hash",
10
- "properties": {
11
- "data": {
12
- "type": "hash",
13
- "properties": {
14
- "videocontrol": { "type": "string" },
15
- "list": { "type": "array" }
16
- },
17
- "required": [
18
- "videocontrol",
19
- "list"
20
- ]
21
- },
22
- "plugin": { "type": "string" }
23
- },
24
- "required": [
25
- "data",
26
- "plugin"
27
- ]
28
- }
29
- },
30
- "required": [
31
- "janus",
32
- "session_id",
33
- "sender",
34
- "transaction",
35
- "plugindata"
36
- ]
37
- }