1 /**************************************************************************
3 * Copyright 2012 BMW Car IT GmbH
4 * Copyright (C) 2012 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
5 * Copyright (C) 2012 Bayerische Motorenwerke Aktiengesellschaft
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ****************************************************************************/
20 #include "ilm_client.h"
21 #include "ilm_types.h"
22 #include "IpcModuleLoader.h"
23 #include "ObjectType.h"
32 #include <sys/types.h>
36 //=============================================================================
38 //=============================================================================
39 const int gReceiveTimeout = -1; // in ms, negative value for infinite
40 const int gResponseTimeout = 500; // in ms
42 // must be same as GraphicalObject::INVALID_ID, but this is defined in C++
43 // and can not be used here
44 #define INVALID_ID 0xFFFFFFFF
46 // queue names for incoming notifications and messages
47 #define NOTIFICATION_QUEUE_NAME "/ilmClient%dNotification"
48 #define INCOMING_QUEUE_NAME "/ilmClient%dIncoming"
50 //=============================================================================
52 //=============================================================================
53 extern char *__progname; // automatically gets assigned argv[0]
55 static struct IpcModule gIpcModule;
57 static pthread_t gReceiveThread;
58 static pthread_mutex_t gSendReceiveLock;
59 static pthread_t gNotificationThread;
61 static mqd_t incomingMqRead;
62 static mqd_t incomingMqWrite;
64 static mqd_t notificationMqRead;
65 static mqd_t notificationMqWrite;
67 static t_ilm_bool gInitialized = ILM_FALSE;
69 //=============================================================================
70 // notification management
71 //=============================================================================
72 #define MAX_CALLBACK_COUNT 64
76 layerNotificationFunc callback;
77 } static gLayerNotificationCallbacks[MAX_CALLBACK_COUNT];
82 surfaceNotificationFunc callback;
83 } static gSurfaceNotificationCallbacks[MAX_CALLBACK_COUNT];
85 void initNotificationCallbacks()
88 for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
90 gLayerNotificationCallbacks[i].id = INVALID_ID;
91 gLayerNotificationCallbacks[i].callback = NULL;
92 gSurfaceNotificationCallbacks[i].id = INVALID_ID;
93 gSurfaceNotificationCallbacks[i].callback = NULL;
97 layerNotificationFunc getLayerNotificationCallback(t_ilm_layer layer)
100 for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
102 if (gLayerNotificationCallbacks[i].id == layer)
104 return gLayerNotificationCallbacks[i].callback;
110 surfaceNotificationFunc getSurfaceNotificationCallback(t_ilm_surface surface)
113 for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
115 if (gSurfaceNotificationCallbacks[i].id == surface)
117 return gSurfaceNotificationCallbacks[i].callback;
123 t_ilm_bool findLayerCallback(t_ilm_layer layer)
127 // try to overwrite existing entry for layer id
128 for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
130 if (gLayerNotificationCallbacks[i].id == layer)
138 t_ilm_bool addLayerCallback(t_ilm_layer layer, layerNotificationFunc func)
142 if (findLayerCallback(layer))
147 // find free slot and store callback
148 for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
150 if (gLayerNotificationCallbacks[i].id == INVALID_ID)
152 gLayerNotificationCallbacks[i].id = layer;
153 gLayerNotificationCallbacks[i].callback = func;
157 printf("DbusIpcModule: addLayerCallback() failed. no free slots.");
161 t_ilm_bool findSurfaceCallback(t_ilm_surface surface)
165 // try to overwrite existing entry for layer id
166 for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
168 if (gSurfaceNotificationCallbacks[i].id == surface)
176 t_ilm_bool addSurfaceCallback(t_ilm_surface surface, surfaceNotificationFunc func)
180 if (findSurfaceCallback(surface))
185 // find free slot and store callback
186 for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
188 if (gSurfaceNotificationCallbacks[i].id == INVALID_ID)
190 gSurfaceNotificationCallbacks[i].id = surface;
191 gSurfaceNotificationCallbacks[i].callback = func;
195 printf("DbusIpcModule: addSurfaceCallback() failed. no free slots.");
199 void removeLayerCallback(t_ilm_layer layer)
202 for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
204 if (gLayerNotificationCallbacks[i].id == layer)
206 gLayerNotificationCallbacks[i].id = INVALID_ID;
207 gLayerNotificationCallbacks[i].callback = NULL;
213 void removeSurfaceCallback(t_ilm_surface layer)
216 for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
218 if (gSurfaceNotificationCallbacks[i].id == layer)
220 gSurfaceNotificationCallbacks[i].id = INVALID_ID;
221 gSurfaceNotificationCallbacks[i].callback = NULL;
227 //=============================================================================
228 // handling of internal notification thread for dispatching notifications
229 // Note: notification callbacks may be blocked by client, but receive thread
230 // must not be blocked
231 //=============================================================================
232 void* notificationThreadLoop(void* param)
236 t_ilm_message notification;
238 while (-1 != mq_receive(notificationMqRead, (char*)¬ification, sizeof(notification), NULL))
240 t_ilm_const_string name = gIpcModule.getMessageName(notification);
242 // this depends on message name, but it is fast
247 struct ilmLayerProperties properties;
249 gIpcModule.getUint(notification, &id);
250 gIpcModule.getUint(notification, &mask);
251 gIpcModule.getDouble(notification, &properties.opacity);
252 gIpcModule.getUint(notification, &properties.sourceX);
253 gIpcModule.getUint(notification, &properties.sourceY);
254 gIpcModule.getUint(notification, &properties.sourceWidth);
255 gIpcModule.getUint(notification, &properties.sourceHeight);
256 gIpcModule.getUint(notification, &properties.origSourceWidth);
257 gIpcModule.getUint(notification, &properties.origSourceHeight);
258 gIpcModule.getUint(notification, &properties.destX);
259 gIpcModule.getUint(notification, &properties.destY);
260 gIpcModule.getUint(notification, &properties.destWidth);
261 gIpcModule.getUint(notification, &properties.destHeight);
262 gIpcModule.getUint(notification, &properties.orientation);
263 gIpcModule.getBool(notification, &properties.visibility);
264 gIpcModule.getUint(notification, &properties.type);
265 gIpcModule.getBool(notification, &properties.chromaKeyEnabled);
266 gIpcModule.getUint(notification, &properties.chromaKeyRed);
267 gIpcModule.getUint(notification, &properties.chromaKeyGreen);
268 gIpcModule.getUint(notification, &properties.chromaKeyBlue);
269 gIpcModule.getInt(notification, &properties.creatorPid);
271 layerNotificationFunc func = getLayerNotificationCallback(id);
274 (*func)(id, &properties, mask);
278 fprintf(stderr, "notification for layer %d received, but no callback set\n", id);
286 struct ilmSurfaceProperties properties;
288 gIpcModule.getUint(notification, &id);
289 gIpcModule.getUint(notification, &mask);
290 gIpcModule.getDouble(notification, &properties.opacity);
291 gIpcModule.getUint(notification, &properties.sourceX);
292 gIpcModule.getUint(notification, &properties.sourceY);
293 gIpcModule.getUint(notification, &properties.sourceWidth);
294 gIpcModule.getUint(notification, &properties.sourceHeight);
295 gIpcModule.getUint(notification, &properties.origSourceWidth);
296 gIpcModule.getUint(notification, &properties.origSourceHeight);
297 gIpcModule.getUint(notification, &properties.destX);
298 gIpcModule.getUint(notification, &properties.destY);
299 gIpcModule.getUint(notification, &properties.destWidth);
300 gIpcModule.getUint(notification, &properties.destHeight);
301 gIpcModule.getUint(notification, &properties.orientation);
302 gIpcModule.getBool(notification, &properties.visibility);
303 gIpcModule.getUint(notification, &properties.frameCounter);
304 gIpcModule.getUint(notification, &properties.drawCounter);
305 gIpcModule.getUint(notification, &properties.updateCounter);
306 gIpcModule.getUint(notification, &properties.pixelformat);
307 gIpcModule.getUint(notification, &properties.nativeSurface);
308 gIpcModule.getUint(notification, &properties.inputDevicesAcceptance);
309 gIpcModule.getBool(notification, &properties.chromaKeyEnabled);
310 gIpcModule.getUint(notification, &properties.chromaKeyRed);
311 gIpcModule.getUint(notification, &properties.chromaKeyGreen);
312 gIpcModule.getUint(notification, &properties.chromaKeyBlue);
313 gIpcModule.getInt(notification, &properties.creatorPid);
315 surfaceNotificationFunc func = getSurfaceNotificationCallback(id);
318 (*func)(id, &properties, mask);
322 fprintf(stderr, "notification for surface %d received, but no callback set\n", id);
325 gIpcModule.destroyMessage(notification);
330 //=============================================================================
331 // handling of internal receive thread for event handling
332 //=============================================================================
333 void* receiveThreadLoop(void* param)
337 t_ilm_bool running = ILM_TRUE;
341 t_ilm_message message = gIpcModule.receive(gReceiveTimeout);
342 t_ilm_message_type messageType = gIpcModule.getMessageType(message);
345 case IpcMessageTypeNotification:
346 if (-1 == mq_send(notificationMqWrite, (char*)&message, sizeof(message), 0))
350 printf("Notification queue full, dropped notification %s\n", gIpcModule.getMessageName(message));
355 case IpcMessageTypeCommand:
356 case IpcMessageTypeError:
357 if (-1 == mq_send(incomingMqWrite, (char*)&message, sizeof(message), 0))
361 printf("Incoming queue full, dropped message %s\n", gIpcModule.getMessageName(message));
366 case IpcMessageTypeNone:
370 printf("ilmClient: discarded unexpected message (type: %d)\n", (int)messageType);
371 gIpcModule.destroyMessage(message);
379 void calculateTimeout(struct timeval* currentTime, int giventimeout, struct timespec* timeout)
381 // nanoseconds is old value in nanoseconds + the given milliseconds as nanoseconds
382 t_ilm_ulong newNanoSeconds = currentTime->tv_usec * 1000 + giventimeout * (1000 * 1000);
384 // only use non full seconds, otherwise overflow!
385 timeout->tv_nsec = newNanoSeconds % (1000000000);
387 // new seconds are old seconds + full seconds from new nanoseconds part
388 timeout->tv_sec = currentTime->tv_sec + (newNanoSeconds / 1000000000 );
391 t_ilm_bool sendAndWaitForResponse(t_ilm_message command, t_ilm_message* response, int timeoutInMs)
396 t_ilm_message_type responseType = IpcMessageTypeNone;
398 // send / receive may only be performed by one thread at a time
399 pthread_mutex_lock(&gSendReceiveLock);
401 if (gIpcModule.sendToService(command))
403 if (-1 == mq_receive(incomingMqRead, (char*)response, sizeof(t_ilm_message), NULL))
405 fprintf(stderr,"waitForResponse: mq_receive failed, errno = %d\n", errno);
409 responseType = gIpcModule.getMessageType(*response);
412 pthread_mutex_unlock(&gSendReceiveLock);
414 return (*response && (IpcMessageTypeCommand == responseType));
417 //=============================================================================
419 //=============================================================================
420 ilmErrorTypes ilm_init()
422 ilmErrorTypes result = ILM_FAILED;
426 printf("ilm_init() was called, but ilmClientLib is already initialized. returning success, but initialization was skipped this time.\n");
430 initNotificationCallbacks();
432 if (loadIpcModule(&gIpcModule))
436 if (gIpcModule.initClientMode())
438 result = ILM_SUCCESS;
440 struct mq_attr mqAttr =
443 .mq_msgsize = sizeof(t_ilm_message),
444 .mq_flags = 0, //O_NONBLOCK,
449 snprintf(mqName, sizeof(mqName), NOTIFICATION_QUEUE_NAME, getpid());
451 notificationMqWrite = mq_open(mqName, O_WRONLY | O_CREAT, 0600, &mqAttr);
452 notificationMqRead = mq_open(mqName, O_RDONLY);
453 mq_unlink(mqName); // is destroyed on closed filedescriptor
455 snprintf(mqName, sizeof(mqName), INCOMING_QUEUE_NAME, getpid());
456 incomingMqWrite = mq_open(mqName, O_WRONLY | O_CREAT, 0600, &mqAttr);
457 incomingMqRead = mq_open(mqName, O_RDONLY);
458 mq_unlink(mqName); // is destroyed on closed filedescriptor
460 if ((mqd_t)-1 == notificationMqRead || (mqd_t)-1 == notificationMqWrite)
462 printf("mq_open failed, errno = %d\n", errno);
466 pthread_mutex_init(&gSendReceiveLock, NULL);
468 pthread_attr_t notificationThreadAttributes;
469 pthread_attr_init(¬ificationThreadAttributes);
470 pthread_attr_setdetachstate(¬ificationThreadAttributes,
471 PTHREAD_CREATE_JOINABLE);
473 int ret = pthread_create(&gReceiveThread,
474 ¬ificationThreadAttributes,
480 printf("Failed to start internal receive thread. returned %d = %s\n", ret, (ret == EAGAIN ? "EAGAIN" : "EINVAL"));
484 ret = pthread_create(&gNotificationThread,
485 ¬ificationThreadAttributes,
486 notificationThreadLoop,
491 printf("Failed to start internal notification thread. returned %d = %s\n", ret, (ret == EAGAIN ? "EAGAIN" : "EINVAL"));
498 printf("Failed to initialize Client Ipc Module");
502 t_ilm_message response = 0;
503 t_ilm_message command = gIpcModule.createMessage("ServiceConnect");
505 && gIpcModule.appendUint(command, pid)
506 && gIpcModule.appendString(command, __progname)
507 && sendAndWaitForResponse(command, &response, gResponseTimeout))
509 result = ILM_SUCCESS;
514 printf("Failed to connect to LayerManagerService.");
516 gIpcModule.destroyMessage(response);
517 gIpcModule.destroyMessage(command);
520 gInitialized = (result == ILM_SUCCESS) ? ILM_TRUE : ILM_FALSE;
525 ilmErrorTypes ilm_destroy()
527 ilmErrorTypes result = ILM_FAILED;
529 t_ilm_message response = 0;
530 t_ilm_message command = gIpcModule.createMessage("ServiceDisconnect");
532 && gIpcModule.appendUint(command, getpid())
533 && sendAndWaitForResponse(command, &response, gResponseTimeout))
535 result = ILM_SUCCESS;
537 gIpcModule.destroyMessage(response);
538 gIpcModule.destroyMessage(command);
540 // cancel worker threads
541 void* threadReturnValue = NULL;
543 pthread_cancel(gReceiveThread);
544 pthread_cancel(gNotificationThread);
546 pthread_join(gReceiveThread, &threadReturnValue);
547 pthread_join(gNotificationThread, &threadReturnValue);
549 pthread_mutex_unlock(&gSendReceiveLock);
551 pthread_mutex_destroy(&gSendReceiveLock);
553 gIpcModule.destroy();
555 mq_close(notificationMqRead);
556 mq_close(notificationMqWrite);
558 mq_close(incomingMqRead);
559 mq_close(incomingMqWrite);
561 gInitialized = ILM_FALSE;
566 ilmErrorTypes ilm_getPropertiesOfSurface(t_ilm_uint surfaceID, struct ilmSurfaceProperties* pSurfaceProperties)
568 ilmErrorTypes returnValue = ILM_FAILED;
570 t_ilm_message response = 0;
571 t_ilm_message command = gIpcModule.createMessage("GetPropertiesOfSurface");
573 if (pSurfaceProperties
575 && gIpcModule.appendUint(command, surfaceID)
576 && sendAndWaitForResponse(command, &response, gResponseTimeout)
577 && gIpcModule.getDouble(response, &pSurfaceProperties->opacity)
578 && gIpcModule.getUint(response, &pSurfaceProperties->sourceX)
579 && gIpcModule.getUint(response, &pSurfaceProperties->sourceY)
580 && gIpcModule.getUint(response, &pSurfaceProperties->sourceWidth)
581 && gIpcModule.getUint(response, &pSurfaceProperties->sourceHeight)
582 && gIpcModule.getUint(response, &pSurfaceProperties->origSourceWidth)
583 && gIpcModule.getUint(response, &pSurfaceProperties->origSourceHeight)
584 && gIpcModule.getUint(response, &pSurfaceProperties->destX)
585 && gIpcModule.getUint(response, &pSurfaceProperties->destY)
586 && gIpcModule.getUint(response, &pSurfaceProperties->destWidth)
587 && gIpcModule.getUint(response, &pSurfaceProperties->destHeight)
588 && gIpcModule.getUint(response, &pSurfaceProperties->orientation)
589 && gIpcModule.getBool(response, &pSurfaceProperties->visibility)
590 && gIpcModule.getUint(response, &pSurfaceProperties->frameCounter)
591 && gIpcModule.getUint(response, &pSurfaceProperties->drawCounter)
592 && gIpcModule.getUint(response, &pSurfaceProperties->updateCounter)
593 && gIpcModule.getUint(response, &pSurfaceProperties->pixelformat)
594 && gIpcModule.getUint(response, &pSurfaceProperties->nativeSurface)
595 && gIpcModule.getUint(response, &pSurfaceProperties->inputDevicesAcceptance)
596 && gIpcModule.getBool(response, &pSurfaceProperties->chromaKeyEnabled)
597 && gIpcModule.getUint(response, &pSurfaceProperties->chromaKeyRed)
598 && gIpcModule.getUint(response, &pSurfaceProperties->chromaKeyGreen)
599 && gIpcModule.getUint(response, &pSurfaceProperties->chromaKeyBlue)
600 && gIpcModule.getInt(response, &pSurfaceProperties->creatorPid))
602 returnValue = ILM_SUCCESS;
604 gIpcModule.destroyMessage(response);
605 gIpcModule.destroyMessage(command);
609 ilmErrorTypes ilm_getPropertiesOfLayer(t_ilm_uint layerID, struct ilmLayerProperties* pLayerProperties)
611 ilmErrorTypes returnValue = ILM_FAILED;
613 t_ilm_message response = 0;
614 t_ilm_message command = gIpcModule.createMessage("GetPropertiesOfLayer");
617 && gIpcModule.appendUint(command, layerID)
618 && sendAndWaitForResponse(command, &response, gResponseTimeout)
619 && gIpcModule.getDouble(response, &pLayerProperties->opacity)
620 && gIpcModule.getUint(response, &pLayerProperties->sourceX)
621 && gIpcModule.getUint(response, &pLayerProperties->sourceY)
622 && gIpcModule.getUint(response, &pLayerProperties->sourceWidth)
623 && gIpcModule.getUint(response, &pLayerProperties->sourceHeight)
624 && gIpcModule.getUint(response, &pLayerProperties->origSourceWidth)
625 && gIpcModule.getUint(response, &pLayerProperties->origSourceHeight)
626 && gIpcModule.getUint(response, &pLayerProperties->destX)
627 && gIpcModule.getUint(response, &pLayerProperties->destY)
628 && gIpcModule.getUint(response, &pLayerProperties->destWidth)
629 && gIpcModule.getUint(response, &pLayerProperties->destHeight)
630 && gIpcModule.getUint(response, &pLayerProperties->orientation)
631 && gIpcModule.getBool(response, &pLayerProperties->visibility)
632 && gIpcModule.getUint(response, &pLayerProperties->type)
633 && gIpcModule.getBool(response, &pLayerProperties->chromaKeyEnabled)
634 && gIpcModule.getUint(response, &pLayerProperties->chromaKeyRed)
635 && gIpcModule.getUint(response, &pLayerProperties->chromaKeyGreen)
636 && gIpcModule.getUint(response, &pLayerProperties->chromaKeyBlue)
637 && gIpcModule.getInt(response, &pLayerProperties->creatorPid))
639 returnValue = ILM_SUCCESS;
641 gIpcModule.destroyMessage(response);
642 gIpcModule.destroyMessage(command);
646 ilmErrorTypes ilm_getNumberOfHardwareLayers(t_ilm_uint screenID, t_ilm_uint* pNumberOfHardwareLayers)
648 ilmErrorTypes returnValue = ILM_FAILED;
650 t_ilm_message response = 0;
651 t_ilm_message command = gIpcModule.createMessage("GetNumberOfHardwareLayers");
652 if (pNumberOfHardwareLayers
654 && gIpcModule.appendUint(command, screenID)
655 && sendAndWaitForResponse(command, &response, gResponseTimeout)
656 && gIpcModule.getUint(response, pNumberOfHardwareLayers))
658 returnValue = ILM_SUCCESS;
660 gIpcModule.destroyMessage(response);
661 gIpcModule.destroyMessage(command);
665 ilmErrorTypes ilm_getScreenResolution(t_ilm_uint screenID, t_ilm_uint* pWidth, t_ilm_uint* pHeight)
667 ilmErrorTypes returnValue = ILM_FAILED;
669 t_ilm_message response = 0;
670 t_ilm_message command = gIpcModule.createMessage("GetScreenResolution");
671 if (pWidth && pHeight
673 && gIpcModule.appendUint(command, screenID)
674 && sendAndWaitForResponse(command, &response, gResponseTimeout)
675 && gIpcModule.getUint(response, pWidth)
676 && gIpcModule.getUint(response, pHeight))
678 returnValue = ILM_SUCCESS;
680 gIpcModule.destroyMessage(response);
681 gIpcModule.destroyMessage(command);
685 ilmErrorTypes ilm_getLayerIDs(t_ilm_int* pLength, t_ilm_layer** ppArray)
687 ilmErrorTypes returnValue = ILM_FAILED;
689 t_ilm_message response = 0;
690 t_ilm_message command = gIpcModule.createMessage("ListAllLayerIDS");
691 if (pLength && ppArray
693 && sendAndWaitForResponse(command, &response, gResponseTimeout)
694 && gIpcModule.getUintArray(response, ppArray, pLength))
696 returnValue = ILM_SUCCESS;
698 gIpcModule.destroyMessage(response);
699 gIpcModule.destroyMessage(command);
703 ilmErrorTypes ilm_getLayerIDsOnScreen(t_ilm_uint screenId, t_ilm_int* pLength, t_ilm_layer** ppArray)
705 ilmErrorTypes returnValue = ILM_FAILED;
707 t_ilm_message response = 0;
708 t_ilm_message command = gIpcModule.createMessage("ListAllLayerIDsOnScreen");
709 if (pLength && ppArray
711 && gIpcModule.appendUint(command, screenId)
712 && sendAndWaitForResponse(command, &response, gResponseTimeout)
713 && gIpcModule.getUintArray(response, ppArray, pLength))
715 returnValue = ILM_SUCCESS;
717 gIpcModule.destroyMessage(response);
718 gIpcModule.destroyMessage(command);
722 ilmErrorTypes ilm_getSurfaceIDs(t_ilm_int* pLength, t_ilm_surface** ppArray)
724 ilmErrorTypes returnValue = ILM_FAILED;
726 t_ilm_message response = 0;
727 t_ilm_message command = gIpcModule.createMessage("ListAllSurfaceIDS");
728 if (pLength && ppArray
730 && sendAndWaitForResponse(command, &response, gResponseTimeout)
731 && gIpcModule.getUintArray(response, ppArray, pLength))
733 returnValue = ILM_SUCCESS;
735 gIpcModule.destroyMessage(response);
736 gIpcModule.destroyMessage(command);
740 ilmErrorTypes ilm_getSurfaceIDsOnLayer(t_ilm_layer layer, t_ilm_int* pLength, t_ilm_surface** ppArray)
742 ilmErrorTypes returnValue = ILM_FAILED;
744 t_ilm_message response = 0;
745 t_ilm_message command = gIpcModule.createMessage("ListSurfaceofLayer");
746 if (pLength && ppArray
748 && gIpcModule.appendUint(command, layer)
749 && sendAndWaitForResponse(command, &response, gResponseTimeout)
750 && gIpcModule.getUintArray(response, ppArray, pLength))
752 returnValue = ILM_SUCCESS;
754 gIpcModule.destroyMessage(response);
755 gIpcModule.destroyMessage(command);
759 ilmErrorTypes ilm_layerCreate(t_ilm_layer* pLayerId)
761 ilmErrorTypes returnValue = ILM_FAILED;
763 if (pLayerId && (INVALID_ID != *pLayerId))
765 t_ilm_message response = 0;
766 t_ilm_message command = gIpcModule.createMessage("CreateLayerFromId");
768 && gIpcModule.appendUint(command, *pLayerId)
769 && sendAndWaitForResponse(command, &response, gResponseTimeout)
770 && gIpcModule.getUint(response, pLayerId))
772 returnValue = ILM_SUCCESS;
774 gIpcModule.destroyMessage(response);
775 gIpcModule.destroyMessage(command);
779 t_ilm_message response = 0;
780 t_ilm_message command = gIpcModule.createMessage("CreateLayer");
782 && sendAndWaitForResponse(command, &response, gResponseTimeout)
783 && gIpcModule.getUint(response, pLayerId))
785 returnValue = ILM_SUCCESS;
787 gIpcModule.destroyMessage(response);
788 gIpcModule.destroyMessage(command);
793 ilmErrorTypes ilm_layerCreateWithDimension(t_ilm_layer* pLayerId, t_ilm_uint width, t_ilm_uint height)
795 ilmErrorTypes returnValue = ILM_FAILED;
797 if (pLayerId && (INVALID_ID != *pLayerId))
799 t_ilm_message response = 0;
800 t_ilm_message command = gIpcModule.createMessage("CreateLayerFromIdWithDimension");
802 && gIpcModule.appendUint(command, *pLayerId)
803 && gIpcModule.appendUint(command, width)
804 && gIpcModule.appendUint(command, height)
805 && sendAndWaitForResponse(command, &response, gResponseTimeout)
806 && gIpcModule.getUint(response, pLayerId))
808 returnValue = ILM_SUCCESS;
810 gIpcModule.destroyMessage(response);
811 gIpcModule.destroyMessage(command);
815 t_ilm_message response = 0;
816 t_ilm_message command = gIpcModule.createMessage("CreateLayerWithDimension");
818 && gIpcModule.appendUint(command, width)
819 && gIpcModule.appendUint(command, height)
820 && sendAndWaitForResponse(command, &response, gResponseTimeout)
821 && gIpcModule.getUint(response, pLayerId))
823 returnValue = ILM_SUCCESS;
825 gIpcModule.destroyMessage(response);
826 gIpcModule.destroyMessage(command);
831 ilmErrorTypes ilm_layerRemove(t_ilm_layer layerId)
833 ilmErrorTypes returnValue = ILM_FAILED;
835 t_ilm_message response = 0;
836 t_ilm_message command = gIpcModule.createMessage("RemoveLayer");
838 && gIpcModule.appendUint(command, layerId)
839 && sendAndWaitForResponse(command, &response, gResponseTimeout))
841 returnValue = ILM_SUCCESS;
843 gIpcModule.destroyMessage(response);
844 gIpcModule.destroyMessage(command);
848 ilmErrorTypes ilm_layerAddSurface(t_ilm_layer layerId, t_ilm_surface surfaceId)
850 ilmErrorTypes returnValue = ILM_FAILED;
852 t_ilm_message response = 0;
853 t_ilm_message command = gIpcModule.createMessage("AddSurfaceToLayer");
855 && gIpcModule.appendUint(command, surfaceId)
856 && gIpcModule.appendUint(command, layerId)
857 && sendAndWaitForResponse(command, &response, gResponseTimeout))
859 returnValue = ILM_SUCCESS;
861 gIpcModule.destroyMessage(response);
862 gIpcModule.destroyMessage(command);
866 ilmErrorTypes ilm_layerRemoveSurface(t_ilm_layer layerId, t_ilm_surface surfaceId)
868 ilmErrorTypes returnValue = ILM_FAILED;
870 t_ilm_message response = 0;
871 t_ilm_message command = gIpcModule.createMessage("RemoveSurfaceFromLayer");
873 && gIpcModule.appendUint(command, surfaceId)
874 && gIpcModule.appendUint(command, layerId)
875 && sendAndWaitForResponse(command, &response, gResponseTimeout))
877 returnValue = ILM_SUCCESS;
879 gIpcModule.destroyMessage(response);
880 gIpcModule.destroyMessage(command);
884 ilmErrorTypes ilm_layerGetType(t_ilm_layer layerId, ilmLayerType* pLayerType)
886 ilmErrorTypes returnValue = ILM_FAILED;
888 t_ilm_message response = 0;
889 t_ilm_message command = gIpcModule.createMessage("GetLayerType");
892 && gIpcModule.appendUint(command, layerId)
893 && sendAndWaitForResponse(command, &response, gResponseTimeout)
894 && gIpcModule.getUint(response, pLayerType))
896 returnValue = ILM_SUCCESS;
898 gIpcModule.destroyMessage(response);
899 gIpcModule.destroyMessage(command);
903 ilmErrorTypes ilm_layerSetVisibility(t_ilm_layer layerId, t_ilm_bool newVisibility)
905 ilmErrorTypes returnValue = ILM_FAILED;
907 t_ilm_message response = 0;
908 t_ilm_message command = gIpcModule.createMessage("SetLayerVisibility");
910 && gIpcModule.appendUint(command, layerId)
911 && gIpcModule.appendBool(command, newVisibility)
912 && sendAndWaitForResponse(command, &response, gResponseTimeout))
914 returnValue = ILM_SUCCESS;
916 gIpcModule.destroyMessage(response);
917 gIpcModule.destroyMessage(command);
921 ilmErrorTypes ilm_layerGetVisibility(t_ilm_layer layerId, t_ilm_bool *pVisibility)
923 ilmErrorTypes returnValue = ILM_FAILED;
925 t_ilm_message response = 0;
926 t_ilm_message command = gIpcModule.createMessage("GetLayerVisibility");
929 && gIpcModule.appendUint(command, layerId)
930 && sendAndWaitForResponse(command, &response, gResponseTimeout)
931 && gIpcModule.getBool(response, pVisibility))
933 returnValue = ILM_SUCCESS;
935 gIpcModule.destroyMessage(response);
936 gIpcModule.destroyMessage(command);
940 ilmErrorTypes ilm_layerSetOpacity(t_ilm_layer layerId, t_ilm_float opacity)
942 ilmErrorTypes returnValue = ILM_FAILED;
944 t_ilm_message response = 0;
945 t_ilm_message command = gIpcModule.createMessage("SetLayerOpacity");
947 && gIpcModule.appendUint(command, layerId)
948 && gIpcModule.appendDouble(command, opacity)
949 && sendAndWaitForResponse(command, &response, gResponseTimeout))
951 returnValue = ILM_SUCCESS;
953 gIpcModule.destroyMessage(response);
954 gIpcModule.destroyMessage(command);
958 ilmErrorTypes ilm_layerGetOpacity(t_ilm_layer layerId, t_ilm_float *pOpacity)
960 ilmErrorTypes returnValue = ILM_FAILED;
962 t_ilm_message response = 0;
963 t_ilm_message command = gIpcModule.createMessage("GetLayerOpacity");
966 && gIpcModule.appendUint(command, layerId)
967 && sendAndWaitForResponse(command, &response, gResponseTimeout)
968 && gIpcModule.getDouble(response, pOpacity))
970 returnValue = ILM_SUCCESS;
972 gIpcModule.destroyMessage(response);
973 gIpcModule.destroyMessage(command);
977 ilmErrorTypes ilm_layerSetSourceRectangle(t_ilm_layer layerId, t_ilm_uint x, t_ilm_uint y, t_ilm_uint width, t_ilm_uint height)
979 ilmErrorTypes returnValue = ILM_FAILED;
981 t_ilm_message response = 0;
982 t_ilm_message command = gIpcModule.createMessage("SetLayerSourceRegion");
984 && gIpcModule.appendUint(command, layerId)
985 && gIpcModule.appendUint(command, x)
986 && gIpcModule.appendUint(command, y)
987 && gIpcModule.appendUint(command, width)
988 && gIpcModule.appendUint(command, height)
989 && sendAndWaitForResponse(command, &response, gResponseTimeout))
991 returnValue = ILM_SUCCESS;
993 gIpcModule.destroyMessage(response);
994 gIpcModule.destroyMessage(command);
998 ilmErrorTypes ilm_layerSetDestinationRectangle(t_ilm_layer layerId, t_ilm_int x, t_ilm_int y, t_ilm_int width, t_ilm_int height)
1000 ilmErrorTypes returnValue = ILM_FAILED;
1002 t_ilm_message response = 0;
1003 t_ilm_message command = gIpcModule.createMessage("SetLayerDestinationRegion");
1005 && gIpcModule.appendUint(command, layerId)
1006 && gIpcModule.appendUint(command, x)
1007 && gIpcModule.appendUint(command, y)
1008 && gIpcModule.appendUint(command, width)
1009 && gIpcModule.appendUint(command, height)
1010 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1012 returnValue = ILM_SUCCESS;
1014 gIpcModule.destroyMessage(response);
1015 gIpcModule.destroyMessage(command);
1019 ilmErrorTypes ilm_layerGetDimension(t_ilm_layer layerId, t_ilm_uint *pDimension)
1021 ilmErrorTypes returnValue = ILM_FAILED;
1023 t_ilm_message response = 0;
1024 t_ilm_message command = gIpcModule.createMessage("GetLayerDimension");
1027 && gIpcModule.appendUint(command, layerId)
1028 && sendAndWaitForResponse(command, &response, gResponseTimeout)
1029 && gIpcModule.getUint(response, &pDimension[0])
1030 && gIpcModule.getUint(response, &pDimension[1]))
1032 returnValue = ILM_SUCCESS;
1034 gIpcModule.destroyMessage(response);
1035 gIpcModule.destroyMessage(command);
1039 ilmErrorTypes ilm_layerSetDimension(t_ilm_layer layerId, t_ilm_uint *pDimension)
1041 ilmErrorTypes returnValue = ILM_FAILED;
1043 t_ilm_message response = 0;
1044 t_ilm_message command = gIpcModule.createMessage("SetLayerDimension");
1047 && gIpcModule.appendUint(command, layerId)
1048 && gIpcModule.appendUint(command, pDimension[0])
1049 && gIpcModule.appendUint(command, pDimension[1])
1050 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1052 returnValue = ILM_SUCCESS;
1054 gIpcModule.destroyMessage(response);
1055 gIpcModule.destroyMessage(command);
1059 ilmErrorTypes ilm_layerGetPosition(t_ilm_layer layerId, t_ilm_uint *pPosition)
1061 ilmErrorTypes returnValue = ILM_FAILED;
1063 t_ilm_message response = 0;
1064 t_ilm_message command = gIpcModule.createMessage("GetLayerPosition");
1067 && gIpcModule.appendUint(command, layerId)
1068 && sendAndWaitForResponse(command, &response, gResponseTimeout)
1069 && gIpcModule.getUint(response, &pPosition[0])
1070 && gIpcModule.getUint(response, &pPosition[1]))
1072 returnValue = ILM_SUCCESS;
1074 gIpcModule.destroyMessage(response);
1075 gIpcModule.destroyMessage(command);
1079 ilmErrorTypes ilm_layerSetPosition(t_ilm_layer layerId, t_ilm_uint *pPosition)
1081 ilmErrorTypes returnValue = ILM_FAILED;
1083 t_ilm_message response = 0;
1084 t_ilm_message command = gIpcModule.createMessage("SetLayerPosition");
1087 && gIpcModule.appendUint(command, layerId)
1088 && gIpcModule.appendUint(command, pPosition[0])
1089 && gIpcModule.appendUint(command, pPosition[1])
1090 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1092 returnValue = ILM_SUCCESS;
1094 gIpcModule.destroyMessage(response);
1095 gIpcModule.destroyMessage(command);
1099 ilmErrorTypes ilm_layerSetOrientation(t_ilm_layer layerId, ilmOrientation orientation)
1101 ilmErrorTypes returnValue = ILM_FAILED;
1103 t_ilm_message response = 0;
1104 t_ilm_message command = gIpcModule.createMessage("SetLayerOrientation");
1106 && gIpcModule.appendUint(command, layerId)
1107 && gIpcModule.appendUint(command, orientation)
1108 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1110 returnValue = ILM_SUCCESS;
1112 gIpcModule.destroyMessage(response);
1113 gIpcModule.destroyMessage(command);
1117 ilmErrorTypes ilm_layerGetOrientation(t_ilm_layer layerId, ilmOrientation *pOrientation)
1119 ilmErrorTypes returnValue = ILM_FAILED;
1121 t_ilm_message response = 0;
1122 t_ilm_message command = gIpcModule.createMessage("GetLayerOrientation");
1125 && gIpcModule.appendUint(command, layerId)
1126 && sendAndWaitForResponse(command, &response, gResponseTimeout)
1127 && gIpcModule.getUint(response, pOrientation))
1129 returnValue = ILM_SUCCESS;
1131 gIpcModule.destroyMessage(response);
1132 gIpcModule.destroyMessage(command);
1136 ilmErrorTypes ilm_layerSetChromaKey(t_ilm_layer layerId, t_ilm_int* pColor)
1138 ilmErrorTypes returnValue = ILM_FAILED;
1140 t_ilm_message response = 0;
1141 t_ilm_message command = gIpcModule.createMessage("SetLayerChromaKey");
1143 && gIpcModule.appendUint(command, layerId))
1145 t_ilm_bool comResult = ILM_TRUE;
1147 // Checking pColor has a content, otherwise chromakey is disabled
1150 const t_ilm_uint number = 3;
1151 comResult = gIpcModule.appendUintArray(command, (t_ilm_uint *)pColor, number);
1154 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1156 returnValue = ILM_SUCCESS;
1158 gIpcModule.destroyMessage(response);
1160 gIpcModule.destroyMessage(command);
1164 ilmErrorTypes ilm_layerSetRenderOrder(t_ilm_layer layerId, t_ilm_layer *pSurfaceId, t_ilm_int number)
1166 ilmErrorTypes returnValue = ILM_FAILED;
1168 t_ilm_message response = 0;
1169 t_ilm_message command = gIpcModule.createMessage("SetSurfaceRenderOrderWithinLayer");
1172 && gIpcModule.appendUint(command, layerId)
1173 && gIpcModule.appendUintArray(command, pSurfaceId, number)
1174 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1176 returnValue = ILM_SUCCESS;
1178 gIpcModule.destroyMessage(response);
1179 gIpcModule.destroyMessage(command);
1183 ilmErrorTypes ilm_layerGetCapabilities(t_ilm_layer layerId, t_ilm_layercapabilities *pCapabilities)
1185 ilmErrorTypes returnValue = ILM_FAILED;
1187 t_ilm_message response = 0;
1188 t_ilm_message command = gIpcModule.createMessage("GetLayerCapabilities");
1191 && gIpcModule.appendUint(command, layerId)
1192 && sendAndWaitForResponse(command, &response, gResponseTimeout)
1193 && gIpcModule.getUint(response, pCapabilities))
1195 returnValue = ILM_SUCCESS;
1197 gIpcModule.destroyMessage(response);
1198 gIpcModule.destroyMessage(command);
1202 ilmErrorTypes ilm_layerTypeGetCapabilities(ilmLayerType layerType, t_ilm_layercapabilities *pCapabilities)
1204 ilmErrorTypes returnValue = ILM_FAILED;
1206 t_ilm_message response = 0;
1207 t_ilm_message command = gIpcModule.createMessage("GetLayertypeCapabilities");
1210 && gIpcModule.appendUint(command, layerType)
1211 && sendAndWaitForResponse(command, &response, gResponseTimeout)
1212 && gIpcModule.getUint(response, pCapabilities))
1214 returnValue = ILM_SUCCESS;
1216 gIpcModule.destroyMessage(response);
1217 gIpcModule.destroyMessage(command);
1221 ilmErrorTypes ilm_surfaceCreate(t_ilm_nativehandle nativehandle, t_ilm_int width, t_ilm_int height, ilmPixelFormat pixelFormat, t_ilm_surface* pSurfaceId)
1223 ilmErrorTypes returnValue = ILM_FAILED;
1225 if (pSurfaceId && (INVALID_ID != *pSurfaceId))
1227 t_ilm_message response = 0;
1228 t_ilm_message command = gIpcModule.createMessage("CreateSurfaceFromId");
1230 && gIpcModule.appendUint(command, nativehandle)
1231 && gIpcModule.appendUint(command, width)
1232 && gIpcModule.appendUint(command, height)
1233 && gIpcModule.appendUint(command, pixelFormat)
1234 && gIpcModule.appendUint(command, *pSurfaceId)
1235 && sendAndWaitForResponse(command, &response, gResponseTimeout)
1236 && gIpcModule.getUint(response, pSurfaceId))
1238 returnValue = ILM_SUCCESS;
1240 gIpcModule.destroyMessage(response);
1241 gIpcModule.destroyMessage(command);
1245 t_ilm_message response = 0;
1246 t_ilm_message command = gIpcModule.createMessage("CreateSurface");
1248 && gIpcModule.appendUint(command, nativehandle)
1249 && gIpcModule.appendUint(command, width)
1250 && gIpcModule.appendUint(command, height)
1251 && gIpcModule.appendUint(command, pixelFormat)
1252 && sendAndWaitForResponse(command, &response, gResponseTimeout)
1253 && gIpcModule.getUint(response, pSurfaceId))
1255 returnValue = ILM_SUCCESS;
1257 gIpcModule.destroyMessage(response);
1258 gIpcModule.destroyMessage(command);
1263 ilmErrorTypes ilm_surfaceInitialize(t_ilm_surface *pSurfaceId)
1265 ilmErrorTypes returnValue = ILM_FAILED;
1267 if (pSurfaceId && (INVALID_ID != *pSurfaceId))
1269 t_ilm_message response = 0;
1270 t_ilm_message command = gIpcModule.createMessage("InitializeSurfaceFromId");
1272 && gIpcModule.appendUint(command, *pSurfaceId)
1273 && sendAndWaitForResponse(command, &response, gResponseTimeout)
1274 && gIpcModule.getUint(response, pSurfaceId))
1276 returnValue = ILM_SUCCESS;
1278 gIpcModule.destroyMessage(response);
1279 gIpcModule.destroyMessage(command);
1283 t_ilm_message response = 0;
1284 t_ilm_message command = gIpcModule.createMessage("InitializeSurface");
1286 && sendAndWaitForResponse(command, &response, gResponseTimeout)
1287 && gIpcModule.getUint(response, pSurfaceId))
1289 returnValue = ILM_SUCCESS;
1291 gIpcModule.destroyMessage(response);
1292 gIpcModule.destroyMessage(command);
1297 ilmErrorTypes ilm_surfaceSetNativeContent(t_ilm_nativehandle nativehandle, t_ilm_int width, t_ilm_int height, ilmPixelFormat pixelFormat, t_ilm_surface surfaceId)
1299 ilmErrorTypes returnValue = ILM_FAILED;
1301 t_ilm_message response = 0;
1302 t_ilm_message command = gIpcModule.createMessage("SetSurfaceNativeContent");
1304 && gIpcModule.appendUint(command, surfaceId)
1305 && gIpcModule.appendUint(command, nativehandle)
1306 && gIpcModule.appendUint(command, width)
1307 && gIpcModule.appendUint(command, height)
1308 && gIpcModule.appendUint(command, pixelFormat)
1309 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1311 returnValue = ILM_SUCCESS;
1313 gIpcModule.destroyMessage(response);
1314 gIpcModule.destroyMessage(command);
1318 ilmErrorTypes ilm_surfaceRemoveNativeContent(t_ilm_surface surfaceId)
1320 ilmErrorTypes returnValue = ILM_FAILED;
1322 t_ilm_message response = 0;
1323 t_ilm_message command = gIpcModule.createMessage("RemoveSurfaceNativeContent");
1325 && gIpcModule.appendUint(command, surfaceId)
1326 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1328 returnValue = ILM_SUCCESS;
1330 gIpcModule.destroyMessage(response);
1331 gIpcModule.destroyMessage(command);
1335 ilmErrorTypes ilm_surfaceRemove(t_ilm_surface surfaceId)
1337 ilmErrorTypes returnValue = ILM_FAILED;
1339 t_ilm_message response = 0;
1340 t_ilm_message command = gIpcModule.createMessage("RemoveSurface");
1342 && gIpcModule.appendUint(command, surfaceId)
1343 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1345 returnValue = ILM_SUCCESS;
1347 gIpcModule.destroyMessage(response);
1348 gIpcModule.destroyMessage(command);
1352 ilmErrorTypes ilm_surfaceSetVisibility(t_ilm_surface surfaceId, t_ilm_bool newVisibility)
1354 ilmErrorTypes returnValue = ILM_FAILED;
1356 t_ilm_message response = 0;
1357 t_ilm_message command = gIpcModule.createMessage("SetSurfaceVisibility");
1359 && gIpcModule.appendUint(command, surfaceId)
1360 && gIpcModule.appendBool(command, newVisibility)
1361 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1363 returnValue = ILM_SUCCESS;
1365 gIpcModule.destroyMessage(response);
1366 gIpcModule.destroyMessage(command);
1370 ilmErrorTypes ilm_surfaceGetVisibility(t_ilm_surface surfaceId, t_ilm_bool *pVisibility)
1372 ilmErrorTypes returnValue = ILM_FAILED;
1374 t_ilm_message response = 0;
1375 t_ilm_message command = gIpcModule.createMessage("GetSurfaceVisibility");
1378 && gIpcModule.appendUint(command, surfaceId)
1379 && sendAndWaitForResponse(command, &response, gResponseTimeout)
1380 && gIpcModule.getBool(response, pVisibility))
1382 returnValue = ILM_SUCCESS;
1384 gIpcModule.destroyMessage(response);
1385 gIpcModule.destroyMessage(command);
1389 ilmErrorTypes ilm_surfaceSetOpacity(t_ilm_surface surfaceId, t_ilm_float opacity)
1391 ilmErrorTypes returnValue = ILM_FAILED;
1393 t_ilm_message response = 0;
1394 t_ilm_message command = gIpcModule.createMessage("SetSurfaceOpacity");
1396 && gIpcModule.appendUint(command, surfaceId)
1397 && gIpcModule.appendDouble(command, opacity)
1398 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1400 returnValue = ILM_SUCCESS;
1402 gIpcModule.destroyMessage(response);
1403 gIpcModule.destroyMessage(command);
1407 ilmErrorTypes ilm_surfaceGetOpacity(t_ilm_surface surfaceId, t_ilm_float *pOpacity)
1409 ilmErrorTypes returnValue = ILM_FAILED;
1411 t_ilm_message response = 0;
1412 t_ilm_message command = gIpcModule.createMessage("GetSurfaceOpacity");
1415 && gIpcModule.appendUint(command, surfaceId)
1416 && sendAndWaitForResponse(command, &response, gResponseTimeout)
1417 && gIpcModule.getDouble(response, pOpacity))
1419 returnValue = ILM_SUCCESS;
1421 gIpcModule.destroyMessage(response);
1422 gIpcModule.destroyMessage(command);
1426 ilmErrorTypes ilm_surfaceSetSourceRectangle(t_ilm_surface surfaceId, t_ilm_int x, t_ilm_int y, t_ilm_int width, t_ilm_int height)
1428 ilmErrorTypes returnValue = ILM_FAILED;
1430 t_ilm_message response = 0;
1431 t_ilm_message command = gIpcModule.createMessage("SetSurfaceSourceRegion");
1433 && gIpcModule.appendUint(command, surfaceId)
1434 && gIpcModule.appendUint(command, x)
1435 && gIpcModule.appendUint(command, y)
1436 && gIpcModule.appendUint(command, width)
1437 && gIpcModule.appendUint(command, height)
1438 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1440 returnValue = ILM_SUCCESS;
1442 gIpcModule.destroyMessage(response);
1443 gIpcModule.destroyMessage(command);
1447 ilmErrorTypes ilm_surfaceSetDestinationRectangle(t_ilm_surface surfaceId, t_ilm_int x, t_ilm_int y, t_ilm_int width, t_ilm_int height)
1449 ilmErrorTypes returnValue = ILM_FAILED;
1451 t_ilm_message response = 0;
1452 t_ilm_message command = gIpcModule.createMessage("SetSurfaceDestinationRegion");
1454 && gIpcModule.appendUint(command, surfaceId)
1455 && gIpcModule.appendUint(command, x)
1456 && gIpcModule.appendUint(command, y)
1457 && gIpcModule.appendUint(command, width)
1458 && gIpcModule.appendUint(command, height)
1459 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1461 returnValue = ILM_SUCCESS;
1463 gIpcModule.destroyMessage(response);
1464 gIpcModule.destroyMessage(command);
1468 ilmErrorTypes ilm_surfaceGetDimension(t_ilm_surface surfaceId, t_ilm_uint *pDimension)
1470 ilmErrorTypes returnValue = ILM_FAILED;
1472 t_ilm_message response = 0;
1473 t_ilm_message command = gIpcModule.createMessage("GetSurfaceDimension");
1476 && gIpcModule.appendUint(command, surfaceId)
1477 && sendAndWaitForResponse(command, &response, gResponseTimeout)
1478 && gIpcModule.getUint(response, &pDimension[0])
1479 && gIpcModule.getUint(response, &pDimension[1]))
1481 returnValue = ILM_SUCCESS;
1483 gIpcModule.destroyMessage(response);
1484 gIpcModule.destroyMessage(command);
1488 ilmErrorTypes ilm_surfaceSetDimension(t_ilm_surface surfaceId, t_ilm_uint *pDimension)
1490 ilmErrorTypes returnValue = ILM_FAILED;
1492 t_ilm_message response = 0;
1493 t_ilm_message command = gIpcModule.createMessage("SetSurfaceDimension");
1496 && gIpcModule.appendUint(command, surfaceId)
1497 && gIpcModule.appendUint(command, pDimension[0])
1498 && gIpcModule.appendUint(command, pDimension[1])
1499 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1501 returnValue = ILM_SUCCESS;
1503 gIpcModule.destroyMessage(response);
1504 gIpcModule.destroyMessage(command);
1508 ilmErrorTypes ilm_surfaceGetPosition(t_ilm_surface surfaceId, t_ilm_uint *pPosition)
1510 ilmErrorTypes returnValue = ILM_FAILED;
1512 t_ilm_message response = 0;
1513 t_ilm_message command = gIpcModule.createMessage("GetSurfacePosition");
1516 && gIpcModule.appendUint(command, surfaceId)
1517 && sendAndWaitForResponse(command, &response, gResponseTimeout)
1518 && gIpcModule.getUint(response, &pPosition[0])
1519 && gIpcModule.getUint(response, &pPosition[1]))
1521 returnValue = ILM_SUCCESS;
1523 gIpcModule.destroyMessage(response);
1524 gIpcModule.destroyMessage(command);
1528 ilmErrorTypes ilm_surfaceSetPosition(t_ilm_surface surfaceId, t_ilm_uint *pPosition)
1530 ilmErrorTypes returnValue = ILM_FAILED;
1532 t_ilm_message response = 0;
1533 t_ilm_message command = gIpcModule.createMessage("SetSurfacePosition");
1536 && gIpcModule.appendUint(command, surfaceId)
1537 && gIpcModule.appendUint(command, pPosition[0])
1538 && gIpcModule.appendUint(command, pPosition[1])
1539 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1541 returnValue = ILM_SUCCESS;
1543 gIpcModule.destroyMessage(response);
1544 gIpcModule.destroyMessage(command);
1548 ilmErrorTypes ilm_surfaceSetOrientation(t_ilm_surface surfaceId, ilmOrientation orientation)
1550 ilmErrorTypes returnValue = ILM_FAILED;
1552 t_ilm_message response = 0;
1553 t_ilm_message command = gIpcModule.createMessage("SetSurfaceOrientation");
1555 && gIpcModule.appendUint(command, surfaceId)
1556 && gIpcModule.appendUint(command, orientation)
1557 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1559 returnValue = ILM_SUCCESS;
1561 gIpcModule.destroyMessage(response);
1562 gIpcModule.destroyMessage(command);
1566 ilmErrorTypes ilm_surfaceGetOrientation(t_ilm_surface surfaceId, ilmOrientation *pOrientation)
1568 ilmErrorTypes returnValue = ILM_FAILED;
1570 t_ilm_message response = 0;
1571 t_ilm_message command = gIpcModule.createMessage("GetSurfaceOrientation");
1574 && gIpcModule.appendUint(command, surfaceId)
1575 && sendAndWaitForResponse(command, &response, gResponseTimeout)
1576 && gIpcModule.getUint(response, pOrientation))
1578 returnValue = ILM_SUCCESS;
1580 gIpcModule.destroyMessage(response);
1581 gIpcModule.destroyMessage(command);
1585 ilmErrorTypes ilm_surfaceGetPixelformat(t_ilm_layer surfaceId, ilmPixelFormat *pPixelformat)
1587 ilmErrorTypes returnValue = ILM_FAILED;
1589 t_ilm_message response = 0;
1590 t_ilm_message command = gIpcModule.createMessage("GetSurfacePixelformat");
1593 && gIpcModule.appendUint(command, surfaceId)
1594 && sendAndWaitForResponse(command, &response, gResponseTimeout)
1595 && gIpcModule.getUint(response, pPixelformat))
1597 returnValue = ILM_SUCCESS;
1599 gIpcModule.destroyMessage(response);
1600 gIpcModule.destroyMessage(command);
1604 ilmErrorTypes ilm_surfaceSetChromaKey(t_ilm_surface surfaceId, t_ilm_int* pColor)
1606 ilmErrorTypes returnValue = ILM_FAILED;
1608 t_ilm_message response = 0;
1609 t_ilm_message command = gIpcModule.createMessage("SetSurfaceChromaKey");
1611 && gIpcModule.appendUint(command, surfaceId))
1613 t_ilm_bool comResult = ILM_TRUE;
1615 // Checking pColor has a content, otherwise chromakey is disabled
1618 const t_ilm_uint number = 3;
1619 comResult = gIpcModule.appendUintArray(command, (t_ilm_uint *)pColor, number);
1622 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1624 returnValue = ILM_SUCCESS;
1627 gIpcModule.destroyMessage(response);
1628 gIpcModule.destroyMessage(command);
1632 ilmErrorTypes ilm_displaySetRenderOrder(t_ilm_display display, t_ilm_layer *pLayerId, const t_ilm_uint number)
1634 ilmErrorTypes returnValue = ILM_FAILED;
1636 t_ilm_message response = 0;
1637 t_ilm_message command = gIpcModule.createMessage("SetRenderOrderOfLayers");
1640 && gIpcModule.appendUintArray(command, pLayerId, number)
1641 && gIpcModule.appendUint(command, display)
1642 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1644 returnValue = ILM_SUCCESS;
1646 gIpcModule.destroyMessage(response);
1647 gIpcModule.destroyMessage(command);
1651 ilmErrorTypes ilm_getScreenIDs(t_ilm_uint* pNumberOfIDs, t_ilm_uint** ppIDs)
1653 ilmErrorTypes returnValue = ILM_FAILED;
1655 t_ilm_message response = 0;
1656 t_ilm_message command = gIpcModule.createMessage("GetScreenIDs");
1657 if (pNumberOfIDs && ppIDs
1659 && sendAndWaitForResponse(command, &response, gResponseTimeout)
1660 && gIpcModule.getUintArray(response, ppIDs, (t_ilm_int *)pNumberOfIDs))
1662 returnValue = ILM_SUCCESS;
1664 gIpcModule.destroyMessage(response);
1665 gIpcModule.destroyMessage(command);
1669 ilmErrorTypes ilm_takeScreenshot(t_ilm_uint screen, t_ilm_const_string filename)
1671 ilmErrorTypes returnValue = ILM_FAILED;
1673 t_ilm_message response = 0;
1674 t_ilm_message command = gIpcModule.createMessage("ScreenShot");
1676 && gIpcModule.appendUint(command, screen)
1677 && gIpcModule.appendString(command, filename)
1678 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1680 returnValue = ILM_SUCCESS;
1682 gIpcModule.destroyMessage(response);
1683 gIpcModule.destroyMessage(command);
1687 ilmErrorTypes ilm_takeLayerScreenshot(t_ilm_const_string filename, t_ilm_layer layerid)
1689 ilmErrorTypes returnValue = ILM_FAILED;
1691 t_ilm_message response = 0;
1692 t_ilm_message command = gIpcModule.createMessage("ScreenShotOfLayer");
1694 && gIpcModule.appendString(command, filename)
1695 && gIpcModule.appendUint(command, layerid)
1696 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1698 returnValue = ILM_SUCCESS;
1700 gIpcModule.destroyMessage(response);
1701 gIpcModule.destroyMessage(command);
1705 ilmErrorTypes ilm_takeSurfaceScreenshot(t_ilm_const_string filename, t_ilm_surface surfaceid)
1707 ilmErrorTypes returnValue = ILM_FAILED;
1709 t_ilm_message response = 0;
1710 t_ilm_message command = gIpcModule.createMessage("ScreenShotOfSurface");
1712 && gIpcModule.appendString(command, filename)
1713 && gIpcModule.appendUint(command, surfaceid)
1714 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1716 returnValue = ILM_SUCCESS;
1718 gIpcModule.destroyMessage(response);
1719 gIpcModule.destroyMessage(command);
1723 ilmErrorTypes ilm_SetKeyboardFocusOn(t_ilm_surface surfaceId)
1725 ilmErrorTypes returnValue = ILM_FAILED;
1727 t_ilm_message response = 0;
1728 t_ilm_message command = gIpcModule.createMessage("SetKeyboardFocusOn");
1730 && gIpcModule.appendUint(command, surfaceId)
1731 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1733 returnValue = ILM_SUCCESS;
1735 gIpcModule.destroyMessage(response);
1736 gIpcModule.destroyMessage(command);
1740 ilmErrorTypes ilm_GetKeyboardFocusSurfaceId(t_ilm_surface* pSurfaceId)
1742 ilmErrorTypes returnValue = ILM_FAILED;
1744 t_ilm_message response = 0;
1745 t_ilm_message command = gIpcModule.createMessage("GetKeyboardFocusSurfaceId");
1747 && sendAndWaitForResponse(command, &response, gResponseTimeout)
1748 && gIpcModule.getUint(response, pSurfaceId))
1750 returnValue = ILM_SUCCESS;
1752 gIpcModule.destroyMessage(response);
1753 gIpcModule.destroyMessage(command);
1757 ilmErrorTypes ilm_UpdateInputEventAcceptanceOn(t_ilm_surface surfaceId, ilmInputDevice devices, t_ilm_bool acceptance)
1759 ilmErrorTypes returnValue = ILM_FAILED;
1761 t_ilm_message response = 0;
1762 t_ilm_message command = gIpcModule.createMessage("UpdateInputEventAcceptanceOn");
1764 && gIpcModule.appendUint(command, surfaceId)
1765 && gIpcModule.appendUint(command, devices)
1766 && gIpcModule.appendBool(command, acceptance)
1767 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1769 returnValue = ILM_SUCCESS;
1771 gIpcModule.destroyMessage(response);
1772 gIpcModule.destroyMessage(command);
1776 ilmErrorTypes ilm_SetOptimizationMode(ilmOptimization id, ilmOptimizationMode mode)
1778 ilmErrorTypes returnValue = ILM_FAILED;
1780 t_ilm_message response = 0;
1781 t_ilm_message command = gIpcModule.createMessage("SetOptimizationMode");
1783 && gIpcModule.appendUint(command,id)
1784 && gIpcModule.appendUint(command,mode)
1785 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1787 returnValue = ILM_SUCCESS;
1789 gIpcModule.destroyMessage(response);
1790 gIpcModule.destroyMessage(command);
1794 ilmErrorTypes ilm_GetOptimizationMode(ilmOptimization id, ilmOptimizationMode* pMode)
1796 ilmErrorTypes returnValue = ILM_FAILED;
1797 t_ilm_message response = 0;
1798 t_ilm_message command = gIpcModule.createMessage("GetOptimizationMode");
1800 && gIpcModule.appendUint(command,id)
1801 && sendAndWaitForResponse(command, &response, gResponseTimeout)
1802 && gIpcModule.getUint(response, pMode))
1804 returnValue = ILM_SUCCESS;
1806 gIpcModule.destroyMessage(response);
1807 gIpcModule.destroyMessage(command);
1811 ilmErrorTypes ilm_commitChanges()
1813 ilmErrorTypes returnValue = ILM_FAILED;
1815 t_ilm_message response = 0;
1816 t_ilm_message command = gIpcModule.createMessage("CommitChanges");
1819 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1821 returnValue = ILM_SUCCESS;
1823 gIpcModule.destroyMessage(response);
1824 gIpcModule.destroyMessage(command);
1828 ilmErrorTypes ilm_layerAddNotification(t_ilm_layer layer, layerNotificationFunc callback)
1830 ilmErrorTypes returnValue = ILM_FAILED;
1832 if (findLayerCallback(layer))
1834 return ILM_ERROR_INVALID_ARGUMENTS;
1837 t_ilm_message response = 0;
1838 t_ilm_message command = gIpcModule.createMessage("LayerAddNotification");
1840 && gIpcModule.appendUint(command, layer)
1841 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1843 addLayerCallback(layer, callback);
1844 returnValue = ILM_SUCCESS;
1846 gIpcModule.destroyMessage(response);
1847 gIpcModule.destroyMessage(command);
1851 ilmErrorTypes ilm_layerRemoveNotification(t_ilm_layer layer)
1853 ilmErrorTypes returnValue = ILM_FAILED;
1855 if (!findLayerCallback(layer))
1857 return ILM_ERROR_INVALID_ARGUMENTS;
1860 t_ilm_message response = 0;
1861 t_ilm_message command = gIpcModule.createMessage("LayerRemoveNotification");
1863 && gIpcModule.appendUint(command, layer)
1864 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1866 removeLayerCallback(layer);
1867 returnValue = ILM_SUCCESS;
1869 gIpcModule.destroyMessage(response);
1870 gIpcModule.destroyMessage(command);
1874 ilmErrorTypes ilm_surfaceAddNotification(t_ilm_surface surface, surfaceNotificationFunc callback)
1876 ilmErrorTypes returnValue = ILM_FAILED;
1878 if (findSurfaceCallback(surface))
1880 return ILM_ERROR_INVALID_ARGUMENTS;
1883 t_ilm_message response = 0;
1884 t_ilm_message command = gIpcModule.createMessage("SurfaceAddNotification");
1886 && gIpcModule.appendUint(command, surface)
1887 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1889 addSurfaceCallback(surface, callback);
1890 returnValue = ILM_SUCCESS;
1892 gIpcModule.destroyMessage(response);
1893 gIpcModule.destroyMessage(command);
1897 ilmErrorTypes ilm_surfaceRemoveNotification(t_ilm_surface surface)
1899 ilmErrorTypes returnValue = ILM_FAILED;
1901 if (!findSurfaceCallback(surface))
1903 return ILM_ERROR_INVALID_ARGUMENTS;
1906 t_ilm_message response = 0;
1907 t_ilm_message command = gIpcModule.createMessage("SurfaceRemoveNotification");
1909 && gIpcModule.appendUint(command, surface)
1910 && sendAndWaitForResponse(command, &response, gResponseTimeout))
1912 removeSurfaceCallback(surface);
1913 returnValue = ILM_SUCCESS;
1915 gIpcModule.destroyMessage(response);
1916 gIpcModule.destroyMessage(command);
1920 ilmErrorTypes ilm_getPropertiesOfScreen(t_ilm_display screenID, struct ilmScreenProperties* pScreenProperties)
1922 ilmErrorTypes returnValue = ILM_FAILED;
1924 t_ilm_message response = 0;
1925 t_ilm_message command = gIpcModule.createMessage("GetPropertiesOfScreen");
1926 if (pScreenProperties
1928 && gIpcModule.appendUint(command, screenID)
1929 && sendAndWaitForResponse(command, &response, gResponseTimeout)
1930 && gIpcModule.getUintArray(response, &pScreenProperties->layerIds, &pScreenProperties->layerCount)
1931 && gIpcModule.getUint(response, &pScreenProperties->harwareLayerCount)
1932 && gIpcModule.getUint(response, &pScreenProperties->screenWidth)
1933 && gIpcModule.getUint(response, &pScreenProperties->screenHeight))
1935 returnValue = ILM_SUCCESS;
1937 gIpcModule.destroyMessage(response);
1938 gIpcModule.destroyMessage(command);