ruby_rabbitmq_janus 1.1.12 → 1.2.0
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.
- checksums.yaml +4 -4
- data/README.md +127 -0
- data/Rakefile +1 -3
- data/config/default.md +14 -14
- data/config/default.yml +12 -18
- data/config/requests.md +80 -0
- data/config/requests/{channel → peer}/answer.json +1 -1
- data/config/requests/{channel → peer}/offer.json +0 -0
- data/lib/generators/ruby_rabbitmq_janus/install_generator.rb +1 -0
- data/lib/rrj/errors/config.rb +8 -1
- data/lib/rrj/errors/error.rb +18 -5
- data/lib/rrj/errors/janus.rb +4 -2
- data/lib/rrj/errors/janus_message.rb +19 -15
- data/lib/rrj/errors/janus_response.rb +13 -26
- data/lib/rrj/errors/janus_transaction.rb +7 -13
- data/lib/rrj/errors/rabbit.rb +3 -9
- data/lib/rrj/info.rb +1 -1
- data/lib/rrj/init.rb +118 -68
- data/lib/rrj/janus/processus/concurrency.rb +8 -22
- data/lib/rrj/janus/processus/event.rb +13 -15
- data/lib/rrj/janus/processus/keepalive.rb +20 -15
- data/lib/rrj/janus/responses/response.rb +0 -1
- data/lib/rrj/janus/transactions/admin.rb +14 -22
- data/lib/rrj/janus/transactions/handle.rb +19 -33
- data/lib/rrj/janus/transactions/session.rb +13 -6
- data/lib/rrj/janus/transactions/transaction.rb +16 -24
- data/lib/rrj/rabbit/connect.rb +3 -4
- data/lib/rrj/rabbit/propertie.rb +6 -9
- data/lib/rrj/rabbit/publish/admin.rb +1 -1
- data/lib/rrj/rabbit/publish/base_publisher.rb +5 -0
- data/lib/rrj/rabbit/publish/listener.rb +1 -1
- data/lib/rrj/rabbit/publish/non_exclusive.rb +1 -1
- data/lib/rrj/tools/config.rb +44 -18
- data/lib/rrj/tools/log.rb +30 -15
- data/lib/rrj/tools/replaces/admin.rb +1 -3
- data/lib/rrj/tools/replaces/replace.rb +1 -6
- data/lib/rrj/tools/requests.rb +8 -8
- data/lib/rrj/tools/tools.rb +0 -1
- data/lib/ruby_rabbitmq_janus.rb +1 -0
- data/spec/request/admin/request_handle_info_spec.rb +3 -3
- data/spec/request/base/request_attach_spec.rb +7 -10
- data/spec/request/base/request_detach_spec.rb +6 -9
- data/spec/request/peer/request_answer_spec.rb +66 -0
- data/spec/request/peer/request_offer_spec.rb +113 -0
- data/spec/request/peer/request_trickle_spec.rb +9 -11
- data/spec/rrj/rrj_log_spec.rb +1 -6
- data/spec/spec_helper.rb +0 -1
- data/spec/support/examples.rb +6 -9
- data/spec/support/schemas/config/config.json +20 -32
- data/spec/support/schemas/request/peer/answer.json +15 -0
- data/spec/support/schemas/request/peer/offer.json +15 -0
- data/spec/support/schemas/request/peer/trickle.json +4 -12
- metadata +10 -19
- data/config/requests/channel/README.md +0 -29
- data/config/requests/channel/create.json +0 -9
- data/config/requests/channel/describe.json +0 -10
- data/config/requests/channel/destroy.json +0 -10
- data/config/requests/channel/exists.json +0 -10
- data/config/requests/channel/join.json +0 -11
- data/config/requests/channel/leave.json +0 -11
- data/config/requests/channel/list.json +0 -9
- data/config/requests/channel/select.json +0 -11
- data/config/requests/channel/trickle.json +0 -10
- data/config/requests/videocast/join.json +0 -12
- data/config/requests/videocast/leave.json +0 -11
- data/config/ruby-rabbitmq-janus.yml +0 -27
- data/lib/rrj/errors/request.rb +0 -21
- data/lib/rrj/tools/env.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 319f21f0c9819cad786787a0d4d3959d81136ff9
|
4
|
+
data.tar.gz: 04309841a1a11d5e43e1a5869fd4b87e74e2763b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1a66b42070c411b11c6c83c94db4ba3e738d990fdefc404b04ff540ff36e17b816ddec79cdacd1a54c8e861a38fc8a8c5a25b2354619e55c326047d6b218114
|
7
|
+
data.tar.gz: bb9d2e51ba0c821a17d1463a4add055c0479bb395fd41d533e2a35e33e49cefd9f925a612887ebb23acdfe36ba047f984d34bbd7f8e8f8c22ca797143c3cd69d
|
data/README.md
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
[](https://travis-ci.org/dazzl-tv/ruby-rabbitmq-janus)
|
2
|
+
[](https://badge.fury.io/rb/ruby_rabbitmq_janus)
|
3
|
+
[](http://inch-ci.org/github/dazzl-tv/ruby-rabbitmq-janus)
|
4
|
+
|
5
|
+
# ruby-rabbitmq-janus -- RRJ
|
6
|
+
|
7
|
+
Ruby Gem for Janus WebRTC Gateway integration using RabbitMQ message queue
|
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
|
+
|
14
|
+
|
15
|
+
This gem is product by [Dazzl.tv](http://dazzl.tv)
|
16
|
+
|
17
|
+
## Menu
|
18
|
+
* [How to use](#how-to-use)
|
19
|
+
* [Installation](#installation)
|
20
|
+
* [Configuration](#configuration)
|
21
|
+
* [Generators](#generators)
|
22
|
+
* [Requests](#requests)
|
23
|
+
* [Usage](#usage)
|
24
|
+
* [Upgrade](#upgrade)
|
25
|
+
* [Development](#development)
|
26
|
+
* [RSpec](#rspec-test)
|
27
|
+
* [Documentation](#documentation)
|
28
|
+
* [Read documentation](#read-documentation)
|
29
|
+
* [Generate developer documentation](#generate-developer-documentation)
|
30
|
+
|
31
|
+
## How to use
|
32
|
+
|
33
|
+
### Installation
|
34
|
+
|
35
|
+
Use rubygem for installing gem in your application. Add in your Gemfile
|
36
|
+
```ruby
|
37
|
+
gem 'ruby_rabbitmq_janus'
|
38
|
+
```
|
39
|
+
|
40
|
+
### Configuration
|
41
|
+
|
42
|
+
If you want used a customize configuration see [ruby-rabbitmq-janus.yml](config/default.md)
|
43
|
+
|
44
|
+
#### Generators
|
45
|
+
|
46
|
+
Use generator for complete installation :
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
rails g -h
|
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.
|
62
|
+
```
|
63
|
+
|
64
|
+
#### Requests
|
65
|
+
|
66
|
+
For create an new request is simple. Use a command generator :
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
rails g ruby_rabbitmq_janus:create_request test info 'transaction:<string>,body:{plugins:false}'
|
70
|
+
create config/requests/test/info.json
|
71
|
+
```
|
72
|
+
|
73
|
+
For more explain in requests files see [default requests](config/requests.md).
|
74
|
+
|
75
|
+
### Usage
|
76
|
+
|
77
|
+
|
78
|
+
TODO ...
|
79
|
+
|
80
|
+
## Development
|
81
|
+
|
82
|
+
### RSpec test
|
83
|
+
|
84
|
+
```linux
|
85
|
+
bundle exec rspec
|
86
|
+
```
|
87
|
+
|
88
|
+
TIPS: for rspec install janus and rabbitmq server configured by default for user
|
89
|
+
rabbitmq and use plugin echotest for janus server.
|
90
|
+
|
91
|
+
Use tags for rspec :
|
92
|
+
|
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 |
|
105
|
+
|
106
|
+
## Upgrade
|
107
|
+
|
108
|
+
For upgrade your application read [CHANGELOG.md](CHANGELOG.md)
|
109
|
+
|
110
|
+
### Documentation
|
111
|
+
|
112
|
+
#### Read documentation
|
113
|
+
|
114
|
+
The documentation is accessible in [rubydoc](http://www.rubydoc.info/gems/ruby_rabbitmq_janus/)
|
115
|
+
|
116
|
+
#### Generate developer documentation
|
117
|
+
|
118
|
+
This doc is generated with yard.
|
119
|
+
|
120
|
+
```
|
121
|
+
# Genereate doc
|
122
|
+
yard
|
123
|
+
# Launch server
|
124
|
+
yard server
|
125
|
+
```
|
126
|
+
|
127
|
+
[See Yard Getting Started](http://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md)
|
data/Rakefile
CHANGED
@@ -3,9 +3,7 @@
|
|
3
3
|
require 'bundler/gem_tasks'
|
4
4
|
require 'rspec/core/rake_task'
|
5
5
|
|
6
|
-
RSpec::Core::RakeTask.new(:spec)
|
7
|
-
t.rspec_opts = '--tag ~level:admin'
|
8
|
-
end
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
9
7
|
|
10
8
|
RSpec::Core::RakeTask.new(:no_request_spec) do |t|
|
11
9
|
t.rspec_opts = '--tag ~type:request'
|
data/config/default.md
CHANGED
@@ -6,39 +6,39 @@ By default the configuration file look like this :
|
|
6
6
|
|
7
7
|
```yaml
|
8
8
|
rabbit:
|
9
|
-
host:
|
9
|
+
host: localhost
|
10
10
|
port: 5672
|
11
|
-
vhost:
|
12
|
-
user:
|
13
|
-
pass:
|
11
|
+
vhost: /
|
12
|
+
user: guest
|
13
|
+
pass: guest
|
14
14
|
admin_pass: janusoverlord
|
15
15
|
|
16
16
|
queues:
|
17
|
-
|
18
|
-
|
17
|
+
standard:
|
18
|
+
from: from-janus
|
19
|
+
to: to-janus
|
19
20
|
admin:
|
20
|
-
|
21
|
-
|
21
|
+
from: from-janus-admin
|
22
|
+
to: to-janus-admin
|
22
23
|
|
23
24
|
janus:
|
25
|
+
session:
|
26
|
+
keepalive: 45
|
24
27
|
plugins:
|
25
28
|
- janus.plugin.echotest
|
26
29
|
|
27
30
|
gem:
|
28
31
|
log:
|
29
|
-
level:
|
30
|
-
session:
|
31
|
-
keepalive: 45
|
32
|
-
thread:
|
33
|
-
enable: false
|
34
|
-
number: 1
|
32
|
+
level: info
|
35
33
|
```
|
36
34
|
|
37
35
|
## Customize
|
36
|
+
|
38
37
|
For customizing a configuration add a yml file in your rails project in
|
39
38
|
`config/ruby-rabbitmq-janus.yml`, or use rails generator with command `rails generate
|
40
39
|
ruby_rabbitmq_janus:configuration`.
|
41
40
|
|
42
41
|
## Ressources
|
42
|
+
|
43
43
|
* [Configuration of RabbitMQ](https://www.rabbitmq.com/configure.html#config-items)
|
44
44
|
* [Configuration of Janus queue](https://janus.conf.meetecho.com/docs/rest.html#rabbit)
|
data/config/default.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Rabbit information connection
|
2
2
|
rabbit:
|
3
3
|
# Precise RabbitMQ host - Default 'localhost'
|
4
|
-
host:
|
4
|
+
host: localhost
|
5
5
|
# Precise RabbitMQ port - Default '5672'
|
6
6
|
port: 5672
|
7
7
|
# Precise RabbitMQ vhost - Default '/'
|
@@ -15,19 +15,23 @@ rabbit:
|
|
15
15
|
|
16
16
|
# RabbitMQ Queue information
|
17
17
|
queues:
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
standard:
|
19
|
+
# Queue sending response to janus server
|
20
|
+
from: from-janus
|
21
|
+
# Queue sending a message for janus server
|
22
|
+
to: to-janus
|
23
23
|
admin:
|
24
24
|
# Queue sending response to admin API janus
|
25
|
-
|
25
|
+
from: from-janus-admin
|
26
26
|
# Queue sending a message for admin API janus
|
27
|
-
|
27
|
+
to: to-janus-admin
|
28
28
|
|
29
29
|
# Janus plugin used
|
30
30
|
janus:
|
31
|
+
# Option for sessions
|
32
|
+
session:
|
33
|
+
# Define time to send a keepalive message in seconds
|
34
|
+
keepalive: 55
|
31
35
|
# Create an array to plugin
|
32
36
|
plugins:
|
33
37
|
- janus.plugin.echotest
|
@@ -39,13 +43,3 @@ gem:
|
|
39
43
|
# Define level to log
|
40
44
|
# UNKNOW, FATAL, ERROR, WARN, INFO, DEBUG
|
41
45
|
level: info
|
42
|
-
# Option for sessions
|
43
|
-
session:
|
44
|
-
# Define time to send a keepalive message in seconds
|
45
|
-
keepalive: 45
|
46
|
-
# Option for used multi thread
|
47
|
-
thread:
|
48
|
-
# Boolean for activate options thread
|
49
|
-
enable: false
|
50
|
-
# Number of core
|
51
|
-
number: 1
|
data/config/requests.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# Requests
|
2
|
+
|
3
|
+
## Defaults request
|
4
|
+
|
5
|
+
By default this gem contains many request :
|
6
|
+
|
7
|
+
```linux
|
8
|
+
├── admin
|
9
|
+
│ ├── handle_info.json
|
10
|
+
│ ├── handles.json
|
11
|
+
│ ├── log_level.json
|
12
|
+
│ └── sessions.json
|
13
|
+
├── base
|
14
|
+
│ ├── attach.json
|
15
|
+
│ ├── create.json
|
16
|
+
│ ├── destroy.json
|
17
|
+
│ ├── detach.json
|
18
|
+
│ ├── info.json
|
19
|
+
│ └── keepalive.json
|
20
|
+
├── peer
|
21
|
+
│ ├── answer.json
|
22
|
+
│ ├── offer.json
|
23
|
+
│ ├── trickle.json
|
24
|
+
```
|
25
|
+
|
26
|
+
* Folder `admin` contains admin requests for interact with Janus Admin/Monitor
|
27
|
+
API. [See official docs.](https://janus.conf.meetecho.com/docs/admin.html)
|
28
|
+
* Folder `base` contains base requests for interact with Janus.
|
29
|
+
|
30
|
+
## Request files
|
31
|
+
|
32
|
+
All request is writing in JSON format and contains many informations.
|
33
|
+
|
34
|
+
Example base request with type `'base::info'` :
|
35
|
+
|
36
|
+
```json
|
37
|
+
{
|
38
|
+
"janus": "info",
|
39
|
+
"transaction": "<string>"
|
40
|
+
}
|
41
|
+
```
|
42
|
+
|
43
|
+
For more explain to construct request sending to Janus [see official documentation](https://janus.conf.meetecho.com/docs/rest.html).
|
44
|
+
|
45
|
+
Some fields are customizables. For this fields is a gem to apply a transformation :
|
46
|
+
|
47
|
+
* session_id
|
48
|
+
* handle_id
|
49
|
+
* transaction
|
50
|
+
* candidate
|
51
|
+
* admin_secret - *just for admin secret*
|
52
|
+
* level - *just for admin secret*
|
53
|
+
|
54
|
+
Each fields use an type :
|
55
|
+
|
56
|
+
* "\<number\>" - Is an integer
|
57
|
+
* "\<string\>" - Is a string
|
58
|
+
* "\<plugin[X]\>" - Is a plugin with X is a key to array in config file
|
59
|
+
* "\<array\>" - Is a array. If array contains a single value is transform to string format.
|
60
|
+
|
61
|
+
## Complex request
|
62
|
+
|
63
|
+
Example peer request with type `'peer:offer'` :
|
64
|
+
|
65
|
+
```json
|
66
|
+
{
|
67
|
+
"janus": "message",
|
68
|
+
"session_id": "<number>",
|
69
|
+
"handle_id": "<number>",
|
70
|
+
"transaction": "<string>",
|
71
|
+
"body": {
|
72
|
+
"audio": "true",
|
73
|
+
"video": "true"
|
74
|
+
},
|
75
|
+
"jsep": {
|
76
|
+
"type": "offer",
|
77
|
+
"sdp": "<string>"
|
78
|
+
}
|
79
|
+
}
|
80
|
+
```
|
File without changes
|
data/lib/rrj/errors/config.rb
CHANGED
@@ -3,17 +3,24 @@
|
|
3
3
|
module RubyRabbitmqJanus
|
4
4
|
module Errors
|
5
5
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
6
|
+
|
6
7
|
# Define an error if the configuration file is not here
|
7
8
|
class ConfigFileNotFound < Errors::RRJError
|
9
|
+
# Initialize a error for Config class if file don't exist.
|
10
|
+
# It's a fatal error
|
11
|
+
# @param [String] file Is a file path
|
8
12
|
def initialize(file)
|
9
13
|
super \
|
10
|
-
"Error for configuration file (#{file}), does on exist.", :
|
14
|
+
"Error for configuration file (#{file}), does on exist.", :fatal
|
11
15
|
end
|
12
16
|
end
|
13
17
|
|
14
18
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
19
|
+
|
15
20
|
# Define and error if rubrik level is not present
|
16
21
|
class LevelNotDefine < Errors::RRJError
|
22
|
+
# Initialize a error for config class if log level option is not present.
|
23
|
+
# It's a warning error
|
17
24
|
def initialize
|
18
25
|
super \
|
19
26
|
'Error in configuration file : option level is not present.', :warn
|
data/lib/rrj/errors/error.rb
CHANGED
@@ -1,37 +1,50 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# rubocop:disable Metrics/LineLength
|
3
2
|
|
4
3
|
module RubyRabbitmqJanus
|
5
4
|
# Define all error in gem
|
6
5
|
module Errors
|
7
6
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
7
|
+
|
8
8
|
# Define errors to gems
|
9
9
|
class RRJError < StandardError
|
10
|
+
# Initialize a error standard in this gem
|
11
|
+
# @param [String] message Text returning in raise
|
12
|
+
# @param [Symbol] level Important to error
|
10
13
|
def initialize(message, level)
|
11
14
|
super(message)
|
12
|
-
Tools::Log.
|
15
|
+
log = Tools::Log.instance
|
16
|
+
Tools::Log.instance_method(level).bind(log).call(message)
|
13
17
|
end
|
14
18
|
end
|
15
19
|
|
16
20
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
21
|
+
|
17
22
|
# Define an exception if gem dont initialize correctly
|
18
23
|
class RRJErrorInit < RRJError
|
24
|
+
# Initialize a error for instanciate class. It's a fatal error
|
25
|
+
# @param [String] message Text returning in raise
|
19
26
|
def initialize(message)
|
20
27
|
super "Gem is not instanciate correctly : #{message}", :fatal
|
21
28
|
end
|
22
29
|
end
|
23
30
|
|
24
31
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
32
|
+
|
25
33
|
# Define an error if method message_post given an exception
|
26
34
|
class RRJErrorPost < RRJError
|
35
|
+
# Initialize a error for message posting. It's a fatal error
|
36
|
+
# @param [String] message Text returning in raise
|
27
37
|
def initialize(message)
|
28
38
|
super "Post message is failed : #{message}", :fatal
|
29
39
|
end
|
30
40
|
end
|
31
41
|
|
32
42
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
33
|
-
|
43
|
+
|
44
|
+
# Define an error if method transaction given an exception
|
34
45
|
class RRJErrorTransaction < RRJError
|
46
|
+
# Initialize a error for transaction failed. It's a fatal error
|
47
|
+
# @param [String] message Text returning in raise
|
35
48
|
def initialize(message)
|
36
49
|
super "Transaction is failed : #{message}", :fatal
|
37
50
|
end
|
@@ -40,13 +53,14 @@ module RubyRabbitmqJanus
|
|
40
53
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
41
54
|
# Define an error if method start_handle given an exception
|
42
55
|
class RRJErrorHandle < RRJError
|
56
|
+
# Initialize a error for transaction with a handle. It's a fatal error
|
57
|
+
# @param [String] message Text returning in raise
|
43
58
|
def initialize(message)
|
44
59
|
super "Transaction handle is failed : #{message}", :fatal
|
45
60
|
end
|
46
61
|
end
|
47
62
|
end
|
48
63
|
end
|
49
|
-
# rubocop:enable Metrics/LineLength
|
50
64
|
|
51
65
|
require 'rrj/errors/janus'
|
52
66
|
require 'rrj/errors/janus_message'
|
@@ -55,4 +69,3 @@ require 'rrj/errors/janus_transaction'
|
|
55
69
|
|
56
70
|
require 'rrj/errors/config'
|
57
71
|
require 'rrj/errors/rabbit'
|
58
|
-
require 'rrj/errors/request'
|