Skip to content

Commit 1df1c9f

Browse files
committed
Server source separated into libraries, this makes the code easier to read.
Signed-off-by: Juan Carlos del Valle <jc.ekinox@gmail.com> (imekinox)
1 parent cdea8fd commit 1df1c9f

File tree

15 files changed

+922
-267
lines changed

15 files changed

+922
-267
lines changed
Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,37 @@
1-
######################################################################################
2-
# ActionScript socket server builder
3-
######################################################################################
4-
5-
if (WIN32)
6-
set_source_files_properties(server/as3-server.c PROPERTIES LANGUAGE CXX)
7-
8-
set(THREADS_USE_PTHREADS_WIN32 true)
9-
find_package(Threads REQUIRED)
10-
11-
include_directories(${THREADS_PTHREADS_INCLUDE_DIR})
12-
endif()
13-
14-
add_executable(as3-server server/as3-server.c)
15-
if(APPLE)
16-
set(CMAKE_EXE_LINKER_FLAGS "-framework CoreFoundation -framework IOKit")
17-
else(APPLE)
18-
find_package(Threads REQUIRED)
19-
if (WIN32)
20-
set(MATH_LIB "")
21-
else(WIN32)
22-
set(MATH_LIB "m")
23-
endif()
24-
25-
endif()
26-
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../wrappers/c_sync)
27-
28-
target_link_libraries(as3-server freenect_sync_static ${MATH_LIB} ${CMAKE_THREAD_LIBS_INIT})
1+
######################################################################################
2+
# ActionScript socket server builder
3+
######################################################################################
4+
5+
find_package(JPEG REQUIRED)
6+
7+
include_directories(${JPEG_INCLUDE_DIR})
8+
9+
add_library (as3_jpeg server/as3_jpeg.c)
10+
target_link_libraries (as3_jpeg ${JPEG_LIBRARIES})
11+
12+
add_library (freenect_network server/freenect_network.c)
13+
14+
if (WIN32)
15+
set_source_files_properties(server/as3-server.c PROPERTIES LANGUAGE CXX)
16+
17+
set(THREADS_USE_PTHREADS_WIN32 true)
18+
find_package(Threads REQUIRED)
19+
20+
include_directories(${THREADS_PTHREADS_INCLUDE_DIR})
21+
endif()
22+
23+
add_executable(as3-server server/as3-server.c)
24+
if(APPLE)
25+
set(CMAKE_EXE_LINKER_FLAGS "-framework CoreFoundation -framework IOKit")
26+
else(APPLE)
27+
find_package(Threads REQUIRED)
28+
if (WIN32)
29+
set(MATH_LIB "")
30+
else(WIN32)
31+
set(MATH_LIB "m")
32+
endif()
33+
34+
endif()
35+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../wrappers/c_sync)
36+
37+
target_link_libraries(as3-server freenect_sync_static as3_jpeg freenect_network ${MATH_LIB} ${CMAKE_THREAD_LIBS_INIT})

wrappers/actionscript/org/as3kinect/as3kinect.as

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@
4242
public static const MIC_ID:int = 2;
4343

4444
public static const GET_DEPTH:int = 0;
45-
public static const GET_VIDEO:int = 1;
46-
public static const MIRROR_DEPTH:int = 2;
47-
public static const MIRROR_VIDEO:int = 3;
48-
public static const MIN_DEPTH:int = 4;
49-
public static const MAX_DEPTH:int = 5;
45+
public static const GET_RAW_DEPTH:int = 1;
46+
public static const GET_VIDEO:int = 2;
47+
public static const MIRROR_DEPTH:int = 3;
48+
public static const MIRROR_VIDEO:int = 4;
49+
public static const MIN_DEPTH:int = 5;
50+
public static const MAX_DEPTH:int = 6;
51+
public static const DEPTH_COMPRESSION:int = 7;
52+
public static const VIDEO_COMPRESSION:int = 8;
5053

5154
public static const MOVE_MOTOR:int = 0;
5255
public static const LED_COLOR:int = 1;

wrappers/actionscript/org/as3kinect/as3kinectDepth.as

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ package org.as3kinect {
4040
private var _is_mirrored:Boolean;
4141
private var _min_distance:int;
4242
private var _max_distance:int;
43+
private var _compression:int;
4344
public var bitmap:BitmapData;
4445

4546
public function as3kinectDepth(){
@@ -49,6 +50,7 @@ package org.as3kinect {
4950
_is_mirrored = false;
5051
_min_distance = 600;
5152
_max_distance = 800;
53+
_compression = 20;
5254
bitmap = new BitmapData(as3kinect.IMG_WIDTH, as3kinect.IMG_HEIGHT, false, 0xFF000000);
5355
}
5456

@@ -69,6 +71,23 @@ package org.as3kinect {
6971
}
7072
}
7173

74+
/*
75+
* Tell server to send the latest depth raw frame
76+
* Note: We should lock the command while we are waiting for the data to avoid lag
77+
*/
78+
public function getRawBuffer():void {
79+
if(!_depth_busy){
80+
_depth_busy = true;
81+
_data.clear();
82+
_data.writeByte(as3kinect.CAMERA_ID);
83+
_data.writeByte(as3kinect.GET_RAW_DEPTH);
84+
_data.writeInt(0);
85+
if(_socket.sendCommand(_data) != as3kinect.SUCCESS){
86+
throw new Error('Data was not complete');
87+
}
88+
}
89+
}
90+
7291
public function set busy(flag:Boolean):void
7392
{
7493
_depth_busy = flag;
@@ -132,5 +151,23 @@ package org.as3kinect {
132151
{
133152
return _max_distance;
134153
}
154+
155+
public function set compression(quality:int):void
156+
{
157+
_data.clear();
158+
_data.writeByte(as3kinect.CAMERA_ID);
159+
_data.writeByte(as3kinect.DEPTH_COMPRESSION);
160+
_data.writeInt(int(quality));
161+
if(_socket.sendCommand(_data) != as3kinect.SUCCESS){
162+
throw new Error('Depth: Cannot change depth compression');
163+
} else {
164+
_compression = quality;
165+
}
166+
}
167+
168+
public function get compression():int
169+
{
170+
return _compression;
171+
}
135172
}
136173
}

wrappers/actionscript/org/as3kinect/as3kinectMotor.as

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ package org.as3kinect {
3838
private var _data:ByteArray;
3939
private var _motor_busy:Boolean;
4040
private var _motor_data:motorData;
41+
private var _motor_position:Number;
4142

4243
public function as3kinectMotor(){
4344
_socket = as3kinectSocket.instance;
4445
_data = new ByteArray;
4546
_motor_busy = false;
4647
_motor_data = new motorData;
48+
_motor_position = 0;
4749
}
4850

4951

@@ -104,9 +106,16 @@ package org.as3kinect {
104106
_data.writeInt(position);
105107
if(_socket.sendCommand(_data) != as3kinect.SUCCESS){
106108
throw new Error('Data was not complete');
109+
} else {
110+
_motor_position = position;
107111
}
108112
}
109-
113+
114+
public function get position():Number
115+
{
116+
return _motor_position;
117+
}
118+
110119
// 0 = Turn Off
111120
// 1 = Green
112121
// 2 = Red

0 commit comments

Comments
 (0)