druzy-protocol-plugin-upnp 0.1.0 → 0.2.0

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: 751e1986eae403b671a3c1f26f3eb897e2defd90
4
- data.tar.gz: fe4b7c3d1b39aac7c85589ab8f21a935bfcd1850
3
+ metadata.gz: 12bfde020b1c1459f480e2fdb040df24f0f1a494
4
+ data.tar.gz: 27ead9847637fceb7481627847b06b4425f7056b
5
5
  SHA512:
6
- metadata.gz: 4f850c0059b9efb9c1367deb93dfb9ba3fd7f043d27d603b1839d30639dc2de39ed4f0c63e01a4dd999eabea135584106e51cc40606b8f6304cd5b4b27f632b8
7
- data.tar.gz: b47b0283e4253da3dd1cde8b1fe7f3320acf95a723f3b45d2362750d28607b09bb405aee16c296492f623e5ced9d6756ccec181b0b20893cf41269496a1fd35a
6
+ metadata.gz: 1f21e48242a26aee06021d4bae205851dd8b5ac778f2254ef93dafbd26c73ca923c95a5755ed3278b7ac14d44db6266697d654f3eb314814652ca2ca2ce90d28
7
+ data.tar.gz: 4f1e6890821e754284048e1d92942e913865092892269a4b6a1c9e7d1a6bd10bd1927a1e8077a1f0f5cc46eb277109a78b8aa806723aa32467f2c0419626b936
@@ -1,8 +1,10 @@
1
- require 'druzy/protocol/plugin/upnp/version'
1
+ require_relative 'upnp/version'
2
+
2
3
  require 'druzy/server'
3
- require 'easy_upnp/ssdp_searcher'
4
+ require 'druzy/upnp/ssdp'
4
5
  require 'filemagic'
5
- require 'nokogiri'
6
+
7
+ require 'druzy/protocol' if $0 == __FILE__
6
8
 
7
9
  module Druzy
8
10
  module Protocol
@@ -13,21 +15,14 @@ module Druzy
13
15
 
14
16
  class UpnpDiscoverer < Druzy::Protocol::Discoverer
15
17
 
16
- @@urn_connection_manager='urn:schemas-upnp-org:service:ConnectionManager:1'
17
- @@urn_rendering_control='urn:schemas-upnp-org:service:RenderingControl:1'
18
-
19
- def start_discoverer(delay=10, identifier=nil)
20
- searcher = EasyUpnp::SsdpSearcher.new
21
- devices = searcher.search('upnp:rootdevice')
22
- for device in devices
23
- begin
24
- if device.all_services.include?(@@urn_connection_manager) && device.all_services.include?(@@urn_rendering_control)
25
- if block_given?
26
- yield(UpnpRenderer.new(device))
27
- end
28
- end
29
- rescue
30
-
18
+ @@urn_media_renderer = "urn:schemas-upnp-org:device:MediaRenderer:1"
19
+
20
+ def start_discoverer(args={})
21
+ args[:delay] ||=10
22
+ args[:identifier] ||=@@urn_media_renderer
23
+ searcher = Druzy::Upnp::Ssdp.new.search(args[:identifier], args[:delay]) do |device|
24
+ if block_given?
25
+ yield UpnpRenderer.new(device)
31
26
  end
32
27
  end
33
28
  end
@@ -41,51 +36,41 @@ module Druzy
41
36
 
42
37
  class UpnpRenderer < Druzy::Protocol::Renderer
43
38
 
44
- def initialize(easy_upnp)
45
- @av_transport = easy_upnp.service('urn:schemas-upnp-org:service:AVTransport:1')
46
- @rendering_control = easy_upnp.service('urn:schemas-upnp-org:service:RenderingControl:1')
47
- @connection_manager = easy_upnp.service('urn:schemas-upnp-org:service:ConnectionManager:1')
39
+ def initialize(druzy_device)
40
+ @druzy_device = druzy_device
41
+
48
42
  @av_transport_id=nil
49
43
  @connection_id=nil
50
44
  @rcs_id=nil
51
45
 
52
- document = open(easy_upnp.service_definition(easy_upnp.all_services.first)[:location]) { |f| f.read }
53
- xml = Nokogiri::XML(document)
54
- xml.remove_namespaces!
55
- url_base=xml.xpath("//URLBase").text
56
- url_icon=url_base+xml.xpath("//device/iconList/icon/url").first.text
57
-
58
- super(easy_upnp.uuid,"upnp",easy_upnp.device_name,url_icon)
46
+ super(@druzy_device.udn,"upnp",@druzy_device.friendly_name,@druzy_device.icon_list.first)
59
47
 
60
48
  end
61
49
 
62
50
  def play
63
- @av_transport.Play({:InstanceID => @av_transport_id, :Speed => "1"})
51
+ @druzy_device.AVTransport.Play("InstanceID" => @av_transport_id, "Speed" => 1)
64
52
  end
65
53
 
66
54
  def pause
67
- @av_transport.Pause({:InstanceID => @av_transport_id})
55
+ @druzy_device.AVTransport.Pause("InstanceID" => @av_transport_id)
68
56
  end
69
57
 
70
58
  def stop
71
- puts "dans stop"
72
- puts @av_transport.Stop({:InstanceID => @av_transport_id})
73
- puts "apres"
59
+ @druzy_device.AVTransport.Stop("InstanceID" => @av_transport_id)
74
60
  end
75
61
 
76
62
  def send(file)
77
63
  #vérification du protocol
78
- protocols = @connection_manager.GetProtocolInfo[:Sink]
64
+ protocols = @druzy_device.ConnectionManager.GetProtocolInfo["Sink"]
79
65
  mimetype=FileMagic.new(FileMagic::MAGIC_MIME_TYPE).file(file)
80
66
  ask_protocol="http-get:*:"+mimetype+":*"
81
67
  if protocols[ask_protocol] != nil
82
- if @connection_id == nil || @av_transport_id == nil || rcs_id == nil
83
- ids=@connection_manager.PrepareForConnection({:RemoteProtocolInfo => ask_protocol, :PeerConnectionManager => "/", :PeerConnectionID => -1, :Direction => "Output"})
84
- @connection_id = ids[:ConnectionID]
85
- @av_transport_id = ids[:AVTransportID]
86
- @rcs_id = ids[:RcsID]
68
+ if @connection_id == nil || @av_transport_id == nil || @rcs_id == nil
69
+ ids=@druzy_device.ConnectionManager.PrepareForConnection("RemoteProtocolInfo" => ask_protocol, "PeerConnectionManager" => "/", "PeerConnectionID" => -1, "Direction" => "Output")
70
+ @connection_id = ids["ConnectionID"]
71
+ @av_transport_id = ids["AVTransportID"]
72
+ @rcs_id = ids["RcsID"]
87
73
  end
88
-
89
74
  #ajout du fichier au serveur
90
75
  r=Druzy::Server::RestrictedFileServer.instance(PORT)
91
76
  r.add_file(file)
@@ -104,7 +89,7 @@ module Druzy
104
89
  </item>
105
90
  </DIDL-Lite>)
106
91
  #envoie de l'url au renderer
107
- @av_transport.SetAVTransportURI({:InstanceID => @av_transport_id, :CurrentURI => r.get_address(file), :CurrentURIMetaData => xml})
92
+ @druzy_device.AVTransport.SetAVTransportURI("InstanceID" => @av_transport_id, "CurrentURI" => r.get_address(file), "CurrentURIMetaData" => xml)
108
93
  end
109
94
 
110
95
  end
@@ -120,16 +105,10 @@ if __FILE__ == $0
120
105
 
121
106
 
122
107
  up=Druzy::Protocol::Plugin::Upnp::UpnpDiscoverer.new
123
- up.start_discoverer{ |device|
124
- device.send("/home/druzy/elliot.mp4")
125
- device.play
126
- sleep(10)
127
- device.pause
128
- sleep(5)
129
- device.play
130
- sleep(5)
131
- device.stop
132
- }
108
+ up.start_discoverer(:delay => 10, :identifier => "uuid:aad2b343-11c8-346d-dd41-065160c19d82") do |device|
109
+ puts device.identifier
110
+ puts device.name
111
+ end
133
112
 
134
113
  Thread.list.each{|t| t.join if t!=Thread.main}
135
114
  end
@@ -2,7 +2,7 @@ module Druzy
2
2
  module Protocol
3
3
  module Plugin
4
4
  module Upnp
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: druzy-protocol-plugin-upnp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Le Greneur
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-11 00:00:00.000000000 Z
11
+ date: 2016-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: druzy-protocol
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.1
19
+ version: 1.0.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.1
26
+ version: 1.0.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: druzy-server
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.0.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: easy_upnp
42
+ name: druzy-upnp
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.2.3
47
+ version: 2.0.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.2.3
54
+ version: 2.0.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: ruby-filemagic
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.7.1
69
- - !ruby/object:Gem::Dependency
70
- name: nokogiri
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: 1.6.6.2
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: 1.6.6.2
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: bundler
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -137,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
123
  version: '0'
138
124
  requirements: []
139
125
  rubyforge_project:
140
- rubygems_version: 2.2.2
126
+ rubygems_version: 2.5.1
141
127
  signing_key:
142
128
  specification_version: 4
143
129
  summary: Plugin to discover a upnp media renderer