wiretap 0.1
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/LICENSE +32 -0
- data/README +93 -0
- data/ext/Makefile +146 -0
- data/ext/audio_format.cpp +224 -0
- data/ext/bmp.cpp +65 -0
- data/ext/extconf.rb +85 -0
- data/ext/format.cpp +347 -0
- data/ext/image.h +27 -0
- data/ext/image_format.cpp +194 -0
- data/ext/node.cpp +401 -0
- data/ext/nodechildren.cpp +67 -0
- data/ext/nodeframes.cpp +233 -0
- data/ext/nodemetadata.cpp +90 -0
- data/ext/ppm.cpp +132 -0
- data/ext/server.cpp +202 -0
- data/ext/serverlist.cpp +183 -0
- data/ext/sgi.cpp +69 -0
- data/ext/testserver/Makefile +5 -0
- data/ext/testserver/cfg/wiretap_path_translation_db.xml +44 -0
- data/ext/testserver/cfg/wiretapd.cfg +74 -0
- data/ext/testserver/cfg/wiretapd.res +60 -0
- data/ext/testserver/db.sql +50 -0
- data/ext/testserver/server.cpp +206 -0
- data/ext/testserver/testserver.rb +146 -0
- data/ext/thread_worker.cpp +85 -0
- data/ext/wiretap.cpp +68 -0
- data/ext/wiretap.h +115 -0
- data/lib/wiretap.rb +280 -0
- data/test/audio.rb +27 -0
- data/test/convert.rb +35 -0
- data/test/image.rb +101 -0
- data/test/read_frames.rb +142 -0
- data/test/wiretap-images/01.ppm +0 -0
- data/test/wiretap-images/32bit.stoneimage +621 -0
- data/test/wiretap-images/36bit.stoneimage +1036 -0
- data/test/wiretap-images/48bit.stoneimage +800 -1
- 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/b1.stonesound +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/wiretap-images/output.wav +0 -0
- data/test/write_frames.rb +82 -0
- metadata +138 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
<!-- This database specifies how a path on a remote machine should be -->
|
2
|
+
<!-- accessed from another machine. The API function "translatePaths" -->
|
3
|
+
<!-- uses the rules specified in this file. Any instance of this file -->
|
4
|
+
<!-- be replaced with a symbolic link to another instance. -->
|
5
|
+
|
6
|
+
<translations>
|
7
|
+
|
8
|
+
<!-- Translations between two specified hosts: -->
|
9
|
+
<!-- ex. -->
|
10
|
+
<!-- <map src_host="server01" src_path="/CXFS/new_clips" -->
|
11
|
+
<!-- dst_host="client01" dst_path="/hosts/server/CXFS/clips" /> -->
|
12
|
+
|
13
|
+
<!-- Translations between a specified host and a group: -->
|
14
|
+
<!-- ex. -->
|
15
|
+
<!-- <map src_host="nt_server" src_path="D:\" -->
|
16
|
+
<!-- dst_host="LustreStations" dst_path="/hosts/server/CXFS/" /> -->
|
17
|
+
|
18
|
+
<!-- Translations between two groups: -->
|
19
|
+
<!-- ex. -->
|
20
|
+
<!-- <map src_host="BurnRenderFarm" src_path="/CXFS/" -->
|
21
|
+
<!-- dst_host="LustreStations" dst_path="/hosts/server/CXFS/" /> -->
|
22
|
+
|
23
|
+
<!-- Translation between two operating systems: -->
|
24
|
+
<!-- {'Irix', 'Linux', 'MacOSX', 'WindowsNT'}: -->
|
25
|
+
<!-- ex. -->
|
26
|
+
<!-- <map src_os="WindowsNT" src_path="C:\Documents and Settings\" -->
|
27
|
+
<!-- dst_os="Irix" dst_path="/users/" /> -->
|
28
|
+
|
29
|
+
<!-- Groups of hosts, can include the optional os attribute of group: -->
|
30
|
+
<!-- ex. -->
|
31
|
+
<!-- <group name="BurnRenderFarm" os="Linux"> -->
|
32
|
+
<!-- <host name="server01" /> -->
|
33
|
+
<!-- <host name="192.168.1.114" /> -->
|
34
|
+
<!-- <host name="192.168.1.118" /> -->
|
35
|
+
<!-- <host name="192.168.1.119" /> -->
|
36
|
+
<!-- </group> -->
|
37
|
+
<!-- -->
|
38
|
+
<!-- <group name="LustreStations"> -->
|
39
|
+
<!-- <host name="client01" /> -->
|
40
|
+
<!-- <host name="192.168.1.106" /> -->
|
41
|
+
<!-- <host name="192.168.1.110" /> -->
|
42
|
+
<!-- </group> -->
|
43
|
+
|
44
|
+
</translations>
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#
|
2
|
+
# Default WireTap Server configuration file
|
3
|
+
#
|
4
|
+
|
5
|
+
[Server]
|
6
|
+
|
7
|
+
# IP addresses to publish in self discovery in addition to house network
|
8
|
+
# IP address which is automatically obtained via gethostname().
|
9
|
+
# Adresses are given in the order in which they should be tried.
|
10
|
+
#
|
11
|
+
#IP0=<ip address of network adapter: numerical or DNS entry>
|
12
|
+
#IP1=<...>
|
13
|
+
#<...>
|
14
|
+
IP0=127.0.0.1
|
15
|
+
|
16
|
+
# TCP port used for data/frame transfers. Default = 7550
|
17
|
+
#
|
18
|
+
#FramePort=<port number>
|
19
|
+
|
20
|
+
# TCP port used for node metadata access. Default = 7549
|
21
|
+
#
|
22
|
+
#NodePort=<port number>
|
23
|
+
|
24
|
+
# TCP multicast port used for advertising servers. Default = 7555
|
25
|
+
#
|
26
|
+
#MulticastPort=<port number>
|
27
|
+
|
28
|
+
|
29
|
+
[PathTranslation]
|
30
|
+
|
31
|
+
# Sets the full path to the path translation database file, The default is set
|
32
|
+
# to cfg/wiretap_path_translation_db.xml, adjacent to the exectuable.
|
33
|
+
#
|
34
|
+
#FilePath=<full path to XML translation file>
|
35
|
+
|
36
|
+
|
37
|
+
[Localization]
|
38
|
+
|
39
|
+
# Sets the path to the resource file containing all localized strings.
|
40
|
+
# You may specify a relative path, in which case we will search for it from
|
41
|
+
# within the same directory where we find the configuration file (i.e., this
|
42
|
+
# file).
|
43
|
+
# By default, there is no localization resource file.
|
44
|
+
#
|
45
|
+
#ResourceFilePath=<path to resource file>
|
46
|
+
|
47
|
+
# Sets the localization language of the WireTap server subsystem. This decides
|
48
|
+
# which strings should be loaded from the file above. The language must be one
|
49
|
+
# of ENG (default), CHS, JPN, DEU, FRA.
|
50
|
+
#
|
51
|
+
#Language=ENG
|
52
|
+
|
53
|
+
|
54
|
+
[Logger]
|
55
|
+
|
56
|
+
# Sets the logging level to one of 'user', 'error', 'warn', 'notice', 'debug'.
|
57
|
+
# Default is 'notice'.
|
58
|
+
#
|
59
|
+
Level=debug
|
60
|
+
|
61
|
+
# Sets the maximum size of a log file before it rotates.
|
62
|
+
#
|
63
|
+
#MaxLogFileSizeInMB=50
|
64
|
+
|
65
|
+
# Sets the maximum number of log files to keep. A log file is created each
|
66
|
+
# time the server is run.
|
67
|
+
#
|
68
|
+
#MaxNumLogFiles=50
|
69
|
+
|
70
|
+
# Sets absolute path to the directory where the log files will be stored.
|
71
|
+
# If not specified, a directory called "log" adjacent to the executable file
|
72
|
+
# will be used. The specified (or default) directory must already exist.
|
73
|
+
#
|
74
|
+
#LogDir=/tmp
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#
|
2
|
+
# WireTap localization resource file. All WireTap server strings for all
|
3
|
+
# supported languages are located in this file. Each section is identified by
|
4
|
+
# the language code. The localization team will take this file and localize
|
5
|
+
# all string for each language.
|
6
|
+
#
|
7
|
+
[ENG]
|
8
|
+
|
9
|
+
WireTapServerAPI:Unimplemented=Not implemented
|
10
|
+
WireTapBaseServer:ServiceUnavailable=Service unavailable
|
11
|
+
WireTapFrameServer:Unimplemented=Not implemented
|
12
|
+
WireTapFrameServer:InvalidStreamId=Invalid stream identifier
|
13
|
+
WireTapNodeServer:InvalidScanFormat=Invalid scan format
|
14
|
+
WireTapNodeServer:InvalidNodeType=Invalid node type
|
15
|
+
WireTapNodeServer:ServiceUnavailable=Service unavailable
|
16
|
+
WireTapNodeServer:IllegalFramePath=Illegal character in frame path
|
17
|
+
|
18
|
+
[JPN]
|
19
|
+
|
20
|
+
WireTapServerAPI:Unimplemented=��������Ă��܂���
|
21
|
+
WireTapBaseServer:ServiceUnavailable=�T�[�r�X���g�p�ł��܂���
|
22
|
+
WireTapFrameServer:Unimplemented=��������Ă��܂���
|
23
|
+
WireTapFrameServer:InvalidStreamId=�����ȃX�g���[�����ʎq
|
24
|
+
WireTapNodeServer:InvalidScanFormat=�����ȃX�L���� �t�H�[�}�b�g
|
25
|
+
WireTapNodeServer:InvalidNodeType=�����ȃm�[�h �^�C�v
|
26
|
+
WireTapNodeServer:ServiceUnavailable=�T�[�r�X���g�p�ł��܂���
|
27
|
+
WireTapNodeServer:IllegalFramePath=�t���[�� �p�X�̕s������
|
28
|
+
|
29
|
+
[FRA]
|
30
|
+
|
31
|
+
WireTapServerAPI:Unimplemented=Not implemented
|
32
|
+
WireTapBaseServer:ServiceUnavailable=Service unavailable
|
33
|
+
WireTapFrameServer:Unimplemented=Not implemented
|
34
|
+
WireTapFrameServer:InvalidStreamId=Invalid stream identifier
|
35
|
+
WireTapNodeServer:InvalidScanFormat=Invalid scan format
|
36
|
+
WireTapNodeServer:InvalidNodeType=Invalid node type
|
37
|
+
WireTapNodeServer:ServiceUnavailable=Service unavailable
|
38
|
+
WireTapNodeServer:IllegalFramePath=Illegal character in frame path
|
39
|
+
|
40
|
+
[DEU]
|
41
|
+
|
42
|
+
WireTapServerAPI:Unimplemented=Nicht implementiert
|
43
|
+
WireTapBaseServer:ServiceUnavailable=Dienst nicht verf�gbar
|
44
|
+
WireTapFrameServer:Unimplemented=Nicht implementiert
|
45
|
+
WireTapFrameServer:InvalidStreamId=Ung�ltige Stream-ID
|
46
|
+
WireTapNodeServer:InvalidScanFormat=Ung�ltiges Scan-Format
|
47
|
+
WireTapNodeServer:InvalidNodeType=Ung�ltiger Knotentyp
|
48
|
+
WireTapNodeServer:ServiceUnavailable=Dienst nicht verf�gbar
|
49
|
+
WireTapNodeServer:IllegalFramePath=Unzul�ssiges Zeichen in Frame-Pfad
|
50
|
+
|
51
|
+
[CHS]
|
52
|
+
|
53
|
+
WireTapServerAPI:Unimplemented=δִ��
|
54
|
+
WireTapBaseServer:ServiceUnavailable=û�з���
|
55
|
+
WireTapFrameServer:Unimplemented=δִ��
|
56
|
+
WireTapFrameServer:InvalidStreamId=��Ч����������ʶ��
|
57
|
+
WireTapNodeServer:InvalidScanFormat=��Ч��ɨ���ʽ
|
58
|
+
WireTapNodeServer:InvalidNodeType=��Ч�Ľڵ�����
|
59
|
+
WireTapNodeServer:ServiceUnavailable=û�з���
|
60
|
+
WireTapNodeServer:IllegalFramePath=֡·�����зǷ��ַ�
|
@@ -0,0 +1,50 @@
|
|
1
|
+
-- MySQL dump 10.10
|
2
|
+
--
|
3
|
+
-- Host: localhost Database: wiretap_development
|
4
|
+
-- ------------------------------------------------------
|
5
|
+
-- Server version 5.0.27
|
6
|
+
|
7
|
+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
8
|
+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
9
|
+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
10
|
+
/*!40101 SET NAMES utf8 */;
|
11
|
+
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
12
|
+
/*!40103 SET TIME_ZONE='+00:00' */;
|
13
|
+
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
14
|
+
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
15
|
+
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
16
|
+
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
17
|
+
|
18
|
+
--
|
19
|
+
-- Table structure for table `nodes`
|
20
|
+
--
|
21
|
+
|
22
|
+
DROP TABLE IF EXISTS `nodes`;
|
23
|
+
CREATE TABLE `nodes` (
|
24
|
+
`id` bigint(20) NOT NULL auto_increment,
|
25
|
+
`parent_id` bigint(20) default NULL,
|
26
|
+
`name` varchar(255) default NULL,
|
27
|
+
`kind` varchar(255) default NULL,
|
28
|
+
PRIMARY KEY (`id`)
|
29
|
+
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
|
30
|
+
|
31
|
+
--
|
32
|
+
-- Dumping data for table `nodes`
|
33
|
+
--
|
34
|
+
|
35
|
+
LOCK TABLES `nodes` WRITE;
|
36
|
+
/*!40000 ALTER TABLE `nodes` DISABLE KEYS */;
|
37
|
+
INSERT INTO `nodes` VALUES (1,NULL,'/',''),(2,1,'stonefs','volume'),(3,2,'Julik','project'),(4,3,'Default','library'),(5,4,'toyota_10bit','clip');
|
38
|
+
/*!40000 ALTER TABLE `nodes` ENABLE KEYS */;
|
39
|
+
UNLOCK TABLES;
|
40
|
+
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
41
|
+
|
42
|
+
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
43
|
+
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
44
|
+
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
45
|
+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
46
|
+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
47
|
+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
48
|
+
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
49
|
+
|
50
|
+
-- Dump completed on 2007-01-11 11:16:29
|
@@ -0,0 +1,206 @@
|
|
1
|
+
#include <WireTapServerAPI.h>
|
2
|
+
#include <string.h>
|
3
|
+
#include <exception>
|
4
|
+
#include <ruby.h>
|
5
|
+
#include <rubyio.h>
|
6
|
+
|
7
|
+
VALUE mWiretap, cTestServer, cAudioFormat, cClipFormat;
|
8
|
+
ID to_i;
|
9
|
+
extern void Init_format();
|
10
|
+
extern void wiretap_format_free(WireTapClipFormat* format);
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
class TestException : public std::exception
|
15
|
+
{
|
16
|
+
public:
|
17
|
+
TestException( const char *msg ) throw() : what_( msg ) {}
|
18
|
+
virtual ~TestException() throw() {}
|
19
|
+
virtual const char *what() const throw() { return what_; }
|
20
|
+
|
21
|
+
private:
|
22
|
+
const char *what_;
|
23
|
+
};
|
24
|
+
|
25
|
+
class TestServer : public WireTapServerAPI
|
26
|
+
{
|
27
|
+
protected:
|
28
|
+
VALUE _server;
|
29
|
+
public:
|
30
|
+
TestServer() : WireTapServerAPI( 0 ) {
|
31
|
+
_server = rb_funcall(cTestServer, rb_intern("new"), 0);
|
32
|
+
rb_gc_register_address(&_server);
|
33
|
+
}
|
34
|
+
virtual ~TestServer() {
|
35
|
+
rb_gc_unregister_address(&_server);
|
36
|
+
}
|
37
|
+
|
38
|
+
protected:
|
39
|
+
virtual void initialize( int argc, char **argv ) {
|
40
|
+
VALUE rargv[argc];
|
41
|
+
for(int i = 0; i < argc; i++) {
|
42
|
+
rargv[i] = rb_str_new2(argv[i]);
|
43
|
+
}
|
44
|
+
rb_funcall2(_server, rb_intern("init"), argc, rargv);
|
45
|
+
}
|
46
|
+
|
47
|
+
virtual void uninitialize() {
|
48
|
+
rb_funcall(_server, rb_intern("uninitialize"), 0);
|
49
|
+
}
|
50
|
+
|
51
|
+
virtual void getServerInfo( WireTapServerInfo &info ) {
|
52
|
+
info.setProduct( "Test IFFFS" );
|
53
|
+
info.setVendor( "Discreet" );
|
54
|
+
info.setProductVersionMajor( 1 );
|
55
|
+
info.setProductVersionMinor( 7 );
|
56
|
+
info.setProductVersionMaint( 0 );
|
57
|
+
info.setProductVersionStr( "1.7" );
|
58
|
+
info.setProductBuild( 123 );
|
59
|
+
info.setDatabase( "Test" );
|
60
|
+
}
|
61
|
+
|
62
|
+
virtual void getRootNode( WireTapStr &nodeId ) {
|
63
|
+
VALUE node_id = rb_funcall(_server, rb_intern("get_root_node"), 0);
|
64
|
+
Check_Type(node_id, T_STRING);
|
65
|
+
nodeId = RSTRING(node_id)->ptr;
|
66
|
+
}
|
67
|
+
|
68
|
+
virtual void createNode( const char *nodeId, const char *displayName, int type, WireTapStr &newChildNode ) {
|
69
|
+
if ( strcmp( nodeId, "/" ) != 0 ) {
|
70
|
+
throw( TestException( "Can only create child nodes of the root node" ) );
|
71
|
+
}
|
72
|
+
VALUE node = rb_funcall(_server, rb_intern("create_node"), 3, rb_str_new2(nodeId), rb_str_new2(displayName), INT2FIX(type));
|
73
|
+
Check_Type(node, T_STRING);
|
74
|
+
newChildNode = RSTRING(node)->ptr;
|
75
|
+
}
|
76
|
+
|
77
|
+
virtual void createClipNode( const char *parentNodeId, const char *displayName, int type, const WireTapClipFormat &format, WireTapStr &newChildNode ) {
|
78
|
+
VALUE clipformat = Data_Wrap_Struct(cClipFormat, 0, wiretap_format_free, new WireTapClipFormat(format));
|
79
|
+
VALUE node = rb_funcall(_server, rb_intern("create_clip_node"), 4, rb_str_new2(parentNodeId), rb_str_new2(displayName), INT2FIX(type), clipformat);
|
80
|
+
Check_Type(node, T_STRING);
|
81
|
+
newChildNode = RSTRING(node)->ptr;
|
82
|
+
}
|
83
|
+
|
84
|
+
virtual void destroyNode( const char *nodeId ) {
|
85
|
+
rb_funcall(_server, rb_intern("destroy_node"), 1, rb_str_new2(nodeId));
|
86
|
+
}
|
87
|
+
|
88
|
+
virtual void getChildren( const char *parentNodeId, WireTapStrList &childNodeIds, WireTapStrList &displayNames ) {
|
89
|
+
VALUE nodes = rb_funcall(_server, rb_intern("get_children"), 1, rb_str_new2(parentNodeId));
|
90
|
+
if(nodes == Qnil) {
|
91
|
+
return;
|
92
|
+
}
|
93
|
+
Check_Type(nodes, T_ARRAY);
|
94
|
+
for(int j = 0; j < RARRAY(nodes)->len; j++) {
|
95
|
+
VALUE description = RARRAY(nodes)->ptr[j];
|
96
|
+
Check_Type(description, T_ARRAY);
|
97
|
+
|
98
|
+
Check_Type(RARRAY(description)->ptr[0], T_STRING);
|
99
|
+
childNodeIds.push_back(RSTRING(RARRAY(description)->ptr[0])->ptr);
|
100
|
+
|
101
|
+
Check_Type(RARRAY(description)->ptr[1], T_STRING);
|
102
|
+
displayNames.push_back(RSTRING(RARRAY(description)->ptr[1])->ptr);
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
virtual void getNodeType( const char *nodeId, int &type ) {
|
107
|
+
type = NUM2INT(rb_funcall(_server, rb_intern("get_node_type"), 1, rb_str_new2(nodeId)));
|
108
|
+
}
|
109
|
+
|
110
|
+
virtual void getNodeTypeStr( const char *nodeId, WireTapStr &typeStr ) {
|
111
|
+
VALUE node_type = rb_funcall(_server, rb_intern("get_node_type_str"), 1, rb_str_new2(nodeId));
|
112
|
+
Check_Type(node_type, T_STRING);
|
113
|
+
typeStr = RSTRING(node_type)->ptr;
|
114
|
+
}
|
115
|
+
|
116
|
+
virtual bool isClipNode( const char *nodeId ) {
|
117
|
+
return RTEST(rb_funcall(_server, rb_intern("clip?"), 1, rb_str_new2(nodeId)));
|
118
|
+
}
|
119
|
+
|
120
|
+
virtual void strToNodeType( const char *str, int &type ) const {
|
121
|
+
type = NUM2INT(rb_funcall(_server, rb_intern("str_to_node_type"), 1, rb_str_new2(str)));
|
122
|
+
}
|
123
|
+
|
124
|
+
virtual void getDisplayName( const char *nodeId, WireTapStr &str ) {
|
125
|
+
VALUE name = rb_funcall(_server, rb_intern("get_display_name"), 1, rb_str_new2(nodeId));
|
126
|
+
Check_Type(name, T_STRING);
|
127
|
+
str = RSTRING(name)->ptr;
|
128
|
+
}
|
129
|
+
|
130
|
+
virtual void getFramePaths( const char *nodeId, WireTapStrList &paths ) {
|
131
|
+
VALUE frames = rb_funcall(_server, rb_intern("get_frame_paths"), 1, rb_str_new2(nodeId));
|
132
|
+
Check_Type(frames, T_ARRAY);
|
133
|
+
for(int j = 0; j < RARRAY(frames)->len; j++) {
|
134
|
+
Check_Type(RARRAY(frames)->ptr[j], T_STRING);
|
135
|
+
paths.push_back(RSTRING(RARRAY(frames)->ptr[j])->ptr);
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
virtual void setFramePaths( const char *nodeId, const WireTapStrList &paths, const WireTapClipFormat &format ) {
|
140
|
+
throw( TestException( "setFramePaths: unimplemented" ) );
|
141
|
+
}
|
142
|
+
|
143
|
+
virtual void getClipFormat( const char *nodeId, WireTapClipFormat &format ) {
|
144
|
+
VALUE r_format = rb_funcall(_server, rb_intern("get_clip_format"), 1, rb_str_new2(nodeId));
|
145
|
+
if(r_format == Qnil) {
|
146
|
+
return;
|
147
|
+
}
|
148
|
+
WireTapClipFormat* _format;
|
149
|
+
Data_Get_Struct(r_format, WireTapClipFormat, _format);
|
150
|
+
// Copy _format to _format
|
151
|
+
throw( TestException( "getClipFormat: unimplemented" ) );
|
152
|
+
}
|
153
|
+
|
154
|
+
virtual void getMetaData( const char *nodeId,
|
155
|
+
const char *streamName,
|
156
|
+
WireTapStr &metaData )
|
157
|
+
{
|
158
|
+
throw( TestException( "getMetaData: unimplemented" ) );
|
159
|
+
}
|
160
|
+
|
161
|
+
virtual void setMetaData( const char *nodeId,
|
162
|
+
const char *streamName, const char *metaData )
|
163
|
+
{
|
164
|
+
throw( TestException( "setMetaData: unimplemented" ) );
|
165
|
+
}
|
166
|
+
|
167
|
+
virtual void queryMetaDataSupport( const char *nodeId,
|
168
|
+
WireTapStrList &streamNames )
|
169
|
+
{
|
170
|
+
throw( TestException( "queryMetaDataSupport: unimplemented" ) );
|
171
|
+
}
|
172
|
+
|
173
|
+
virtual WireTapStr streamIdToFilePath( const char *streamId )
|
174
|
+
{
|
175
|
+
// Just return the stream ID passed in as the file path.
|
176
|
+
//
|
177
|
+
return WireTapStr( streamId );
|
178
|
+
}
|
179
|
+
};
|
180
|
+
|
181
|
+
#define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
|
182
|
+
int Argc;
|
183
|
+
char **Argv;
|
184
|
+
FILE* log_file;
|
185
|
+
|
186
|
+
void logger( WireTapServerAPI::Level lev, const char *msg, const char *module, int line ) {
|
187
|
+
//fprintf(log_file, "%d: %s in %s:%d", lev, msg, module, line);
|
188
|
+
printf("%d: %s in %s:%d", lev, msg, module, line);
|
189
|
+
}
|
190
|
+
|
191
|
+
VALUE server_run(VALUE self) {
|
192
|
+
TestServer server;
|
193
|
+
int argc = 1;
|
194
|
+
char *argv[1] = {"server"};
|
195
|
+
return server.mainLoop(argc, argv);
|
196
|
+
}
|
197
|
+
|
198
|
+
extern "C"
|
199
|
+
|
200
|
+
void Init_server() {
|
201
|
+
mWiretap = rb_const_get(rb_cObject, rb_intern("Wiretap"));
|
202
|
+
cTestServer = rb_const_get(mWiretap, rb_intern("TestServer"));
|
203
|
+
Init_format();
|
204
|
+
rb_define_singleton_method(mWiretap, "server_run", VALUEFUNC(server_run), 0);
|
205
|
+
to_i = rb_intern("to_i");
|
206
|
+
}
|
@@ -0,0 +1,146 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'active_record'
|
5
|
+
|
6
|
+
ActiveRecord::Base.establish_connection(
|
7
|
+
:adapter => "mysql",
|
8
|
+
:socket => "/var/run/mysqld/mysqld.sock",
|
9
|
+
:database => "wiretap_development",
|
10
|
+
:username => "root",
|
11
|
+
:password => ""
|
12
|
+
)
|
13
|
+
|
14
|
+
class Node < ActiveRecord::Base
|
15
|
+
acts_as_tree
|
16
|
+
|
17
|
+
def self.root
|
18
|
+
Node.find(:first, :conditions => "parent_id is NULL")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module Wiretap
|
23
|
+
class TestServer
|
24
|
+
|
25
|
+
#initialize with array of argument.
|
26
|
+
def init(*args)
|
27
|
+
puts "Initing with #{args.inspect}"
|
28
|
+
end
|
29
|
+
|
30
|
+
# shutdown server
|
31
|
+
def uninitialize
|
32
|
+
puts "Unitializing"
|
33
|
+
end
|
34
|
+
|
35
|
+
# root node ID is usually "/"
|
36
|
+
def get_root_node
|
37
|
+
puts "Requested root node"
|
38
|
+
"/"
|
39
|
+
end
|
40
|
+
|
41
|
+
# create node, being child of node_id with name display_name of kind type
|
42
|
+
# returning id of new node
|
43
|
+
def create_node(node_id, display_name, type)
|
44
|
+
puts "Create node: #{node_id}:#{display_name}:#{type}"
|
45
|
+
""
|
46
|
+
end
|
47
|
+
|
48
|
+
# create node, being child of node_id with name display_name of kind type
|
49
|
+
# returning id of new node
|
50
|
+
def create_clip_node(node_id, display_name, type, format)
|
51
|
+
puts "Creating clip node: #{node_id}:#{display_name}:#{type}:#{format}"
|
52
|
+
""
|
53
|
+
end
|
54
|
+
|
55
|
+
# destroy node by it's ID
|
56
|
+
def destroy_node(node_id)
|
57
|
+
puts "Destroying #{node_id}"
|
58
|
+
end
|
59
|
+
|
60
|
+
# get_children returns list of pairs of name: [ [id, display_name], [id, display_name], ...]
|
61
|
+
def get_children(parent_node_id)
|
62
|
+
parent_node_id = to_internal_id(parent_node_id)
|
63
|
+
puts "Get children of: #{parent_node_id}"
|
64
|
+
Node.find(parent_node_id).children.map {|child| ["/"+child.name, child.name]}
|
65
|
+
end
|
66
|
+
|
67
|
+
# returns numeric type of requested node
|
68
|
+
def get_node_type(node_id)
|
69
|
+
puts "Get node type: #{node_id}"
|
70
|
+
self.class.translate_type_from_string(get_node_type_str(node_id))
|
71
|
+
end
|
72
|
+
|
73
|
+
# returns symbolic (string) type of requested node
|
74
|
+
def get_node_type_str(node_id)
|
75
|
+
node_id = to_internal_id(node_id)
|
76
|
+
puts "Get node type str: #{node_id}"
|
77
|
+
Node.find(node_id).kind
|
78
|
+
end
|
79
|
+
|
80
|
+
# predicate function, whether node is clip node
|
81
|
+
def clip?(node_id)
|
82
|
+
puts "Is clip: #{node_id}"
|
83
|
+
["clip", "clip_audio", "clip_audiostream"].include? get_node_type(node_id)
|
84
|
+
end
|
85
|
+
|
86
|
+
# convert string type to node type
|
87
|
+
def str_to_node_type(str)
|
88
|
+
puts "String to node type: #{str}"
|
89
|
+
self.class.translate_type_from_string str
|
90
|
+
end
|
91
|
+
|
92
|
+
# get display name of node by it's physical ID
|
93
|
+
def get_display_name(node_id)
|
94
|
+
node_id = to_internal_id(node_id)
|
95
|
+
puts "Get display name: #{node_id}"
|
96
|
+
Node.find(node_id).name
|
97
|
+
end
|
98
|
+
|
99
|
+
# Loads some mysterious frame paths
|
100
|
+
def get_frame_paths(node_id)
|
101
|
+
puts "Get frame paths: #{node_id}"
|
102
|
+
[]
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
def root
|
107
|
+
File.dirname(__FILE__) + "/../../test/wiretap_root/192.168.171.17"
|
108
|
+
end
|
109
|
+
|
110
|
+
def path(node_id)
|
111
|
+
root + "/" + node_id
|
112
|
+
end
|
113
|
+
|
114
|
+
def to_internal_id(node_id)
|
115
|
+
case node_id
|
116
|
+
when "/"
|
117
|
+
return 1
|
118
|
+
end
|
119
|
+
Node.find(:first, :conditions => ["name = ?", node_id]).id rescue node_id
|
120
|
+
end
|
121
|
+
|
122
|
+
@@node_types = [
|
123
|
+
"node",
|
124
|
+
"host",
|
125
|
+
"volume",
|
126
|
+
"project",
|
127
|
+
"library",
|
128
|
+
"reel",
|
129
|
+
"clip",
|
130
|
+
"clip_hires",
|
131
|
+
"clip_lowres",
|
132
|
+
"clip_slate",
|
133
|
+
"clip_audio",
|
134
|
+
"clip_audiostream",
|
135
|
+
"user",
|
136
|
+
"setup",
|
137
|
+
"user_preference"
|
138
|
+
]
|
139
|
+
def self.translate_type_from_string(type)
|
140
|
+
@@node_types.index(type) || (puts "Fuck: #{type}"; 0)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
require 'server'
|
146
|
+
Wiretap.server_run
|
@@ -0,0 +1,85 @@
|
|
1
|
+
#include <ruby.h>
|
2
|
+
#include <rubyio.h>
|
3
|
+
#include <sys/types.h>
|
4
|
+
#include <sys/wait.h>
|
5
|
+
#include <unistd.h>
|
6
|
+
#include <string.h>
|
7
|
+
#include <stdio.h>
|
8
|
+
#include <errno.h>
|
9
|
+
|
10
|
+
|
11
|
+
extern VALUE mWiretap;
|
12
|
+
#define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
|
13
|
+
|
14
|
+
|
15
|
+
VALUE mThreadWorker;
|
16
|
+
int children_count;
|
17
|
+
|
18
|
+
static void start_command(int number) {
|
19
|
+
VALUE command = rb_yield(INT2NUM(number));
|
20
|
+
Check_Type(command, T_STRING);
|
21
|
+
|
22
|
+
char command_fmt[] = "exec %s";
|
23
|
+
char command_line[RSTRING(command)->len + sizeof(command_fmt) + 20];
|
24
|
+
snprintf(command_line, sizeof(command_line), command_fmt, RSTRING(command)->ptr);
|
25
|
+
|
26
|
+
pid_t pid = fork();
|
27
|
+
switch(pid) {
|
28
|
+
case -1: {
|
29
|
+
rb_raise(rb_eStandardError, "Couldn't fork because of: %s", strerror(errno));
|
30
|
+
}
|
31
|
+
case 0: {
|
32
|
+
execl("/bin/sh", "sh", "-c", command_line, NULL);
|
33
|
+
}
|
34
|
+
default: {
|
35
|
+
children_count++;
|
36
|
+
break;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
static int init_worker(int num_procs) {
|
42
|
+
int i;
|
43
|
+
for(i = 0; i < num_procs; i++) {
|
44
|
+
start_command(i);
|
45
|
+
}
|
46
|
+
return i;
|
47
|
+
}
|
48
|
+
|
49
|
+
/*
|
50
|
+
* ThreadWorker.run(children_count = 8, &block)
|
51
|
+
*
|
52
|
+
* Block receives number of iteration and returns command, required to launch
|
53
|
+
* at this iteration.
|
54
|
+
*
|
55
|
+
* This function is supposed to work for converting multiple files via
|
56
|
+
* convert utility.
|
57
|
+
*/
|
58
|
+
|
59
|
+
static VALUE thread_worker_run(int argc, VALUE* argv, VALUE self) {
|
60
|
+
VALUE num_procs;
|
61
|
+
rb_scan_args(argc, argv, "01", &num_procs);
|
62
|
+
if(num_procs == Qnil) {
|
63
|
+
num_procs = INT2FIX(8);
|
64
|
+
}
|
65
|
+
|
66
|
+
int counter = init_worker(NUM2INT(num_procs));
|
67
|
+
while(1) {
|
68
|
+
break;
|
69
|
+
}
|
70
|
+
|
71
|
+
int status;
|
72
|
+
pid_t child_pid;
|
73
|
+
while((child_pid = wait(&status)) != -1) {
|
74
|
+
start_command(counter++);
|
75
|
+
}
|
76
|
+
return Qtrue;
|
77
|
+
}
|
78
|
+
|
79
|
+
void Init_thread_worker() {
|
80
|
+
mThreadWorker = rb_define_module_under(mWiretap, "ThreadWorker");
|
81
|
+
|
82
|
+
rb_define_singleton_method(mThreadWorker, "run", VALUEFUNC(thread_worker_run), -1);
|
83
|
+
}
|
84
|
+
|
85
|
+
|