20 #include <freerdp/config.h>
26 #include "mf_mountain_lion.h"
28 #define MF_INFO_DEFAULT_FPS 30
29 #define MF_INFO_MAXPEERS 32
31 static mfInfo* mfInfoInstance = NULL;
33 int mf_info_lock(mfInfo* mfi)
35 int status = pthread_mutex_lock(&mfi->mutex);
51 int mf_info_try_lock(mfInfo* mfi, UINT32 ms)
53 int status = pthread_mutex_trylock(&mfi->mutex);
73 int mf_info_unlock(mfInfo* mfi)
75 int status = pthread_mutex_unlock(&mfi->mutex);
91 static mfInfo* mf_info_init(
void)
95 mfi = (mfInfo*)calloc(1,
sizeof(mfInfo));
99 pthread_mutex_init(&mfi->mutex, NULL);
101 mfi->peers = (freerdp_peer**)calloc(MF_INFO_MAXPEERS,
sizeof(freerdp_peer*));
108 mfi->framesPerSecond = MF_INFO_DEFAULT_FPS;
109 mfi->input_disabled = FALSE;
115 mfInfo* mf_info_get_instance(
void)
117 if (mfInfoInstance == NULL)
118 mfInfoInstance = mf_info_init();
120 return mfInfoInstance;
123 void mf_info_peer_register(mfInfo* mfi, mfPeerContext* context)
125 if (mf_info_lock(mfi) > 0)
129 if (mfi->peerCount == MF_INFO_MAXPEERS)
137 if (mfi->peerCount == 0)
139 mf_mlion_display_info(&mfi->servscreen_width, &mfi->servscreen_height, &mfi->scale);
140 mf_mlion_screen_updates_init();
141 mf_mlion_start_getting_screen_updates();
146 for (
int i = 0; i < MF_INFO_MAXPEERS; ++i)
149 if (mfi->peers[i] == NULL)
156 mfi->peers[peerId] = ((rdpContext*)context)->peer;
157 mfi->peers[peerId]->pId = peerId;
164 void mf_info_peer_unregister(mfInfo* mfi, mfPeerContext* context)
166 if (mf_info_lock(mfi) > 0)
170 peerId = ((rdpContext*)context)->peer->pId;
171 mfi->peers[peerId] = NULL;
174 if (mfi->peerCount == 0)
175 mf_mlion_stop_getting_screen_updates();
181 BOOL mf_info_have_updates(mfInfo* mfi)
183 if (mfi->framesWaiting == 0)
189 void mf_info_update_changes(mfInfo* mfi)
193 void mf_info_find_invalid_region(mfInfo* mfi)
195 mf_mlion_get_dirty_region(&mfi->invalid);
198 void mf_info_clear_invalid_region(mfInfo* mfi)
200 mf_mlion_clear_dirty_region();
201 mfi->invalid.height = 0;
202 mfi->invalid.width = 0;
205 void mf_info_invalidate_full_screen(mfInfo* mfi)
209 mfi->invalid.height = mfi->servscreen_height;
210 mfi->invalid.width = mfi->servscreen_width;
213 BOOL mf_info_have_invalid_region(mfInfo* mfi)
215 if (mfi->invalid.width * mfi->invalid.height == 0)
221 void mf_info_getScreenData(mfInfo* mfi,
long* width,
long* height, BYTE** pBits,
int* pitch)
223 *width = mfi->invalid.width / mfi->scale;
224 *height = mfi->invalid.height / mfi->scale;
225 *pitch = mfi->servscreen_width * mfi->scale * 4;
227 mf_mlion_get_pixelData(mfi->invalid.x / mfi->scale, mfi->invalid.y / mfi->scale, *width,
230 *pBits = *pBits + (mfi->invalid.x * 4) + (*pitch * mfi->invalid.y);