Beispiel #1
0
BOOL wf_info_peer_register(wfInfo* wfi, wfPeerContext* context)
{
	int i;
	int peerId;

	if (!wfi || !context)
		return FALSE;

	if (!wf_info_lock(wfi))
		return FALSE;

	if (wfi->peerCount == WF_INFO_MAXPEERS)
		goto fail_peer_count;

	context->info = wfi;
	if (!(context->updateEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
		goto fail_update_event;

	//get the offset of the top left corner of selected screen
	EnumDisplayMonitors(NULL, NULL, wf_info_monEnumCB, 0);
	_IDcount = 0;

#ifdef WITH_DXGI_1_2
	if (wfi->peerCount == 0)
		if (wf_dxgi_init(wfi) != 0)
			goto fail_driver_init;
#else
	if (!wf_mirror_driver_activate(wfi))
		goto fail_driver_init;
#endif
	//look through the array of peers until an empty slot
	for (i = 0; i < WF_INFO_MAXPEERS; ++i)
	{
		//empty index will be our peer id
		if (wfi->peers[i] == NULL)
		{
			peerId = i;
			break;
		}
	}

	wfi->peers[peerId] = ((rdpContext*) context)->peer;
	wfi->peers[peerId]->pId = peerId;
	wfi->peerCount++;

	WLog_INFO(TAG, "Registering Peer: id=%d #=%d", peerId, wfi->peerCount);
	wf_info_unlock(wfi);
	wfreerdp_server_peer_callback_event(peerId, WF_SRV_CALLBACK_EVENT_CONNECT);

	return TRUE;

fail_driver_init:
	CloseHandle(context->updateEvent);
	context->updateEvent = NULL;
fail_update_event:
fail_peer_count:
	context->socketClose = TRUE;
	wf_info_unlock(wfi);
	return FALSE;
}
Beispiel #2
0
void wf_info_peer_register(wfInfo* wfi, wfPeerContext* context)
{
    if (wf_info_lock(wfi) > 0)
    {
        int i;
        int peerId;
        if (wfi->peerCount == WF_INFO_MAXPEERS)
        {
            context->socketClose = TRUE;
            wf_info_unlock(wfi);
            return;
        }

        context->info = wfi;
        context->updateEvent = CreateEvent(NULL, TRUE, FALSE, NULL);

        //get the offset of the top left corner of selected screen
        EnumDisplayMonitors(NULL, NULL, wf_info_monEnumCB, 0);
        _IDcount = 0;

#ifdef WITH_WIN8
        if (wfi->peerCount == 0)
            wf_dxgi_init(wfi);
#else
        if (wf_mirror_driver_activate(wfi) == FALSE)
        {
            context->socketClose = TRUE;
            wf_info_unlock(wfi);
            return;
        }
#endif
        //look trhough the array of peers until an empty slot
        for(i=0; i<WF_INFO_MAXPEERS; ++i)
        {
            //empty index will be our peer id
            if (wfi->peers[i] == NULL)
            {
                peerId = i;
                break;
            }
        }

        wfi->peers[peerId] = ((rdpContext*) context)->peer;
        wfi->peers[peerId]->pId = peerId;
        wfi->peerCount++;
        printf("Registering Peer: id=%d #=%d\n", peerId, wfi->peerCount);

        wf_info_unlock(wfi);

        wfreerdp_server_peer_callback_event(peerId, WF_SRV_CALLBACK_EVENT_CONNECT);
    }
}
Beispiel #3
0
void wf_update_peer_activate(wfInfo* wfi, wfPeerContext* context)
{
	if (wf_info_lock(wfi) > 0)
	{
		if (wfi->activePeerCount < 1)
		{
#ifndef WITH_WIN8
			wf_mirror_driver_activate(wfi);
#endif
			ResumeThread(wfi->updateThread);
		}

		wf_update_encoder_reset(wfi);
		wfi->activePeerCount++;

		printf("Activating Peer Updates: %d\n", wfi->activePeerCount);

		wf_info_unlock(wfi);
	}
}