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

Class Method Details

.audio_format(filename) ⇒ Object



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")


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'ext/image_format.cpp', line 47

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



19
20
21
22
# File 'ext/image_format.cpp', line 19

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;
}

.image_format(input) ⇒ Object

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")


30
31
32
33
34
35
36
37
38
39
40
# File 'ext/image_format.cpp', line 30

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_runObject



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);
}