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 +4 -4
- data/lib/druzy/protocol/plugin/upnp.rb +31 -52
- data/lib/druzy/protocol/plugin/upnp/version.rb +1 -1
- metadata +8 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12bfde020b1c1459f480e2fdb040df24f0f1a494
|
4
|
+
data.tar.gz: 27ead9847637fceb7481627847b06b4425f7056b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f21e48242a26aee06021d4bae205851dd8b5ac778f2254ef93dafbd26c73ca923c95a5755ed3278b7ac14d44db6266697d654f3eb314814652ca2ca2ce90d28
|
7
|
+
data.tar.gz: 4f1e6890821e754284048e1d92942e913865092892269a4b6a1c9e7d1a6bd10bd1927a1e8077a1f0f5cc46eb277109a78b8aa806723aa32467f2c0419626b936
|
@@ -1,8 +1,10 @@
|
|
1
|
-
|
1
|
+
require_relative 'upnp/version'
|
2
|
+
|
2
3
|
require 'druzy/server'
|
3
|
-
require '
|
4
|
+
require 'druzy/upnp/ssdp'
|
4
5
|
require 'filemagic'
|
5
|
-
|
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
|
-
@@
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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(
|
45
|
-
@
|
46
|
-
|
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
|
-
|
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
|
-
@
|
51
|
+
@druzy_device.AVTransport.Play("InstanceID" => @av_transport_id, "Speed" => 1)
|
64
52
|
end
|
65
53
|
|
66
54
|
def pause
|
67
|
-
@
|
55
|
+
@druzy_device.AVTransport.Pause("InstanceID" => @av_transport_id)
|
68
56
|
end
|
69
57
|
|
70
58
|
def stop
|
71
|
-
|
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 = @
|
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=@
|
84
|
-
@connection_id = ids[
|
85
|
-
@av_transport_id = ids[
|
86
|
-
@rcs_id = ids[
|
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
|
-
@
|
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
|
124
|
-
device.
|
125
|
-
device.
|
126
|
-
|
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
|
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.
|
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-
|
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.
|
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.
|
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:
|
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.
|
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.
|
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.
|
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
|