Exemplo n.º 1
0
/* Called when we have a new peer connecting */
void mf_peer_context_new(freerdp_peer* client, mfPeerContext* context)
{
	context->info = mf_info_get_instance();
	context->rfx_context = rfx_context_new();
	context->rfx_context->mode = RLGR3;
	context->rfx_context->width = client->settings->DesktopWidth;
	context->rfx_context->height = client->settings->DesktopHeight;
	rfx_context_set_pixel_format(context->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8);
	
	//context->nsc_context = nsc_context_new();
	//nsc_context_set_pixel_format(context->nsc_context, RDP_PIXEL_FORMAT_B8G8R8A8);
	
	context->s = stream_new(0xFFFF);
	
	//#ifdef WITH_SERVER_CHANNELS
	context->vcm = WTSCreateVirtualChannelManager(client);
	//#endif
	
	mf_info_peer_register(context->info, context);
}
Exemplo n.º 2
0
/* Called when we have a new peer connecting */
BOOL mf_peer_context_new(freerdp_peer* client, mfPeerContext* context)
{
	if (!(context->info = mf_info_get_instance()))
		return FALSE;

	if (!(context->rfx_context = rfx_context_new(TRUE)))
		goto fail_rfx_context;

	context->rfx_context->mode = RLGR3;
	context->rfx_context->width = client->settings->DesktopWidth;
	context->rfx_context->height = client->settings->DesktopHeight;
	rfx_context_set_pixel_format(context->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8);
	
	//if (!(context->nsc_context = nsc_context_new()))
	//	goto fail_nsc_context;
	//nsc_context_set_pixel_format(context->nsc_context, RDP_PIXEL_FORMAT_B8G8R8A8);
	
	if (!(context->s = Stream_New(NULL, 0xFFFF)))
		goto fail_stream_new;
	
	context->vcm = WTSOpenServerA((LPSTR) client->context);

	if (!context->vcm || context->vcm == INVALID_HANDLE_VALUE)
		goto fail_open_server;
	
	mf_info_peer_register(context->info, context);

	return TRUE;

fail_open_server:
	Stream_Free(context->s, TRUE);
	context->s = NULL;
fail_stream_new:
	rfx_context_free(context->rfx_context);
	context->rfx_context = NULL;
fail_rfx_context:

	return FALSE;
}
Exemplo n.º 3
0
void mf_peer_rfx_update(freerdp_peer* client)
{
	//check
	mfInfo* mfi = mf_info_get_instance();
	
	mf_info_find_invalid_region(mfi);
	
	if (mf_info_have_invalid_region(mfi) == false) {
		return;
	}
	
	
	long width;
	long height;
	int pitch;
	BYTE* dataBits = NULL;
	
	mf_info_getScreenData(mfi, &width, &height, &dataBits, &pitch);
	
	mf_info_clear_invalid_region(mfi);
	
	//encode
	
	wStream* s;
	RFX_RECT rect;
	rdpUpdate* update;
	mfPeerContext* mfp;
	SURFACE_BITS_COMMAND* cmd;
	
	update = client->update;
	mfp = (mfPeerContext*) client->context;
	cmd = &update->surface_bits_command;
	
	
	s = mfp->s;
	Stream_Clear(s);
	Stream_SetPosition(s, 0);
	
	UINT32 x = mfi->invalid.x / mfi->scale;
	UINT32 y = mfi->invalid.y / mfi->scale;
	
	rect.x = 0;
	rect.y = 0;
	rect.width = width;
	rect.height = height;
	
	mfp->rfx_context->width = mfi->servscreen_width;
	mfp->rfx_context->height = mfi->servscreen_height;
	
	if (!(rfx_compose_message(mfp->rfx_context, s, &rect, 1,
		(BYTE*) dataBits, rect.width, rect.height, pitch)))
	{
		return;
	}
	
	cmd->destLeft = x;
	cmd->destTop = y;
	cmd->destRight = x + rect.width;
	cmd->destBottom = y + rect.height;
	
	
	cmd->bpp = 32;
	cmd->codecID = 3;
	cmd->width = rect.width;
	cmd->height = rect.height;
	cmd->bitmapDataLength = Stream_GetPosition(s);
	cmd->bitmapData = Stream_Buffer(s);
	
	//send
	
	update->SurfaceBits(update->context, cmd);
	
	//clean up... maybe?
	
}
Exemplo n.º 4
0
void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
{
	float width, height;
	
	CGWheelCount wheelCount = 2;
	UINT32 scroll_x = 0;
	UINT32 scroll_y = 0;
	
	if (flags & PTR_FLAGS_WHEEL)
	{
		scroll_y = flags & WheelRotationMask;
		
		if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
		{
			scroll_y = -(flags & WheelRotationMask) / 392;
		}
		else
		{
			scroll_y = (flags & WheelRotationMask) / 120;
		}
		
		CGEventSourceRef source = CGEventSourceCreate (kCGEventSourceStateHIDSystemState);
		CGEventRef scroll = CGEventCreateScrollWheelEvent(source,
								  kCGScrollEventUnitLine,
								  wheelCount,
								  scroll_y,
								  scroll_x);
		CGEventPost(kCGHIDEventTap, scroll);
		
		CFRelease(scroll);
		CFRelease(source);
	}
	/*
	 ///////////////////////////////////////////////
	 // We dont support horizontal scrolling yet...
	 ///////////////////////////////////////////////
	else if (flags & PTR_FLAGS_)
	{
		scroll_y = flags & WheelRotationMask;
		
		if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
		{
			scroll_y = -(flags & WheelRotationMask) / 392;
		}
		else
		{
			scroll_y = (flags & WheelRotationMask) / 120;
		}
		
		CGEventSourceRef source = CGEventSourceCreate (kCGEventSourceStateCombinedSessionState);
		CGEventRef scroll = CGEventCreateScrollWheelEvent(source,
								  kCGScrollEventUnitLine,
								  wheelCount,
								  scroll_y,
								  scroll_x);
		CGEventPost(kCGHIDEventTap, scroll);
		
		CFRelease(scroll);
		CFRelease(source);
	} */
	else
	{
		
		mfInfo * mfi;
		CGEventSourceRef source = CGEventSourceCreate (kCGEventSourceStateHIDSystemState);
		CGEventType mouseType = kCGEventNull;
		CGMouseButton mouseButton = kCGMouseButtonLeft;
		
		
		mfi = mf_info_get_instance();
		
		//width and height of primary screen (even in multimon setups
		width = (float) mfi->servscreen_width;
		height = (float) mfi->servscreen_height;
		
		x += mfi->servscreen_xoffset;
		y += mfi->servscreen_yoffset;
		
		if (flags & PTR_FLAGS_MOVE)
		{
			if (mfi->mouse_down_left == TRUE)
			{
				mouseType = kCGEventLeftMouseDragged;
			}
			else if (mfi->mouse_down_right == TRUE)
			{
				mouseType = kCGEventRightMouseDragged;
			}
			else if (mfi->mouse_down_other == TRUE)
			{
				mouseType = kCGEventOtherMouseDragged;
			}
			else
			{
				mouseType = kCGEventMouseMoved;
			}
			
			CGEventRef move = CGEventCreateMouseEvent(source,
								  mouseType,
								  CGPointMake(x, y),
								  mouseButton // ignored for just movement
								  );
			
			CGEventPost(kCGHIDEventTap, move);
			
			CFRelease(move);
		}
		
		if (flags & PTR_FLAGS_BUTTON1)
		{
			mouseButton = kCGMouseButtonLeft;
			if (flags & PTR_FLAGS_DOWN)
			{
				mouseType = kCGEventLeftMouseDown;
				mfi->mouse_down_left = TRUE;
			}
			else
			{
				mouseType = kCGEventLeftMouseUp;
				mfi->mouse_down_right = FALSE;
			}
		}
		else if (flags & PTR_FLAGS_BUTTON2)
		{
			mouseButton = kCGMouseButtonRight;
			if (flags & PTR_FLAGS_DOWN)
			{
				mouseType = kCGEventRightMouseDown;
				mfi->mouse_down_right = TRUE;
			}
			else
			{
				mouseType = kCGEventRightMouseUp;
				mfi->mouse_down_right = FALSE;
			}
			
		}
		else if (flags & PTR_FLAGS_BUTTON3)
		{
			mouseButton = kCGMouseButtonCenter;
			if (flags & PTR_FLAGS_DOWN)
			{
				mouseType = kCGEventOtherMouseDown;
				mfi->mouse_down_other = TRUE;
			}
			else
			{
				mouseType = kCGEventOtherMouseUp;
				mfi->mouse_down_other = FALSE;
			}
			
		}
		
		
		CGEventRef mouseEvent = CGEventCreateMouseEvent(source,
								mouseType,
								CGPointMake(x, y),
								mouseButton
								);
		CGEventPost(kCGHIDEventTap, mouseEvent);
		
		CFRelease(mouseEvent);
		CFRelease(source);
	}
}
Exemplo n.º 5
0
void mf_peer_rfx_update(freerdp_peer* client)
{
    //check
    mfInfo* mfi = mf_info_get_instance();
    
    mf_info_find_invalid_region(mfi);
    
    if (mf_info_have_invalid_region(mfi) == false) {
        return;
    }
   
    
    long width;
    long height;
    int pitch;
    BYTE* dataBits = NULL;
    
    mf_info_getScreenData(mfi, &width, &height, &dataBits, &pitch);
    
    mf_info_clear_invalid_region(mfi);
    
    //encode
    
    STREAM* s;
	RFX_RECT rect;
	rdpUpdate* update;
	mfPeerContext* mfp;
	SURFACE_BITS_COMMAND* cmd;
    
	update = client->update;
	mfp = (mfPeerContext*) client->context;
	cmd = &update->surface_bits_command;
    
    
    s = mfp->s;
    stream_clear(s);
	stream_set_pos(s, 0);
    
    UINT32 x = mfi->invalid.x / mfi->scale;
    UINT32 y = mfi->invalid.y / mfi->scale;
    
    rect.x = 0;
    rect.y = 0;
    rect.width = width;
    rect.height = height;
    
    mfp->rfx_context->width = mfi->servscreen_width;
    mfp->rfx_context->height = mfi->servscreen_height;
    
    rfx_compose_message(mfp->rfx_context, s, &rect, 1,
                        (BYTE*) dataBits, rect.width, rect.height, pitch);
    
    cmd->destLeft = x;
    cmd->destTop = y;
    cmd->destRight = x + rect.width;
    cmd->destBottom = y + rect.height;
    
    
	cmd->bpp = 32;
	cmd->codecID = 3;
	cmd->width = rect.width;
	cmd->height = rect.height;
	cmd->bitmapDataLength = stream_get_length(s);
	cmd->bitmapData = stream_get_head(s);
    
    //send
    
    update->SurfaceBits(update->context, cmd);
    
    //clean up
    
    // note: need to stop getting new dirty rects until here
    
    
    /*
    CGColorSpaceRelease(rgbColorSpace);
    CGImageRelease(image);
    CGContextRelease(context);
    
    CVPixelBufferUnlockBaseAddress(pxbuffer, 0);
    CVPixelBufferRelease(pxbuffer);
    */
}