1 /***************************************************************************
2 * Copyright 2012 BMW Car IT GmbH
3 * Copyright (C) 2012 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 ****************************************************************************/
20 #include "GenericCommunicator.h"
21 #include "ilm_types.h"
24 #include "Configuration.h"
26 #include "ICommandExecutor.h"
27 #include "CommitCommand.h"
28 #include "LayerCreateCommand.h"
29 #include "SurfaceCreateCommand.h"
30 #include "SurfaceGetDimensionCommand.h"
31 #include "LayerGetDimensionCommand.h"
32 #include "SurfaceGetOpacityCommand.h"
33 #include "LayerGetOpacityCommand.h"
34 #include "SurfaceGetPixelformatCommand.h"
35 #include "LayerGetVisibilityCommand.h"
36 #include "SurfaceGetVisibilityCommand.h"
37 #include "LayerAddSurfaceCommand.h"
38 #include "LayerRemoveSurfaceCommand.h"
39 #include "LayerRemoveCommand.h"
40 #include "SurfaceRemoveCommand.h"
41 #include "SurfaceGetOrientationCommand.h"
42 #include "LayerGetOrientationCommand.h"
43 #include "LayerSetDestinationRectangleCommand.h"
44 #include "SurfaceSetDestinationRectangleCommand.h"
45 #include "LayerSetOpacityCommand.h"
46 #include "SurfaceSetOpacityCommand.h"
47 #include "LayerSetSourceRectangleCommand.h"
48 #include "SurfaceSetSourceRectangleCommand.h"
49 #include "LayerSetOrientationCommand.h"
50 #include "SurfaceSetOrientationCommand.h"
51 #include "LayerSetVisibilityCommand.h"
52 #include "SurfaceSetVisibilityCommand.h"
53 #include "DebugCommand.h"
54 #include "ExitCommand.h"
55 #include "ScreenSetRenderOrderCommand.h"
56 #include "LayerSetRenderOrderCommand.h"
57 #include "LayerSetDimensionCommand.h"
58 #include "SurfaceSetDimensionCommand.h"
59 #include "LayerSetPositionCommand.h"
60 #include "SurfaceSetPositionCommand.h"
61 #include "LayerGetPositionCommand.h"
62 #include "SurfaceGetPositionCommand.h"
63 #include "ShaderCreateCommand.h"
64 #include "ShaderDestroyCommand.h"
65 #include "SurfaceSetShaderCommand.h"
66 #include "ShaderSetUniformsCommand.h"
67 #include "ScreenDumpCommand.h"
68 #include "LayerDumpCommand.h"
69 #include "SurfaceDumpCommand.h"
70 #include "SurfaceSetNativeContentCommand.h"
71 #include "SurfaceRemoveNativeContentCommand.h"
72 #include "SurfaceSetKeyboardFocusCommand.h"
73 #include "SurfaceGetKeyboardFocusCommand.h"
74 #include "SurfaceUpdateInputEventAcceptance.h"
75 #include "SurfaceSetChromaKeyCommand.h"
76 #include "LayerSetChromaKeyCommand.h"
77 #include "SetOptimizationModeCommand.h"
78 #include "GetOptimizationModeCommand.h"
79 #include "SetSynchronizedSurfacesCommand.h"
80 #include "RemoveSynchronizedSurfacesCommand.h"
91 #define DEFAULT_SCREEN 0
93 GenericCommunicator::GenericCommunicator(ICommandExecutor& executor, Configuration& config)
94 : ICommunicator(&executor)
95 , PluginBase(executor, config, Communicator_Api_v1)
96 , m_running(ILM_FALSE)
98 MethodTable manager_methods[] =
100 { "ServiceConnect", &GenericCommunicator::ServiceConnect },
101 { "ServiceDisconnect", &GenericCommunicator::ServiceDisconnect },
102 { "Debug", &GenericCommunicator::Debug },
103 { "ScreenShot", &GenericCommunicator::ScreenShot },
104 { "ScreenShotOfLayer", &GenericCommunicator::ScreenShotOfLayer },
105 { "ScreenShotOfSurface", &GenericCommunicator::ScreenShotOfSurface },
106 { "GetScreenResolution", &GenericCommunicator::GetScreenResolution },
107 { "GetNumberOfHardwareLayers", &GenericCommunicator::GetNumberOfHardwareLayers },
108 { "GetScreenIDs", &GenericCommunicator::GetScreenIDs },
109 { "ListAllLayerIDS", &GenericCommunicator::ListAllLayerIDS },
110 { "ListAllLayerIDsOnScreen", &GenericCommunicator::ListAllLayerIDsOnScreen },
111 { "ListAllSurfaceIDS", &GenericCommunicator::ListAllSurfaceIDS },
112 { "ListSurfaceofLayer", &GenericCommunicator::ListSurfaceofLayer },
113 { "GetPropertiesOfSurface", &GenericCommunicator::GetPropertiesOfSurface },
114 { "GetPropertiesOfLayer", &GenericCommunicator::GetPropertiesOfLayer },
115 { "CreateSurface", &GenericCommunicator::CreateSurface },
116 { "CreateSurfaceFromId", &GenericCommunicator::CreateSurfaceFromId },
117 { "InitializeSurface", &GenericCommunicator::InitializeSurface },
118 { "InitializeSurfaceFromId", &GenericCommunicator::InitializeSurfaceFromId },
119 { "SetSurfaceNativeContent", &GenericCommunicator::SetSurfaceNativeContent },
120 { "RemoveSurfaceNativeContent", &GenericCommunicator::RemoveSurfaceNativeContent },
121 { "RemoveSurface", &GenericCommunicator::RemoveSurface },
122 { "CreateLayer", &GenericCommunicator::CreateLayer },
123 { "CreateLayerFromId", &GenericCommunicator::CreateLayerFromId },
124 { "CreateLayerWithDimension", &GenericCommunicator::CreateLayerWithDimension },
125 { "CreateLayerFromIdWithDimension", &GenericCommunicator::CreateLayerFromIdWithDimension },
126 { "RemoveLayer", &GenericCommunicator::RemoveLayer },
127 { "AddSurfaceToLayer", &GenericCommunicator::AddSurfaceToLayer },
128 { "RemoveSurfaceFromLayer", &GenericCommunicator::RemoveSurfaceFromLayer },
129 { "SetSurfaceSourceRegion", &GenericCommunicator::SetSurfaceSourceRegion },
130 { "SetLayerSourceRegion", &GenericCommunicator::SetLayerSourceRegion },
131 { "SetSurfaceDestinationRegion", &GenericCommunicator::SetSurfaceDestinationRegion },
132 { "SetSurfacePosition", &GenericCommunicator::SetSurfacePosition },
133 { "GetSurfacePosition", &GenericCommunicator::GetSurfacePosition },
134 { "SetSurfaceDimension", &GenericCommunicator::SetSurfaceDimension },
135 { "SetLayerDestinationRegion", &GenericCommunicator::SetLayerDestinationRegion },
136 { "SetLayerPosition", &GenericCommunicator::SetLayerPosition },
137 { "GetLayerPosition", &GenericCommunicator::GetLayerPosition },
138 { "SetLayerDimension", &GenericCommunicator::SetLayerDimension },
139 { "GetLayerDimension", &GenericCommunicator::GetLayerDimension },
140 { "GetSurfaceDimension", &GenericCommunicator::GetSurfaceDimension },
141 { "SetSurfaceOpacity", &GenericCommunicator::SetSurfaceOpacity },
142 { "SetLayerOpacity", &GenericCommunicator::SetLayerOpacity },
143 { "GetSurfaceOpacity", &GenericCommunicator::GetSurfaceOpacity },
144 { "GetLayerOpacity", &GenericCommunicator::GetLayerOpacity },
145 { "SetSurfaceOrientation", &GenericCommunicator::SetSurfaceOrientation },
146 { "GetSurfaceOrientation", &GenericCommunicator::GetSurfaceOrientation },
147 { "SetLayerOrientation", &GenericCommunicator::SetLayerOrientation },
148 { "GetLayerOrientation", &GenericCommunicator::GetLayerOrientation },
149 { "GetSurfacePixelformat", &GenericCommunicator::GetSurfacePixelformat },
150 { "SetSurfaceVisibility", &GenericCommunicator::SetSurfaceVisibility },
151 { "SetLayerVisibility", &GenericCommunicator::SetLayerVisibility },
152 { "GetSurfaceVisibility", &GenericCommunicator::GetSurfaceVisibility },
153 { "GetLayerVisibility", &GenericCommunicator::GetLayerVisibility },
154 { "SetRenderOrderOfLayers", &GenericCommunicator::SetRenderOrderOfLayers },
155 { "SetSurfaceRenderOrderWithinLayer", &GenericCommunicator::SetSurfaceRenderOrderWithinLayer },
156 { "GetLayerType", &GenericCommunicator::GetLayerType },
157 { "GetLayertypeCapabilities", &GenericCommunicator::GetLayertypeCapabilities },
158 { "GetLayerCapabilities", &GenericCommunicator::GetLayerCapabilities },
159 { "Exit", &GenericCommunicator::Exit },
160 { "CommitChanges", &GenericCommunicator::CommitChanges },
161 { "CreateShader", &GenericCommunicator::CreateShader },
162 { "DestroyShader", &GenericCommunicator::DestroyShader },
163 { "SetShader", &GenericCommunicator::SetShader },
164 { "SetUniforms", &GenericCommunicator::SetUniforms },
165 { "SetKeyboardFocusOn", &GenericCommunicator::SetKeyboardFocusOn },
166 { "GetKeyboardFocusSurfaceId", &GenericCommunicator::GetKeyboardFocusSurfaceId },
167 { "UpdateInputEventAcceptanceOn", &GenericCommunicator::UpdateInputEventAcceptanceOn },
168 { "SetSurfaceChromaKey", &GenericCommunicator::SetSurfaceChromaKey },
169 { "SetLayerChromaKey", &GenericCommunicator::SetLayerChromaKey },
170 { "LayerAddNotification", &GenericCommunicator::LayerAddNotification },
171 { "SurfaceAddNotification", &GenericCommunicator::SurfaceAddNotification },
172 { "LayerRemoveNotification", &GenericCommunicator::LayerRemoveNotification },
173 { "SurfaceRemoveNotification", &GenericCommunicator::SurfaceRemoveNotification },
174 { "SetOptimizationMode", &GenericCommunicator::SetOptimizationMode },
175 { "GetOptimizationMode", &GenericCommunicator::GetOptimizationMode },
176 { "GetPropertiesOfScreen", &GenericCommunicator::GetPropertiesOfScreen },
177 { "SetSynchronizedSurfaces", &GenericCommunicator::SetSynchronizedSurfaces },
178 { "RemoveSynchronizedSurfaces", &GenericCommunicator::RemoveSynchronizedSurfaces }
181 int entryCount = sizeof(manager_methods) / sizeof(MethodTable);
183 for (int index = 0; index < entryCount; ++index)
185 MethodTable* method = &manager_methods[index];
186 if (method->function)
188 m_callBackTable[method->name] = *method;
189 LOG_DEBUG("GenericCommunicator", "registered callback for " << method->name);
193 memset(&m_ipcModule, 0, sizeof(m_ipcModule));
195 mThreadId = pthread_self();
198 bool GenericCommunicator::start()
200 LOG_DEBUG("GenericCommunicator", "Starting up IpcModules.");
202 if (!loadIpcModule(&m_ipcModule))
204 LOG_ERROR("GenericCommunicator", "Loading IpcModule failed.");
207 LOG_DEBUG("GenericCommunicator", "Loading IpcModule success.");
209 if (!m_ipcModule.initServiceMode())
211 LOG_ERROR("GenericCommunicator", "Initializing IpcModule failed.");
214 LOG_DEBUG("GenericCommunicator", "Initializing IpcModule success.");
216 m_running = ILM_TRUE;
217 pluginSetHealth(HealthRunning);
226 void GenericCommunicator::stop()
228 LOG_INFO("GenericCommunicator", "stopping");
234 m_ipcModule.destroy();
236 pluginSetHealth(HealthStopped);
239 void GenericCommunicator::process(int timeout_ms)
241 t_ilm_message message = m_ipcModule.receive(timeout_ms);
247 t_ilm_message_type messageType = m_ipcModule.getMessageType(message);
248 t_ilm_const_string name = m_ipcModule.getMessageName(message);
249 t_ilm_client_handle senderHandle = m_ipcModule.getSenderHandle(message);
253 case IpcMessageTypeCommand:
254 if (m_callBackTable.end() != m_callBackTable.find(name))
256 LOG_DEBUG("GenericCommunicator", "received: " << name << " from "
257 << m_executor->getSenderName(senderHandle)
258 << "(" << m_executor->getSenderPid(senderHandle) << ")");
259 CallBackMethod method = m_callBackTable[name].function;
260 (this->*method)(message);
264 LOG_WARNING("GenericCommunicator", "Received unknown command " << name
265 << " from " << m_executor->getSenderName(senderHandle)
266 << "(pid " << m_executor->getSenderPid(senderHandle) << ")");
268 processNotificationQueue();
271 case IpcMessageTypeConnect:
272 LOG_DEBUG("GenericCommunicator", "client " << m_executor->getSenderName(senderHandle)
273 << "(pid " << m_executor->getSenderPid(senderHandle) << ") connected");
276 case IpcMessageTypeDisconnect:
277 LOG_DEBUG("GenericCommunicator", "client " << m_executor->getSenderName(senderHandle)
278 << "(pid " << m_executor->getSenderPid(senderHandle) << ") disconnected");
280 const LayerMap& layers = m_executor->getScene()->getAllLayers();
281 LayerMapConstIterator layerIter = layers.begin();
282 LayerMapConstIterator layerIterEnd = layers.end();
283 for (; layerIter != layerIterEnd; ++layerIter)
285 Layer* layer = layerIter->second;
286 layer->removeNotification(senderHandle);
289 const SurfaceMap& surfaces = m_executor->getScene()->getAllSurfaces();
290 SurfaceMapConstIterator surfaceIter = surfaces.begin();
291 SurfaceMapConstIterator surfaceIterEnd = surfaces.end();
292 for (; surfaceIter != surfaceIterEnd; ++surfaceIter)
294 Surface* surface = surfaceIter->second;
295 surface->removeNotification(senderHandle);
297 m_executor->removeApplicationReference(senderHandle);
301 case IpcMessageTypeError:
302 LOG_DEBUG("GenericCommunicator", "Received error message " << name << " from "
303 << m_executor->getSenderName(senderHandle)
304 << "(pid " << m_executor->getSenderPid(senderHandle) << ")");
307 case IpcMessageTypeShutdown:
308 case IpcMessageTypeNone:
312 LOG_DEBUG("GenericCommunicator", "Received unknown data from "
313 << m_executor->getSenderName(senderHandle)
314 << "(pid " << m_executor->getSenderPid(senderHandle) << "), Message type: " << messageType);
317 m_ipcModule.destroyMessage(message);
320 void GenericCommunicator::setdebug(bool onoff)
322 (void)onoff; // TODO: remove, only prevents warning
325 t_ilm_bool GenericCommunicator::threadMainLoop()
331 t_ilm_const_string GenericCommunicator::pluginGetName() const
333 return "GenericCommunicator";
336 void GenericCommunicator::ServiceConnect(t_ilm_message message)
338 t_ilm_message response;
339 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
341 unsigned int processId = 0;
342 char processName[1024];
343 m_ipcModule.getUint(message, &processId);
344 m_ipcModule.getString(message, processName);
346 m_executor->addApplicationReference(clientHandle, new IApplicationReference(processName, processId));
348 LOG_DEBUG("GenericCommunicator", "ServiceConnect called from "
349 << m_executor->getSenderName(clientHandle)
350 << "(" << m_executor->getSenderPid(clientHandle) << ")");
352 response = m_ipcModule.createResponse(message);
353 m_ipcModule.sendToClients(response, &clientHandle, 1);
354 m_ipcModule.destroyMessage(response);
357 void GenericCommunicator::ServiceDisconnect(t_ilm_message message)
359 t_ilm_message response;
360 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
362 LOG_DEBUG("GenericCommunicator", "ServiceDisconnect called from "
363 << m_executor->getSenderName(clientHandle)
364 << "(" << m_executor->getSenderPid(clientHandle) << ")");
366 m_executor->removeApplicationReference(clientHandle);
368 response = m_ipcModule.createResponse(message);
369 m_ipcModule.sendToClients(response, &clientHandle, 1);
370 m_ipcModule.destroyMessage(response);
373 void GenericCommunicator::Debug(t_ilm_message message)
375 t_ilm_message response;
376 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
377 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
378 t_ilm_bool param = ILM_FALSE;
379 m_ipcModule.getBool(message, ¶m);
381 t_ilm_bool status = m_executor->execute(new DebugCommand(clientPid, param));
384 response = m_ipcModule.createResponse(message);
388 response = m_ipcModule.createErrorResponse(message);
389 m_ipcModule.appendUint(response, ILM_ERROR_INVALID_ARGUMENTS);
392 m_ipcModule.sendToClients(response, &clientHandle, 1);
393 m_ipcModule.destroyMessage(response);
396 void GenericCommunicator::GetScreenResolution(t_ilm_message message)
398 t_ilm_message response;
399 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
401 m_ipcModule.getUint(message, &screenid);
402 uint* resolution = m_executor->getScreenResolution(screenid);
404 response = m_ipcModule.createResponse(message);
405 m_ipcModule.appendUint(response, resolution[0]);
406 m_ipcModule.appendUint(response, resolution[1]);
407 m_ipcModule.sendToClients(response, &clientHandle, 1);
408 m_ipcModule.destroyMessage(response);
410 delete [] resolution;
413 void GenericCommunicator::GetNumberOfHardwareLayers(t_ilm_message message)
415 t_ilm_message response;
416 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
418 m_ipcModule.getUint(message, &screenid);
419 uint numberOfHardwareLayers = m_executor->getNumberOfHardwareLayers(screenid);
420 response = m_ipcModule.createResponse(message);
421 m_ipcModule.appendUint(response, numberOfHardwareLayers);
422 m_ipcModule.sendToClients(response, &clientHandle, 1);
423 m_ipcModule.destroyMessage(response);
426 void GenericCommunicator::GetScreenIDs(t_ilm_message message)
428 t_ilm_message response;
429 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
431 uint* IDs = m_executor->getScreenIDs(&length);
432 response = m_ipcModule.createResponse(message);
433 m_ipcModule.appendUintArray(response, IDs, length);
434 m_ipcModule.sendToClients(response, &clientHandle, 1);
435 m_ipcModule.destroyMessage(response);
439 void GenericCommunicator::ScreenShot(t_ilm_message message)
441 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
442 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
443 t_ilm_message response;
447 m_ipcModule.getUint(message, &screenid);
448 m_ipcModule.getString(message, filename);
450 t_ilm_bool status = m_executor->execute(new ScreenDumpCommand(clientPid, filename, screenid));
453 response = m_ipcModule.createResponse(message);
457 response = m_ipcModule.createErrorResponse(message);
458 m_ipcModule.appendUint(response, ILM_ERROR_INVALID_ARGUMENTS);
461 m_ipcModule.sendToClients(response, &clientHandle, 1);
462 m_ipcModule.destroyMessage(response);
465 void GenericCommunicator::ScreenShotOfLayer(t_ilm_message message)
467 t_ilm_message response;
468 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
469 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
471 m_ipcModule.getString(message, filename);
473 m_ipcModule.getUint(message, &layerid);
475 t_ilm_bool status = m_executor->execute(new LayerDumpCommand(clientPid, filename, layerid));
478 response = m_ipcModule.createResponse(message);
482 response = m_ipcModule.createErrorResponse(message);
483 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
486 m_ipcModule.sendToClients(response, &clientHandle, 1);
487 m_ipcModule.destroyMessage(response);
490 void GenericCommunicator::ScreenShotOfSurface(t_ilm_message message)
492 t_ilm_message response;
493 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
494 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
496 m_ipcModule.getString(message, filename);
498 m_ipcModule.getUint(message, &id);
499 t_ilm_bool status = m_executor->execute(new SurfaceDumpCommand(clientPid, filename, id));
502 response = m_ipcModule.createResponse(message);
506 response = m_ipcModule.createErrorResponse(message);
507 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
510 m_ipcModule.sendToClients(response, &clientHandle, 1);
511 m_ipcModule.destroyMessage(response);
514 void GenericCommunicator::ListAllLayerIDS(t_ilm_message message)
516 t_ilm_message response;
517 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
520 m_executor->getScene()->lockScene();
521 m_executor->getScene()->getLayerIDs(&length, &array);
522 m_executor->getScene()->unlockScene();
523 response = m_ipcModule.createResponse(message);
524 m_ipcModule.appendUintArray(response, array, length);
525 m_ipcModule.sendToClients(response, &clientHandle, 1);
526 m_ipcModule.destroyMessage(response);
529 void GenericCommunicator::ListAllLayerIDsOnScreen(t_ilm_message message)
531 t_ilm_message response;
532 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
534 m_ipcModule.getUint(message, &screenID);
538 m_executor->getScene()->lockScene();
539 t_ilm_bool status = m_executor->getScene()->getLayerIDsOfScreen(screenID, &length, &array);
540 m_executor->getScene()->unlockScene();
543 response = m_ipcModule.createResponse(message);
544 m_ipcModule.appendUintArray(response, array, length);
548 response = m_ipcModule.createErrorResponse(message);
549 m_ipcModule.appendUint(response, ILM_ERROR_INVALID_ARGUMENTS);
552 m_ipcModule.sendToClients(response, &clientHandle, 1);
553 m_ipcModule.destroyMessage(response);
558 void GenericCommunicator::ListAllSurfaceIDS(t_ilm_message message)
560 t_ilm_message response;
561 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
564 m_executor->getScene()->lockScene();
565 m_executor->getScene()->getSurfaceIDs(&length, &array);
566 m_executor->getScene()->unlockScene();
567 response = m_ipcModule.createResponse(message);
568 m_ipcModule.appendUintArray(response, array, length);
569 m_ipcModule.sendToClients(response, &clientHandle, 1);
570 m_ipcModule.destroyMessage(response);
573 void GenericCommunicator::ListSurfaceofLayer(t_ilm_message message)
575 t_ilm_message response;
576 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
578 m_ipcModule.getUint(message, &id);
579 m_executor->getScene()->lockScene();
580 Layer* layer = m_executor->getScene()->getLayer(id);
583 std::list<Surface*> surfaces = layer->getAllSurfaces();
585 uint length = surfaces.size();
586 uint* array = new uint[length];
589 for (std::list<Surface*>::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it)
592 array[arrayPos] = s->getID();
595 m_executor->getScene()->unlockScene();
597 response = m_ipcModule.createResponse(message);
598 m_ipcModule.appendUintArray(response, array, length);
603 m_executor->getScene()->unlockScene();
604 response = m_ipcModule.createErrorResponse(message);
605 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
608 m_ipcModule.sendToClients(response, &clientHandle, 1);
609 m_ipcModule.destroyMessage(response);
612 void GenericCommunicator::GetPropertiesOfSurface(t_ilm_message message)
614 t_ilm_message response;
615 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
617 m_ipcModule.getUint(message, &id);
619 Surface* surface = m_executor->getScene()->getSurface(id);
622 Rectangle dest = surface->getDestinationRegion();
623 Rectangle src = surface->getSourceRegion();
624 OrientationType orientation = surface->getOrientation();
625 unsigned char chromaKeyRed = 0;
626 unsigned char chromaKeyGreen = 0;
627 unsigned char chromaKeyBlue = 0;
628 surface->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
630 response = m_ipcModule.createResponse(message);
631 m_ipcModule.appendDouble(response, surface->getOpacity());
632 m_ipcModule.appendUint(response, src.x);
633 m_ipcModule.appendUint(response, src.y);
634 m_ipcModule.appendUint(response, src.width);
635 m_ipcModule.appendUint(response, src.height);
636 m_ipcModule.appendUint(response, surface->OriginalSourceWidth);
637 m_ipcModule.appendUint(response, surface->OriginalSourceHeight);
638 m_ipcModule.appendUint(response, dest.x);
639 m_ipcModule.appendUint(response, dest.y);
640 m_ipcModule.appendUint(response, dest.width);
641 m_ipcModule.appendUint(response, dest.height);
642 m_ipcModule.appendUint(response, orientation);
643 m_ipcModule.appendBool(response, surface->getVisibility());
644 m_ipcModule.appendUint(response, surface->frameCounter);
645 m_ipcModule.appendUint(response, surface->drawCounter);
646 m_ipcModule.appendUint(response, surface->updateCounter);
647 m_ipcModule.appendUint(response, surface->getPixelFormat());
648 m_ipcModule.appendUint(response, surface->getNativeContent());
649 m_ipcModule.appendUint(response, surface->getInputEventAcceptanceOnDevices());
650 m_ipcModule.appendBool(response, surface->getChromaKeyEnabled());
651 m_ipcModule.appendUint(response, chromaKeyRed);
652 m_ipcModule.appendUint(response, chromaKeyGreen);
653 m_ipcModule.appendUint(response, chromaKeyBlue);
654 m_ipcModule.appendInt(response, surface->getCreatorPid());
658 response = m_ipcModule.createErrorResponse(message);
659 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
662 m_ipcModule.sendToClients(response, &clientHandle, 1);
663 m_ipcModule.destroyMessage(response);
666 void GenericCommunicator::GetPropertiesOfLayer(t_ilm_message message)
668 t_ilm_message response;
669 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
671 m_ipcModule.getUint(message, &id);
673 Layer* layer = m_executor->getScene()->getLayer(id);
676 Rectangle dest = layer->getDestinationRegion();
677 Rectangle src = layer->getSourceRegion();
678 OrientationType orientation = layer->getOrientation();
679 unsigned char chromaKeyRed = 0;
680 unsigned char chromaKeyGreen = 0;
681 unsigned char chromaKeyBlue = 0;
682 layer->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
684 response = m_ipcModule.createResponse(message);
685 m_ipcModule.appendDouble(response, layer->getOpacity());
686 m_ipcModule.appendUint(response, src.x);
687 m_ipcModule.appendUint(response, src.y);
688 m_ipcModule.appendUint(response, src.width);
689 m_ipcModule.appendUint(response, src.height);
690 m_ipcModule.appendUint(response, layer->OriginalSourceWidth);
691 m_ipcModule.appendUint(response, layer->OriginalSourceHeight);
692 m_ipcModule.appendUint(response, dest.x);
693 m_ipcModule.appendUint(response, dest.y);
694 m_ipcModule.appendUint(response, dest.width);
695 m_ipcModule.appendUint(response, dest.height);
696 m_ipcModule.appendUint(response, orientation);
697 m_ipcModule.appendBool(response, layer->getVisibility());
698 m_ipcModule.appendUint(response, layer->getLayerType());
699 m_ipcModule.appendBool(response, layer->getChromaKeyEnabled());
700 m_ipcModule.appendUint(response, chromaKeyRed);
701 m_ipcModule.appendUint(response, chromaKeyGreen);
702 m_ipcModule.appendUint(response, chromaKeyBlue);
703 m_ipcModule.appendInt(response, layer->getCreatorPid());
707 response = m_ipcModule.createErrorResponse(message);
708 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
711 m_ipcModule.sendToClients(response, &clientHandle, 1);
712 m_ipcModule.destroyMessage(response);
715 void GenericCommunicator::CreateSurface(t_ilm_message message)
717 t_ilm_message response;
718 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
719 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
723 uint pixelformat = 0;
724 PixelFormat pf = PIXELFORMAT_UNKNOWN;
725 uint id = GraphicalObject::INVALID_ID;
727 m_ipcModule.getUint(message, &handle);
728 m_ipcModule.getUint(message, &width);
729 m_ipcModule.getUint(message, &height);
730 m_ipcModule.getUint(message, &pixelformat);
732 pf = (PixelFormat) pixelformat;
734 // First of all create the surface
735 t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
737 // after that apply the native content
738 status &= m_executor->execute(new SurfaceSetNativeContentCommand(clientPid, id, handle, pf, width, height));
742 response = m_ipcModule.createResponse(message);
743 m_ipcModule.appendUint(response, id);
747 response = m_ipcModule.createErrorResponse(message);
748 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
751 m_ipcModule.sendToClients(response, &clientHandle, 1);
752 m_ipcModule.destroyMessage(response);
755 void GenericCommunicator::CreateSurfaceFromId(t_ilm_message message)
757 t_ilm_message response;
758 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
759 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
763 uint pixelformat = 0;
764 PixelFormat pf = PIXELFORMAT_UNKNOWN;
767 m_ipcModule.getUint(message, &handle);
768 m_ipcModule.getUint(message, &width);
769 m_ipcModule.getUint(message, &height);
770 m_ipcModule.getUint(message, &pixelformat);
771 m_ipcModule.getUint(message, &id);
773 pf = (PixelFormat) pixelformat;
775 // First of all create the surface
776 t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
778 // after that apply the native content
779 status &= m_executor->execute(new SurfaceSetNativeContentCommand(clientPid, id, handle, pf, width, height));
783 response = m_ipcModule.createResponse(message);
784 m_ipcModule.appendUint(response, id);
788 response = m_ipcModule.createErrorResponse(message);
789 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
792 m_ipcModule.sendToClients(response, &clientHandle, 1);
793 m_ipcModule.destroyMessage(response);
796 void GenericCommunicator::InitializeSurface(t_ilm_message message)
798 t_ilm_message response;
799 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
800 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
801 uint id = GraphicalObject::INVALID_ID;
803 t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
806 response = m_ipcModule.createResponse(message);
807 m_ipcModule.appendUint(response, id);
811 response = m_ipcModule.createErrorResponse(message);
812 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
815 m_ipcModule.sendToClients(response, &clientHandle, 1);
816 m_ipcModule.destroyMessage(response);
819 void GenericCommunicator::InitializeSurfaceFromId(t_ilm_message message)
821 t_ilm_message response;
822 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
823 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
825 m_ipcModule.getUint(message, &id);
826 t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
829 response = m_ipcModule.createResponse(message);
830 m_ipcModule.appendUint(response, id);
834 response = m_ipcModule.createErrorResponse(message);
835 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
838 m_ipcModule.sendToClients(response, &clientHandle, 1);
839 m_ipcModule.destroyMessage(response);
842 void GenericCommunicator::SetSurfaceNativeContent(t_ilm_message message)
844 t_ilm_message response;
845 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
846 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
851 uint pixelformat = 0;
852 PixelFormat pf = PIXELFORMAT_UNKNOWN;
854 m_ipcModule.getUint(message, &id);
855 m_ipcModule.getUint(message, &handle);
856 m_ipcModule.getUint(message, &width);
857 m_ipcModule.getUint(message, &height);
858 m_ipcModule.getUint(message, &pixelformat);
860 pf = (PixelFormat) pixelformat;
862 t_ilm_bool status = m_executor->execute(new SurfaceSetNativeContentCommand(clientPid, id, handle, pf, width, height));
865 response = m_ipcModule.createResponse(message);
869 response = m_ipcModule.createErrorResponse(message);
870 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
873 m_ipcModule.sendToClients(response, &clientHandle, 1);
874 m_ipcModule.destroyMessage(response);
877 void GenericCommunicator::RemoveSurfaceNativeContent(t_ilm_message message)
879 t_ilm_message response;
880 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
881 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
883 m_ipcModule.getUint(message, &id);
885 t_ilm_bool status = m_executor->execute(new SurfaceRemoveNativeContentCommand(clientPid, id));
888 response = m_ipcModule.createResponse(message);
892 response = m_ipcModule.createErrorResponse(message);
893 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
896 m_ipcModule.sendToClients(response, &clientHandle, 1);
897 m_ipcModule.destroyMessage(response);
900 void GenericCommunicator::RemoveSurface(t_ilm_message message)
902 t_ilm_message response;
903 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
904 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
906 m_ipcModule.getUint(message, ¶m);
907 t_ilm_bool status = m_executor->execute(new SurfaceRemoveCommand(clientPid, param));
910 response = m_ipcModule.createResponse(message);
914 response = m_ipcModule.createErrorResponse(message);
915 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
918 m_ipcModule.sendToClients(response, &clientHandle, 1);
919 m_ipcModule.destroyMessage(response);
922 void GenericCommunicator::CreateLayer(t_ilm_message message)
924 t_ilm_message response;
925 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
926 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
927 uint id = GraphicalObject::INVALID_ID;
928 // use resolution of default screen as default width and height of layers
929 uint* resolution = m_executor->getScreenResolution(DEFAULT_SCREEN);
930 t_ilm_bool status = m_executor->execute(new LayerCreateCommand(clientPid, resolution[0], resolution[1], &id));
933 response = m_ipcModule.createResponse(message);
934 m_ipcModule.appendUint(response, id);
938 response = m_ipcModule.createErrorResponse(message);
939 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
942 m_ipcModule.sendToClients(response, &clientHandle, 1);
943 m_ipcModule.destroyMessage(response);
946 void GenericCommunicator::CreateLayerFromId(t_ilm_message message)
948 t_ilm_message response;
949 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
950 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
951 uint id = GraphicalObject::INVALID_ID;
953 m_ipcModule.getUint(message, &id);
954 // use resolution of default screen as default width and height of layers
955 uint* resolution = m_executor->getScreenResolution(DEFAULT_SCREEN);
956 t_ilm_bool status = m_executor->execute(new LayerCreateCommand(clientPid, resolution[0], resolution[1], &id));
959 response = m_ipcModule.createResponse(message);
960 m_ipcModule.appendUint(response, id);
964 response = m_ipcModule.createErrorResponse(message);
965 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
968 m_ipcModule.sendToClients(response, &clientHandle, 1);
969 m_ipcModule.destroyMessage(response);
971 delete [] resolution;
975 void GenericCommunicator::CreateLayerWithDimension(t_ilm_message message)
977 t_ilm_message response;
978 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
979 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
981 m_ipcModule.getUint(message, &width);
983 m_ipcModule.getUint(message, &height);
985 uint id = GraphicalObject::INVALID_ID;
986 t_ilm_bool status = m_executor->execute(new LayerCreateCommand(clientPid, width, height, &id));
989 response = m_ipcModule.createResponse(message);
990 m_ipcModule.appendUint(response, id);
994 response = m_ipcModule.createErrorResponse(message);
995 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
998 m_ipcModule.sendToClients(response, &clientHandle, 1);
999 m_ipcModule.destroyMessage(response);
1002 void GenericCommunicator::CreateLayerFromIdWithDimension(t_ilm_message message)
1004 t_ilm_message response;
1005 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1006 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1007 uint id = GraphicalObject::INVALID_ID;
1010 t_ilm_bool status = ILM_FALSE;
1012 m_ipcModule.getUint(message, &id);
1013 m_ipcModule.getUint(message, &width);
1014 m_ipcModule.getUint(message, &height);
1016 status = m_executor->execute(new LayerCreateCommand(clientPid, width, height, &id));
1019 response = m_ipcModule.createResponse(message);
1020 m_ipcModule.appendUint(response, id);
1024 response = m_ipcModule.createErrorResponse(message);
1025 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
1028 m_ipcModule.sendToClients(response, &clientHandle, 1);
1029 m_ipcModule.destroyMessage(response);
1032 void GenericCommunicator::RemoveLayer(t_ilm_message message)
1034 t_ilm_message response;
1035 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1036 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1038 m_ipcModule.getUint(message, ¶m);
1039 t_ilm_bool status = m_executor->execute(new LayerRemoveCommand(clientPid, param));
1042 response = m_ipcModule.createResponse(message);
1046 response = m_ipcModule.createErrorResponse(message);
1047 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1050 m_ipcModule.sendToClients(response, &clientHandle, 1);
1051 m_ipcModule.destroyMessage(response);
1054 void GenericCommunicator::AddSurfaceToLayer(t_ilm_message message)
1056 t_ilm_message response;
1057 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1058 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1062 m_ipcModule.getUint(message, &surfaceid);
1063 m_ipcModule.getUint(message, &layer);
1065 t_ilm_bool status = m_executor->execute(new LayerAddSurfaceCommand(clientPid, layer, surfaceid));
1068 response = m_ipcModule.createResponse(message);
1072 response = m_ipcModule.createErrorResponse(message);
1073 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
1076 m_ipcModule.sendToClients(response, &clientHandle, 1);
1077 m_ipcModule.destroyMessage(response);
1080 void GenericCommunicator::RemoveSurfaceFromLayer(t_ilm_message message)
1082 t_ilm_message response;
1083 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1084 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1087 m_ipcModule.getUint(message, &surfaceid);
1088 m_ipcModule.getUint(message, &layerid);
1090 t_ilm_bool status = m_executor->execute(new LayerRemoveSurfaceCommand(clientPid, layerid, surfaceid));
1093 response = m_ipcModule.createResponse(message);
1097 response = m_ipcModule.createErrorResponse(message);
1098 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1101 m_ipcModule.sendToClients(response, &clientHandle, 1);
1102 m_ipcModule.destroyMessage(response);
1105 void GenericCommunicator::SetSurfaceSourceRegion(t_ilm_message message)
1107 t_ilm_message response;
1108 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1109 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1116 m_ipcModule.getUint(message, &id);
1117 m_ipcModule.getUint(message, &x);
1118 m_ipcModule.getUint(message, &y);
1119 m_ipcModule.getUint(message, &width);
1120 m_ipcModule.getUint(message, &height);
1122 t_ilm_bool status = m_executor->execute(new SurfaceSetSourceRectangleCommand(clientPid, id, x, y, width, height));
1125 response = m_ipcModule.createResponse(message);
1129 response = m_ipcModule.createErrorResponse(message);
1130 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1133 m_ipcModule.sendToClients(response, &clientHandle, 1);
1134 m_ipcModule.destroyMessage(response);
1137 void GenericCommunicator::SetLayerSourceRegion(t_ilm_message message)
1139 t_ilm_message response;
1140 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1141 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1148 m_ipcModule.getUint(message, &id);
1149 m_ipcModule.getUint(message, &x);
1150 m_ipcModule.getUint(message, &y);
1151 m_ipcModule.getUint(message, &width);
1152 m_ipcModule.getUint(message, &height);
1154 t_ilm_bool status = m_executor->execute(new LayerSetSourceRectangleCommand(clientPid, id, x, y, width, height));
1157 response = m_ipcModule.createResponse(message);
1161 response = m_ipcModule.createErrorResponse(message);
1162 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1165 m_ipcModule.sendToClients(response, &clientHandle, 1);
1166 m_ipcModule.destroyMessage(response);
1169 void GenericCommunicator::SetSurfaceDestinationRegion(t_ilm_message message)
1171 t_ilm_message response;
1172 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1173 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1180 m_ipcModule.getUint(message, &id);
1181 m_ipcModule.getUint(message, &x);
1182 m_ipcModule.getUint(message, &y);
1183 m_ipcModule.getUint(message, &width);
1184 m_ipcModule.getUint(message, &height);
1186 t_ilm_bool status = m_executor->execute(new SurfaceSetDestinationRectangleCommand(clientPid, id, x, y, width, height));
1189 response = m_ipcModule.createResponse(message);
1193 response = m_ipcModule.createErrorResponse(message);
1194 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1197 m_ipcModule.sendToClients(response, &clientHandle, 1);
1198 m_ipcModule.destroyMessage(response);
1201 void GenericCommunicator::SetSurfacePosition(t_ilm_message message)
1203 t_ilm_message response;
1204 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1205 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1210 m_ipcModule.getUint(message, &id);
1211 m_ipcModule.getUint(message, &x);
1212 m_ipcModule.getUint(message, &y);
1214 t_ilm_bool status = m_executor->execute(new SurfaceSetPositionCommand(clientPid, id, x, y));
1217 response = m_ipcModule.createResponse(message);
1221 response = m_ipcModule.createErrorResponse(message);
1222 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1225 m_ipcModule.sendToClients(response, &clientHandle, 1);
1226 m_ipcModule.destroyMessage(response);
1229 void GenericCommunicator::GetSurfacePosition(t_ilm_message message)
1231 t_ilm_message response;
1232 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1233 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1238 m_ipcModule.getUint(message, &id);
1240 t_ilm_bool status = m_executor->execute(new SurfaceGetPositionCommand(clientPid, id, &x, &y));
1243 response = m_ipcModule.createResponse(message);
1244 m_ipcModule.appendUint(response, x);
1245 m_ipcModule.appendUint(response, y);
1249 response = m_ipcModule.createErrorResponse(message);
1250 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1253 m_ipcModule.sendToClients(response, &clientHandle, 1);
1254 m_ipcModule.destroyMessage(response);
1257 void GenericCommunicator::SetSurfaceDimension(t_ilm_message message)
1259 t_ilm_message response;
1260 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1261 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1266 m_ipcModule.getUint(message, &id);
1267 m_ipcModule.getUint(message, &width);
1268 m_ipcModule.getUint(message, &height);
1270 t_ilm_bool status = m_executor->execute(new SurfaceSetDimensionCommand(clientPid, id, width, height));
1273 response = m_ipcModule.createResponse(message);
1277 response = m_ipcModule.createErrorResponse(message);
1278 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1281 m_ipcModule.sendToClients(response, &clientHandle, 1);
1282 m_ipcModule.destroyMessage(response);
1285 void GenericCommunicator::SetLayerDestinationRegion(t_ilm_message message)
1287 t_ilm_message response;
1288 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1289 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1296 m_ipcModule.getUint(message, &id);
1297 m_ipcModule.getUint(message, &x);
1298 m_ipcModule.getUint(message, &y);
1299 m_ipcModule.getUint(message, &width);
1300 m_ipcModule.getUint(message, &height);
1302 t_ilm_bool status = m_executor->execute(new LayerSetDestinationRectangleCommand(clientPid, id, x, y, width, height));
1305 response = m_ipcModule.createResponse(message);
1309 response = m_ipcModule.createErrorResponse(message);
1310 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1313 m_ipcModule.sendToClients(response, &clientHandle, 1);
1314 m_ipcModule.destroyMessage(response);
1317 void GenericCommunicator::SetLayerPosition(t_ilm_message message)
1319 t_ilm_message response;
1320 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1321 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1326 m_ipcModule.getUint(message, &id);
1327 m_ipcModule.getUint(message, &x);
1328 m_ipcModule.getUint(message, &y);
1330 t_ilm_bool status = m_executor->execute(new LayerSetPositionCommand(clientPid, id, x, y));
1333 response = m_ipcModule.createResponse(message);
1337 response = m_ipcModule.createErrorResponse(message);
1338 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1341 m_ipcModule.sendToClients(response, &clientHandle, 1);
1342 m_ipcModule.destroyMessage(response);
1345 void GenericCommunicator::GetLayerPosition(t_ilm_message message)
1347 t_ilm_message response;
1348 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1349 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1354 m_ipcModule.getUint(message, &id);
1356 t_ilm_bool status = m_executor->execute(new LayerGetPositionCommand(clientPid, id, &x, &y));
1359 response = m_ipcModule.createResponse(message);
1360 m_ipcModule.appendUint(response, x);
1361 m_ipcModule.appendUint(response, y);
1365 response = m_ipcModule.createErrorResponse(message);
1366 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1369 m_ipcModule.sendToClients(response, &clientHandle, 1);
1370 m_ipcModule.destroyMessage(response);
1373 void GenericCommunicator::SetLayerDimension(t_ilm_message message)
1375 t_ilm_message response;
1376 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1377 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1382 m_ipcModule.getUint(message, &id);
1383 m_ipcModule.getUint(message, &width);
1384 m_ipcModule.getUint(message, &height);
1386 t_ilm_bool status = m_executor->execute(new LayerSetDimensionCommand(clientPid, id, width, height));
1389 response = m_ipcModule.createResponse(message);
1393 response = m_ipcModule.createErrorResponse(message);
1394 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1397 m_ipcModule.sendToClients(response, &clientHandle, 1);
1398 m_ipcModule.destroyMessage(response);
1401 void GenericCommunicator::GetLayerDimension(t_ilm_message message)
1403 t_ilm_message response;
1404 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1405 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1410 m_ipcModule.getUint(message, &id);
1412 t_ilm_bool status = m_executor->execute(new LayerGetDimensionCommand(clientPid, id, &width, &height));
1415 response = m_ipcModule.createResponse(message);
1416 m_ipcModule.appendUint(response, width);
1417 m_ipcModule.appendUint(response, height);
1421 response = m_ipcModule.createErrorResponse(message);
1422 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1425 m_ipcModule.sendToClients(response, &clientHandle, 1);
1426 m_ipcModule.destroyMessage(response);
1429 void GenericCommunicator::GetSurfaceDimension(t_ilm_message message)
1431 t_ilm_message response;
1432 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1433 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1438 m_ipcModule.getUint(message, &id);
1440 t_ilm_bool status = m_executor->execute(new SurfaceGetDimensionCommand(clientPid, id, &width, &height));
1443 response = m_ipcModule.createResponse(message);
1444 m_ipcModule.appendUint(response, width);
1445 m_ipcModule.appendUint(response, height);
1449 response = m_ipcModule.createErrorResponse(message);
1450 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1453 m_ipcModule.sendToClients(response, &clientHandle, 1);
1454 m_ipcModule.destroyMessage(response);
1457 void GenericCommunicator::SetSurfaceOpacity(t_ilm_message message)
1459 t_ilm_message response;
1460 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1461 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1465 m_ipcModule.getUint(message, &id);
1466 m_ipcModule.getDouble(message, ¶m);
1468 t_ilm_bool status = m_executor->execute(new SurfaceSetOpacityCommand(clientPid, id, param));
1471 response = m_ipcModule.createResponse(message);
1475 response = m_ipcModule.createErrorResponse(message);
1476 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1479 m_ipcModule.sendToClients(response, &clientHandle, 1);
1480 m_ipcModule.destroyMessage(response);
1483 void GenericCommunicator::SetLayerOpacity(t_ilm_message message)
1485 t_ilm_message response;
1486 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1487 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1491 m_ipcModule.getUint(message, &id);
1492 m_ipcModule.getDouble(message, ¶m);
1494 t_ilm_bool status = m_executor->execute(new LayerSetOpacityCommand(clientPid, id, param));
1497 response = m_ipcModule.createResponse(message);
1501 response = m_ipcModule.createErrorResponse(message);
1502 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1505 m_ipcModule.sendToClients(response, &clientHandle, 1);
1506 m_ipcModule.destroyMessage(response);
1509 void GenericCommunicator::GetSurfaceOpacity(t_ilm_message message)
1511 t_ilm_message response;
1512 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1513 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1517 m_ipcModule.getUint(message, &id);
1519 t_ilm_bool status = m_executor->execute(new SurfaceGetOpacityCommand(clientPid, id, ¶m));
1522 response = m_ipcModule.createResponse(message);
1523 m_ipcModule.appendDouble(response, param);
1527 response = m_ipcModule.createErrorResponse(message);
1528 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1531 m_ipcModule.sendToClients(response, &clientHandle, 1);
1532 m_ipcModule.destroyMessage(response);
1535 void GenericCommunicator::GetLayerOpacity(t_ilm_message message)
1537 t_ilm_message response;
1538 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1539 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1543 m_ipcModule.getUint(message, &id);
1545 t_ilm_bool status = m_executor->execute(new LayerGetOpacityCommand(clientPid, id, ¶m));
1548 response = m_ipcModule.createResponse(message);
1549 m_ipcModule.appendDouble(response, param);
1553 response = m_ipcModule.createErrorResponse(message);
1554 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1557 m_ipcModule.sendToClients(response, &clientHandle, 1);
1558 m_ipcModule.destroyMessage(response);
1561 void GenericCommunicator::SetSurfaceOrientation(t_ilm_message message)
1563 t_ilm_message response;
1564 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1565 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1568 OrientationType o = Zero;
1570 m_ipcModule.getUint(message, &id);
1571 m_ipcModule.getUint(message, ¶m);
1573 o = (OrientationType) param;
1575 t_ilm_bool status = m_executor->execute(new SurfaceSetOrientationCommand(clientPid, id, o));
1578 response = m_ipcModule.createResponse(message);
1582 response = m_ipcModule.createErrorResponse(message);
1583 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1586 m_ipcModule.sendToClients(response, &clientHandle, 1);
1587 m_ipcModule.destroyMessage(response);
1590 void GenericCommunicator::GetSurfaceOrientation(t_ilm_message message)
1592 t_ilm_message response;
1593 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1594 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1598 m_ipcModule.getUint(message, &id);
1600 t_ilm_bool status = m_executor->execute(new SurfaceGetOrientationCommand(clientPid, id, &o));
1603 response = m_ipcModule.createResponse(message);
1604 m_ipcModule.appendUint(response, o);
1608 response = m_ipcModule.createErrorResponse(message);
1609 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1612 m_ipcModule.sendToClients(response, &clientHandle, 1);
1613 m_ipcModule.destroyMessage(response);
1616 void GenericCommunicator::SetLayerOrientation(t_ilm_message message)
1618 t_ilm_message response;
1619 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1620 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1623 OrientationType o = Zero;
1625 m_ipcModule.getUint(message, &id);
1626 m_ipcModule.getUint(message, ¶m);
1628 o = (OrientationType) param;
1630 t_ilm_bool status = m_executor->execute(new LayerSetOrientationCommand(clientPid, id, o));
1633 response = m_ipcModule.createResponse(message);
1637 response = m_ipcModule.createErrorResponse(message);
1638 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1641 m_ipcModule.sendToClients(response, &clientHandle, 1);
1642 m_ipcModule.destroyMessage(response);
1645 void GenericCommunicator::GetLayerOrientation(t_ilm_message message)
1647 t_ilm_message response;
1648 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1649 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1653 m_ipcModule.getUint(message, &id);
1655 t_ilm_bool status = m_executor->execute(new LayerGetOrientationCommand(clientPid, id, &o));
1658 response = m_ipcModule.createResponse(message);
1659 m_ipcModule.appendUint(response, o);
1663 response = m_ipcModule.createErrorResponse(message);
1664 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1667 m_ipcModule.sendToClients(response, &clientHandle, 1);
1668 m_ipcModule.destroyMessage(response);
1671 void GenericCommunicator::GetSurfacePixelformat(t_ilm_message message)
1673 t_ilm_message response;
1674 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1675 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1677 PixelFormat pixelFormat = (PixelFormat)ILM_PIXEL_FORMAT_UNKNOWN;
1679 m_ipcModule.getUint(message, &id);
1681 t_ilm_bool status = m_executor->execute(new SurfaceGetPixelformatCommand(clientPid, id, &pixelFormat));
1684 response = m_ipcModule.createResponse(message);
1685 m_ipcModule.appendUint(response, pixelFormat);
1689 response = m_ipcModule.createErrorResponse(message);
1690 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1693 m_ipcModule.sendToClients(response, &clientHandle, 1);
1694 m_ipcModule.destroyMessage(response);
1697 void GenericCommunicator::SetSurfaceVisibility(t_ilm_message message)
1699 t_ilm_message response;
1700 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1701 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1703 t_ilm_bool newVis = ILM_FALSE;
1705 m_ipcModule.getUint(message, &surfaceid);
1706 m_ipcModule.getBool(message, &newVis);
1708 t_ilm_bool status = m_executor->execute(new SurfaceSetVisibilityCommand(clientPid, surfaceid, newVis));
1711 response = m_ipcModule.createResponse(message);
1715 response = m_ipcModule.createErrorResponse(message);
1716 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1719 m_ipcModule.sendToClients(response, &clientHandle, 1);
1720 m_ipcModule.destroyMessage(response);
1723 void GenericCommunicator::SetLayerVisibility(t_ilm_message message)
1725 t_ilm_message response;
1726 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1727 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1729 t_ilm_bool myparam = ILM_FALSE;
1731 m_ipcModule.getUint(message, &layerid);
1732 m_ipcModule.getBool(message, &myparam);
1734 t_ilm_bool status = m_executor->execute(new LayerSetVisibilityCommand(clientPid, layerid, myparam));
1737 response = m_ipcModule.createResponse(message);
1741 response = m_ipcModule.createErrorResponse(message);
1742 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1745 m_ipcModule.sendToClients(response, &clientHandle, 1);
1746 m_ipcModule.destroyMessage(response);
1749 void GenericCommunicator::GetSurfaceVisibility(t_ilm_message message)
1751 t_ilm_message response;
1752 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1753 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1755 bool visibility = false;
1757 m_ipcModule.getUint(message, &id);
1759 t_ilm_bool status = m_executor->execute(new SurfaceGetVisibilityCommand(clientPid, id, &visibility));
1762 response = m_ipcModule.createResponse(message);
1763 m_ipcModule.appendBool(response, visibility);
1767 response = m_ipcModule.createErrorResponse(message);
1768 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1771 m_ipcModule.sendToClients(response, &clientHandle, 1);
1772 m_ipcModule.destroyMessage(response);
1775 void GenericCommunicator::GetLayerVisibility(t_ilm_message message)
1777 t_ilm_message response;
1778 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1779 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1781 bool visibility = false;
1783 m_ipcModule.getUint(message, &id);
1785 t_ilm_bool status = m_executor->execute(new LayerGetVisibilityCommand(clientPid, id, &visibility));
1788 response = m_ipcModule.createResponse(message);
1789 m_ipcModule.appendBool(response, visibility);
1793 response = m_ipcModule.createErrorResponse(message);
1794 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1797 m_ipcModule.sendToClients(response, &clientHandle, 1);
1798 m_ipcModule.destroyMessage(response);
1801 void GenericCommunicator::SetSynchronizedSurfaces(t_ilm_message message)
1803 t_ilm_message response;
1804 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1805 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1807 // ipcArray was created in ipcModule using malloc (it's implemented C)
1808 // so we copy it to a buffer created with new() and discard
1809 // the ipcArray using free() to avoid memory corruption
1810 uint* ipcArray = NULL;
1813 m_ipcModule.getUintArray(message, &ipcArray, &length);
1814 array = new uint[length];
1815 memset(array, 0, length * sizeof(uint));
1816 memcpy(array, ipcArray, length * sizeof(uint));
1819 t_ilm_bool status = m_executor->execute(new SetSynchronizedSurfacesCommand(clientPid, array, length));
1822 response = m_ipcModule.createResponse(message);
1826 response = m_ipcModule.createErrorResponse(message);
1827 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1830 m_ipcModule.sendToClients(response, &clientHandle, 1);
1831 m_ipcModule.destroyMessage(response);
1834 void GenericCommunicator::RemoveSynchronizedSurfaces(t_ilm_message message)
1836 t_ilm_message response;
1837 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1838 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1840 // ipcArray was created in ipcModule using malloc (it's implemented C)
1841 // so we copy it to a buffer created with new() and discard
1842 // the ipcArray using free() to avoid memory corruption
1843 uint* ipcArray = NULL;
1846 m_ipcModule.getUintArray(message, &ipcArray, &length);
1847 array = new uint[length];
1848 memset(array, 0, length * sizeof(uint));
1849 memcpy(array, ipcArray, length * sizeof(uint));
1852 t_ilm_bool status = m_executor->execute(new RemoveSynchronizedSurfacesCommand(clientPid, array, length));
1855 response = m_ipcModule.createResponse(message);
1859 response = m_ipcModule.createErrorResponse(message);
1860 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1863 m_ipcModule.sendToClients(response, &clientHandle, 1);
1864 m_ipcModule.destroyMessage(response);
1867 void GenericCommunicator::SetRenderOrderOfLayers(t_ilm_message message)
1869 t_ilm_message response;
1870 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1871 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1873 // ipcArray was created in ipcModule using malloc (it's implemented C)
1874 // so we copy it to a buffer created with new() and discard
1875 // the ipcArray using free() to avoid memory corruption
1876 uint* ipcArray = NULL;
1879 m_ipcModule.getUintArray(message, &ipcArray, &length);
1880 array = new uint[length];
1881 memset(array, 0, length * sizeof(uint));
1882 memcpy(array, ipcArray, length * sizeof(uint));
1887 m_ipcModule.getUint(message, &screenID);
1889 t_ilm_bool status = m_executor->execute(new ScreenSetRenderOrderCommand(clientPid, screenID, array, length));
1892 response = m_ipcModule.createResponse(message);
1896 response = m_ipcModule.createErrorResponse(message);
1897 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1900 m_ipcModule.sendToClients(response, &clientHandle, 1);
1901 m_ipcModule.destroyMessage(response);
1904 void GenericCommunicator::SetSurfaceRenderOrderWithinLayer(t_ilm_message message)
1906 t_ilm_message response;
1907 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1908 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1911 m_ipcModule.getUint(message, &layerid);
1913 // ipcArray was created in ipcModule using malloc (it's implemented C)
1914 // so we copy it to a buffer created with new() and discard
1915 // the ipcArray using free() to avoid memory corruption
1916 uint* ipcArray = NULL;
1919 m_ipcModule.getUintArray(message, &ipcArray, &length);
1920 array = new uint[length];
1921 memset(array, 0, length * sizeof(uint));
1922 memcpy(array, ipcArray, length * sizeof(uint));
1925 t_ilm_bool status = m_executor->execute(new LayerSetRenderOrderCommand(clientPid, layerid, array, length));
1928 response = m_ipcModule.createResponse(message);
1932 response = m_ipcModule.createErrorResponse(message);
1933 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1936 m_ipcModule.sendToClients(response, &clientHandle, 1);
1937 m_ipcModule.destroyMessage(response);
1940 void GenericCommunicator::GetLayerType(t_ilm_message message)
1942 t_ilm_message response;
1943 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1945 m_ipcModule.getUint(message, &id);
1947 Layer* layer = m_executor->getScene()->getLayer(id);
1950 response = m_ipcModule.createResponse(message);
1951 m_ipcModule.appendUint(response, layer->getLayerType());
1955 response = m_ipcModule.createErrorResponse(message);
1956 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1959 m_ipcModule.sendToClients(response, &clientHandle, 1);
1960 m_ipcModule.destroyMessage(response);
1963 void GenericCommunicator::GetLayertypeCapabilities(t_ilm_message message)
1965 t_ilm_message response;
1966 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1968 LayerType type = Unknown;
1970 m_ipcModule.getUint(message, &id);
1972 type = (LayerType) id;
1974 uint capabilities = m_executor->getLayerTypeCapabilities(type);
1975 response = m_ipcModule.createResponse(message);
1976 m_ipcModule.appendUint(response, capabilities);
1977 m_ipcModule.sendToClients(response, &clientHandle, 1);
1978 m_ipcModule.destroyMessage(response);
1981 void GenericCommunicator::GetLayerCapabilities(t_ilm_message message)
1983 t_ilm_message response;
1984 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1986 m_ipcModule.getUint(message, &id);
1988 Layer* layer = m_executor->getScene()->getLayer(id);
1991 response = m_ipcModule.createResponse(message);
1992 m_ipcModule.appendUint(response, layer->getCapabilities());
1996 response = m_ipcModule.createErrorResponse(message);
1997 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2000 m_ipcModule.sendToClients(response, &clientHandle, 1);
2001 m_ipcModule.destroyMessage(response);
2004 void GenericCommunicator::FadeIn(t_ilm_message message)
2006 t_ilm_message response;
2007 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2008 response = m_ipcModule.createErrorResponse(message);
2009 m_ipcModule.appendUint(response, ILM_ERROR_NOT_IMPLEMENTED);
2010 m_ipcModule.sendToClients(response, &clientHandle, 1);
2011 m_ipcModule.destroyMessage(response);
2014 void GenericCommunicator::SynchronizedFade(t_ilm_message message)
2016 t_ilm_message response;
2017 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2018 response = m_ipcModule.createErrorResponse(message);
2019 m_ipcModule.appendUint(response, ILM_ERROR_NOT_IMPLEMENTED);
2020 m_ipcModule.sendToClients(response, &clientHandle, 1);
2021 m_ipcModule.destroyMessage(response);
2024 void GenericCommunicator::FadeOut(t_ilm_message message)
2026 t_ilm_message response;
2027 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2028 response = m_ipcModule.createErrorResponse(message);
2029 m_ipcModule.appendUint(response, ILM_ERROR_NOT_IMPLEMENTED);
2030 m_ipcModule.sendToClients(response, &clientHandle, 1);
2031 m_ipcModule.destroyMessage(response);
2034 void GenericCommunicator::Exit(t_ilm_message message)
2036 t_ilm_message response;
2037 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2038 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2039 t_ilm_bool status = m_executor->execute(new ExitCommand(clientPid));
2042 response = m_ipcModule.createResponse(message);
2046 response = m_ipcModule.createErrorResponse(message);
2047 m_ipcModule.appendUint(response, ILM_ERROR_INVALID_ARGUMENTS);
2050 m_ipcModule.sendToClients(response, &clientHandle, 1);
2051 m_ipcModule.destroyMessage(response);
2054 void GenericCommunicator::CommitChanges(t_ilm_message message)
2056 t_ilm_message response;
2057 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2058 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2059 t_ilm_bool status = m_executor->execute(new CommitCommand(clientPid));
2062 response = m_ipcModule.createResponse(message);
2066 response = m_ipcModule.createErrorResponse(message);
2067 m_ipcModule.appendUint(response, ILM_ERROR_INVALID_ARGUMENTS);
2070 m_ipcModule.sendToClients(response, &clientHandle, 1);
2071 m_ipcModule.destroyMessage(response);
2074 void GenericCommunicator::CreateShader(t_ilm_message message)
2076 t_ilm_message response;
2077 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2078 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2079 char vertname[1024];
2080 char fragname[1024];
2083 m_ipcModule.getString(message, vertname);
2084 m_ipcModule.getString(message, fragname);
2086 t_ilm_bool status = m_executor->execute(new ShaderCreateCommand(clientPid, vertname, fragname, &id));
2089 response = m_ipcModule.createResponse(message);
2090 m_ipcModule.appendUint(response, id);
2094 response = m_ipcModule.createErrorResponse(message);
2095 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2098 m_ipcModule.sendToClients(response, &clientHandle, 1);
2099 m_ipcModule.destroyMessage(response);
2102 void GenericCommunicator::DestroyShader(t_ilm_message message)
2104 t_ilm_message response;
2105 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2106 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2109 m_ipcModule.getUint(message, &shaderid);
2111 t_ilm_bool status = m_executor->execute(new ShaderDestroyCommand(clientPid, shaderid));
2114 response = m_ipcModule.createResponse(message);
2118 response = m_ipcModule.createErrorResponse(message);
2119 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2122 m_ipcModule.sendToClients(response, &clientHandle, 1);
2123 m_ipcModule.destroyMessage(response);
2126 void GenericCommunicator::SetShader(t_ilm_message message)
2128 t_ilm_message response;
2129 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2130 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2134 m_ipcModule.getUint(message, &surfaceId);
2135 m_ipcModule.getUint(message, &shaderid);
2137 t_ilm_bool status = m_executor->execute(new SurfaceSetShaderCommand(clientPid, surfaceId, shaderid));
2140 response = m_ipcModule.createResponse(message);
2144 response = m_ipcModule.createErrorResponse(message);
2145 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2148 m_ipcModule.sendToClients(response, &clientHandle, 1);
2149 m_ipcModule.destroyMessage(response);
2152 void GenericCommunicator::SetUniforms(t_ilm_message message)
2154 t_ilm_message response;
2155 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2156 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2158 std::vector<string> uniforms;
2160 m_ipcModule.getUint(message, &id);
2163 //m_ipcModule.getStringArray(&uniforms);
2165 t_ilm_bool status = m_executor->execute(new ShaderSetUniformsCommand(clientPid, id, uniforms));
2168 response = m_ipcModule.createResponse(message);
2172 response = m_ipcModule.createErrorResponse(message);
2173 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2176 m_ipcModule.sendToClients(response, &clientHandle, 1);
2177 m_ipcModule.destroyMessage(response);
2180 void GenericCommunicator::SetKeyboardFocusOn(t_ilm_message message)
2182 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2183 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2184 t_ilm_message response;
2187 m_ipcModule.getUint(message, &surfaceId);
2189 t_ilm_bool status = m_executor->execute(new SurfaceSetKeyboardFocusCommand(clientPid, surfaceId));
2192 response = m_ipcModule.createResponse(message);
2196 response = m_ipcModule.createErrorResponse(message);
2197 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2200 m_ipcModule.sendToClients(response, &clientHandle, 1);
2201 m_ipcModule.destroyMessage(response);
2205 void GenericCommunicator::GetKeyboardFocusSurfaceId(t_ilm_message message)
2207 t_ilm_message response;
2208 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2209 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2212 t_ilm_bool status = m_executor->execute(new SurfaceGetKeyboardFocusCommand(clientPid, &surfaceId));
2215 response = m_ipcModule.createResponse(message);
2216 m_ipcModule.appendUint(response, surfaceId);
2220 response = m_ipcModule.createErrorResponse(message);
2221 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2224 m_ipcModule.sendToClients(response, &clientHandle, 1);
2225 m_ipcModule.destroyMessage(response);
2229 void GenericCommunicator::UpdateInputEventAcceptanceOn(t_ilm_message message)
2231 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2232 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2233 t_ilm_message response;
2236 InputDevice devices;
2239 m_ipcModule.getUint(message, &surfaceId);
2240 m_ipcModule.getUint(message, &udevices);
2241 m_ipcModule.getBool(message, &accept);
2243 devices = (InputDevice) udevices;
2245 t_ilm_bool status = m_executor->execute(new SurfaceUpdateInputEventAcceptance(clientPid, surfaceId, devices, accept));
2248 response = m_ipcModule.createResponse(message);
2252 response = m_ipcModule.createErrorResponse(message);
2253 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2256 m_ipcModule.sendToClients(response, &clientHandle, 1);
2257 m_ipcModule.destroyMessage(response);
2260 void GenericCommunicator::SetSurfaceChromaKey(t_ilm_message message)
2262 t_ilm_message response;
2263 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2264 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2269 m_ipcModule.getUint(message, &surfaceid);
2270 m_ipcModule.getUintArray(message, &array, &length);
2272 t_ilm_bool status = m_executor->execute(new SurfaceSetChromaKeyCommand(clientPid, surfaceid, array, length));
2275 response = m_ipcModule.createResponse(message);
2279 response = m_ipcModule.createErrorResponse(message);
2280 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2283 m_ipcModule.sendToClients(response, &clientHandle, 1);
2284 m_ipcModule.destroyMessage(response);
2287 void GenericCommunicator::SetLayerChromaKey(t_ilm_message message)
2289 t_ilm_message response;
2290 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2291 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2296 m_ipcModule.getUint(message, &layerid);
2297 m_ipcModule.getUintArray(message, &array, &length);
2299 t_ilm_bool status = m_executor->execute(new LayerSetChromaKeyCommand(clientPid, layerid, array, length));
2302 response = m_ipcModule.createResponse(message);
2306 response = m_ipcModule.createErrorResponse(message);
2307 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2310 m_ipcModule.sendToClients(response, &clientHandle, 1);
2311 m_ipcModule.destroyMessage(response);
2314 void GenericCommunicator::LayerAddNotification(t_ilm_message message)
2316 t_ilm_message response;
2317 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2320 m_ipcModule.getUint(message, &layerid);
2322 Layer* layer = m_executor->getScene()->getLayer(layerid);
2325 layer->addNotification(clientHandle);
2326 response = m_ipcModule.createResponse(message);
2330 response = m_ipcModule.createErrorResponse(message);
2331 m_ipcModule.appendUint(response, ILM_ERROR_INVALID_ARGUMENTS);
2334 m_ipcModule.sendToClients(response, &clientHandle, 1);
2335 m_ipcModule.destroyMessage(response);
2338 void GenericCommunicator::SurfaceAddNotification(t_ilm_message message)
2340 t_ilm_message response;
2341 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2344 m_ipcModule.getUint(message, &surfaceid);
2346 Surface* surface = m_executor->getScene()->getSurface(surfaceid);
2349 surface->addNotification(clientHandle);
2350 response = m_ipcModule.createResponse(message);
2354 response = m_ipcModule.createErrorResponse(message);
2355 m_ipcModule.appendUint(response, ILM_ERROR_INVALID_ARGUMENTS);
2358 m_ipcModule.sendToClients(response, &clientHandle, 1);
2359 m_ipcModule.destroyMessage(response);
2362 void GenericCommunicator::LayerRemoveNotification(t_ilm_message message)
2364 t_ilm_message response;
2365 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2368 m_ipcModule.getUint(message, &layerid);
2370 Layer* layer = m_executor->getScene()->getLayer(layerid);
2373 layer->removeNotification(clientHandle);
2374 response = m_ipcModule.createResponse(message);
2378 response = m_ipcModule.createErrorResponse(message);
2379 m_ipcModule.appendUint(response, ILM_ERROR_INVALID_ARGUMENTS);
2382 m_ipcModule.sendToClients(response, &clientHandle, 1);
2383 m_ipcModule.destroyMessage(response);
2386 void GenericCommunicator::SurfaceRemoveNotification(t_ilm_message message)
2388 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2389 t_ilm_message response;
2392 m_ipcModule.getUint(message, &surfaceid);
2394 Surface* surface = m_executor->getScene()->getSurface(surfaceid);
2397 surface->removeNotification(clientHandle);
2398 response = m_ipcModule.createResponse(message);
2402 response = m_ipcModule.createErrorResponse(message);
2403 m_ipcModule.appendUint(response, ILM_ERROR_INVALID_ARGUMENTS);
2406 m_ipcModule.sendToClients(response, &clientHandle, 1);
2407 m_ipcModule.destroyMessage(response);
2410 void GenericCommunicator::processNotificationQueue()
2412 NotificationQueue& notificationQueue = m_executor->getClientNotificationQueue();
2413 NotificationQueue::iterator iter = notificationQueue.begin();
2414 NotificationQueue::iterator end = notificationQueue.end();
2416 for (; iter != end; ++iter)
2418 GraphicalObject* object = iter->first;
2419 t_ilm_notification_mask mask = iter->second;
2420 sendNotification(object, mask);
2422 notificationQueue.clear();
2425 void GenericCommunicator::sendNotification(GraphicalObject* object, t_ilm_notification_mask mask)
2427 switch (object->type)
2431 Layer* layer = static_cast<Layer*>(object);
2434 ApplicationReferenceList& arl = layer->getNotificationClients();
2438 t_ilm_message notification;
2439 Rectangle dest = layer->getDestinationRegion();
2440 Rectangle src = layer->getSourceRegion();
2441 OrientationType orientation = layer->getOrientation();
2443 unsigned char chromaKeyRed = 0;
2444 unsigned char chromaKeyGreen = 0;
2445 unsigned char chromaKeyBlue = 0;
2446 layer->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
2448 std::stringstream notificationName;
2449 notificationName << "NotificationForLayer" << layer->getID();
2451 notification = m_ipcModule.createNotification(notificationName.str().c_str());
2452 m_ipcModule.appendUint(notification, layer->getID());
2453 m_ipcModule.appendUint(notification, mask);
2455 m_ipcModule.appendDouble(notification, layer->getOpacity());
2456 m_ipcModule.appendUint(notification, src.x);
2457 m_ipcModule.appendUint(notification, src.y);
2458 m_ipcModule.appendUint(notification, src.width);
2459 m_ipcModule.appendUint(notification, src.height);
2460 m_ipcModule.appendUint(notification, layer->OriginalSourceWidth);
2461 m_ipcModule.appendUint(notification, layer->OriginalSourceHeight);
2462 m_ipcModule.appendUint(notification, dest.x);
2463 m_ipcModule.appendUint(notification, dest.y);
2464 m_ipcModule.appendUint(notification, dest.width);
2465 m_ipcModule.appendUint(notification, dest.height);
2466 m_ipcModule.appendUint(notification, orientation);
2467 m_ipcModule.appendBool(notification, layer->getVisibility());
2468 m_ipcModule.appendUint(notification, layer->getLayerType());
2469 m_ipcModule.appendBool(notification, layer->getChromaKeyEnabled());
2470 m_ipcModule.appendUint(notification, chromaKeyRed);
2471 m_ipcModule.appendUint(notification, chromaKeyGreen);
2472 m_ipcModule.appendUint(notification, chromaKeyBlue);
2473 m_ipcModule.appendInt(notification, layer->getCreatorPid());
2475 int clientCount = arl.size();
2476 t_ilm_client_handle clientArray[256];
2478 ApplicationReferenceList::iterator iter = arl.begin();
2479 ApplicationReferenceList::iterator end = arl.end();
2481 for (int clientNumber = 0;
2482 iter != end, clientNumber < 256;
2483 ++iter, ++clientNumber)
2485 t_ilm_client_handle client = *iter;
2486 clientArray[clientNumber] = client;
2489 LOG_DEBUG("GenericCommunicator", "Sending " << clientCount << " notification(s): layer " << layer->getID() << " was updated.");
2491 if (!m_ipcModule.sendToClients(notification, clientArray, clientCount))
2493 LOG_ERROR("GenericCommunicator", "Sending notification to clients failed.")
2496 m_ipcModule.destroyMessage(notification);
2503 Surface* surface = static_cast<Surface*>(object);
2506 ApplicationReferenceList& arl = surface->getNotificationClients();
2510 t_ilm_message notification;
2511 std::stringstream notificationName;
2512 notificationName << "NotificationForSurface" << surface->getID();
2514 unsigned char chromaKeyRed = 0;
2515 unsigned char chromaKeyGreen = 0;
2516 unsigned char chromaKeyBlue = 0;
2517 surface->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
2519 notification = m_ipcModule.createNotification(notificationName.str().c_str());
2520 m_ipcModule.appendUint(notification, surface->getID());
2521 m_ipcModule.appendUint(notification, mask);
2523 m_ipcModule.appendDouble(notification, surface->getOpacity());
2524 m_ipcModule.appendUint(notification, surface->getSourceRegion().x);
2525 m_ipcModule.appendUint(notification, surface->getSourceRegion().y);
2526 m_ipcModule.appendUint(notification, surface->getSourceRegion().width);
2527 m_ipcModule.appendUint(notification, surface->getSourceRegion().height);
2528 m_ipcModule.appendUint(notification, surface->OriginalSourceWidth);
2529 m_ipcModule.appendUint(notification, surface->OriginalSourceHeight);
2530 m_ipcModule.appendUint(notification, surface->getDestinationRegion().x);
2531 m_ipcModule.appendUint(notification, surface->getDestinationRegion().y);
2532 m_ipcModule.appendUint(notification, surface->getDestinationRegion().width);
2533 m_ipcModule.appendUint(notification, surface->getDestinationRegion().height);
2534 m_ipcModule.appendUint(notification, surface->getOrientation());
2535 m_ipcModule.appendBool(notification, surface->getVisibility());
2536 m_ipcModule.appendUint(notification, surface->frameCounter);
2537 m_ipcModule.appendUint(notification, surface->drawCounter);
2538 m_ipcModule.appendUint(notification, surface->updateCounter);
2539 m_ipcModule.appendUint(notification, surface->getPixelFormat());
2540 m_ipcModule.appendUint(notification, surface->getNativeContent());
2541 m_ipcModule.appendUint(notification, surface->getInputEventAcceptanceOnDevices());
2542 m_ipcModule.appendBool(notification, surface->getChromaKeyEnabled());
2543 m_ipcModule.appendUint(notification, chromaKeyRed);
2544 m_ipcModule.appendUint(notification, chromaKeyGreen);
2545 m_ipcModule.appendUint(notification, chromaKeyBlue);
2546 m_ipcModule.appendInt(notification, surface->getCreatorPid());
2548 int clientCount = arl.size();
2549 t_ilm_client_handle clients[256];
2551 ApplicationReferenceList::iterator iter = arl.begin();
2552 ApplicationReferenceList::iterator end = arl.end();
2554 for (int clientNumber = 0;
2555 iter != end, clientNumber < 256;
2556 ++iter, ++clientNumber)
2558 clients[clientNumber] = *iter;
2561 LOG_DEBUG("GenericCommunicator", "Sending " << clientCount << " notification(s): surface " << surface->getID() << " was updated.");
2563 if (!m_ipcModule.sendToClients(notification, clients, clientCount))
2565 LOG_ERROR("GenericCommunicator", "Sending notification to clients failed.")
2568 m_ipcModule.destroyMessage(notification);
2574 LOG_INFO("GenericCommunicator", "Unknown notification found in queue.");
2579 HealthCondition GenericCommunicator::pluginGetHealth()
2581 HealthCondition health = PluginBase::pluginGetHealth();
2582 if (0 != pthread_kill(mThreadId, 0))
2584 health = HealthDead;
2589 void GenericCommunicator::SetOptimizationMode(t_ilm_message message)
2591 t_ilm_message response;
2592 OptimizationType optimizationId;
2593 OptimizationModeType optimizationMode;
2594 unsigned int optMode;
2595 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2596 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2598 m_ipcModule.getUint(message, &optMode);
2599 optimizationId = (OptimizationType)optMode;
2600 m_ipcModule.getUint(message, &optMode);
2601 optimizationMode = (OptimizationModeType)optMode;
2603 t_ilm_bool status = m_executor->execute(new SetOptimizationModeCommand(clientPid, optimizationId, optimizationMode));
2606 response = m_ipcModule.createResponse(message);
2610 response = m_ipcModule.createErrorResponse(message);
2611 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2613 m_ipcModule.sendToClients(response, &clientHandle, 1);
2614 m_ipcModule.destroyMessage(response);
2617 void GenericCommunicator::GetOptimizationMode(t_ilm_message message)
2619 t_ilm_message response;
2620 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2621 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2622 OptimizationType optimizationId;
2623 OptimizationModeType optimizationMode;
2626 m_ipcModule.getUint(message, &o);
2627 optimizationId = (OptimizationType)o;
2629 t_ilm_bool status = m_executor->execute(new GetOptimizationModeCommand(clientPid, optimizationId, &optimizationMode));
2632 response = m_ipcModule.createResponse(message);
2633 m_ipcModule.appendUint(response, (unsigned int)optimizationMode);
2637 response = m_ipcModule.createErrorResponse(message);
2638 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2640 m_ipcModule.sendToClients(response, &clientHandle, 1);
2641 m_ipcModule.destroyMessage(response);
2644 void GenericCommunicator::GetPropertiesOfScreen(t_ilm_message message)
2646 t_ilm_message response;
2647 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2649 m_ipcModule.getUint(message, &id);
2651 LmScreen* screen = m_executor->getScene()->getScreen(id);
2654 LayerList renderOrder = screen->getCurrentRenderOrder();
2655 std::vector<t_ilm_layer> layerIdVector;
2657 LayerListConstIterator iter = renderOrder.begin();
2658 LayerListConstIterator end = renderOrder.end();
2659 for (; iter != end; ++iter)
2661 layerIdVector.push_back((*iter)->getID());
2664 uint numberOfHardwareLayers = m_executor->getNumberOfHardwareLayers(id);
2665 uint* resolution = m_executor->getScreenResolution(id);
2667 response = m_ipcModule.createResponse(message);
2668 m_ipcModule.appendUintArray(response, layerIdVector.data(), layerIdVector.size());
2669 m_ipcModule.appendUint(response, numberOfHardwareLayers);
2670 m_ipcModule.appendUint(response, resolution[0]);
2671 m_ipcModule.appendUint(response, resolution[1]);
2675 response = m_ipcModule.createErrorResponse(message);
2676 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2679 m_ipcModule.sendToClients(response, &clientHandle, 1);
2680 m_ipcModule.destroyMessage(response);
2683 DECLARE_LAYERMANAGEMENT_PLUGIN(GenericCommunicator)