Fixed mac server compilation.
This commit is contained in:
parent
d982cf0e90
commit
8eaba5b002
@ -27,7 +27,7 @@ if(FREERDP_VENDOR)
|
||||
|
||||
if(NOT WIN32)
|
||||
if(APPLE AND (NOT IOS))
|
||||
#add_subdirectory(Mac)
|
||||
add_subdirectory(Mac)
|
||||
endif()
|
||||
else()
|
||||
#add_subdirectory(Windows)
|
||||
|
@ -28,6 +28,9 @@
|
||||
#include "mf_info.h"
|
||||
#include "mf_mountain_lion.h"
|
||||
|
||||
#define MF_INFO_DEFAULT_FPS 30
|
||||
#define MF_INFO_MAXPEERS 32
|
||||
|
||||
static mfInfo* mfInfoInstance = NULL;
|
||||
|
||||
int mf_info_lock(mfInfo* mfi)
|
||||
@ -142,7 +145,7 @@ void mf_info_peer_register(mfInfo* mfi, mfPeerContext* context)
|
||||
mf_mlion_start_getting_screen_updates();
|
||||
}
|
||||
|
||||
peerId = NULL;
|
||||
peerId = 0;
|
||||
|
||||
for(i=0; i<MF_INFO_MAXPEERS; ++i)
|
||||
{
|
||||
|
@ -291,10 +291,9 @@ static const CGKeyCode keymap[256] =
|
||||
0xFF, //0xfe
|
||||
};
|
||||
|
||||
void mf_input_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
|
||||
BOOL mf_input_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
|
||||
{
|
||||
CGEventSourceRef source = CGEventSourceCreate (kCGEventSourceStateHIDSystemState);
|
||||
|
||||
CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
|
||||
BOOL keyDown = TRUE;
|
||||
CGEventRef kbEvent;
|
||||
CGKeyCode kCode = 0xFF;
|
||||
@ -306,7 +305,8 @@ void mf_input_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
|
||||
|
||||
if (flags & KBD_FLAGS_EXTENDED)
|
||||
{
|
||||
switch (code) {
|
||||
switch (code)
|
||||
{
|
||||
//case 0x52: //insert
|
||||
case 0x53:
|
||||
kCode = kVK_ForwardDelete;
|
||||
@ -357,17 +357,17 @@ void mf_input_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
|
||||
CGEventPost(kCGHIDEventTap, kbEvent);
|
||||
CFRelease(kbEvent);
|
||||
CFRelease(source);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void mf_input_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
|
||||
BOOL mf_input_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
|
||||
{
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
||||
BOOL mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
||||
{
|
||||
float width, height;
|
||||
|
||||
CGWheelCount wheelCount = 2;
|
||||
INT32 scroll_x = 0;
|
||||
INT32 scroll_y = 0;
|
||||
@ -386,32 +386,26 @@ void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
||||
else
|
||||
scroll_x = scroll;
|
||||
|
||||
CGEventSourceRef source = CGEventSourceCreate (kCGEventSourceStateHIDSystemState);
|
||||
CGEventRef scroll = CGEventCreateScrollWheelEvent(source,
|
||||
CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
|
||||
CGEventRef scrollEvent = CGEventCreateScrollWheelEvent(source,
|
||||
kCGScrollEventUnitLine,
|
||||
wheelCount,
|
||||
scroll_y,
|
||||
scroll_x);
|
||||
CGEventPost(kCGHIDEventTap, scroll);
|
||||
|
||||
CFRelease(scroll);
|
||||
CGEventPost(kCGHIDEventTap, scrollEvent);
|
||||
CFRelease(scrollEvent);
|
||||
CFRelease(source);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
mfInfo * mfi;
|
||||
CGEventSourceRef source = CGEventSourceCreate (kCGEventSourceStateHIDSystemState);
|
||||
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;
|
||||
|
||||
@ -439,15 +433,14 @@ void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
||||
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;
|
||||
@ -462,6 +455,7 @@ void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
||||
else if (flags & PTR_FLAGS_BUTTON2)
|
||||
{
|
||||
mouseButton = kCGMouseButtonRight;
|
||||
|
||||
if (flags & PTR_FLAGS_DOWN)
|
||||
{
|
||||
mouseType = kCGEventRightMouseDown;
|
||||
@ -472,11 +466,11 @@ void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
||||
mouseType = kCGEventRightMouseUp;
|
||||
mfi->mouse_down_right = FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
else if (flags & PTR_FLAGS_BUTTON3)
|
||||
{
|
||||
mouseButton = kCGMouseButtonCenter;
|
||||
|
||||
if (flags & PTR_FLAGS_DOWN)
|
||||
{
|
||||
mouseType = kCGEventOtherMouseDown;
|
||||
@ -487,40 +481,43 @@ void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
||||
mouseType = kCGEventOtherMouseUp;
|
||||
mfi->mouse_down_other = FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
CGEventRef mouseEvent = CGEventCreateMouseEvent(source,
|
||||
mouseType,
|
||||
CGPointMake(x, y),
|
||||
mouseButton
|
||||
);
|
||||
CGEventPost(kCGHIDEventTap, mouseEvent);
|
||||
|
||||
CFRelease(mouseEvent);
|
||||
CFRelease(source);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void mf_input_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
||||
BOOL mf_input_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
||||
{
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
void mf_input_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code)
|
||||
BOOL mf_input_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void mf_input_unicode_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code)
|
||||
BOOL mf_input_unicode_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void mf_input_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
||||
BOOL mf_input_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void mf_input_extended_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
||||
BOOL mf_input_extended_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -22,15 +22,15 @@
|
||||
|
||||
#include "mf_interface.h"
|
||||
|
||||
void mf_input_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code);
|
||||
void mf_input_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code);
|
||||
void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y);
|
||||
void mf_input_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y);
|
||||
BOOL mf_input_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code);
|
||||
BOOL mf_input_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code);
|
||||
BOOL mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y);
|
||||
BOOL mf_input_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y);
|
||||
|
||||
//dummy versions
|
||||
void mf_input_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code);
|
||||
void mf_input_unicode_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code);
|
||||
void mf_input_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y);
|
||||
void mf_input_extended_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y);
|
||||
BOOL mf_input_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code);
|
||||
BOOL mf_input_unicode_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code);
|
||||
BOOL mf_input_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y);
|
||||
BOOL mf_input_extended_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y);
|
||||
|
||||
#endif /* FREERDP_SERVER_MAC_INPUT_H */
|
@ -25,6 +25,7 @@
|
||||
#include <freerdp/codec/rfx.h>
|
||||
#include <winpr/stream.h>
|
||||
#include <freerdp/peer.h>
|
||||
#include <freerdp/codec/color.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
|
||||
@ -33,6 +34,7 @@
|
||||
#include "mf_input.h"
|
||||
#include "mf_event.h"
|
||||
#include "mf_rdpsnd.h"
|
||||
#include "mf_audin.h"
|
||||
|
||||
#include <mach/clock.h>
|
||||
#include <mach/mach.h>
|
||||
@ -44,22 +46,19 @@
|
||||
#include "CoreVideo/CoreVideo.h"
|
||||
|
||||
//refactor these
|
||||
int info_last_sec = 0;
|
||||
int info_last_nsec = 0;
|
||||
static int info_last_sec = 0;
|
||||
static int info_last_nsec = 0;
|
||||
|
||||
dispatch_source_t info_timer;
|
||||
dispatch_queue_t info_queue;
|
||||
static dispatch_source_t info_timer;
|
||||
static dispatch_queue_t info_queue;
|
||||
|
||||
mfEventQueue* info_event_queue;
|
||||
static mfEventQueue* info_event_queue;
|
||||
|
||||
static CGLContextObj glContext;
|
||||
static CGContextRef bmp;
|
||||
static CGImageRef img;
|
||||
|
||||
CGLContextObj glContext;
|
||||
CGContextRef bmp;
|
||||
CGImageRef img;
|
||||
|
||||
|
||||
|
||||
BOOL mf_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount)
|
||||
static BOOL mf_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount)
|
||||
{
|
||||
if (info_event_queue->pipe_fd[0] == -1)
|
||||
return TRUE;
|
||||
@ -69,33 +68,8 @@ BOOL mf_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL mf_peer_check_fds(freerdp_peer* client)
|
||||
{
|
||||
mfPeerContext* context = (mfPeerContext*) client->context;
|
||||
mfEvent* event;
|
||||
|
||||
if (context->activated == FALSE)
|
||||
return TRUE;
|
||||
|
||||
event = mf_event_peek(info_event_queue);
|
||||
|
||||
if (event != NULL)
|
||||
{
|
||||
if (event->type == MF_EVENT_TYPE_REGION)
|
||||
{
|
||||
}
|
||||
else if (event->type == MF_EVENT_TYPE_FRAME_TICK)
|
||||
{
|
||||
event = mf_event_pop(info_event_queue);
|
||||
mf_peer_rfx_update(client);
|
||||
mf_event_free(event);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void mf_peer_rfx_update(freerdp_peer* client)
|
||||
static void mf_peer_rfx_update(freerdp_peer* client)
|
||||
{
|
||||
//check
|
||||
mfInfo* mfi = mf_info_get_instance();
|
||||
@ -154,8 +128,34 @@ void mf_peer_rfx_update(freerdp_peer* client)
|
||||
//clean up... maybe?
|
||||
}
|
||||
|
||||
static BOOL mf_peer_check_fds(freerdp_peer* client)
|
||||
{
|
||||
mfPeerContext* context = (mfPeerContext*) client->context;
|
||||
mfEvent* event;
|
||||
|
||||
if (context->activated == FALSE)
|
||||
return TRUE;
|
||||
|
||||
event = mf_event_peek(info_event_queue);
|
||||
|
||||
if (event != NULL)
|
||||
{
|
||||
if (event->type == FREERDP_SERVER_MAC_EVENT_TYPE_REGION)
|
||||
{
|
||||
}
|
||||
else if (event->type == FREERDP_SERVER_MAC_EVENT_TYPE_FRAME_TICK)
|
||||
{
|
||||
event = mf_event_pop(info_event_queue);
|
||||
mf_peer_rfx_update(client);
|
||||
mf_event_free(event);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Called when we have a new peer connecting */
|
||||
BOOL mf_peer_context_new(freerdp_peer* client, mfPeerContext* context)
|
||||
static BOOL mf_peer_context_new(freerdp_peer* client, mfPeerContext* context)
|
||||
{
|
||||
if (!(context->info = mf_info_get_instance()))
|
||||
return FALSE;
|
||||
@ -166,7 +166,7 @@ BOOL mf_peer_context_new(freerdp_peer* client, mfPeerContext* 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_BGRA32);
|
||||
rfx_context_set_pixel_format(context->rfx_context, PIXEL_FORMAT_BGRA32);
|
||||
|
||||
if (!(context->s = Stream_New(NULL, 0xFFFF)))
|
||||
goto fail_stream_new;
|
||||
@ -189,7 +189,7 @@ fail_rfx_context:
|
||||
}
|
||||
|
||||
/* Called after a peer disconnects */
|
||||
void mf_peer_context_free(freerdp_peer* client, mfPeerContext* context)
|
||||
static void mf_peer_context_free(freerdp_peer* client, mfPeerContext* context)
|
||||
{
|
||||
if (context)
|
||||
{
|
||||
@ -204,19 +204,19 @@ void mf_peer_context_free(freerdp_peer* client, mfPeerContext* context)
|
||||
audin_server_context_free(context->audin);
|
||||
|
||||
#endif
|
||||
//#ifdef CHANNEL_RDPSND_SERVER
|
||||
#ifdef CHANNEL_RDPSND_SERVER
|
||||
mf_peer_rdpsnd_stop();
|
||||
|
||||
if (context->rdpsnd)
|
||||
rdpsnd_server_context_free(context->rdpsnd);
|
||||
|
||||
//#endif
|
||||
#endif
|
||||
WTSCloseServer(context->vcm);
|
||||
}
|
||||
}
|
||||
|
||||
/* Called when a new client connects */
|
||||
BOOL mf_peer_init(freerdp_peer* client)
|
||||
static BOOL mf_peer_init(freerdp_peer* client)
|
||||
{
|
||||
client->ContextSize = sizeof(mfPeerContext);
|
||||
client->ContextNew = (psPeerContextNew) mf_peer_context_new;
|
||||
@ -239,7 +239,7 @@ BOOL mf_peer_init(freerdp_peer* client)
|
||||
dispatch_source_set_event_handler(info_timer, ^
|
||||
{
|
||||
//DEBUG_WARN( "dispatch\n");
|
||||
mfEvent* event = mf_event_new(MF_EVENT_TYPE_FRAME_TICK);
|
||||
mfEvent* event = mf_event_new(FREERDP_SERVER_MAC_EVENT_TYPE_FRAME_TICK);
|
||||
mf_event_push(info_event_queue, (mfEvent*) event);
|
||||
}
|
||||
);
|
||||
@ -249,7 +249,7 @@ BOOL mf_peer_init(freerdp_peer* client)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL mf_peer_post_connect(freerdp_peer* client)
|
||||
static BOOL mf_peer_post_connect(freerdp_peer* client)
|
||||
{
|
||||
mfPeerContext* context = (mfPeerContext*) client->context;
|
||||
rdpSettings* settings = client->settings;
|
||||
@ -271,12 +271,14 @@ BOOL mf_peer_post_connect(freerdp_peer* client)
|
||||
mfi->mouse_down_left = FALSE;
|
||||
mfi->mouse_down_right = FALSE;
|
||||
mfi->mouse_down_other = FALSE;
|
||||
#ifdef CHANNEL_RDPSND_SERVER
|
||||
|
||||
if (WTSVirtualChannelManagerIsChannelJoined(context->vcm, "rdpsnd"))
|
||||
{
|
||||
mf_peer_rdpsnd_init(context); /* Audio Output */
|
||||
}
|
||||
|
||||
#endif
|
||||
/* Dynamic Virtual Channels */
|
||||
#ifdef CHANNEL_AUDIN_SERVER
|
||||
mf_peer_audin_init(context); /* Audio Input */
|
||||
@ -284,16 +286,18 @@ BOOL mf_peer_post_connect(freerdp_peer* client)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL mf_peer_activate(freerdp_peer* client)
|
||||
static BOOL mf_peer_activate(freerdp_peer* client)
|
||||
{
|
||||
mfPeerContext* context = (mfPeerContext*) client->context;
|
||||
rfx_context_reset(context->rfx_context);
|
||||
rfx_context_reset(context->rfx_context, client->settings->DesktopWidth,
|
||||
client->settings->DesktopHeight);
|
||||
context->activated = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void mf_peer_synchronize_event(rdpInput* input, UINT32 flags)
|
||||
static BOOL mf_peer_synchronize_event(rdpInput* input, UINT32 flags)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void mf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
|
||||
@ -308,29 +312,19 @@ void mf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
|
||||
}
|
||||
}
|
||||
|
||||
void mf_peer_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
|
||||
static BOOL mf_peer_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
|
||||
{
|
||||
}
|
||||
|
||||
static void mf_peer_suppress_output(rdpContext* context, BYTE allow,
|
||||
RECTANGLE_16* area)
|
||||
{
|
||||
}
|
||||
|
||||
BOOL mf_peer_accepted(freerdp_listener* instance, freerdp_peer* client)
|
||||
{
|
||||
pthread_t th;
|
||||
|
||||
if (pthread_create(&th, 0, mf_peer_main_loop, client) == 0)
|
||||
{
|
||||
pthread_detach(th);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void* mf_peer_main_loop(void* arg)
|
||||
static BOOL mf_peer_suppress_output(rdpContext* context, BYTE allow,
|
||||
const RECTANGLE_16* area)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static void* mf_peer_main_loop(void* arg)
|
||||
{
|
||||
int i;
|
||||
int fds;
|
||||
@ -439,3 +433,16 @@ void* mf_peer_main_loop(void* arg)
|
||||
freerdp_peer_free(client);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL mf_peer_accepted(freerdp_listener* instance, freerdp_peer* client)
|
||||
{
|
||||
pthread_t th;
|
||||
|
||||
if (pthread_create(&th, 0, mf_peer_main_loop, client) == 0)
|
||||
{
|
||||
pthread_detach(th);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -22,23 +22,6 @@
|
||||
|
||||
#include "mf_interface.h"
|
||||
|
||||
BOOL mf_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount);
|
||||
BOOL mf_peer_check_fds(freerdp_peer* client);
|
||||
|
||||
void mf_peer_rfx_update(freerdp_peer* client);
|
||||
|
||||
BOOL mf_peer_context_new(freerdp_peer* client, mfPeerContext* context);
|
||||
void mf_peer_context_free(freerdp_peer* client, mfPeerContext* context);
|
||||
|
||||
BOOL mf_peer_init(freerdp_peer* client);
|
||||
|
||||
BOOL mf_peer_post_connect(freerdp_peer* client);
|
||||
BOOL mf_peer_activate(freerdp_peer* client);
|
||||
|
||||
void mf_peer_synchronize_event(rdpInput* input, UINT32 flags);
|
||||
|
||||
BOOL mf_peer_accepted(freerdp_listener* instance, freerdp_peer* client);
|
||||
|
||||
void* mf_peer_main_loop(void* arg);
|
||||
|
||||
#endif /* FREERDP_SERVER_MAC_PEER_H */
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "mf_info.h"
|
||||
#include "mf_rdpsnd.h"
|
||||
|
||||
#include <winpr/sysinfo.h>
|
||||
#include <freerdp/log.h>
|
||||
#define TAG SERVER_TAG("mac")
|
||||
|
||||
@ -45,7 +46,6 @@ static void mf_peer_rdpsnd_activated(RdpsndServerContext* context)
|
||||
int i, j;
|
||||
BOOL formatAgreed = FALSE;
|
||||
AUDIO_FORMAT* agreedFormat = NULL;
|
||||
|
||||
//we should actually loop through the list of client formats here
|
||||
//and see if we can send the client something that it supports...
|
||||
WLog_DBG(TAG, "Client supports the following %d formats: ", context->num_client_formats);
|
||||
@ -65,9 +65,9 @@ static void mf_peer_rdpsnd_activated(RdpsndServerContext* context)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (formatAgreed == TRUE)
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (formatAgreed == FALSE)
|
||||
@ -95,16 +95,14 @@ static void mf_peer_rdpsnd_activated(RdpsndServerContext* context)
|
||||
}
|
||||
|
||||
recorderState.dataFormat.mSampleRate = agreedFormat->nSamplesPerSec;
|
||||
recorderState.dataFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked;;
|
||||
recorderState.dataFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger |
|
||||
kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked;;
|
||||
recorderState.dataFormat.mBytesPerPacket = 4;
|
||||
recorderState.dataFormat.mFramesPerPacket = 1;
|
||||
recorderState.dataFormat.mBytesPerFrame = 4;
|
||||
recorderState.dataFormat.mChannelsPerFrame = agreedFormat->nChannels;
|
||||
recorderState.dataFormat.mBitsPerChannel = agreedFormat->wBitsPerSample;
|
||||
|
||||
|
||||
recorderState.snd_context = context;
|
||||
|
||||
status = AudioQueueNewInput(&recorderState.dataFormat,
|
||||
mf_peer_rdpsnd_input_callback,
|
||||
&recorderState,
|
||||
@ -118,35 +116,28 @@ static void mf_peer_rdpsnd_activated(RdpsndServerContext* context)
|
||||
WLog_DBG(TAG, "Failed to create a new Audio Queue. Status code: %"PRId32"", status);
|
||||
}
|
||||
|
||||
UInt32 dataFormatSize = sizeof (recorderState.dataFormat);
|
||||
|
||||
UInt32 dataFormatSize = sizeof(recorderState.dataFormat);
|
||||
AudioQueueGetProperty(recorderState.queue,
|
||||
kAudioConverterCurrentInputStreamDescription,
|
||||
&recorderState.dataFormat,
|
||||
&dataFormatSize);
|
||||
|
||||
|
||||
mf_rdpsnd_derive_buffer_size(recorderState.queue, &recorderState.dataFormat, 0.05, &recorderState.bufferByteSize);
|
||||
|
||||
mf_rdpsnd_derive_buffer_size(recorderState.queue, &recorderState.dataFormat, 0.05,
|
||||
&recorderState.bufferByteSize);
|
||||
|
||||
for (i = 0; i < SND_NUMBUFFERS; ++i)
|
||||
{
|
||||
AudioQueueAllocateBuffer(recorderState.queue,
|
||||
recorderState.bufferByteSize,
|
||||
&recorderState.buffers[i]);
|
||||
|
||||
AudioQueueEnqueueBuffer(recorderState.queue,
|
||||
recorderState.buffers[i],
|
||||
0,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
recorderState.currentPacket = 0;
|
||||
recorderState.isRunning = true;
|
||||
|
||||
AudioQueueStart (recorderState.queue, NULL);
|
||||
|
||||
AudioQueueStart(recorderState.queue, NULL);
|
||||
}
|
||||
|
||||
BOOL mf_peer_rdpsnd_init(mfPeerContext* context)
|
||||
@ -154,19 +145,15 @@ BOOL mf_peer_rdpsnd_init(mfPeerContext* context)
|
||||
context->rdpsnd = rdpsnd_server_context_new(context->vcm);
|
||||
context->rdpsnd->rdpcontext = &context->_p;
|
||||
context->rdpsnd->data = context;
|
||||
|
||||
context->rdpsnd->server_formats = supported_audio_formats;
|
||||
context->rdpsnd->num_server_formats = sizeof(supported_audio_formats) / sizeof(supported_audio_formats[0]);
|
||||
|
||||
context->rdpsnd->num_server_formats = sizeof(supported_audio_formats) / sizeof(
|
||||
supported_audio_formats[0]);
|
||||
context->rdpsnd->src_format.wFormatTag = 1;
|
||||
context->rdpsnd->src_format.nChannels = 2;
|
||||
context->rdpsnd->src_format.nSamplesPerSec = 44100;
|
||||
context->rdpsnd->src_format.wBitsPerSample = 16;
|
||||
|
||||
context->rdpsnd->Activated = mf_peer_rdpsnd_activated;
|
||||
|
||||
context->rdpsnd->Initialize(context->rdpsnd, TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -174,36 +161,32 @@ BOOL mf_peer_rdpsnd_stop()
|
||||
{
|
||||
recorderState.isRunning = false;
|
||||
AudioQueueStop(recorderState.queue, true);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void mf_peer_rdpsnd_input_callback (void *inUserData,
|
||||
void mf_peer_rdpsnd_input_callback(void* inUserData,
|
||||
AudioQueueRef inAQ,
|
||||
AudioQueueBufferRef inBuffer,
|
||||
const AudioTimeStamp *inStartTime,
|
||||
const AudioTimeStamp* inStartTime,
|
||||
UInt32 inNumberPacketDescriptions,
|
||||
const AudioStreamPacketDescription *inPacketDescs)
|
||||
const AudioStreamPacketDescription* inPacketDescs)
|
||||
{
|
||||
OSStatus status;
|
||||
AQRecorderState * rState;
|
||||
AQRecorderState* rState;
|
||||
rState = inUserData;
|
||||
|
||||
|
||||
if (inNumberPacketDescriptions == 0 && rState->dataFormat.mBytesPerPacket != 0)
|
||||
{
|
||||
inNumberPacketDescriptions = inBuffer->mAudioDataByteSize / rState->dataFormat.mBytesPerPacket;
|
||||
}
|
||||
|
||||
|
||||
if (rState->isRunning == 0)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
rState->snd_context->SendSamples(rState->snd_context, inBuffer->mAudioData,
|
||||
inBuffer->mAudioDataByteSize/4, (UINT16)(GetTickCount() & 0xffff));
|
||||
|
||||
inBuffer->mAudioDataByteSize / 4, (UINT16)(GetTickCount() & 0xffff));
|
||||
status = AudioQueueEnqueueBuffer(
|
||||
rState->queue,
|
||||
inBuffer,
|
||||
@ -214,21 +197,20 @@ void mf_peer_rdpsnd_input_callback (void *inUserD
|
||||
{
|
||||
WLog_DBG(TAG, "AudioQueueEnqueueBuffer() returned status = %"PRId32"", status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void mf_rdpsnd_derive_buffer_size (AudioQueueRef audioQueue,
|
||||
AudioStreamBasicDescription *ASBDescription,
|
||||
void mf_rdpsnd_derive_buffer_size(AudioQueueRef audioQueue,
|
||||
AudioStreamBasicDescription* ASBDescription,
|
||||
Float64 seconds,
|
||||
UInt32 *outBufferSize)
|
||||
UInt32* outBufferSize)
|
||||
{
|
||||
static const int maxBufferSize = 0x50000;
|
||||
|
||||
int maxPacketSize = ASBDescription->mBytesPerPacket;
|
||||
|
||||
if (maxPacketSize == 0)
|
||||
{
|
||||
UInt32 maxVBRPacketSize = sizeof(maxPacketSize);
|
||||
AudioQueueGetProperty (audioQueue,
|
||||
AudioQueueGetProperty(audioQueue,
|
||||
kAudioQueueProperty_MaximumOutputPacketSize,
|
||||
// in Mac OS X v10.5, instead use
|
||||
// kAudioConverterPropertyMaximumOutputPacketSize
|
||||
@ -239,6 +221,6 @@ void mf_rdpsnd_derive_buffer_size (AudioQueueRef audioQueue,
|
||||
|
||||
Float64 numBytesForTime =
|
||||
ASBDescription->mSampleRate * maxPacketSize * seconds;
|
||||
*outBufferSize = (UInt32) (numBytesForTime < maxBufferSize ? numBytesForTime : maxBufferSize);
|
||||
*outBufferSize = (UInt32)(numBytesForTime < maxBufferSize ? numBytesForTime : maxBufferSize);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user