Class: Wiretap::Node
- Inherits:
-
Object
- Object
- Wiretap::Node
- Defined in:
- lib/wiretap.rb,
ext/node.cpp
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
-
#==(other) ⇒ Object
:nodoc:.
- #[](path) ⇒ Object
- #audio? ⇒ Boolean
- #children ⇒ Object
- #clip? ⇒ Boolean
- #create_clip(*args) ⇒ Object
-
#create_library(name) {|node| ... } ⇒ Object
Creates a library as a child of the Project node.
-
#create_node(*args) ⇒ Object
Provided a name and a type creates a child node.
-
#create_project(name) {|node| ... } ⇒ Object
Creates a project as a child of the Volume node.
-
#create_reel(name) {|node| ... } ⇒ Object
Creates a reel as a child of a Desktop or Library node.
-
#destroy ⇒ Object
Destroys all the children of the node and node itself.
- #destroyed? ⇒ Boolean
- #find(path) ⇒ Object
-
#find_child(path) ⇒ Object
Find a Wiretap node in the children of the current node.
- #hires? ⇒ Boolean
- #host? ⇒ Boolean
-
#id ⇒ Object
Returns the node ID of the given node - a unique path to the node on the particular Wiretap host.
-
#id=(id) ⇒ Object
Sets the node ID, use with caution.
-
#import_image(name, filename) ⇒ Object
Imports the first frame of an image in PPM format.
- #import_video(name, file) ⇒ Object
- #library? ⇒ Boolean
- #lowres? ⇒ Boolean
-
#ls ⇒ Object
Returns a list of names of all child nodes.
-
#meta ⇒ Object
Extract the node metadata object @node.metadata.
-
#metadata ⇒ Object
Extract the node metadata object @node.metadata.
-
#name ⇒ Object
Get name of the particular node.
- #node? ⇒ Boolean
- #project? ⇒ Boolean
- #reel? ⇒ Boolean
-
#reload ⇒ Object
Reload the node information from the server.
- #slate? ⇒ Boolean
- #to_s ⇒ Object (also: #inspect)
-
#type ⇒ Object
Get extended type of the particular node as string.
-
#uri ⇒ Object
Returns a URL for the node that you can later pass to Wiretap::open Be alert though that it doesn’t use the frame IDs - that is, if you have 7 reels of the same name (which is a disaster and you should really think about your behavior) and you ask for the uri of the second one, the first one is going to be reopened when you pass the uri to Wiretap::open This is done so that you can maintain “soft links” to specific objects on libraries instead of the frame IDs.
- #volume? ⇒ Boolean
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
62 63 64 |
# File 'lib/wiretap.rb', line 62 def parent @parent end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
61 62 63 |
# File 'lib/wiretap.rb', line 61 def server @server end |
Instance Method Details
#==(other) ⇒ Object
:nodoc:
69 70 71 72 |
# File 'lib/wiretap.rb', line 69 def ==(other) #:nodoc: return false if other.nil? (other.id == self.id) && (other.server == self.server) end |
#[](path) ⇒ Object
64 65 66 67 |
# File 'lib/wiretap.rb', line 64 def [](path) return find(path) if path.is_a?(String) return children[path] if path.is_a?(Numeric) end |
#audio? ⇒ Boolean
#children ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'ext/nodechildren.cpp', line 45 static VALUE wiretap_node_children(VALUE self) { Check_Node_Alive(self); WireTapNodeHandle* node; Data_Get_Struct(self, WireTapNodeHandle, node); VALUE children = Data_Wrap_Struct(cNodeChildren, 0, wiretap_node_children_free, node); rb_iv_set(children, "@node", self); rb_iv_set(children, "@server", rb_iv_get(self, "@server")); return children; } |
#clip? ⇒ Boolean
#create_clip(*args) ⇒ Object
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'ext/node.cpp', line 233
static VALUE wiretap_node_create_clip(int argc, VALUE* argv, VALUE self) {
WireTapNodeHandle* node;
Data_Get_Struct(self, WireTapNodeHandle, node);
VALUE display_name, extended_type, format;
Check_Node_Alive(self);
rb_scan_args(argc, argv, "12", &display_name, &extended_type, &format);
Check_Type(display_name, T_STRING);
WireTapNodeHandle node_return;
if(extended_type == Qnil) {
extended_type = INT2FIX(IFFFS_WT_TYPE_CLIP);
}
if(format == Qnil) {
format = rb_funcall(self, rb_intern("format"), 0);
}
WireTapClipFormat *f;
Data_Get_Struct(format, WireTapClipFormat, f);
switch(TYPE(extended_type)) {
case T_FIXNUM:
NODERUN_EX_E(node, node->createClipNode(CSTR(display_name), *f, NUM2INT(extended_type), node_return));
break;
case T_STRING:
NODERUN_EX_E(node, node->createClipNode(CSTR(display_name), *f, CSTR(extended_type), node_return));
break;
default:
rb_raise(rb_eArgError, "extended type must be integer or string (for instance CLIP, CLIP_SLATE, PROJECT etc.)");
}
return wiretap_node_create_with(node_return, rb_iv_get(self, "@server"), self);
}
|
#create_library(name) {|node| ... } ⇒ Object
Creates a library as a child of the Project node
114 115 116 117 118 |
# File 'lib/wiretap.rb', line 114 def create_library(name) node = create_node(name, "LIBRARY") yield node if block_given? node end |
#create_node(*args) ⇒ Object
Provided a name and a type creates a child node
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'ext/node.cpp', line 204
static VALUE wiretap_node_create_node(int argc, VALUE* argv, VALUE self) {
Check_Node_Alive(self);
WireTapNodeHandle* node;
Data_Get_Struct(self, WireTapNodeHandle, node);
VALUE display_name, extended_type;
rb_scan_args(argc, argv, "11", &display_name, &extended_type);
Check_Type(display_name, T_STRING);
WireTapNodeHandle node_return;
if(extended_type == Qnil) {
extended_type = INT2FIX(0);
}
switch(TYPE(extended_type)) {
case T_FIXNUM:
NODERUN_EX_E(node, node->createNode(CSTR(display_name), NUM2INT(extended_type), node_return));
break;
case T_STRING:
NODERUN_EX_E(node, node->createNode(CSTR(display_name), CSTR(extended_type), node_return));
break;
default:
rb_raise(rb_eArgError, "extended type must be integer or string");
}
return wiretap_node_create_with(node_return, rb_iv_get(self, "@server"), self);
}
|
#create_project(name) {|node| ... } ⇒ Object
Creates a project as a child of the Volume node
107 108 109 110 111 |
# File 'lib/wiretap.rb', line 107 def create_project(name) node = create_node(name, "PROJECT") yield node if block_given? node end |
#create_reel(name) {|node| ... } ⇒ Object
Creates a reel as a child of a Desktop or Library node
121 122 123 124 125 |
# File 'lib/wiretap.rb', line 121 def create_reel(name) node = create_node(name, "REEL") yield node if block_given? node end |
#destroy ⇒ Object
Destroys all the children of the node and node itself
151 152 153 154 155 156 |
# File 'lib/wiretap.rb', line 151 def destroy return true if self.destroyed? children.each {|child| child.destroy unless child.destroyed? } rescue nil destroy_self end |
#destroyed? ⇒ Boolean
81 82 83 |
# File 'lib/wiretap.rb', line 81 def destroyed? @destroyed ? true : false end |
#find(path) ⇒ Object
74 75 76 77 78 79 |
# File 'lib/wiretap.rb', line 74 def find(path) return self if path.empty? return (find_child(path.shift).find(path) rescue nil) if path.respond_to?(:shift) find_child(path) end |
#find_child(path) ⇒ Object
Find a Wiretap node in the children of the current node
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'ext/node.cpp', line 106
static VALUE wiretap_node_find(VALUE self, VALUE path) {
Check_Node_Alive(self);
WireTapNodeHandle* node;
Check_Type(path, T_STRING);
Data_Get_Struct(self, WireTapNodeHandle, node);
if(LEN(path) == 0) {
return self;
}
WireTapNodeHandle child;
if(!WireTapFindChild(*node, CSTR(path), child)) {
if(!node->lastError() || !*node->lastError()) {
return Qnil;
}
rb_raise(eError, "Problem while looking for child '%s': %s", CSTR(path), node->lastError());
}
return wiretap_node_create_with(child, rb_iv_get(self, "@server"), self);
}
|
#hires? ⇒ Boolean
#host? ⇒ Boolean
#id ⇒ Object
Returns the node ID of the given node - a unique path to the node on the particular Wiretap host
73 74 75 76 77 78 79 |
# File 'ext/node.cpp', line 73
static VALUE wiretap_node_get_id(VALUE self) {
Check_Node_Alive(self);
WireTapNodeHandle* node;
Data_Get_Struct(self, WireTapNodeHandle, node);
return rb_str_new2(node->getNodeId().id());
}
|
#id=(id) ⇒ Object
Sets the node ID, use with caution
82 83 84 85 86 87 88 89 90 |
# File 'ext/node.cpp', line 82
static VALUE wiretap_node_set_id(VALUE self, VALUE id) {
Check_Node_Alive(self);
WireTapNodeHandle* node;
Check_Type(id, T_STRING);
Data_Get_Struct(self, WireTapNodeHandle, node);
node->setNodeId(WireTapNodeId(STR(id)));
return self;
}
|
#import_image(name, filename) ⇒ Object
Imports the first frame of an image in PPM format
142 143 144 145 146 147 148 |
# File 'lib/wiretap.rb', line 142 def import_image(name, filename) format = Wiretap::PPM::format(filename) node = create_clip(name, "CLIP", format) node.frames.count = 1 node.frames.write_from_file(0, filename) node end |
#import_video(name, file) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/wiretap.rb', line 127 def import_video(name, file) =begin 1. create directory 2. change to it 3. run mplayer -vo pnm -ao pcm:file=output.wav on our movie 4. format = Wiretap::PPM::format(Dir["."].entries.first) 5. create clip with this format 6. @clip.import_directory(".") 7. Find out format of output.wav 8. create audioclip with this format. NOTE: by default, output format from mplayer is dlaudio_int16_le 9. @audio.import_music("output.wav") =end end |
#library? ⇒ Boolean
#lowres? ⇒ Boolean
#ls ⇒ Object
Returns a list of names of all child nodes
102 103 104 |
# File 'lib/wiretap.rb', line 102 def ls children.map {|c| c.name} end |
#meta ⇒ Object
Extract the node metadata object
@node.
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'ext/node.cpp', line 288
static VALUE wiretap_node_metadata(VALUE self) {
Check_Node_Alive(self);
WireTapNodeHandle* node;
Data_Get_Struct(self, WireTapNodeHandle, node);
VALUE metadata = Data_Wrap_Struct(cNodeMetaData, 0, node_leave, node);
rb_iv_set(metadata, "@node", self);
/*
WireTapStr metaDataBody; <--- !
node->getMetaData(streamName, filter, depth)
plainly speaking - somehow this has to happen, all that schtuff
*/
return metadata;
}
|
#metadata ⇒ Object
Extract the node metadata object
@node.
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'ext/node.cpp', line 288
static VALUE wiretap_node_metadata(VALUE self) {
Check_Node_Alive(self);
WireTapNodeHandle* node;
Data_Get_Struct(self, WireTapNodeHandle, node);
VALUE metadata = Data_Wrap_Struct(cNodeMetaData, 0, node_leave, node);
rb_iv_set(metadata, "@node", self);
/*
WireTapStr metaDataBody; <--- !
node->getMetaData(streamName, filter, depth)
plainly speaking - somehow this has to happen, all that schtuff
*/
return metadata;
}
|
#name ⇒ Object
Get name of the particular node
192 193 194 195 196 197 198 199 200 |
# File 'ext/node.cpp', line 192
static VALUE wiretap_node_get_name(VALUE self) {
Check_Node_Alive(self);
WireTapNodeHandle* node;
Data_Get_Struct(self, WireTapNodeHandle, node);
WireTapStr name;
NODERUN_E(node, node->getDisplayName(name));
return wiretap_to_str(name);
}
|
#node? ⇒ Boolean
#project? ⇒ Boolean
#reel? ⇒ Boolean
#reload ⇒ Object
Reload the node information from the server
93 94 95 96 97 98 99 100 101 102 103 |
# File 'ext/node.cpp', line 93
static VALUE wiretap_node_reload(VALUE self) {
Check_Node_Alive(self);
WireTapNodeHandle* node;
Data_Get_Struct(self, WireTapNodeHandle, node);
WireTapNodeId id = node->getNodeId();
WireTapServerHandle server = node->getServer();
delete node;
*((WireTapNodeHandle **)&(RDATA(self)->data)) = new WireTapNodeHandle(server, id.id());
return self;
}
|
#slate? ⇒ Boolean
#to_s ⇒ Object Also known as: inspect
96 97 98 |
# File 'lib/wiretap.rb', line 96 def to_s "#<#{self.class.to_s} '#{self.name}', children: #{self.children.count}>" end |
#type ⇒ Object
Get extended type of the particular node as string
179 180 181 182 183 184 185 186 187 |
# File 'ext/node.cpp', line 179
static VALUE wiretap_node_get_type(VALUE self) {
Check_Node_Alive(self);
WireTapNodeHandle* node;
Data_Get_Struct(self, WireTapNodeHandle, node);
WireTapStr type;
NODERUN_E(node, node->getNodeTypeStr(type));
return wiretap_to_str(type);
}
|
#uri ⇒ Object
Returns a URL for the node that you can later pass to Wiretap::open Be alert though that it doesn’t use the frame IDs - that is, if you have 7 reels of the same name (which is a disaster and you should really think about your behavior) and you ask for the uri of the second one, the first one is going to be reopened when you pass the uri to Wiretap::open This is done so that you can maintain “soft links” to specific objects on libraries instead of the frame IDs. When the clip gets edited you can still access it by name, although the frame IDs have changed. Same is valid for the reel IDs.
92 93 94 |
# File 'lib/wiretap.rb', line 92 def uri self.server.hostname + '/' + self.id end |