wiretap 0.1 → 0.1.2
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.
- data/README +2 -1
- data/ext/Makefile +27 -24
- data/ext/audio_format.cpp +10 -8
- data/ext/charstream.h +41 -0
- data/ext/extconf.rb +8 -10
- data/ext/frame_io.cpp +120 -0
- data/ext/frame_io.h +45 -0
- data/ext/image_format.cpp +49 -169
- data/ext/image_io.cpp +466 -0
- data/ext/image_io.h +73 -0
- data/ext/node.cpp +71 -48
- data/ext/nodeframes.cpp +36 -34
- data/ext/nodemetadata.cpp +21 -3
- data/ext/server.cpp +2 -2
- data/ext/serverlist.cpp +20 -8
- data/ext/wiretap.cpp +11 -8
- data/ext/wiretap.h +17 -13
- data/lib/wiretap.rb +65 -5
- data/test_new/common.rb +8 -0
- data/{test/wiretap-images → test_new/fixtures/img/ppm-8bit}/01.ppm +0 -0
- data/test_new/fixtures/raw/cube_2k_12bitP_1f/0.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_2k_8bit_1f/0.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_10bit_5f/0.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_10bit_5f/1.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_10bit_5f/2.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_10bit_5f/3.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_10bit_5f/4.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_12bitP_5f/0.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_12bitP_5f/1.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_12bitP_5f/2.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_12bitP_5f/3.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_12bitP_5f/4.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_12bitU_5f/0.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_12bitU_5f/1.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_12bitU_5f/2.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_12bitU_5f/3.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_12bitU_5f/4.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_8bit_8f/0.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_8bit_8f/1.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_8bit_8f/2.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_8bit_8f/3.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_8bit_8f/4.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_8bit_8f/5.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_8bit_8f/6.stoneimage +0 -0
- data/test_new/fixtures/raw/cube_SD_8bit_8f/7.stoneimage +0 -0
- data/{test/wiretap-images/b1.stonesound → test_new/fixtures/raw-snd/simple.stonesound} +0 -0
- data/{test/wiretap-images/output.wav → test_new/fixtures/snd/simple-wave.wav} +0 -0
- data/test_new/test_audio_conversions.rb +28 -0
- data/test_new/test_image_conversions.rb +132 -0
- data/test_new/test_parts/connect_to_test_host.rb +27 -0
- data/test_new/test_parts/constants.rb +7 -0
- data/test_new/test_parts/create_test_project.rb +37 -0
- data/test_new/test_parts/raw_formats_and_uploads.rb +170 -0
- data/test_new/test_parts/server_list.rb +20 -0
- data/test_new/test_parts/simple_node_lookup_and_browsing.rb +76 -0
- data/test_new/test_suite.rb +70 -0
- data/{test/convert.rb → test_new/test_thread_worker.rb} +2 -3
- metadata +71 -61
- data/ext/bmp.cpp +0 -65
- data/ext/image.h +0 -27
- data/ext/ppm.cpp +0 -132
- data/ext/sgi.cpp +0 -69
- data/test/audio.rb +0 -27
- data/test/image.rb +0 -101
- data/test/read_frames.rb +0 -142
- data/test/wiretap-images/32bit.stoneimage +0 -621
- data/test/wiretap-images/36bit.stoneimage +0 -1036
- data/test/wiretap-images/48bit.stoneimage +1 -800
- data/test/wiretap-images/a.stoneimage +0 -0
- data/test/wiretap-images/a0.stoneimage +0 -0
- data/test/wiretap-images/a1.stoneimage +0 -0
- data/test/wiretap-images/a2.stoneimage +0 -0
- data/test/wiretap-images/a3.stoneimage +0 -0
- data/test/wiretap-images/a4.stoneimage +0 -0
- data/test/wiretap-images/importable-seq/00000001.ppm +0 -0
- data/test/wiretap-images/importable-seq/00000002.ppm +0 -0
- data/test/wiretap-images/importable-seq/00000003.ppm +0 -0
- data/test/wiretap-images/importable-seq/00000004.ppm +0 -0
- data/test/wiretap-images/importable-seq/00000005.ppm +0 -0
- data/test/wiretap-images/importable-seq/00000006.ppm +0 -0
- data/test/wiretap-images/importable-seq/00000007.ppm +0 -0
- data/test/wiretap-images/importable-seq/00000008.ppm +0 -0
- data/test/wiretap-images/importable-seq/00000009.ppm +0 -0
- data/test/wiretap-images/importable-seq/00000010.ppm +0 -0
- data/test/wiretap-images/importable-seq/00000011.ppm +0 -0
- data/test/wiretap-images/importable-seq/00000012.ppm +0 -0
- data/test/wiretap-images/monsters_001.tif +0 -0
- data/test/wiretap-images/monsters_002.tif +0 -0
- data/test/wiretap-images/monsters_003.tif +0 -0
- data/test/wiretap-images/output.mov +0 -0
- data/test/write_frames.rb +0 -82
data/lib/wiretap.rb
CHANGED
|
@@ -24,20 +24,31 @@ module Wiretap
|
|
|
24
24
|
begin
|
|
25
25
|
Timeout.timeout(1) {TCPSocket.new(hostname,'7549')}
|
|
26
26
|
real_alive?
|
|
27
|
-
rescue
|
|
27
|
+
rescue Timeout::Error, SocketError, Errno::ECONNREFUSED
|
|
28
28
|
false
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
|
+
|
|
32
|
+
def children
|
|
33
|
+
root.children
|
|
34
|
+
end
|
|
31
35
|
end
|
|
32
36
|
|
|
37
|
+
# Returned from ServerList and contains information about a specific server. Call ServerInfo#server to retrieve the actual server
|
|
38
|
+
# object
|
|
33
39
|
class ServerInfo
|
|
34
40
|
def uri
|
|
35
41
|
server.uri
|
|
36
42
|
end
|
|
43
|
+
|
|
44
|
+
def to_s #:nodoc:
|
|
45
|
+
super.gsub />$/, " hostname:'#{hostname}'>"
|
|
46
|
+
end
|
|
37
47
|
end
|
|
38
48
|
|
|
39
49
|
class ServerList
|
|
40
50
|
include Enumerable
|
|
51
|
+
def length; count; end
|
|
41
52
|
end
|
|
42
53
|
|
|
43
54
|
class Reel
|
|
@@ -55,17 +66,29 @@ module Wiretap
|
|
|
55
66
|
return children[path] if path.is_a?(Numeric)
|
|
56
67
|
end
|
|
57
68
|
|
|
69
|
+
def ==(other) #:nodoc:
|
|
70
|
+
return false if other.nil?
|
|
71
|
+
(other.id == self.id) && (other.server == self.server)
|
|
72
|
+
end
|
|
73
|
+
|
|
58
74
|
def find(path)
|
|
59
75
|
return self if path.empty?
|
|
76
|
+
|
|
60
77
|
return (find_child(path.shift).find(path) rescue nil) if path.respond_to?(:shift)
|
|
61
78
|
find_child(path)
|
|
62
79
|
end
|
|
63
80
|
|
|
81
|
+
def destroyed?
|
|
82
|
+
@destroyed ? true : false
|
|
83
|
+
end
|
|
84
|
+
|
|
64
85
|
# Returns a URL for the node that you can later pass to Wiretap::open
|
|
65
|
-
# Be alert though that it doesn't use the frame IDs - that is, if you have 7 reels of the same name
|
|
86
|
+
# Be alert though that it doesn't use the frame IDs - that is, if you have 7 reels of the same name
|
|
87
|
+
# (which is a disaster and you should really think about your behavior) and you ask
|
|
66
88
|
# for the uri of the second one, the first one is going to be reopened when you pass the uri to Wiretap::open
|
|
67
89
|
# This is done so that you can maintain "soft links" to specific objects on libraries instead of the frame IDs.
|
|
68
90
|
# When the clip gets edited you can still access it by name, although the frame IDs have changed.
|
|
91
|
+
# Same is valid for the reel IDs.
|
|
69
92
|
def uri
|
|
70
93
|
self.server.hostname + '/' + self.id
|
|
71
94
|
end
|
|
@@ -126,8 +149,10 @@ module Wiretap
|
|
|
126
149
|
|
|
127
150
|
# Destroys all the children of the node and node itself
|
|
128
151
|
def destroy
|
|
129
|
-
|
|
130
|
-
|
|
152
|
+
return true if self.destroyed?
|
|
153
|
+
|
|
154
|
+
children.each {|child| child.destroy unless child.destroyed? } rescue nil
|
|
155
|
+
destroy_self
|
|
131
156
|
end
|
|
132
157
|
end
|
|
133
158
|
|
|
@@ -192,7 +217,11 @@ module Wiretap
|
|
|
192
217
|
|
|
193
218
|
outfile
|
|
194
219
|
end
|
|
195
|
-
|
|
220
|
+
|
|
221
|
+
# Returns the slate clip
|
|
222
|
+
def slate
|
|
223
|
+
children.find{|c| c.kind_of?(SlateClip)}
|
|
224
|
+
end
|
|
196
225
|
protected
|
|
197
226
|
def dump!(path)
|
|
198
227
|
return nil unless clip?
|
|
@@ -204,6 +233,10 @@ module Wiretap
|
|
|
204
233
|
end
|
|
205
234
|
end
|
|
206
235
|
|
|
236
|
+
class SlateClip
|
|
237
|
+
def slate; self; end # :nodoc:
|
|
238
|
+
end
|
|
239
|
+
|
|
207
240
|
class Audio
|
|
208
241
|
def to_s
|
|
209
242
|
"#<#{self.class.to_s} '#{self.name}'>"
|
|
@@ -223,6 +256,10 @@ module Wiretap
|
|
|
223
256
|
include Enumerable
|
|
224
257
|
alias_method :size, :count
|
|
225
258
|
alias_method :length, :count
|
|
259
|
+
|
|
260
|
+
def inspect #:nodoc:
|
|
261
|
+
super.gsub />$/, " length:#{length}>"
|
|
262
|
+
end
|
|
226
263
|
end
|
|
227
264
|
|
|
228
265
|
class AudioFrames
|
|
@@ -245,6 +282,13 @@ module Wiretap
|
|
|
245
282
|
end
|
|
246
283
|
end
|
|
247
284
|
|
|
285
|
+
BITS_PER_PIXEL_TO_BYTES = {
|
|
286
|
+
24 => 3.00003858024691,
|
|
287
|
+
30 => 4,
|
|
288
|
+
32 => 4,
|
|
289
|
+
36 => 4.5,
|
|
290
|
+
48 => 6,
|
|
291
|
+
}
|
|
248
292
|
|
|
249
293
|
attr_reader :node
|
|
250
294
|
@@audio_formats = [:dlaudio_mixed, :dlaudio_float, :dlaudio_float_le, :dlaudio_int16, :dlaudio_int16_le,
|
|
@@ -256,6 +300,22 @@ module Wiretap
|
|
|
256
300
|
def to_s
|
|
257
301
|
"#<Wiretap::ClipFormat size: #{self.width}x#{self.height}, bpp: #{self.bpp}, channels: #{self.channels}, rate: #{self.rate}, tag: #{self.tag}>"
|
|
258
302
|
end
|
|
303
|
+
|
|
304
|
+
def self.buffer_size_for(*opts)
|
|
305
|
+
opts = opts.last || {}
|
|
306
|
+
bpx = opts[:bpp]
|
|
307
|
+
|
|
308
|
+
f_bpx = bpx.to_f
|
|
309
|
+
f_width = opts[:width].to_f
|
|
310
|
+
f_height = opts[:height].to_f
|
|
311
|
+
|
|
312
|
+
puts f_bpx
|
|
313
|
+
puts f_width
|
|
314
|
+
puts f_height
|
|
315
|
+
|
|
316
|
+
f_mult = BITS_PER_PIXEL_TO_BYTES[bpx]
|
|
317
|
+
return (f_mult * f_width * f_height).to_i
|
|
318
|
+
end
|
|
259
319
|
end
|
|
260
320
|
|
|
261
321
|
class AudioFormat
|
data/test_new/common.rb
ADDED
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/common'
|
|
2
|
+
$STAMP = Time.now.to_i
|
|
3
|
+
|
|
4
|
+
class AudioConversionsTest < Test::Unit::TestCase
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
@samples = 48000
|
|
8
|
+
@rate = 48000.0
|
|
9
|
+
@bps = 32
|
|
10
|
+
@temp_outdir = "/tmp/wiretap_test_outputs_#{$STAMP}"
|
|
11
|
+
FileUtils.mkdir_p(@temp_outdir)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_read_audio
|
|
15
|
+
output = "#{@temp_outdir}/stonesound.aiff"
|
|
16
|
+
File.open(FIXTURES_DIR + "/raw-snd/simple.stonesound") do |f|
|
|
17
|
+
Wiretap.dump_audio_data(@samples, @rate, @bps, :dlaudio_float, f.read(@samples*@bps/8), output)
|
|
18
|
+
assert_equal "#{output}: AIFF data, AIFF audio\n", `file #{output}`, "Should be recognized as AIFF audio"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_get_format
|
|
23
|
+
assert @format = Wiretap.audio_format(FIXTURES_DIR + "/snd/simple-wave.wav")
|
|
24
|
+
assert_equal 16, @format.bps
|
|
25
|
+
assert_equal 48000.0, @format.rate
|
|
26
|
+
assert_equal 97280, @format.samples
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/common'
|
|
2
|
+
$STAMP = Time.now.to_i
|
|
3
|
+
|
|
4
|
+
class TestImageConversions < Test::Unit::TestCase
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
@width = 720
|
|
8
|
+
@height = 576
|
|
9
|
+
@temp_outdir = "/tmp/wiretap_test_outputs_#{$STAMP}"
|
|
10
|
+
FileUtils.mkdir_p @temp_outdir
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_dump_bmp_24
|
|
14
|
+
output = "#{@temp_outdir}/sgi_24bit.test_run_%s.bmp"
|
|
15
|
+
3.times do | i |
|
|
16
|
+
File.open(FIXTURES_DIR + "/raw/cube_SD_8bit_8f/%s.stoneimage" % i) do |f|
|
|
17
|
+
Wiretap.dump_image_data(@width, @height, 24, f.read(@width*@height*3), output % i)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_dump_sgi_24
|
|
23
|
+
output = "#{@temp_outdir}/sgi_24bit.test_run_%s.sgi"
|
|
24
|
+
FileUtils.rm_f output
|
|
25
|
+
3.times do | i |
|
|
26
|
+
File.open(FIXTURES_DIR + "/raw/cube_SD_8bit_8f/%s.stoneimage" % i) do |f|
|
|
27
|
+
Wiretap.dump_image_data(@width, @height, 24, f.read(@width*@height*3), output % i )
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_dump_bmp36_unpacked
|
|
33
|
+
output = "#{@temp_outdir}/bmp_36bit_from_12u.test_run_%s.bmp"
|
|
34
|
+
FileUtils.rm_f output
|
|
35
|
+
3.times do | i |
|
|
36
|
+
File.open(FIXTURES_DIR + "/raw/cube_SD_12bitU_5f/%s.stoneimage" % i) do |f|
|
|
37
|
+
Wiretap.dump_image_data(@width, @height, 36, f.read(@width*@height*6), output % i)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_dump_bmp36_packed
|
|
43
|
+
output = "#{@temp_outdir}/bmp_36bit_from_12p.test_run_%s.bmp"
|
|
44
|
+
FileUtils.rm_f output
|
|
45
|
+
3.times do | i |
|
|
46
|
+
File.open(FIXTURES_DIR + "/raw/cube_SD_12bitP_5f/%s.stoneimage" % i) do |f|
|
|
47
|
+
Wiretap.dump_image_data(@width, @height, 36, f.read(@width*@height*9/2), output % i )
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def test_dump_sgi36_unpacked
|
|
53
|
+
output = "#{@temp_outdir}/sgi_36bit_from_12u.test_run_%s.sgi"
|
|
54
|
+
FileUtils.rm_f output
|
|
55
|
+
3.times do | i |
|
|
56
|
+
File.open(FIXTURES_DIR + "/raw/cube_SD_12bitU_5f/%s.stoneimage" % i) do |f|
|
|
57
|
+
Wiretap.dump_image_data(@width, @height, 36, f.read(@width*@height*6), output % i)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_dump_sgi36_packed
|
|
63
|
+
output = "#{@temp_outdir}/sgi_36bit_from_12p.test_run_%s.sgi"
|
|
64
|
+
FileUtils.rm_f output
|
|
65
|
+
3.times do | i |
|
|
66
|
+
File.open(FIXTURES_DIR + "/raw/cube_SD_12bitP_5f/%s.stoneimage" % i) do |f|
|
|
67
|
+
Wiretap.dump_image_data(@width, @height, 36, f.read(@width*@height*9/2), output % i)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def test_dump_bmp32
|
|
73
|
+
output = "#{@temp_outdir}/bmp_32bit_from_10bit.test_run_%s.bmp"
|
|
74
|
+
FileUtils.rm_f output
|
|
75
|
+
3.times do | i |
|
|
76
|
+
File.open(FIXTURES_DIR + "/raw/cube_SD_10bit_5f/%s.stoneimage" % i) do |f|
|
|
77
|
+
Wiretap.dump_image_data(@width, @height, 32, f.read(@width*@height*4), output % i)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def test_dump_sgi32
|
|
83
|
+
output = "#{@temp_outdir}/sgi_32bit_from_10bit.test_run_%s.sgi"
|
|
84
|
+
FileUtils.rm_f output
|
|
85
|
+
3.times do | i |
|
|
86
|
+
File.open(FIXTURES_DIR + "/raw/cube_SD_10bit_5f/%s.stoneimage" % i) do |f|
|
|
87
|
+
Wiretap.dump_image_data(@width, @height, 32, f.read(@width*@height*4), output % i )
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def xtest_dump_sgi48_packed
|
|
93
|
+
output = "#{@temp_outdir}/sgi_48bit_from_12p.test_run_%s.sgi"
|
|
94
|
+
FileUtils.rm_f output
|
|
95
|
+
3.times do | i |
|
|
96
|
+
File.open(FIXTURES_DIR + "/raw/cube_SD_12bitP_5f/%s.stoneimage" % i) do |f|
|
|
97
|
+
Wiretap.dump_image_data(@width, @height, 48, f.read(@width*@height*9/2), output % i)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def test_dump_sgi48_unpacked
|
|
103
|
+
output = "#{@temp_outdir}/sgi_48bit_from_12u.test_run_%s.sgi"
|
|
104
|
+
FileUtils.rm_f output
|
|
105
|
+
3.times do | i |
|
|
106
|
+
File.open(FIXTURES_DIR + "/raw/cube_SD_12bitU_5f/%s.stoneimage" % i) do |f|
|
|
107
|
+
Wiretap.dump_image_data(@width, @height, 48, f.read(@width*@height*6), output % i)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def test_ppm_format
|
|
113
|
+
assert @format = Wiretap::image_format(FIXTURES_DIR + "/img/ppm-8bit/01.ppm"), "Should retrieve format from ppm file"
|
|
114
|
+
assert_equal 720, @format.width
|
|
115
|
+
assert_equal 576, @format.height
|
|
116
|
+
assert_equal 24, @format.bpp
|
|
117
|
+
assert_equal 3, @format.channels
|
|
118
|
+
assert_equal 720*576*3, @format.buffer_size
|
|
119
|
+
assert_equal 25, @format.rate
|
|
120
|
+
assert_equal :progressive, @format.scan
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def test_ppm_to_sgi
|
|
124
|
+
assert Wiretap::convert_image(FIXTURES_DIR + "/img/ppm-8bit/01.ppm","#{@temp_outdir}/ppm1.sgi")
|
|
125
|
+
assert_equal "#{@temp_outdir}/ppm1.sgi: SGI image data, 3-D, 720 x 576, 3 channels\n", `file #{@temp_outdir}/ppm1.sgi`
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def teardown
|
|
129
|
+
`open #{@temp_outdir}`
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module TestConnectToTestHost
|
|
2
|
+
def test_02_connect_to_test_host
|
|
3
|
+
faulty_server = Wiretap::Server.new("xyz.zy.google.net")
|
|
4
|
+
assert_kind_of Wiretap::Server, faulty_server, "This should be a Wiretap server object"
|
|
5
|
+
assert !faulty_server.alive?, "The faulty server should be registered dead"
|
|
6
|
+
|
|
7
|
+
assert_kind_of Wiretap::Server, @server, "This should be a Wiretap server object"
|
|
8
|
+
assert @server.alive?, "The server should be alive to test it - maybe you have mistakenly entered a faulty IP adderss?"
|
|
9
|
+
|
|
10
|
+
assert_equal @test_host, @server.hostname
|
|
11
|
+
assert_match /(\d+)/, @server.version, "Server version has to be a String and has to contain a number"
|
|
12
|
+
assert_match /Discreet/, @server.vendor, "The vendor should be Discreet"
|
|
13
|
+
assert_match /IFFFS/, @server.product, "The product should be IFFS (InfernoFlintFlameSmoke)"
|
|
14
|
+
|
|
15
|
+
assert @server.close!, "The connection should be closed succesfully"
|
|
16
|
+
|
|
17
|
+
assert_raise(Wiretap::Error, "Accessing a closed server handle should raise") do
|
|
18
|
+
root = @server.root
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_02a_bailing_when_opening_from_dead_server
|
|
23
|
+
assert_raise(Wiretap::ServerDead) { nonexistent_lib = Wiretap::open("10.2.2.2/Bla") }
|
|
24
|
+
dead_server = Wiretap::Server.new("10.2.2.2/Bla")
|
|
25
|
+
assert !dead_server.alive?, "The dead server should respond dead"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module TestCreateTestProject
|
|
2
|
+
def test_02a_create_test_project
|
|
3
|
+
begin
|
|
4
|
+
@project = @volume.create_project("RubyWiretapTest_#{Time.now.to_i}")
|
|
5
|
+
assert_kind_of Wiretap::Project, @project
|
|
6
|
+
rescue Wiretap::Error
|
|
7
|
+
@project = @volume[@test_project_name]
|
|
8
|
+
unless @project
|
|
9
|
+
$stderr.puts "This server does not allow creation of Project nodes - #{OLD_SERVER}"
|
|
10
|
+
$stderr.puts "We also cannot find the test project, create a project #{@test_project_name} \
|
|
11
|
+
on your server and try again"
|
|
12
|
+
return
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Overload the project name so that next time we use that project for testing
|
|
17
|
+
ENV['RUBY_WIRETAP_TEST_PROJECT'] = @project.name
|
|
18
|
+
assert_kind_of Wiretap::Project, @project, "Should be a project node"
|
|
19
|
+
|
|
20
|
+
@lib = @project.children[0]
|
|
21
|
+
unless @lib
|
|
22
|
+
begin
|
|
23
|
+
@lib = @project.create_library("TestRun")
|
|
24
|
+
assert_kind_of Wiretap::Library, @lib, "We should have created a library"
|
|
25
|
+
rescue Wiretap::Error
|
|
26
|
+
$stderr.puts "Your test project has no libraries and we cannot create a library automatically. #{OLD_SERVER}"
|
|
27
|
+
return
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Overload the library name so that we use that library next time
|
|
32
|
+
ENV['RUBY_WIRETAP_TEST_LIBRARY'] = @lib.uri
|
|
33
|
+
|
|
34
|
+
# Overload the key for stuff we are going to create on the framestore
|
|
35
|
+
ENV['RUBY_WIRETAP_TEST_RUN'] ||= Time.now.to_i.to_s
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
module TestRawFormatsAndUploads
|
|
2
|
+
BASE_FMT = {
|
|
3
|
+
:ratio => 1.06666004657745, # Pixel aspect
|
|
4
|
+
:meta_tag => :IFFFS_XML,
|
|
5
|
+
:buffer_size => 1244176, # In bytes
|
|
6
|
+
:bpp => 24, # Bits per pixel
|
|
7
|
+
:rate => 25.0, #Framerate
|
|
8
|
+
:tag => :rgb,
|
|
9
|
+
:meta => '<IFFFS_XML Version="1.0"><ClipData><DropMode>NDF</DropMode><SrcTimecode>01:03:31:07</SrcTimecode><TapeName>MASTER_O</TapeName></ClipData></IFFFS_XML>',
|
|
10
|
+
:height => 576,
|
|
11
|
+
:scan => :progressive,
|
|
12
|
+
:channels => 3, # Oh I wish it was 4
|
|
13
|
+
:width => 720,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_04_raw_formats_and_uploads
|
|
18
|
+
@lib = Wiretap::open(@test_library)
|
|
19
|
+
assert_kind_of Wiretap::Library, @lib, "We should have gotten hold of the test library"
|
|
20
|
+
|
|
21
|
+
clip_params = BASE_FMT
|
|
22
|
+
pal_sd = Wiretap::ClipFormat.new(clip_params)
|
|
23
|
+
clip_params.each_pair do | k, v |
|
|
24
|
+
assert pal_sd.respond_to?(k), "Clip format should respond to the getter for #{k}"
|
|
25
|
+
assert pal_sd.respond_to?(k.to_s + "="), "Clip format should respond to the setter for #{k}"
|
|
26
|
+
assert_equal v.to_s, pal_sd.send(k).to_s, "Clip format should retain the value we sent it for #{k}"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Allocate the clip
|
|
30
|
+
begin
|
|
31
|
+
@clip = @lib.create_clip("FirstClip_8bit_#{@test_run}", 'CLIP', pal_sd)
|
|
32
|
+
assert_equal "FirstClip_8bit_#{@test_run}", @clip.name, "The name should have been properly assigned"
|
|
33
|
+
rescue Wiretap::LibraryLocked
|
|
34
|
+
$stderr.puts "\n !! Looks like you still have the library open on your Flame/Smoke. Close it and try to run \
|
|
35
|
+
the tests again"
|
|
36
|
+
return
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
@deletables << @clip
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
fmt = @clip.format
|
|
43
|
+
assert_kind_of Wiretap::ClipFormat, fmt, "Shoud give us the format back"
|
|
44
|
+
|
|
45
|
+
clip_params.each_pair do | k, v |
|
|
46
|
+
assert fmt.respond_to?(k), "Clip format should respond to the getter for #{k}"
|
|
47
|
+
assert fmt.respond_to?(k.to_s + "="), "Clip format should respond to the setter for #{k}"
|
|
48
|
+
assert_equal v.to_s, fmt.send(k).to_s, "Clip format should retain the value we sent it for #{k}"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
raw_cube_dir = TESTS_DIR + '/fixtures/raw/cube_SD_8bit_8f'
|
|
52
|
+
|
|
53
|
+
files = Dir.entries(raw_cube_dir).grep(/stoneimage/).map{|f| raw_cube_dir + '/' + f }
|
|
54
|
+
assert_equal 8, files.length, "We should have 8 paths to 8 frames ready to go"
|
|
55
|
+
|
|
56
|
+
assert_nothing_raised("We should be able to set the length on this new clip") do
|
|
57
|
+
@clip.frames.length = 8
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
assert_raise(Wiretap::Error, "We should NOT be able to allocate the frame length twice") do
|
|
61
|
+
@clip.frames.length = 25
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
assert_kind_of Wiretap::NodeFrames, @clip.frames, "NodeFrames has to be provided to us"
|
|
65
|
+
|
|
66
|
+
assert_nothing_raised("We should easily write the frames one by one") do
|
|
67
|
+
files.each_with_index do | p, i |
|
|
68
|
+
@clip.frames[i] = File.read(p)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
assert_equal 9, @clip.frames.length, "The frame count should be off by 1 because of a bug in Wiretap"
|
|
73
|
+
|
|
74
|
+
dir = "/tmp/wiretap-ruby-export/#{@test_run}"
|
|
75
|
+
assert_nothing_raised("We should be able to create the test exports directory in your /tmp") do
|
|
76
|
+
FileUtils.mkdir_p(dir)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
imgs = []
|
|
80
|
+
assert_nothing_raised("We should be able to export 8bit SGI images") do
|
|
81
|
+
8.times do | at |
|
|
82
|
+
frame_path = "#{dir}/8bit_PAL_#{at}.sgi"
|
|
83
|
+
@clip.frames.dump(at, frame_path)
|
|
84
|
+
imgs << frame_path
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
open_images_in_viewer(imgs, "The images are 8 bit")
|
|
89
|
+
|
|
90
|
+
assert_kind_of Wiretap::SlateClip, @clip.slate, "We should be able to get hold of the slate"
|
|
91
|
+
|
|
92
|
+
raw_cube_dir = TESTS_DIR + '/fixtures/raw/cube_SD_10bit_5f'
|
|
93
|
+
files = Dir.entries(raw_cube_dir).grep(/stoneimage/).map{|f| raw_cube_dir + '/' + f }
|
|
94
|
+
assert_equal 5, files.length, "We should have 5 paths ready to go"
|
|
95
|
+
|
|
96
|
+
ten_bit_clip_params = clip_params.merge({
|
|
97
|
+
:buffer_size => File.stat(files[0]).size, # Life is sweet with a little automation
|
|
98
|
+
:bpp => 32, # Bits per pixel
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
pal_sd_10bit = Wiretap::ClipFormat.new(ten_bit_clip_params)
|
|
102
|
+
ten_bit_clip_params.each_pair do | k, v |
|
|
103
|
+
assert_equal v.to_s, pal_sd_10bit.send(k).to_s, "Clip format should retain the value we sent it for #{k}"
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
assert_nothing_raised("We should be able to create the clip with this format") do
|
|
107
|
+
@clip = @lib.create_clip("TestClip_10bit", "CLIP", pal_sd_10bit)
|
|
108
|
+
@deletables << @clip
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
assert_nothing_raised("We should be able to allocate 5 frames in the new 10bit clip") do
|
|
112
|
+
@clip.frames.length = 5
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
assert_nothing_raised("We should easily write the frames one by one") do
|
|
116
|
+
files.each_with_index do | p, i |
|
|
117
|
+
@clip.frames[i] = File.read(p)
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
imgs = []
|
|
122
|
+
assert_nothing_raised("We should be able to export 16bit SGI images") do
|
|
123
|
+
5.times do | at |
|
|
124
|
+
frame_path = "#{dir}/16bit_PAL_#{at}.sgi"
|
|
125
|
+
@clip.frames.dump(at, frame_path)
|
|
126
|
+
imgs << frame_path
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
open_images_in_viewer(imgs, "The images are 16 bit")
|
|
130
|
+
|
|
131
|
+
raw_cube_dir = TESTS_DIR + '/fixtures/raw/cube_SD_12bitP_5f'
|
|
132
|
+
files = Dir.entries(raw_cube_dir).grep(/stoneimage/).map{|f| raw_cube_dir + '/' + f }
|
|
133
|
+
assert_equal 5, files.length, "We should have 5 paths ready to go"
|
|
134
|
+
|
|
135
|
+
tw_bit_p_bit_clip_params = clip_params.merge({
|
|
136
|
+
:buffer_size => File.stat(files[0]).size, # Life is sweet with a little automation
|
|
137
|
+
:bpp => 36, # Bits per pixel
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
pal_sd_12bit_p = Wiretap::ClipFormat.new(tw_bit_p_bit_clip_params)
|
|
141
|
+
tw_bit_p_bit_clip_params.each_pair do | k, v |
|
|
142
|
+
assert_equal v.to_s, pal_sd_12bit_p.send(k).to_s, "Clip format should retain the value we sent it for #{k}"
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
assert_nothing_raised("We should be able to create the clip with this format") do
|
|
146
|
+
@clip = @lib.create_clip("TestClip_12bitP", "CLIP", pal_sd_12bit_p)
|
|
147
|
+
@deletables << @clip
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
assert_nothing_raised("We should be able to allocate 5 frames in the new 12bitP clip") do
|
|
151
|
+
@clip.frames.length = 5
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
assert_nothing_raised("We should easily write the frames one by one") do
|
|
155
|
+
files.each_with_index do | p, i |
|
|
156
|
+
@clip.frames[i] = File.read(p)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
imgs = []
|
|
161
|
+
assert_nothing_raised("We should be able to export 16bit SGI images") do
|
|
162
|
+
5.times do | at |
|
|
163
|
+
frame_path = "#{dir}/16bit_PAL_#{at}.sgi"
|
|
164
|
+
@clip.frames.dump(at, frame_path)
|
|
165
|
+
imgs << frame_path
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
open_images_in_viewer(imgs, "The images are 16 bit")
|
|
169
|
+
end
|
|
170
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module TestServerList
|
|
2
|
+
def test_01_server_list
|
|
3
|
+
@list = Wiretap::ServerList.new
|
|
4
|
+
assert_kind_of Wiretap::ServerList, @list
|
|
5
|
+
servers = []
|
|
6
|
+
|
|
7
|
+
@list.each do | info |
|
|
8
|
+
assert_kind_of Wiretap::ServerInfo, info, "Should be a Wiretap::ServerInfo object"
|
|
9
|
+
assert info.respond_to?(:server), "ServerInfo should provide the #server method"
|
|
10
|
+
assert_kind_of Wiretap::Server, info.server
|
|
11
|
+
servers << info.server
|
|
12
|
+
end
|
|
13
|
+
assert_equal @list.length, @list.count, "ServerList should provide both length and count and they should equal"
|
|
14
|
+
|
|
15
|
+
# assert_equal servers.length, @list.length, "The number of servers returned should match the number of loop calls"
|
|
16
|
+
assert 0 < @list.length, "ServerList should discover at least one host"
|
|
17
|
+
hostnames = servers.map{|s| s.hostname}
|
|
18
|
+
assert hostnames.include?(@test_host), "One of the discovered servers should have a hostname that you use for testing"
|
|
19
|
+
end
|
|
20
|
+
end
|