Module: Wiretap
- Defined in:
- lib/wiretap.rb,
ext/wiretap.cpp,
ext/testserver/testserver.rb
Defined Under Namespace
Modules: ThreadWorker
Classes: Audio, AudioFormat, AudioFrames, Clip, ClipFormat, Error, HiresClip, Host, Library, LibraryLocked, LowresClip, Node, NodeChildren, NodeFrames, NodeMetaData, Project, Reel, Server, ServerDead, ServerInfo, ServerList, SlateClip, TestServer, Volume
Constant Summary
collapse
- FRAMES_PATTERN =
/[A-Z]_-(\d){10}_[A-Z]_(\d){10}_[A-Z]_(\d){6}/
- CLIENT_VERSION =
rb_str_new2(VERSION)
- AUDIO =
Qfalse
Class Method Summary
collapse
-
.audio_format(filename) ⇒ Object
-
.convert_image(input, output) ⇒ Object
Convert a PPM file to an SGI file.
-
.dump_audio_data(samples, rate, bps, type, raw, filename) ⇒ Object
-
.dump_image_data(width, height, bpp, raw, filename) ⇒ Object
-
.image_format(input) ⇒ Object
Extract Wiretap clip format from image file.
-
.open(uri) ⇒ Object
-
.server_run ⇒ Object
Class Method Details
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
# File 'ext/audio_format.cpp', line 145
static VALUE wiretap_get_audio_format(VALUE self, VALUE filename) {
Check_Type(filename, T_STRING);
SF_INFO sfinfo;
SNDFILE* snd = sf_open(CSTR(filename), SFM_READ, &sfinfo);
WireTapAudioFormat audio_format;
audio_format.setNumSamples(sfinfo.frames);
audio_format.setBitsPerSample(16);
audio_format.setSampleRate(sfinfo.samplerate);
audio_format.setFrameBufferSize(2*sfinfo.frames);
audio_format.setFormatTag("dlaudio_int16_le");
sf_close(snd);
return Data_Wrap_Struct(cAudioFormat, 0, wiretap_format_free, new WireTapAudioFormat(audio_format));
}
|
.convert_image(input, output) ⇒ Object
Convert a PPM file to an SGI file
Wiretap::convert_image("test/wiretap-images/01.ppm", "/tmp/a.sgi")
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
# File 'ext/image_format.cpp', line 162
static VALUE wiretap_convert_image(VALUE self, VALUE input, VALUE output) {
Check_Type(input, T_STRING);
Check_Type(output, T_STRING);
WireTapClipFormat format;
std::auto_ptr<ImageIO> image(ImageIO::open(CSTR(input), format));
if(!image.get()) {
image.release();
THROW("Couldn't open file %s for read", CSTR(input));
}
image->read_format();
std::auto_ptr<unsigned char> frame(image->read_data());
if(!wiretap_write_image_frame(format.width(), format.height(), format.bitsPerPixel(), frame.get(), CSTR(output))) {
rb_warn("Couldn't dump image to file %s", CSTR(output));
return Qfalse;
}
return Qtrue;
}
|
.dump_audio_data(samples, rate, bps, type, raw, filename) ⇒ Object
139
140
141
142
143
|
# File 'ext/audio_format.cpp', line 139
static VALUE wiretap_dump_audio_data(VALUE self, VALUE samples, VALUE rate, VALUE bps, VALUE type, VALUE raw, VALUE filename) {
wiretap_write_audio_frame(NUM2INT(samples), NUM2INT(rb_funcall(rate, rb_intern("to_i"), 0)), NUM2INT(bps), SYM2ID(type),
(unsigned char* )STR(raw), CSTR(filename));
return Qtrue;
}
|
.dump_image_data(width, height, bpp, raw, filename) ⇒ Object
134
135
136
137
|
# File 'ext/image_format.cpp', line 134
VALUE wiretap_dump_image_data(VALUE self, VALUE width, VALUE height, VALUE bpp, VALUE raw, VALUE filename) {
wiretap_write_image_frame(NUM2INT(width), NUM2INT(height), NUM2INT(bpp), (unsigned char* )STR(raw), CSTR(filename));
return Qtrue;
}
|
Extract Wiretap clip format from image file. The format will inherit the bit depths of the image and allocate the framebuffer size into which the imported image will fit
@clipformat = Wiretap::image_format("test/wiretap-images/01.ppm")
145
146
147
148
149
150
151
152
153
154
155
|
# File 'ext/image_format.cpp', line 145
static VALUE wiretap_get_format(VALUE self, VALUE input) {
WireTapClipFormat format;
std::auto_ptr<ImageIO> image(ImageIO::open(CSTR(input), format));
if(!image.get()) {
THROW("Couldn't open file %s for reading", CSTR(input));
}
image->read_format();
VALUE clip_format = rb_funcall(cClipFormat, rb_intern("new"), 0);
DATA_PTR(clip_format) = new WireTapClipFormat(format);
return clip_format;
}
|
.open(uri) ⇒ Object
328
329
330
331
332
333
334
335
|
# File 'lib/wiretap.rb', line 328
def self.open(uri)
return unless match_data = uri.match(/([^\/]+)(\/?)(.*)/)
server = Server.new(match_data.captures.first)
raise Wiretap::ServerDead, "Could not connect to Wiretap host #{match_data.captures.first}" unless server.alive?
return server if match_data.captures.last.empty?
server.find(match_data.captures.last)
end
|
.server_run ⇒ Object
191
192
193
194
195
196
|
# File 'ext/testserver/server.cpp', line 191
VALUE server_run(VALUE self) {
TestServer server;
int argc = 1;
char *argv[1] = {"server"};
return server.mainLoop(argc, argv);
}
|