ruby_rabbitmq_janus 2.2.0.pre.161 → 2.2.0.pre.164

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 182b09224c0eb5b640dcd29c9a5265db471cd769
4
- data.tar.gz: 99833ee6c55b7274ab3e24d6952e84e053c3c15d
3
+ metadata.gz: 96c8fbfa42ec3311a8128965e4bd53a55a7df0a8
4
+ data.tar.gz: 9f891c23002f7a8911a7921c5e0bc73fae3e7629
5
5
  SHA512:
6
- metadata.gz: e62fd19a4055f94140711753854286529a931efa682b6defd849895a77adb21440e34489cfb8e6bdadb948fbfd9aef3062ffffb6372c65fbd23e7c3aeedb868b
7
- data.tar.gz: 5de6c2f983e83669028a4deaf4e227d964328c1b8ce87be486d6586402910d2b4154edaa37ac4d7d7cf0985bc11391cc3b71c96baee4c6f37244580a25108bd2
6
+ metadata.gz: fa157e373a5caacaadba89f783d490aad03d789526fdfc9efd63e27b2eee576cd73d0010af1edd89ba573b1c5e3aacab12910d70366033e4b35ab6305a2b28ee
7
+ data.tar.gz: 898f711848c38e3a258251db1164737c109322f01938ea3225afaf4e1ca8a1ce041156d7f468317506dce3a037101a7e9adf4a309aa97815b08fb4a9c119345a
@@ -10,7 +10,9 @@ module RubyRabbitmqJanus
10
10
  include RubyRabbitmqJanus::Models::JanusInstanceMethods
11
11
  include RubyRabbitmqJanus::Models::JanusInstanceValidations
12
12
 
13
- alias_attribute :instance, :id
13
+ alias_attribute :instance, :id
14
+ alias_attribute :session_id, :session
15
+ alias_attribute :thread_id, :thread
14
16
 
15
17
  after_create { callback_create_after }
16
18
  after_update { callback_update_after }
@@ -8,8 +8,7 @@ module RubyRabbitmqJanus
8
8
 
9
9
  included do
10
10
  # This instance it's a state (enable or disable)
11
- validates :enable, presence: true,
12
- inclusion: { in: [true, false] }
11
+ validates :enable, inclusion: { in: [true, false] }
13
12
  end
14
13
  end
15
14
  end
@@ -11,10 +11,11 @@ module RubyRabbitmqJanus
11
11
  include RubyRabbitmqJanus::Models::JanusInstanceMethods
12
12
  include RubyRabbitmqJanus::Models::JanusInstanceValidations
13
13
 
14
- field :_id, type: String, as: :instance
15
- field :session, type: Integer
14
+ field :session, type: Integer, as: :session_id
16
15
  field :enable, type: Boolean
17
- field :thread, type: Integer
16
+ field :thread, type: Integer, as: :thread_id
17
+
18
+ alias_attribute :instance, :_id
18
19
 
19
20
  set_callback(:create, :after) { callback_create_after }
20
21
  set_callback(:update, :after) { callback_update_after }
@@ -8,7 +8,6 @@ def load_active_record
8
8
  ActiveRecord::Base.establish_connection(active_record)
9
9
  unless ActiveRecord::Base.connection.table_exists? 'janus_instances'
10
10
  ActiveRecord::Base.connection.create_table(:janus_instances) do |table|
11
- table.integer :instance
12
11
  table.integer :session, limit: 8
13
12
  table.boolean :enable
14
13
  table.integer :thread, limit: 8
@@ -4,7 +4,13 @@ def create_janus_instances
4
4
  instance = RubyRabbitmqJanus::Models::JanusInstance
5
5
 
6
6
  (1..2).each do |number|
7
- instance.create!(instance: number, enable: true)
7
+ id_instance = if ENV['MONGO'].match?('true')
8
+ { _id: number.to_s }
9
+ else
10
+ { id: number }
11
+ end
12
+ janus = instance.create(id_instance.merge(enable: true))
13
+ janus.save
8
14
  end
9
15
  end
10
16
 
@@ -38,10 +44,12 @@ def clear
38
44
  end
39
45
 
40
46
  def find_instance
41
- ji = RubyRabbitmqJanus::Models::JanusInstance.all.sample
42
- @session = { 'session_id' => ji.session }
43
- @instance = { 'instance' => ji.instance }
44
- @session_instance = @session.merge(@instance)
47
+ janus_instance = RubyRabbitmqJanus::Models::JanusInstance.all.sample
48
+ unless janus_instance.nil?
49
+ @session = { 'session_id' => janus_instance.session_id }
50
+ @instance = { 'instance' => janus_instance.instance }
51
+ @session_instance = @session.merge(@instance)
52
+ end
45
53
  end
46
54
 
47
55
  def initializer_rrj(metadata)
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ FactoryGirl.define do
4
+ factory :janus_instance, class: RubyRabbitmqJanus::Models::JanusInstance do
5
+ enable true
6
+ end
7
+ end
@@ -6,12 +6,13 @@ describe 'RubyRabbitmqJanus::RRJ -- message type attach' do
6
6
  before(:example) do
7
7
  clear
8
8
  @type = 'base::attach'
9
+ @options = @session_instance
9
10
  end
10
11
 
11
12
  describe '#start_transaction', type: :request,
12
13
  level: :base,
13
14
  name: :attach do
14
- context 'when queue is exclusive', broken: true do
15
+ context 'when queue is exclusive' do
15
16
  include_examples 'transaction should match json schema'
16
17
  end
17
18
 
@@ -3,32 +3,18 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  # @todo Create a message reading by janus
6
- describe 'RubyRabbitmqJanus::RRJ -- message type offer', broken: true do
6
+ describe 'RubyRabbitmqJanus::RRJ -- message type offer' do
7
7
  before(:example) do
8
8
  clear
9
9
  attach_base
10
10
 
11
11
  @type = 'peer::offer'
12
- @options.merge!({
13
- 'sdp' => <<-SDP
14
- v=0
15
- o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com
16
- s=
17
- c=IN IP4 host.atlanta.example.com
18
- t=0 0
19
- m=audio 49170 RTP/AVP 0 8 97
20
- a=rtpmap:0 PCMU/8000
21
- a=rtpmap:8 PCMA/8000
22
- a=rtpmap:97 iLBC/8000
23
- m=video 51372 RTP/AVP 31 32
24
- a=rtpmap:31 H261/90000
25
- a=rtpmap:32 MPV/90000
26
- SDP
27
- })
12
+ @options.merge!('sdp' => SDP_OFFER).merge!(@session_instance)
28
13
  end
29
14
 
30
15
  describe '#start_transaction_handle', type: :request,
31
16
  level: :peer,
17
+ broken: true,
32
18
  name: :offer do
33
19
  context 'when queue is exclusive' do
34
20
  it_behaves_like 'transaction handle should match json schema'
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe RubyRabbitmqJanus::Models::JanusInstance, type: :model,
6
+ name: :janus_instance do
7
+ let(:model) { RubyRabbitmqJanus::Models::JanusInstance }
8
+
9
+ context 'Janus Instance model definition' do
10
+ if ENV['MONGO'].match?('true')
11
+ it { expect(model.attribute_names).to include('_id') }
12
+ it { expect(model.aliased_fields).to eq({ 'id' => '_id', 'session_id' => 'session', 'thread_id' => 'thread', 'instance' => '_id'}) }
13
+ else
14
+ it { expect(model.attribute_names).to include('id') }
15
+ it { expect(model.attribute_aliases).to eq({ 'instance' => 'id', 'session_id' => 'session', 'thread_id' => 'thread' }) }
16
+ end
17
+ it { expect(model.attribute_names).to include('session') }
18
+ it { expect(model.attribute_names).to include('enable') }
19
+ end
20
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe RubyRabbitmqJanus::Models::JanusInstance, type: :model,
6
+ name: :janus_instance do
7
+ before { RubyRabbitmqJanus::Models::JanusInstance.delete_all }
8
+ after do
9
+ RubyRabbitmqJanus::Models::JanusInstance.delete_all
10
+ create_janus_instances
11
+ end
12
+
13
+ let(:janus_id) do
14
+ random_instance = [1, 2].sample
15
+
16
+ if ENV['MONGO'].match?('true')
17
+ { _id: random_instance.to_s }
18
+ else
19
+ { id: random_instance }
20
+ end
21
+ end
22
+ let(:model) { RubyRabbitmqJanus::Models::JanusInstance }
23
+
24
+ context 'Janus Instance simple transaction' do
25
+ it { expect(model.count).to eq(0) }
26
+ end
27
+
28
+ context 'many janus instances' do
29
+ before do
30
+ FactoryGirl.create_list(:janus_instance, 5, enable: false)
31
+ FactoryGirl.create(:janus_instance, janus_id)
32
+ end
33
+
34
+ let(:one) { model.enabled.first }
35
+
36
+ it { expect(model.count).to eq(6) }
37
+ it { expect(model.enabled.count).to eq(1) }
38
+ it { expect(model.find_by_session(one.session).thread).to eq(one.thread) }
39
+ it { expect(model.find_by_instance(one.instance).session).to eq(one.session) }
40
+ end
41
+
42
+ context 'Janus Instance enable' do
43
+ let(:janus) { FactoryGirl.create(:janus_instance, janus_id) }
44
+
45
+ it { expect(janus.valid?).to be_a(TrueClass) }
46
+ it { expect(janus.session).to be_a(Integer) }
47
+ it { expect(janus.enable).to be_a(TrueClass) }
48
+ it { expect(janus.enable).to eq(true) }
49
+ it { expect(janus.thread).to be_a(Integer) }
50
+ end
51
+
52
+ context 'Janus Instance disable' do
53
+ let(:janus) { FactoryGirl.create(:janus_instance, enable: false) }
54
+
55
+ it { expect(janus.valid?).to be_a(TrueClass) }
56
+ it { expect(janus.session).to be_nil }
57
+ it { expect(janus.enable).to be_a(FalseClass) }
58
+ it { expect(janus.enable).to eq(false) }
59
+ it { expect(janus.thread).to be_nil }
60
+ end
61
+ end
data/spec/spec_helper.rb CHANGED
@@ -4,6 +4,7 @@ require 'bundler/setup'
4
4
  require 'pry'
5
5
  require 'json-schema-rspec'
6
6
  require 'rails'
7
+ require 'factory_girl'
7
8
  require 'database_cleaner'
8
9
  ENV['MONGO']='true' if ENV['MONGO'].nil?
9
10
  require ENV['MONGO'].match?('true') ? 'mongoid' : 'active_record'
@@ -12,6 +13,7 @@ require 'ruby_rabbitmq_janus'
12
13
  require 'config/initializer'
13
14
  require 'config/database'
14
15
  require 'config/instance'
16
+ Dir['spec/factories/*.rb'].each { |f| require File.expand_path(f) }
15
17
 
16
18
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
17
19
 
@@ -53,6 +55,9 @@ RSpec.configure do |config|
53
55
  # Exclude request with tag broken
54
56
  config.filter_run_excluding broken: true
55
57
 
58
+ # Configure Factory Girl
59
+ config.include FactoryGirl::Syntax::Methods
60
+
56
61
  # Configure Initializer RRJ and create session with Janus Instance
57
62
  config.before(:example) do |example|
58
63
  initializer_rrj(example.metadata)
@@ -0,0 +1,136 @@
1
+ # frozen_string_literal: true
2
+
3
+ SDP_OFFER =<<EOF
4
+ v=0
5
+ o=- 7041456084360858977 2 IN IP4 127.0.0.1
6
+ s=-
7
+ t=0 0
8
+ a=group:BUNDLE audio video
9
+ a=msid-semantic: WMS 2jKToeOlpzKTn7anwnHOJmzFyhvEYt1kpcMY
10
+ m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 126
11
+ c=IN IP4 0.0.0.0
12
+ a=rtcp:9 IN IP4 0.0.0.0
13
+ a=ice-ufrag:T9QI
14
+ a=ice-pwd:s9YvfGuavTZN0Lqc53JNInEP
15
+ 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
16
+ a=setup:actpass
17
+ a=mid:audio
18
+ a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
19
+ a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
20
+ a=sendonly
21
+ a=rtcp-mux
22
+ a=rtpmap:111 opus/48000/2
23
+ a=rtcp-fb:111 transport-cc
24
+ a=fmtp:111 minptime=10;useinbandfec=1
25
+ a=rtpmap:103 ISAC/16000
26
+ a=rtpmap:104 ISAC/32000
27
+ a=rtpmap:9 G722/8000
28
+ a=rtpmap:0 PCMU/8000
29
+ a=rtpmap:8 PCMA/8000
30
+ a=rtpmap:106 CN/32000
31
+ a=rtpmap:105 CN/16000
32
+ a=rtpmap:13 CN/8000
33
+ a=rtpmap:126 telephone-event/8000
34
+ a=ssrc:2786155512 cname:/+YL75rdcn+UKbf9
35
+ a=ssrc:2786155512 msid:2jKToeOlpzKTn7anwnHOJmzFyhvEYt1kpcMY e0f2490b-468a-4abc-9770-a5f99b13c152
36
+ a=ssrc:2786155512 mslabel:2jKToeOlpzKTn7anwnHOJmzFyhvEYt1kpcMY
37
+ a=ssrc:2786155512 label:e0f2490b-468a-4abc-9770-a5f99b13c152
38
+ m=video 9 UDP/TLS/RTP/SAVPF 100 101 107 116 117 96 97 99 98
39
+ c=IN IP4 0.0.0.0
40
+ a=rtcp:9 IN IP4 0.0.0.0
41
+ a=ice-ufrag:T9QI
42
+ a=ice-pwd:s9YvfGuavTZN0Lqc53JNInEP
43
+ 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
44
+ a=setup:actpass
45
+ a=mid:video
46
+ a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
47
+ a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
48
+ a=extmap:4 urn:3gpp:video-orientation
49
+ a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
50
+ a=sendonly
51
+ a=rtcp-mux
52
+ a=rtcp-rsize
53
+ a=rtpmap:100 VP8/90000
54
+ a=rtcp-fb:100 ccm fir
55
+ a=rtcp-fb:100 nack
56
+ a=rtcp-fb:100 nack pli
57
+ a=rtcp-fb:100 goog-remb
58
+ a=rtcp-fb:100 transport-cc
59
+ a=rtpmap:101 VP9/90000
60
+ a=rtcp-fb:101 ccm fir
61
+ a=rtcp-fb:101 nack
62
+ a=rtcp-fb:101 nack pli
63
+ a=rtcp-fb:101 goog-remb
64
+ a=rtcp-fb:101 transport-cc
65
+ a=rtpmap:107 H264/90000
66
+ a=rtcp-fb:107 ccm fir
67
+ a=rtcp-fb:107 nack
68
+ a=rtcp-fb:107 nack pli
69
+ a=rtcp-fb:107 goog-remb
70
+ a=rtcp-fb:107 transport-cc
71
+ a=fmtp:107 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
72
+ a=rtpmap:116 red/90000
73
+ a=rtpmap:117 ulpfec/90000
74
+ a=rtpmap:96 rtx/90000
75
+ a=fmtp:96 apt=100
76
+ a=rtpmap:97 rtx/90000
77
+ a=fmtp:97 apt=101
78
+ a=rtpmap:99 rtx/90000
79
+ a=fmtp:99 apt=107
80
+ a=rtpmap:98 rtx/90000
81
+ a=fmtp:98 apt=116
82
+ a=ssrc-group:FID 1022811670 258141567
83
+ a=ssrc:1022811670 cname:/+YL75rdcn+UKbf9
84
+ a=ssrc:1022811670 msid:2jKToeOlpzKTn7anwnHOJmzFyhvEYt1kpcMY 25d58816-114a-41d2-aa08-1039e09f942f
85
+ a=ssrc:1022811670 mslabel:2jKToeOlpzKTn7anwnHOJmzFyhvEYt1kpcMY
86
+ a=ssrc:1022811670 label:25d58816-114a-41d2-aa08-1039e09f942f
87
+ a=ssrc:258141567 cname:/+YL75rdcn+UKbf9
88
+ a=ssrc:258141567 msid:2jKToeOlpzKTn7anwnHOJmzFyhvEYt1kpcMY 25d58816-114a-41d2-aa08-1039e09f942f
89
+ a=ssrc:258141567 mslabel:2jKToeOlpzKTn7anwnHOJmzFyhvEYt1kpcMY
90
+ a=ssrc:258141567 label:25d58816-114a-41d2-aa08-1039e09f942f
91
+ EOF
92
+
93
+ SDP_ANSWER = <<SDP
94
+ v=0
95
+ o=- 7041456084360858977 2 IN IP4 127.0.0.1
96
+ s=-
97
+ t=0 0
98
+ a=group:BUNDLE audio video
99
+ a=msid-semantic: WMS 2jKToeOlpzKTn7anwnHOJmzFyhvEYt1kpcMY
100
+ m=audio 9 UDP/TLS/RTP/SAVPF 111
101
+ c=IN IP4 0.0.0.0
102
+ a=rtcp:9 IN IP4 0.0.0.0
103
+ a=ice-ufrag:T9QI
104
+ a=ice-pwd:s9YvfGuavTZN0Lqc53JNInEP
105
+ 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
106
+ a=setup:actpass
107
+ a=mid:audio
108
+ a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
109
+ a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
110
+ a=sendonly
111
+ a=rtcp-mux
112
+ a=rtpmap:111 opus/48000/2
113
+ a=rtcp-fb:111 transport-cc
114
+ a=fmtp:111 minptime=10;useinbandfec=1
115
+ m=video 9 UDP/TLS/RTP/SAVPF 100
116
+ c=IN IP4 0.0.0.0
117
+ a=rtcp:9 IN IP4 0.0.0.0
118
+ a=ice-ufrag:T9QI
119
+ a=ice-pwd:s9YvfGuavTZN0Lqc53JNInEP
120
+ 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
121
+ a=setup:actpass
122
+ a=mid:video
123
+ a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
124
+ a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
125
+ a=extmap:4 urn:3gpp:video-orientation
126
+ a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
127
+ a=sendonly
128
+ a=rtcp-mux
129
+ a=rtcp-rsize
130
+ a=rtpmap:100 VP8/90000
131
+ a=rtcp-fb:100 ccm fir
132
+ a=rtcp-fb:100 nack
133
+ a=rtcp-fb:100 nack pli
134
+ a=rtcp-fb:100 goog-remb
135
+ a=rtcp-fb:100 transport-cc
136
+ SDP
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: 2.2.0.pre.161
4
+ version: 2.2.0.pre.164
5
5
  platform: ruby
6
6
  authors:
7
7
  - VAILLANT Jeremy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-25 00:00:00.000000000 Z
11
+ date: 2017-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -276,6 +276,20 @@ dependencies:
276
276
  - - "~>"
277
277
  - !ruby/object:Gem::Version
278
278
  version: '1.6'
279
+ - !ruby/object:Gem::Dependency
280
+ name: factory_girl
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - "~>"
284
+ - !ruby/object:Gem::Version
285
+ version: '4.8'
286
+ type: :development
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - "~>"
291
+ - !ruby/object:Gem::Version
292
+ version: '4.8'
279
293
  - !ruby/object:Gem::Dependency
280
294
  name: bunny
281
295
  requirement: !ruby/object:Gem::Requirement
@@ -491,6 +505,7 @@ files:
491
505
  - spec/config/initializer.rb
492
506
  - spec/config/instance.rb
493
507
  - spec/config/mongoid.yml
508
+ - spec/factories/janus_instance.rb
494
509
  - spec/request/admin/request_handle_info_spec.rb
495
510
  - spec/request/admin/request_handles_spec.rb
496
511
  - spec/request/admin/request_sessions_spec.rb
@@ -509,7 +524,8 @@ files:
509
524
  - spec/rrj/messages/messages_admin_spec.rb
510
525
  - spec/rrj/messages/messages_message_spec.rb
511
526
  - spec/rrj/messages/messages_standard_spec.rb
512
- - spec/rrj/models/janus_instance.rb
527
+ - spec/rrj/models/janus_instance_definition_spec.rb
528
+ - spec/rrj/models/janus_instance_transaction_spec.rb
513
529
  - spec/rrj/rabbit/connect_spec.rb
514
530
  - spec/rrj/rabbit/propertie_2_spec.rb
515
531
  - spec/rrj/rabbit/propertie_spec.rb
@@ -558,6 +574,7 @@ files:
558
574
  - spec/support/schemas/request/peer/answer.json
559
575
  - spec/support/schemas/request/peer/offer.json
560
576
  - spec/support/schemas/request/peer/trickle.json
577
+ - spec/support/sdp.rb
561
578
  - spec/support/type.rb
562
579
  homepage: https://github.com/dazzl-tv/ruby-rabbitmq-janus
563
580
  licenses:
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe RubyRabbitmqJanus::Models::JanusInstance, type: :model,
6
- name: :janus_instance do
7
- let(:model) { RubyRabbitmqJanus::Models::JanusInstance }
8
-
9
- context 'active record model' do
10
- it { expect(model.attribute_names).to include(ENV['MONGO'].match?('true') ? '_id' : 'id') }
11
- it { expect(model.attribute_names).to include('instance') }
12
- it { expect(model.attribute_names).to include('session') }
13
- it { expect(model.attribute_names).to include('enable') }
14
- end
15
- end