revamped some files
This commit is contained in:
parent
ef3118c763
commit
a3403ab062
@ -1,94 +1,76 @@
|
||||
|
||||
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_ARM_MODE := arm
|
||||
LIBVNCSERVER_ROOT:=./LibVNCServer-0.9.9
|
||||
|
||||
local_c_flags += -Wall -O3 -DLIBVNCSERVER_WITH_WEBSOCKETS -DLIBVNCSERVER_HAVE_LIBPNG
|
||||
LIBVNCSERVER_SRC_FILES:= \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/main.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/rfbserver.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/rfbregion.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/auth.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/sockets.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/stats.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/corre.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/rfbssl_openssl.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/rfbcrypto_openssl.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/hextile.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/rre.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/translate.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/cutpaste.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/httpd.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/cursor.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/font.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/draw.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/websockets.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/selbox.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/cargs.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/ultra.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/scale.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/zlib.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/zrle.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/zrleoutstream.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/zrlepalettehelper.c \
|
||||
$(LIBVNCSERVER_ROOT)/libvncserver/tight.c \
|
||||
$(LIBVNCSERVER_ROOT)/common/d3des.c \
|
||||
$(LIBVNCSERVER_ROOT)/common/vncauth.c \
|
||||
$(LIBVNCSERVER_ROOT)/common/minilzo.c \
|
||||
$(LIBVNCSERVER_ROOT)/common/zywrletemplate.c \
|
||||
$(LIBVNCSERVER_ROOT)/common/turbojpeg.c
|
||||
|
||||
local_src_files:= \
|
||||
input.c \
|
||||
gui.c \
|
||||
adb_method.c \
|
||||
framebuffer_method.c \
|
||||
suinput.c \
|
||||
LOCAL_CFLAGS += -Wall \
|
||||
-O3 \
|
||||
-DLIBVNCSERVER_WITH_WEBSOCKETS \
|
||||
-DLIBVNCSERVER_HAVE_LIBPNG
|
||||
|
||||
LOCAL_LDLIBS += -llog -lz -ldl
|
||||
|
||||
LOCAL_SRC_FILES += \
|
||||
$(LIBVNCSERVER_SRC_FILES)\
|
||||
droidvncserver.c \
|
||||
gralloc_method.c \
|
||||
libvncserver/libvncserver/scale.c \
|
||||
libvncserver/libvncserver/main.c \
|
||||
libvncserver/libvncserver/rfbserver.c \
|
||||
libvncserver/libvncserver/rfbregion.c \
|
||||
libvncserver/libvncserver/auth.c \
|
||||
libvncserver/libvncserver/sockets.c \
|
||||
libvncserver/libvncserver/stats.c \
|
||||
libvncserver/libvncserver/corre.c \
|
||||
libvncserver/libvncserver/hextile.c \
|
||||
libvncserver/libvncserver/rre.c \
|
||||
libvncserver/libvncserver/translate.c \
|
||||
libvncserver/libvncserver/cutpaste.c \
|
||||
libvncserver/libvncserver/httpd.c \
|
||||
libvncserver/libvncserver/cursor.c \
|
||||
libvncserver/libvncserver/font.c \
|
||||
libvncserver/libvncserver/draw.c \
|
||||
libvncserver/libvncserver/selbox.c \
|
||||
libvncserver/libvncserver/minilzo.c \
|
||||
libvncserver/libvncserver/vncauth.c \
|
||||
libvncserver/libvncserver/d3des.c \
|
||||
libvncserver/libvncserver/md5.c \
|
||||
libvncserver/libvncserver/cargs.c \
|
||||
libvncserver/libvncserver/ultra.c \
|
||||
libvncserver/libvncserver/zlib.c \
|
||||
libvncserver/libvncserver/zrle.c \
|
||||
libvncserver/libvncserver/zrleoutstream.c \
|
||||
libvncserver/libvncserver/zrlepalettehelper.c \
|
||||
libvncserver/libvncserver/tight.c \
|
||||
libvncserver/libvncserver/zywrletemplate.c \
|
||||
libvncserver/libvncserver/websockets.c
|
||||
gui.c \
|
||||
inputMethods/input.c \
|
||||
screenMethods/adb.c \
|
||||
screenMethods/framebuffer.c \
|
||||
screenMethods/gralloc.c \
|
||||
screenMethods/flinger.c \
|
||||
suinput/suinput.c
|
||||
|
||||
ginger_up := displaybinder.cpp
|
||||
|
||||
|
||||
local_c_includes := \
|
||||
LOCAL_C_INCLUDES += \
|
||||
$(LOCAL_PATH) \
|
||||
$(LOCAL_PATH)/libvncserver/libvncserver \
|
||||
$(LOCAL_PATH)/libvncserver \
|
||||
$(LOCAL_PATH)/libvncserver/common \
|
||||
$(LOCAL_PATH)/../../zlib \
|
||||
$(LOCAL_PATH)/../../jpeg \
|
||||
$(LOCAL_PATH)/../../openssl/include \
|
||||
$(LOCAL_PATH)/../../libpng \
|
||||
$(LOCAL_PATH)/screenMethods \
|
||||
$(LOCAL_PATH)/inputMethods \
|
||||
$(LOCAL_PATH)/suinput \
|
||||
$(LOCAL_PATH)/../libpng \
|
||||
$(LOCAL_PATH)/../jpeg \
|
||||
$(LOCAL_PATH)/../openssl/include \
|
||||
$(LOCAL_PATH)/$(LIBVNCSERVER_ROOT)/libvncserver \
|
||||
$(LOCAL_PATH)/$(LIBVNCSERVER_ROOT)/common \
|
||||
$(LOCAL_PATH)/$(LIBVNCSERVER_ROOT)/rfb \
|
||||
$(LOCAL_PATH)/$(LIBVNCSERVER_ROOT)/ \
|
||||
$(LOCAL_PATH)/../../nativeMethods/
|
||||
|
||||
#######################################
|
||||
LOCAL_STATIC_LIBRARIES := libjpeg libpng libssl_static libcrypto_static
|
||||
|
||||
# target
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_SRC_FILES += $(local_src_files)
|
||||
LOCAL_CFLAGS += $(local_c_flags) -DANDROID_FROYO
|
||||
LOCAL_C_INCLUDES += $(local_c_includes)
|
||||
|
||||
|
||||
LOCAL_MODULE:= androidvncserver_froyo
|
||||
LOCAL_MODULE_TAGS:= optional
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := libcutils libz libpng jpeg
|
||||
LOCAL_SHARED_LIBRARIES := libcrypto libssl libhardware
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
#######################################
|
||||
|
||||
# target
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_SRC_FILES += $(local_src_files) $(ginger_up)
|
||||
LOCAL_CFLAGS += $(local_c_flags)
|
||||
LOCAL_C_INCLUDES += $(local_c_includes)
|
||||
|
||||
|
||||
LOCAL_MODULE:= androidvncserver_gingerup
|
||||
LOCAL_MODULE_TAGS:= optional
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := libcutils libz libpng jpeg
|
||||
LOCAL_SHARED_LIBRARIES := libcrypto libssl libhardware libsurfaceflinger_client libui
|
||||
LOCAL_MODULE:= androidvncserver
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
@ -18,13 +18,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "framebuffer_method.h"
|
||||
#include "gralloc_method.h"
|
||||
#include "adb_method.h"
|
||||
#include "framebuffer.h"
|
||||
#include "adb.h"
|
||||
|
||||
#include "gui.h"
|
||||
#include "input.h"
|
||||
#include "displaybinder.h"
|
||||
#include "flinger.h"
|
||||
#include "gralloc.h"
|
||||
|
||||
#include "libvncserver/scale.h"
|
||||
#include "rfb/rfb.h"
|
||||
#include "rfb/keysym.h"
|
||||
#include "suinput.h"
|
||||
|
||||
|
||||
#define CONCAT2(a,b) a##b
|
||||
@ -32,48 +37,42 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#define CONCAT3(a,b,c) a##b##c
|
||||
#define CONCAT3E(a,b,c) CONCAT3(a,b,c)
|
||||
|
||||
|
||||
char VNC_PASSWORD[256] = "";
|
||||
int VNC_PORT=5901;
|
||||
/* Android already has 5900 bound natively in some devices. */
|
||||
|
||||
int VNC_PORT=5901;
|
||||
|
||||
unsigned int *cmpbuf;
|
||||
unsigned int *vncbuf;
|
||||
|
||||
static rfbScreenInfoPtr vncscr;
|
||||
|
||||
int idle=0,standby=0, rotation=0,scaling=100;
|
||||
uint32_t idle = 0;
|
||||
uint32_t standby = 0;
|
||||
uint16_t rotation = 0;
|
||||
uint16_t scaling = 100;
|
||||
|
||||
//reverse connection
|
||||
char *rhost = NULL;
|
||||
int rport = 5500;
|
||||
|
||||
void (*update_screen)(void)=NULL;
|
||||
|
||||
enum method_type {AUTO,FRAMEBUFFER,ADB,GRALLOC
|
||||
#ifndef ANDROID_FROYO
|
||||
,GINGERBREAD};
|
||||
#else
|
||||
};
|
||||
#endif
|
||||
|
||||
enum method_type {AUTO,FRAMEBUFFER,ADB,GRALLOC,FLINGER};
|
||||
enum method_type method=AUTO;
|
||||
|
||||
#define PIXEL_TO_VIRTUALPIXEL_FB(i,j) ((j+scrinfo.yoffset)*scrinfo.xres_virtual+i+scrinfo.xoffset)
|
||||
#define PIXEL_TO_VIRTUALPIXEL(i,j) ((j*displayInfo.width)+i)
|
||||
#define PIXEL_TO_VIRTUALPIXEL(i,j) ((j*screenformat.width)+i)
|
||||
|
||||
#define OUT 8
|
||||
#include "update_screen.c"
|
||||
#include "updateScreen.c"
|
||||
#undef OUT
|
||||
|
||||
#define OUT 16
|
||||
#include "update_screen.c"
|
||||
#include "updateScreen.c"
|
||||
#undef OUT
|
||||
|
||||
// #define OUT 24
|
||||
// #include "update_screen.c"
|
||||
// #undef OUT
|
||||
|
||||
#define OUT 32
|
||||
#include "update_screen.c"
|
||||
#include "updateScreen.c"
|
||||
#undef OUT
|
||||
|
||||
inline int getCurrentRotation()
|
||||
@ -146,33 +145,25 @@ void sendServerStopped()
|
||||
void initVncServer(int argc, char **argv)
|
||||
{
|
||||
|
||||
vncbuf = calloc(displayInfo.width * displayInfo.height, displayInfo.bpp/CHAR_BIT);
|
||||
cmpbuf = calloc(displayInfo.width * displayInfo.height, displayInfo.bpp/CHAR_BIT);
|
||||
|
||||
vncbuf = calloc(screenformat.width * screenformat.height, screenformat.bitsPerPixel/CHAR_BIT);
|
||||
cmpbuf = calloc(screenformat.width * screenformat.height, screenformat.bitsPerPixel/CHAR_BIT);
|
||||
|
||||
assert(vncbuf != NULL);
|
||||
assert(cmpbuf != NULL);
|
||||
|
||||
|
||||
if (rotation==0 || rotation==180)
|
||||
vncscr = rfbGetScreen(&argc, argv, displayInfo.width , displayInfo.height, 0 /* not used */ , 3, displayInfo.bpp/CHAR_BIT);
|
||||
vncscr = rfbGetScreen(&argc, argv, screenformat.width , screenformat.height, 0 /* not used */ , 3, screenformat.bitsPerPixel/CHAR_BIT);
|
||||
else
|
||||
vncscr = rfbGetScreen(&argc, argv, displayInfo.height, displayInfo.width, 0 /* not used */ , 3, displayInfo.bpp/CHAR_BIT);
|
||||
vncscr = rfbGetScreen(&argc, argv, screenformat.height, screenformat.width, 0 /* not used */ , 3, screenformat.bitsPerPixel/CHAR_BIT);
|
||||
|
||||
assert(vncscr != NULL);
|
||||
|
||||
vncscr->desktopName = "Android";
|
||||
|
||||
|
||||
vncscr->frameBuffer =(char *)vncbuf;
|
||||
|
||||
|
||||
vncscr->port = VNC_PORT;
|
||||
|
||||
vncscr->kbdAddEvent = keyEvent;
|
||||
vncscr->ptrAddEvent = ptrEvent;
|
||||
vncscr->newClientHook = (rfbNewClientHookPtr)clientHook;
|
||||
|
||||
vncscr->setXCutText = CutText;
|
||||
|
||||
if (strcmp(VNC_PASSWORD,"")!=0)
|
||||
@ -184,19 +175,18 @@ void initVncServer(int argc, char **argv)
|
||||
vncscr->passwordCheck = rfbCheckPasswordByList;
|
||||
}
|
||||
|
||||
|
||||
vncscr->httpDir="/data/data/org.onaips.vnc/files/";
|
||||
vncscr->sslcertfile="self.pem";
|
||||
|
||||
vncscr->serverFormat.redShift=displayInfo.red_offset;
|
||||
vncscr->serverFormat.greenShift=displayInfo.green_offset;
|
||||
vncscr->serverFormat.blueShift=displayInfo.blue_offset;
|
||||
vncscr->serverFormat.redShift = screenformat.redShift;
|
||||
vncscr->serverFormat.greenShift = screenformat.greenShift;
|
||||
vncscr->serverFormat.blueShift = screenformat.blueShift;
|
||||
|
||||
vncscr->serverFormat.redMax=((1<<displayInfo.red_length)-1);
|
||||
vncscr->serverFormat.greenMax=((1<<displayInfo.green_length)-1);
|
||||
vncscr->serverFormat.blueMax=((1<<displayInfo.blue_length)-1);
|
||||
vncscr->serverFormat.redMax = (( 1 << screenformat.redMax) -1);
|
||||
vncscr->serverFormat.greenMax = (( 1 << screenformat.greenMax) -1);
|
||||
vncscr->serverFormat.blueMax = (( 1 << screenformat.blueMax) -1);
|
||||
|
||||
vncscr->serverFormat.bitsPerPixel=displayInfo.bpp;
|
||||
vncscr->serverFormat.bitsPerPixel = screenformat.bitsPerPixel;
|
||||
|
||||
vncscr->alwaysShared = TRUE;
|
||||
vncscr->handleEventsEagerly = TRUE;
|
||||
@ -205,11 +195,8 @@ void initVncServer(int argc, char **argv)
|
||||
rfbInitServer(vncscr);
|
||||
|
||||
//assign update_screen depending on bpp
|
||||
|
||||
if (vncscr->serverFormat.bitsPerPixel == 32)
|
||||
update_screen=&CONCAT2E(update_screen_,32);
|
||||
// else if (vncscr->serverFormat.bitsPerPixel == 24)
|
||||
// update_screen=&CONCAT2E(update_screen_,24);
|
||||
else if (vncscr->serverFormat.bitsPerPixel == 16)
|
||||
update_screen=&CONCAT2E(update_screen_,16);
|
||||
else if (vncscr->serverFormat.bitsPerPixel == 8)
|
||||
@ -222,9 +209,7 @@ void initVncServer(int argc, char **argv)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Mark as dirty since we haven't sent any updates at all yet. */
|
||||
|
||||
rfbMarkRectAsModified(vncscr, 0, 0, vncscr->width, vncscr->height);
|
||||
}
|
||||
|
||||
@ -235,46 +220,46 @@ void rotate(int value)
|
||||
|
||||
L("rotate()");
|
||||
|
||||
|
||||
if (value == -1 ||
|
||||
((value == 90 || value == 270) && (rotation == 0 || rotation == 180)) ||
|
||||
((value==0 || value==180) && (rotation==90 || rotation==270)))
|
||||
{
|
||||
((value == 0 || value == 180) && (rotation == 90 || rotation == 270))) {
|
||||
int h = vncscr->height;
|
||||
int w = vncscr->width;
|
||||
|
||||
vncscr->width = h;
|
||||
vncscr->paddedWidthInBytes = h * displayInfo.bpp / CHAR_BIT;
|
||||
vncscr->paddedWidthInBytes = h * screenformat.bitsPerPixel / CHAR_BIT;
|
||||
vncscr->height = w;
|
||||
|
||||
{
|
||||
rfbClientIteratorPtr iterator;
|
||||
rfbClientPtr cl;
|
||||
iterator = rfbGetClientIterator(vncscr);
|
||||
while ((cl = rfbClientIteratorNext(iterator)) != NULL)
|
||||
cl->newFBSizePending = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (value==-1)
|
||||
{
|
||||
if (value == -1) {
|
||||
rotation += 90;
|
||||
rotation=rotation%360;
|
||||
}
|
||||
else
|
||||
{
|
||||
rotation %= 360;
|
||||
} else {
|
||||
rotation = value;
|
||||
}
|
||||
|
||||
rfbMarkRectAsModified(vncscr, 0, 0, vncscr->width, vncscr->height);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void close_app()
|
||||
{
|
||||
L("Cleaning up...\n");
|
||||
cleanupFramebuffer();
|
||||
if (method == FRAMEBUFFER)
|
||||
closeFB();
|
||||
else if (method == ADB)
|
||||
closeADB();
|
||||
else if (method == GRALLOC)
|
||||
closeGralloc();
|
||||
else if (method == FLINGER)
|
||||
closeFlinger();
|
||||
|
||||
cleanupInput();
|
||||
sendServerStopped();
|
||||
unbindIPCserver();
|
||||
@ -307,6 +292,31 @@ void extractReverseHostPort(char *str)
|
||||
}
|
||||
}
|
||||
|
||||
void initGrabberMethod()
|
||||
{
|
||||
if (method == AUTO) {
|
||||
L("No grabber method selected, auto-detecting...\n");
|
||||
if (initFlinger() != -1)
|
||||
method = FLINGER;
|
||||
else if (initGralloc()!=-1)
|
||||
method = GRALLOC;
|
||||
else if (initFB() != -1) {
|
||||
method = FRAMEBUFFER;
|
||||
} else if (initADB() != -1) {
|
||||
method = ADB;
|
||||
readBufferADB();
|
||||
}
|
||||
} else if (method == FRAMEBUFFER)
|
||||
initFB();
|
||||
else if (method == ADB) {
|
||||
initADB();
|
||||
readBufferADB();
|
||||
} else if (method == GRALLOC)
|
||||
initGralloc();
|
||||
else if (method == FLINGER)
|
||||
initFlinger();
|
||||
}
|
||||
|
||||
void printUsage(char **argv)
|
||||
{
|
||||
L("\nandroidvncserver [parameters]\n"
|
||||
@ -322,20 +332,17 @@ void printUsage(char **argv)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGINT, close_app);//pipe signals
|
||||
//pipe signals
|
||||
signal(SIGINT, close_app);
|
||||
signal(SIGKILL, close_app);
|
||||
signal(SIGILL, close_app);
|
||||
|
||||
if(argc > 1)
|
||||
{
|
||||
if(argc > 1) {
|
||||
int i=1;
|
||||
int r;
|
||||
while(i < argc)
|
||||
{
|
||||
if(*argv[i] == '-')
|
||||
{
|
||||
switch(*(argv[i] + 1))
|
||||
{
|
||||
while(i < argc) {
|
||||
if(*argv[i] == '-') {
|
||||
switch(*(argv[i] + 1)) {
|
||||
case 'h':
|
||||
printUsage(argv);
|
||||
exit(0);
|
||||
@ -346,7 +353,7 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
case 'f':
|
||||
i++;
|
||||
setFramebufferDevice(argv[i]);
|
||||
FB_setDevice(argv[i]);
|
||||
break;
|
||||
case 'P':
|
||||
i++;
|
||||
@ -366,41 +373,30 @@ int main(int argc, char **argv)
|
||||
scaling = r;
|
||||
else
|
||||
scaling = 100;
|
||||
L("scaling to %d percent\n",scaling);
|
||||
break;
|
||||
case 'm':
|
||||
i++;
|
||||
if (strcmp(argv[i],"adb")==0)
|
||||
{
|
||||
method=ADB;
|
||||
L("ADB display grabber selected\n");
|
||||
}
|
||||
else if (strcmp(argv[i],"fb")==0)
|
||||
{
|
||||
method=FRAMEBUFFER;
|
||||
L("Framebuffer display grabber selected\n");
|
||||
}
|
||||
else if (strcmp(argv[i],"gralloc")==0)
|
||||
{
|
||||
method=GRALLOC;
|
||||
L("Gralloc display grabber selected\n");
|
||||
}
|
||||
#ifndef ANDROID_FROYO
|
||||
else if (strcmp(argv[i],"gingerbread")==0)
|
||||
{
|
||||
method=GINGERBREAD;
|
||||
L("Gingerbread display grabber selected\n");
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
L("Grab method \"%s\" not found, reverting to default.\n",argv[i]);
|
||||
}
|
||||
L("scaling to %d%%\n",scaling);
|
||||
break;
|
||||
case 'R':
|
||||
i++;
|
||||
extractReverseHostPort(argv[i]);
|
||||
break;
|
||||
case 'm':
|
||||
i++;
|
||||
if (!strcmp(argv[i],"adb")){
|
||||
method = ADB;
|
||||
L("ADB display grabber selected\n");
|
||||
} else if (!strcmp(argv[i],"fb")) {
|
||||
method = FRAMEBUFFER;
|
||||
L("Framebuffer display grabber selected\n");
|
||||
} else if (!strcmp(argv[i],"gralloc")) {
|
||||
method = GRALLOC;
|
||||
L("Gralloc display grabber selected\n");
|
||||
} else if (!strcmp(argv[i],"flinger")) {
|
||||
method = FLINGER;
|
||||
L("Flinger display grabber selected\n");
|
||||
} else {
|
||||
L("Grab method \"%s\" not found, sticking with auto-detection.\n",argv[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
@ -408,80 +404,37 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
L("Initializing grabber method...\n");
|
||||
|
||||
if (method==AUTO)
|
||||
{
|
||||
L("No grabber method selected, auto-detecting...");
|
||||
do
|
||||
{
|
||||
#ifndef ANDROID_FROYO
|
||||
if (initGingerbreadMethod()!=-1)
|
||||
method=GINGERBREAD;
|
||||
else
|
||||
#endif
|
||||
if (init_gralloc()!=-1)
|
||||
method=GRALLOC;
|
||||
|
||||
else if (initFramebuffer()!=-1)
|
||||
method=FRAMEBUFFER;
|
||||
else if (initADB()!=-1)
|
||||
{
|
||||
method=ADB;
|
||||
updateADBFrame();
|
||||
}
|
||||
break;
|
||||
}
|
||||
while (0);
|
||||
}
|
||||
else if (method==FRAMEBUFFER)
|
||||
initFramebuffer();
|
||||
else if (method==ADB)
|
||||
{
|
||||
initADB();
|
||||
updateADBFrame();
|
||||
}
|
||||
else if (method==GRALLOC)
|
||||
init_gralloc();
|
||||
#ifndef ANDROID_FROYO
|
||||
else if (method==GINGERBREAD)
|
||||
initGingerbreadMethod();
|
||||
#endif
|
||||
initGrabberMethod();
|
||||
|
||||
L("Initializing virtual keyboard and touch device...\n");
|
||||
initInput();
|
||||
|
||||
L("Initializing VNC server:\n");
|
||||
L(" width: %d\n", (int)displayInfo.width);
|
||||
L(" height: %d\n", (int)displayInfo.height);
|
||||
L(" bpp: %d\n", (int)displayInfo.bpp);
|
||||
L(" width: %d\n", (int)screenformat.width);
|
||||
L(" height: %d\n", (int)screenformat.height);
|
||||
L(" bpp: %d\n", (int)screenformat.bitsPerPixel);
|
||||
L(" port: %d\n", (int)VNC_PORT);
|
||||
|
||||
|
||||
L("Colourmap_rgba=%d:%d:%d:%d lenght=%d:%d:%d:%d\n",displayInfo.red_offset,displayInfo.green_offset,displayInfo.blue_offset,displayInfo.alpha_offset,
|
||||
displayInfo.red_length,displayInfo.green_length,displayInfo.blue_length,displayInfo.alpha_length);
|
||||
L("Colourmap_rgba=%d:%d:%d:%d lenght=%d:%d:%d:%d\n", screenformat.redShift, screenformat.greenShift, screenformat.blueShift,screenformat.alphaShift,
|
||||
screenformat.redMax,screenformat.greenMax,screenformat.blueMax,screenformat.alphaMax);
|
||||
|
||||
initVncServer(argc, argv);
|
||||
|
||||
bindIPCserver();
|
||||
sendServerStarted();
|
||||
|
||||
|
||||
|
||||
if (rhost)
|
||||
{
|
||||
if (rhost) {
|
||||
rfbClientPtr cl;
|
||||
cl = rfbReverseConnection(vncscr, rhost, rport);
|
||||
if (cl == NULL)
|
||||
{
|
||||
if (cl == NULL) {
|
||||
char *str=malloc(255*sizeof(char));
|
||||
sprintf(str,"~SHOW|Couldn't connect to remote host:\n%s\n",rhost);
|
||||
|
||||
L("Couldn't connect to remote host: %s\n",rhost);
|
||||
sendMsgToGui(str);
|
||||
free(str);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cl->onHold = FALSE;
|
||||
rfbStartOnHoldClient(cl);
|
||||
}
|
||||
@ -489,11 +442,9 @@ int main(int argc, char **argv)
|
||||
|
||||
rfbRunEventLoop(vncscr,-1,TRUE);
|
||||
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
usleep(300000*(standby/2.0));
|
||||
|
||||
|
||||
if (idle)
|
||||
standby++;
|
||||
else
|
||||
@ -502,12 +453,7 @@ int main(int argc, char **argv)
|
||||
if (vncscr->clientHead == NULL)
|
||||
continue;
|
||||
|
||||
|
||||
update_screen();
|
||||
}
|
||||
|
||||
close_app();
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,7 +17,10 @@ License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
//this file implements a simple IPC connection with the Java GUI
|
||||
|
||||
#include "gui.h"
|
||||
#include "common.h"
|
||||
|
||||
#define SOCKET_ERROR -1
|
||||
#define BUFFER_SIZE 1024
|
||||
@ -41,35 +44,27 @@ int sendMsgToGui(char *buffer)
|
||||
bzero(&server,sizeof(server));
|
||||
server.sin_family = AF_INET;
|
||||
server.sin_addr.s_addr = inet_addr("127.0.0.1");
|
||||
server.sin_port = htons(13131);
|
||||
server.sin_port = htons(DEFAULT_IPC_RECV_PORT);
|
||||
length = sizeof(struct sockaddr_in);
|
||||
|
||||
n=sendto(sock,buffer,
|
||||
strlen(buffer),0,(struct sockaddr *)&server,length);
|
||||
n = sendto(sock,buffer,strlen(buffer),0,(struct sockaddr *)&server,length);
|
||||
if (n < 0) perror("Sendto");
|
||||
|
||||
// L("Sent %s\n",buffer);
|
||||
// n = recvfrom(sock,buffer,256,0,(struct sockaddr *)&from, &length);
|
||||
// if (n < 0) error("recvfrom");
|
||||
// write(1,"Got an ack: ",12);
|
||||
// write(1,buffer,n);
|
||||
|
||||
close(sock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bindIPCserver()
|
||||
{
|
||||
nHostPort=13132;
|
||||
nHostPort=DEFAULT_IPC_SEND_PORT;
|
||||
|
||||
L("Starting IPC connection...");
|
||||
|
||||
/* make a socket */
|
||||
hServerSocket=socket(AF_INET,SOCK_DGRAM,0);
|
||||
|
||||
if(hServerSocket == SOCKET_ERROR)
|
||||
{
|
||||
L("\nCould not make a socket\n");
|
||||
if(hServerSocket == SOCKET_ERROR) {
|
||||
L("Error creating socket\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#define DEFAULT_IPC_RECV_PORT 13131
|
||||
#define DEFAULT_IPC_SEND_PORT 13132
|
||||
#define SOCK_PATH "org.onaips.vnc.gui" //TODO put IPC working on unix sockets
|
||||
|
||||
int sendMsgToGui(char *msg);
|
||||
|
||||
|
@ -22,10 +22,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include "common.h"
|
||||
#include "gui.h"
|
||||
|
||||
#include "rfb/rfb.h"
|
||||
#include "suinput.h"
|
||||
|
||||
#define BUS_VIRTUAL 0x06
|
||||
|
||||
|
||||
|
||||
void initInput();
|
||||
int keysym2scancode(rfbBool down, rfbKeySym c, rfbClientPtr cl, int *sh, int *alt);
|
||||
void transformTouchCoordinates(int *x, int *y,int,int);
|
||||
|
@ -34,7 +34,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define A_CNXN 0x4e584e43
|
||||
@ -44,6 +43,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#define DDMS_RAWIMAGE_VERSION 1
|
||||
|
||||
#define DDMS_RAWIMAGE_VERSION 1
|
||||
|
||||
struct _message {
|
||||
unsigned int command; /* command identifier constant */
|
||||
unsigned int arg0; /* first argument */
|
||||
unsigned int arg1; /* second argument */
|
||||
unsigned int data_length; /* length of payload (0 is allowed) */
|
||||
unsigned int data_crc32; /* crc32 of data payload */
|
||||
unsigned int magic; /* command ^ 0xffffffff */
|
||||
} __attribute__((packed));
|
||||
|
||||
char connect_string[] = {
|
||||
0x43, 0x4e, 0x58, 0x4e, 0x00, 0x00, 0x00, 0x01,
|
||||
0x00, 0x10, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
|
||||
@ -63,6 +73,8 @@ struct fbinfo *fb_info;
|
||||
struct _message *message,*okay_message;
|
||||
int sockfd;
|
||||
|
||||
unsigned int *adbbuf = NULL;
|
||||
|
||||
ssize_t write_socket(int fd, const void *buf, size_t count)
|
||||
{
|
||||
int n = write(fd,buf,count);
|
||||
@ -88,7 +100,7 @@ void read_socket(int fd, void *buf, size_t count)
|
||||
}
|
||||
}
|
||||
|
||||
void send_connect_string()
|
||||
void send_connect_string(void)
|
||||
{
|
||||
write_socket(sockfd,connect_string,sizeof(connect_string));
|
||||
read_socket(sockfd,message,sizeof(struct _message));
|
||||
@ -100,9 +112,9 @@ void send_connect_string()
|
||||
read_socket(sockfd,message,message->data_length);
|
||||
}
|
||||
|
||||
void send_framebuffer_string();
|
||||
void send_framebuffer_string(void);
|
||||
|
||||
int initADB()
|
||||
int initADB(void)
|
||||
{
|
||||
L("--Initializing adb access method--\n");
|
||||
pid_t pid;
|
||||
@ -121,7 +133,7 @@ int initADB()
|
||||
system("killall adbd");
|
||||
system("setprop service.adb.tcp.port -1");
|
||||
system("/sbin/adbd");
|
||||
return;
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -168,7 +180,7 @@ return 0;
|
||||
|
||||
|
||||
|
||||
void send_framebuffer_string()//returns the fb struct size from adb
|
||||
void send_framebuffer_string(void)//returns the fb struct size from adb
|
||||
{
|
||||
int n;
|
||||
char *buffer=NULL;
|
||||
@ -203,6 +215,8 @@ void send_framebuffer_string()//returns the fb struct size from adb
|
||||
|
||||
buffer=(char*)malloc(sizeof(char)*message->data_length);
|
||||
|
||||
struct fbinfo displayInfo;
|
||||
|
||||
read_socket(sockfd,&displayInfo,sizeof(struct fbinfo));
|
||||
|
||||
// L("sizeof(struct fbinfo)=%d\n",sizeof(struct fbinfo));
|
||||
@ -215,9 +229,21 @@ void send_framebuffer_string()//returns the fb struct size from adb
|
||||
if (adbbuf==NULL)
|
||||
adbbuf=(unsigned int*)malloc(displayInfo.size);
|
||||
|
||||
screenformat.bitsPerPixel = displayInfo.bpp;
|
||||
screenformat.width = displayInfo.width;
|
||||
screenformat.height = displayInfo.height;
|
||||
screenformat.redMax = displayInfo.red_length;
|
||||
screenformat.greenMax = displayInfo.green_length;
|
||||
screenformat.blueMax = displayInfo.blue_length;
|
||||
screenformat.alphaMax = displayInfo.alpha_length;
|
||||
screenformat.redShift = displayInfo.red_offset;
|
||||
screenformat.greenShift = displayInfo.green_offset;
|
||||
screenformat.blueShift = displayInfo.blue_offset;
|
||||
screenformat.alphaShift = displayInfo.alpha_offset;
|
||||
screenformat.size = displayInfo.size;
|
||||
}
|
||||
|
||||
void updateADBFrame()
|
||||
unsigned int *readBufferADB(void)
|
||||
{
|
||||
int n=0;
|
||||
int count=0;
|
||||
@ -258,6 +284,12 @@ void updateADBFrame()
|
||||
// if (resp!=A_OKAY)
|
||||
// error("bad OKAY response");
|
||||
|
||||
return adbbuf;
|
||||
}
|
||||
|
||||
void closeADB()
|
||||
{
|
||||
close(sockfd);
|
||||
}
|
||||
|
||||
// test start point
|
||||
|
@ -20,47 +20,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#ifndef ADB_CONNECT_METHOD
|
||||
#define ADB_CONNECT_METHOD
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
// #include <cutils/properties.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
|
||||
|
||||
#define A_CNXN 0x4e584e43
|
||||
#define A_OKAY 0x59414b4f
|
||||
#define A_CLSE 0x45534c43
|
||||
#define A_WRTE 0x45545257
|
||||
|
||||
|
||||
#define DDMS_RAWIMAGE_VERSION 1
|
||||
|
||||
struct _message {
|
||||
unsigned int command; /* command identifier constant */
|
||||
unsigned int arg0; /* first argument */
|
||||
unsigned int arg1; /* second argument */
|
||||
unsigned int data_length; /* length of payload (0 is allowed) */
|
||||
unsigned int data_crc32; /* crc32 of data payload */
|
||||
unsigned int magic; /* command ^ 0xffffffff */
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
|
||||
// void error(const char *msg);
|
||||
// ssize_t write_socket(int fd, const void *buf, size_t count);
|
||||
// ssize_t read_socket(int fd, void *buf, size_t count);
|
||||
// void send_connect_string();
|
||||
|
||||
int initADB();
|
||||
void updateADBFrame();
|
||||
|
||||
unsigned int *adbbuf;
|
||||
int initADB(void);
|
||||
unsigned int *readBufferADB(void);
|
||||
void closeADB(void);
|
||||
|
||||
#endif
|
||||
|
107
jni/vnc/screenMethods/flinger.c
Normal file
107
jni/vnc/screenMethods/flinger.c
Normal file
@ -0,0 +1,107 @@
|
||||
/*
|
||||
droid vnc server - Android VNC server
|
||||
Copyright (C) 2011 Jose Pereira <onaips@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "flinger.h"
|
||||
#include "common.h"
|
||||
|
||||
void *flinger_lib = NULL;
|
||||
|
||||
close_fn_type close_flinger = NULL;
|
||||
readfb_fn_type readfb_flinger = NULL;
|
||||
getscreenformat_fn_type getscreenformat_flinger = NULL;
|
||||
|
||||
int initFlinger(void)
|
||||
{
|
||||
L("--Loading flinger native lib--\n");
|
||||
|
||||
flinger_lib = dlopen("/data/libdvnc_flinger_sdk14.so", RTLD_NOW);
|
||||
if(flinger_lib == NULL) {
|
||||
L("Couldnt load library! Error string: %s\n",dlerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
init_fn_type init_flinger = dlsym(flinger_lib,"init_flinger");
|
||||
if(init_flinger == NULL) {
|
||||
L("Couldn't load init_flinger! Error string: %s\n",dlerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
close_flinger = dlsym(flinger_lib,"close_flinger");
|
||||
if(close_flinger == NULL) {
|
||||
L("Couldn't load close_flinger! Error string: %s\n",dlerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
readfb_flinger = dlsym(flinger_lib,"readfb_flinger");
|
||||
if(readfb_flinger == NULL) {
|
||||
L("Couldn't load readfb_flinger! Error string: %s\n",dlerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
getscreenformat_flinger = dlsym(flinger_lib,"getscreenformat_flinger");
|
||||
if(getscreenformat_flinger == NULL) {
|
||||
L("Couldn't load get_screenformat! Error string: %s\n",dlerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = init_flinger();
|
||||
if (ret == -1) {
|
||||
L("flinger method not supported by this device!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
screenformat = getScreenFormatFlinger();
|
||||
if ( screenformat.width <= 0 ) {
|
||||
L("Error: I have received a bad screen size from flinger.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( readBufferFlinger() == NULL) {
|
||||
L("Error: Could not read surfaceflinger buffer!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
screenFormat getScreenFormatFlinger(void)
|
||||
{
|
||||
screenFormat f;
|
||||
if (getscreenformat_flinger)
|
||||
f = getscreenformat_flinger();
|
||||
return f;
|
||||
}
|
||||
|
||||
void closeFlinger(void)
|
||||
{
|
||||
if (close_flinger)
|
||||
close_flinger();
|
||||
if (flinger_lib)
|
||||
dlclose(flinger_lib);
|
||||
}
|
||||
|
||||
unsigned char *readBufferFlinger(void)
|
||||
{
|
||||
if (readfb_flinger)
|
||||
return readfb_flinger();
|
||||
return NULL;
|
||||
}
|
||||
|
30
jni/vnc/screenMethods/flinger.h
Normal file
30
jni/vnc/screenMethods/flinger.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
droid vnc server - Android VNC server
|
||||
Copyright (C) 2009 Jose Pereira <onaips@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef FLINGER_H
|
||||
#define FLINGER_H
|
||||
|
||||
#include "screenFormat.h"
|
||||
|
||||
int initFlinger(void);
|
||||
void closeFlinger(void);
|
||||
unsigned char *readBufferFlinger(void);
|
||||
screenFormat getScreenFormatFlinger(void);
|
||||
|
||||
#endif
|
@ -21,21 +21,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "framebuffer.h"
|
||||
#include "common.h"
|
||||
#include "gui.h"
|
||||
|
||||
int fbfd = -1;
|
||||
|
||||
unsigned int *fbmmap;
|
||||
|
||||
char framebuffer_device[256] = "/dev/graphics/fb0";
|
||||
|
||||
struct fb_var_screeninfo scrinfo;
|
||||
struct fb_fix_screeninfo fscrinfo;
|
||||
|
||||
void setFramebufferDevice(char *s)
|
||||
void FB_setDevice(char *s)
|
||||
{
|
||||
strcpy(framebuffer_device,s);
|
||||
}
|
||||
|
||||
int initFramebuffer(void)
|
||||
void update_fb_info(void)
|
||||
{
|
||||
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &scrinfo) != 0) {
|
||||
L("ioctl error\n");
|
||||
sendMsgToGui("~SHOW|Framebuffer ioctl error, please try out other display grab method\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
int initFB(void)
|
||||
{
|
||||
L("--Initializing framebuffer access method--\n");
|
||||
|
||||
@ -67,9 +77,8 @@ int initFramebuffer(void)
|
||||
size = scrinfo.yres * 2;
|
||||
}
|
||||
|
||||
if ((scrinfo.bits_per_pixel == 24)) {// && (fscrinfo.line_length/scrinfo.xres_virtual==CHAR_BIT*4))
|
||||
if ((scrinfo.bits_per_pixel == 24)) {
|
||||
scrinfo.bits_per_pixel = 32;
|
||||
|
||||
L("24-bit XRGB display detected\n");
|
||||
}
|
||||
|
||||
@ -83,37 +92,38 @@ int initFramebuffer(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
displayInfo.bpp = scrinfo.bits_per_pixel;
|
||||
displayInfo.size = scrinfo.xres * scrinfo.yres * scrinfo.bits_per_pixel / CHAR_BIT;
|
||||
displayInfo.width = scrinfo.xres;
|
||||
displayInfo.height = scrinfo.yres;
|
||||
displayInfo.red_offset = scrinfo.red.offset;
|
||||
displayInfo.red_length = scrinfo.red.length;
|
||||
displayInfo.green_offset = scrinfo.green.offset;
|
||||
displayInfo.green_length = scrinfo.green.length;
|
||||
displayInfo.blue_offset = scrinfo.blue.offset;
|
||||
displayInfo.blue_length = scrinfo.blue.length;
|
||||
displayInfo.alpha_offset = scrinfo.transp.offset;
|
||||
displayInfo.alpha_length = scrinfo.transp.length;
|
||||
screenformat.bitsPerPixel = scrinfo.bits_per_pixel;
|
||||
screenformat.size = scrinfo.xres * scrinfo.yres * scrinfo.bits_per_pixel / CHAR_BIT;
|
||||
screenformat.width = scrinfo.xres;
|
||||
screenformat.height = scrinfo.yres;
|
||||
screenformat.redShift = scrinfo.red.offset;
|
||||
screenformat.redMax = scrinfo.red.length;
|
||||
screenformat.greenShift = scrinfo.green.offset;
|
||||
screenformat.greenMax = scrinfo.green.length;
|
||||
screenformat.blueShift = scrinfo.blue.offset;
|
||||
screenformat.blueMax = scrinfo.blue.length;
|
||||
screenformat.alphaShift = scrinfo.transp.offset;
|
||||
screenformat.alphaMax = scrinfo.transp.length;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void cleanupFramebuffer(void)
|
||||
void closeFB(void)
|
||||
{
|
||||
if(fbfd != -1)
|
||||
close(fbfd);
|
||||
}
|
||||
|
||||
void update_fb_info()
|
||||
struct fb_var_screeninfo FB_getscrinfo(void)
|
||||
{
|
||||
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &scrinfo) != 0) {
|
||||
L("ioctl error\n");
|
||||
sendMsgToGui("~SHOW|Framebuffer ioctl error, please try out other display grab method\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
return scrinfo;
|
||||
}
|
||||
|
||||
unsigned int *readBufferFB(void)
|
||||
{
|
||||
update_fb_info();
|
||||
return fbmmap;
|
||||
}
|
||||
|
||||
inline int roundUpToPageSize(int x) {
|
||||
return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
|
||||
|
@ -22,15 +22,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include "common.h"
|
||||
|
||||
unsigned int *fbmmap;
|
||||
|
||||
struct fb_var_screeninfo scrinfo;
|
||||
struct fb_fix_screeninfo fscrinfo;
|
||||
|
||||
int initFramebuffer(void);
|
||||
void cleanupFramebuffer(void);
|
||||
void update_fb_info();
|
||||
int roundUpToPageSize(int x);
|
||||
void setFramebufferDevice(char *);
|
||||
int initFB(void);
|
||||
void closeFB(void);
|
||||
unsigned int *readBufferFB(void);
|
||||
void FB_setDevice(char *);
|
||||
struct fb_var_screeninfo FB_getscrinfo(void);
|
||||
|
||||
#endif
|
103
jni/vnc/screenMethods/gralloc.c
Normal file
103
jni/vnc/screenMethods/gralloc.c
Normal file
@ -0,0 +1,103 @@
|
||||
/*
|
||||
droid vnc server - Android VNC server
|
||||
Copyright (C) 2011 Jose Pereira <onaips@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "gralloc.h"
|
||||
#include "common.h"
|
||||
|
||||
void *gralloc_lib = NULL;
|
||||
|
||||
|
||||
close_fn_type close_gralloc = NULL;
|
||||
readfb_fn_type readfb_gralloc = NULL;
|
||||
getscreenformat_fn_type getscreenformat_gralloc = NULL;
|
||||
|
||||
int initGralloc(void)
|
||||
{
|
||||
L("--Loading gralloc native lib--\n");
|
||||
|
||||
gralloc_lib = dlopen("/data/libdvnc_gralloc_sdk14.so", RTLD_NOW);
|
||||
if(gralloc_lib == NULL) {
|
||||
L("Couldnt load library! Error string: %s\n",dlerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
init_fn_type init_gralloc = dlsym(gralloc_lib,"init_gralloc");
|
||||
if(init_gralloc == NULL) {
|
||||
L("Couldn't load init_gralloc! Error string: %s\n",dlerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
close_gralloc = dlsym(gralloc_lib,"close_gralloc");
|
||||
if(close_gralloc == NULL) {
|
||||
L("Couldn't load close_gralloc! Error string: %s\n",dlerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
readfb_gralloc = dlsym(gralloc_lib,"readfb_gralloc");
|
||||
if(readfb_gralloc == NULL) {
|
||||
L("Couldn't load readfb_gralloc! Error string: %s\n",dlerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
getscreenformat_gralloc = dlsym(gralloc_lib,"getscreenformat_gralloc");
|
||||
if(getscreenformat_gralloc == NULL) {
|
||||
L("Couldn't load get_screenformat! Error string: %s\n",dlerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = init_gralloc();
|
||||
if (ret == -1) {
|
||||
L("Gralloc method not supported by this device!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
screenformat = getScreenFormatGralloc();
|
||||
if ( screenformat.width <= 0 ) {
|
||||
L("Error: I have received a bad screen size from gralloc.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
screenFormat getScreenFormatGralloc(void)
|
||||
{
|
||||
screenFormat f;
|
||||
if (getscreenformat_gralloc)
|
||||
f = getscreenformat_gralloc();
|
||||
return f;
|
||||
}
|
||||
|
||||
void closeGralloc(void)
|
||||
{
|
||||
if (close_gralloc)
|
||||
close_gralloc();
|
||||
if (gralloc_lib)
|
||||
dlclose(gralloc_lib);
|
||||
}
|
||||
|
||||
unsigned char *readBufferGralloc(void)
|
||||
{
|
||||
if (readfb_gralloc)
|
||||
return readfb_gralloc();
|
||||
return NULL;
|
||||
}
|
||||
|
30
jni/vnc/screenMethods/gralloc.h
Normal file
30
jni/vnc/screenMethods/gralloc.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
droid vnc server - Android VNC server
|
||||
Copyright (C) 2009 Jose Pereira <onaips@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _GRALLOC_H
|
||||
#define _GRALLOC_H
|
||||
|
||||
#include "screenFormat.h"
|
||||
|
||||
int initGralloc(void);
|
||||
void closeGralloc(void);
|
||||
unsigned char *readBufferGralloc(void);
|
||||
screenFormat getScreenFormatGralloc(void);
|
||||
|
||||
#endif
|
183
jni/vnc/updateScreen.c
Executable file
183
jni/vnc/updateScreen.c
Executable file
@ -0,0 +1,183 @@
|
||||
/*
|
||||
droid VNC server - a vnc server for android
|
||||
Copyright (C) 2011 Jose Pereira <onaips@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#define OUT_T CONCAT3E(uint,OUT,_t)
|
||||
#define FUNCTION CONCAT2E(update_screen_,OUT)
|
||||
|
||||
|
||||
|
||||
void FUNCTION(void)
|
||||
{
|
||||
int i,j;
|
||||
int offset=0,pixelToVirtual;
|
||||
OUT_T* a;
|
||||
OUT_T* b=0;
|
||||
struct fb_var_screeninfo scrinfo; //we'll need this to detect double FB on framebuffer
|
||||
|
||||
if (method==FRAMEBUFFER) {
|
||||
scrinfo = FB_getscrinfo();
|
||||
b = (OUT_T*) readBufferFB();
|
||||
}
|
||||
else if (method==ADB)
|
||||
b = (OUT_T*) readBufferADB();
|
||||
else if (method==GRALLOC)
|
||||
b = (OUT_T*) readBufferGralloc();
|
||||
else if (method==FLINGER)
|
||||
b = (OUT_T*) readBufferFlinger();
|
||||
|
||||
a = (OUT_T*)cmpbuf;
|
||||
|
||||
int max_x=-1,max_y=-1, min_x=99999, min_y=99999;
|
||||
int h;
|
||||
idle=1;
|
||||
|
||||
if (rotation==0) {
|
||||
for (j = 0; j < vncscr->height; j++) {
|
||||
for (i = 0; i < vncscr->width; i++) {
|
||||
offset = j * vncscr->width;
|
||||
|
||||
if (method==FRAMEBUFFER)
|
||||
pixelToVirtual = PIXEL_TO_VIRTUALPIXEL_FB(i,j);
|
||||
else
|
||||
pixelToVirtual = PIXEL_TO_VIRTUALPIXEL(i,j);
|
||||
|
||||
if (a[i + offset]!=b[pixelToVirtual]) {
|
||||
a[i + offset]=b[pixelToVirtual];
|
||||
if (i>max_x)
|
||||
max_x=i;
|
||||
if (i<min_x)
|
||||
min_x=i;
|
||||
|
||||
if (j>max_y)
|
||||
max_y=j;
|
||||
if (j<min_y)
|
||||
min_y=j;
|
||||
|
||||
idle=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (rotation==90) {
|
||||
for (j = 0; j < vncscr->width; j++) {
|
||||
for (i = 0; i < vncscr->height; i++) {
|
||||
offset = i * vncscr->width;
|
||||
|
||||
if (method==FRAMEBUFFER)
|
||||
pixelToVirtual = PIXEL_TO_VIRTUALPIXEL_FB(i,j);
|
||||
else
|
||||
pixelToVirtual = PIXEL_TO_VIRTUALPIXEL(i,j);
|
||||
|
||||
if (a[(vncscr->width - 1 - j + offset)] != b[pixelToVirtual])
|
||||
{
|
||||
a[(vncscr->width - 1 - j + offset)] = b[pixelToVirtual];
|
||||
|
||||
if (i>max_y)
|
||||
max_y=i;
|
||||
if (i<min_y)
|
||||
min_y=i;
|
||||
|
||||
h=vncscr->width-j;
|
||||
|
||||
if (h < min_x)
|
||||
min_x=vncscr->width-j;
|
||||
if (h > max_x)
|
||||
max_x=vncscr->width-j;
|
||||
|
||||
idle=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (rotation==180) {
|
||||
for (j = 0; j < vncscr->height; j++) {
|
||||
for (i = 0; i < vncscr->width; i++) {
|
||||
offset = (vncscr->height - 1 - j) * vncscr->width;
|
||||
|
||||
if (method==FRAMEBUFFER)
|
||||
pixelToVirtual = PIXEL_TO_VIRTUALPIXEL_FB(i,j);
|
||||
else
|
||||
pixelToVirtual = PIXEL_TO_VIRTUALPIXEL(i,j);
|
||||
|
||||
if (a[((vncscr->width - 1 - i) + offset )]!=b[pixelToVirtual]) {
|
||||
a[((vncscr->width - 1 - i) + offset )]=b[pixelToVirtual];
|
||||
|
||||
|
||||
if (i>max_x)
|
||||
max_x=i;
|
||||
if (i<min_x)
|
||||
min_x=i;
|
||||
|
||||
h=vncscr->height-j;
|
||||
|
||||
if (h < min_y)
|
||||
min_y=vncscr->height-j;
|
||||
if (h > max_y)
|
||||
max_y=vncscr->height-j;
|
||||
|
||||
idle=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (rotation==270) {
|
||||
for (j = 0; j < vncscr->width; j++) {
|
||||
for (i = 0; i < vncscr->height; i++) {
|
||||
offset = (vncscr->height - 1 - i) * vncscr->width;
|
||||
|
||||
if (method==FRAMEBUFFER)
|
||||
pixelToVirtual = PIXEL_TO_VIRTUALPIXEL_FB(i,j);
|
||||
else
|
||||
pixelToVirtual = PIXEL_TO_VIRTUALPIXEL(i,j);
|
||||
|
||||
if(a[j + offset] != b[pixelToVirtual]) {
|
||||
a[j + offset] = b[pixelToVirtual];
|
||||
|
||||
if (i>max_y)
|
||||
max_y=i;
|
||||
if (i<min_y)
|
||||
min_y=i;
|
||||
|
||||
if (j < min_x)
|
||||
min_x=j;
|
||||
if (j > max_x)
|
||||
max_x=j;
|
||||
|
||||
idle=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!idle) {
|
||||
memcpy(vncbuf,a,screenformat.width*screenformat.height*screenformat.bitsPerPixel/CHAR_BIT);
|
||||
|
||||
min_x--;
|
||||
min_x--;
|
||||
max_x++;
|
||||
max_y++;
|
||||
|
||||
// L("Changed x(%d-%d) y(%d-%d)\n",min_x,max_x,min_y,max_y);
|
||||
|
||||
rfbMarkRectAsModified(vncscr, min_x, min_y, max_x, max_y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user