libfreerdp-core/surface: separate surface from fastpath.
authorVic Lee <llyzs@163.com>
Tue, 23 Aug 2011 13:01:19 +0000 (21:01 +0800)
committerVic Lee <llyzs@163.com>
Tue, 23 Aug 2011 13:01:19 +0000 (21:01 +0800)
libfreerdp-core/CMakeLists.txt
libfreerdp-core/fastpath.c
libfreerdp-core/surface.c [new file with mode: 0644]
libfreerdp-core/surface.h [new file with mode: 0644]

index 208a7aa..79b4235 100644 (file)
@@ -76,6 +76,8 @@ set(LIBFREERDP_CORE_SRCS
        tpkt.h
        fastpath.c
        fastpath.h
+       surface.c
+       surface.h
        transport.c
        transport.h
        update.c
index fd64ec5..1a1de6d 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "orders.h"
 #include "update.h"
+#include "surface.h"
 
 #include "fastpath.h"
 
@@ -82,71 +83,6 @@ boolean fastpath_read_security_header(rdpFastPath* fastpath, STREAM* s)
        return True;
 }
 
-static int fastpath_recv_update_surfcmd_surface_bits(rdpFastPath* fastpath, STREAM* s)
-{
-       rdpUpdate* update = fastpath->rdp->update;
-       SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command;
-       int pos;
-
-       stream_read_uint16(s, cmd->destLeft);
-       stream_read_uint16(s, cmd->destTop);
-       stream_read_uint16(s, cmd->destRight);
-       stream_read_uint16(s, cmd->destBottom);
-       stream_read_uint8(s, cmd->bpp);
-       stream_seek(s, 2); /* reserved1, reserved2 */
-       stream_read_uint8(s, cmd->codecID);
-       stream_read_uint16(s, cmd->width);
-       stream_read_uint16(s, cmd->height);
-       stream_read_uint32(s, cmd->bitmapDataLength);
-       pos = stream_get_pos(s) + cmd->bitmapDataLength;
-       cmd->bitmapData = stream_get_tail(s);
-
-       IFCALL(update->SurfaceBits, update, cmd);
-
-       stream_set_pos(s, pos);
-
-       return 20 + cmd->bitmapDataLength;
-}
-
-static int fastpath_recv_update_surfcmd_frame_marker(rdpFastPath* fastpath, STREAM* s)
-{
-       uint16 frameAction;
-       uint32 frameId;
-
-       stream_read_uint16(s, frameAction);
-       stream_read_uint32(s, frameId);
-       /*printf("frameAction %d frameId %d\n", frameAction, frameId);*/
-
-       return 6;
-}
-
-static void fastpath_recv_update_surfcmds(rdpFastPath* fastpath, uint16 size, STREAM* s)
-{
-       uint16 cmdType;
-
-       while (size > 2)
-       {
-               stream_read_uint16(s, cmdType);
-               size -= 2;
-
-               switch (cmdType)
-               {
-                       case CMDTYPE_SET_SURFACE_BITS:
-                       case CMDTYPE_STREAM_SURFACE_BITS:
-                               size -= fastpath_recv_update_surfcmd_surface_bits(fastpath, s);
-                               break;
-
-                       case CMDTYPE_FRAME_MARKER:
-                               size -= fastpath_recv_update_surfcmd_frame_marker(fastpath, s);
-                               break;
-
-                       default:
-                               DEBUG_WARN("unknown cmdType 0x%X", cmdType);
-                               return;
-               }
-       }
-}
-
 static void fastpath_recv_orders(rdpFastPath* fastpath, STREAM* s)
 {
        rdpUpdate* update = fastpath->rdp->update;
@@ -202,7 +138,7 @@ static void fastpath_recv_update(rdpFastPath* fastpath, uint8 updateCode, uint16
                        break;
 
                case FASTPATH_UPDATETYPE_SURFCMDS:
-                       fastpath_recv_update_surfcmds(fastpath, size, s);
+                       update_recv_surfcmds(fastpath->rdp->update, size, s);
                        break;
 
                case FASTPATH_UPDATETYPE_PTR_NULL:
diff --git a/libfreerdp-core/surface.c b/libfreerdp-core/surface.c
new file mode 100644 (file)
index 0000000..2e797fc
--- /dev/null
@@ -0,0 +1,86 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Client
+ * Surface Commands
+ *
+ * Copyright 2011 Vic Lee
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "surface.h"
+
+static int update_recv_surfcmd_surface_bits(rdpUpdate* update, STREAM* s)
+{
+       SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command;
+       int pos;
+
+       stream_read_uint16(s, cmd->destLeft);
+       stream_read_uint16(s, cmd->destTop);
+       stream_read_uint16(s, cmd->destRight);
+       stream_read_uint16(s, cmd->destBottom);
+       stream_read_uint8(s, cmd->bpp);
+       stream_seek(s, 2); /* reserved1, reserved2 */
+       stream_read_uint8(s, cmd->codecID);
+       stream_read_uint16(s, cmd->width);
+       stream_read_uint16(s, cmd->height);
+       stream_read_uint32(s, cmd->bitmapDataLength);
+       pos = stream_get_pos(s) + cmd->bitmapDataLength;
+       cmd->bitmapData = stream_get_tail(s);
+
+       IFCALL(update->SurfaceBits, update, cmd);
+
+       stream_set_pos(s, pos);
+
+       return 20 + cmd->bitmapDataLength;
+}
+
+static int update_recv_surfcmd_frame_marker(rdpUpdate* update, STREAM* s)
+{
+       uint16 frameAction;
+       uint32 frameId;
+
+       stream_read_uint16(s, frameAction);
+       stream_read_uint32(s, frameId);
+       /*printf("frameAction %d frameId %d\n", frameAction, frameId);*/
+
+       return 6;
+}
+
+boolean update_recv_surfcmds(rdpUpdate* update, uint16 size, STREAM* s)
+{
+       uint16 cmdType;
+
+       while (size > 2)
+       {
+               stream_read_uint16(s, cmdType);
+               size -= 2;
+
+               switch (cmdType)
+               {
+                       case CMDTYPE_SET_SURFACE_BITS:
+                       case CMDTYPE_STREAM_SURFACE_BITS:
+                               size -= update_recv_surfcmd_surface_bits(update, s);
+                               break;
+
+                       case CMDTYPE_FRAME_MARKER:
+                               size -= update_recv_surfcmd_frame_marker(update, s);
+                               break;
+
+                       default:
+                               DEBUG_WARN("unknown cmdType 0x%X", cmdType);
+                               return False;
+               }
+       }
+       return True;
+}
+
diff --git a/libfreerdp-core/surface.h b/libfreerdp-core/surface.h
new file mode 100644 (file)
index 0000000..960f5cb
--- /dev/null
@@ -0,0 +1,29 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Client
+ * Surface Commands
+ *
+ * Copyright 2011 Vic Lee
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __SURFACE
+#define __SURFACE
+
+#include "rdp.h"
+#include <freerdp/utils/stream.h>
+
+boolean update_recv_surfcmds(rdpUpdate* update, uint16 size, STREAM* s);
+
+#endif /* __SURFACE */
+