sonycam 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sonycam/api.rb +1 -1
- data/lib/sonycam/device_description.rb +2 -2
- data/lib/sonycam/error.rb +1 -1
- data/lib/sonycam/liveview.rb +3 -4
- data/lib/sonycam/packet.rb +11 -11
- data/lib/sonycam/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d111ba16847fff6b8e6dae447b02ae9a9ec0fff
|
4
|
+
data.tar.gz: 89ff24db3ea892420a1bc52ae995b006b3e4fc3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30f57b2cde854524aadd0db65ea03219a02a72f996882ac85f9eaa79a43a285e3515fef22d9e6d026707e5613102c95ac34b8fd69662b5d7b409d89440d9be79
|
7
|
+
data.tar.gz: bb3c910f893622909a3c30ed83ff27b447563bdeefbedb5ef3a25839f32bfdeec0be8438a7328ca1536517873638df96caa35b34f785cea255ffe8e4a0b566c1
|
data/lib/sonycam/api.rb
CHANGED
@@ -14,7 +14,7 @@ module Sonycam
|
|
14
14
|
ret = JSON.parse(@http.request_post(@uri.path, json).body)
|
15
15
|
if ret['error']
|
16
16
|
error_code, error_message = ret['error']
|
17
|
-
raise Sonycam::Error.
|
17
|
+
raise Sonycam::Error.make(error_code), error_message
|
18
18
|
else
|
19
19
|
ret['result']
|
20
20
|
end
|
@@ -21,12 +21,12 @@ module Sonycam
|
|
21
21
|
# Hush, it's a secret, don't tell anyone.
|
22
22
|
if @camera_name == 'DSC-RX100M2'
|
23
23
|
url = @api_url_hash[type].sub('sony', 'camera')
|
24
|
-
puts "DSC-RX100M2 detected, API URL \"#{url}\"
|
24
|
+
puts "DSC-RX100M2 detected, API URL \"#{url}\" is used insteadly."
|
25
25
|
return url
|
26
26
|
end
|
27
27
|
|
28
28
|
if action_list_url = @api_url_hash[type] then "#{action_list_url}/#{type}"
|
29
|
-
else raise "Can
|
29
|
+
else raise "Can not find service type \"#{type}\"."
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
data/lib/sonycam/error.rb
CHANGED
data/lib/sonycam/liveview.rb
CHANGED
@@ -13,17 +13,17 @@ module Sonycam
|
|
13
13
|
buf = ''.force_encoding('BINARY')
|
14
14
|
commen_header = nil
|
15
15
|
payload_header = nil
|
16
|
-
|
16
|
+
response.read_body do |chunk|
|
17
17
|
buf += chunk
|
18
18
|
until buf.empty?
|
19
19
|
case state
|
20
20
|
when :commen_header # 8 bytes
|
21
21
|
break if buf.size < 8
|
22
|
-
commen_header = buf.slice!(0, 8).unpack('
|
22
|
+
commen_header = buf.slice!(0, 8).unpack('aanN')
|
23
23
|
state = :payload_header
|
24
24
|
when :payload_header # 128 bytes
|
25
25
|
break if buf.size < 128
|
26
|
-
payload_header = buf.slice!(0, 128).unpack('
|
26
|
+
payload_header = buf.slice!(0, 128).unpack('a4H6Ca4aa*')
|
27
27
|
state = :payload_data
|
28
28
|
when :payload_data
|
29
29
|
jpeg_data_size = payload_header[1].to_i(16)
|
@@ -34,7 +34,6 @@ module Sonycam
|
|
34
34
|
state = :commen_header
|
35
35
|
yield Packet.new(commen_header, payload_header, jpeg_data, padding_data)
|
36
36
|
end # case state
|
37
|
-
# gets
|
38
37
|
end # until buf.empty?
|
39
38
|
end # response.read_body do |chunk|
|
40
39
|
end # http.request request do |response|
|
data/lib/sonycam/packet.rb
CHANGED
@@ -3,26 +3,26 @@ module Sonycam
|
|
3
3
|
def initialize commen_header, payload_header, jpeg_data, padding_data
|
4
4
|
@packet = {
|
5
5
|
commen_header: {
|
6
|
-
start_byte: commen_header[0],
|
7
|
-
payload_type: commen_header[1],
|
8
|
-
sequence_number: commen_header[2],
|
9
|
-
time_stamp: commen_header[3]
|
6
|
+
start_byte: commen_header[0], # hex, fixed "FF"
|
7
|
+
payload_type: commen_header[1], # int
|
8
|
+
sequence_number: commen_header[2], # int
|
9
|
+
time_stamp: commen_header[3] # int
|
10
10
|
},
|
11
11
|
payload_header: {
|
12
|
-
star_code: payload_header[0],
|
13
|
-
jpeg_data_size: payload_header[1].
|
14
|
-
padding_size: payload_header[2],
|
15
|
-
reserved: payload_header[3],
|
16
|
-
flag: payload_header[4],
|
12
|
+
star_code: payload_header[0], # hex, fixed "24356879"
|
13
|
+
jpeg_data_size: payload_header[1].hex, # int
|
14
|
+
padding_size: payload_header[2], # int
|
15
|
+
reserved: payload_header[3], # hex
|
16
|
+
flag: payload_header[4], # int, fixed "00"
|
17
17
|
reserved_2: payload_header[5]
|
18
|
-
|
19
18
|
},
|
20
19
|
payload_data: {
|
21
20
|
jpeg_data: jpeg_data,
|
22
21
|
padding_data: padding_data
|
23
|
-
}
|
22
|
+
}
|
24
23
|
}
|
25
24
|
end
|
25
|
+
|
26
26
|
def [] key
|
27
27
|
@packet[key]
|
28
28
|
end
|
data/lib/sonycam/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sonycam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Jian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|