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"
31 #include <sys/types.h>
32 #include <semaphore.h>
36 *=============================================================================
38 *=============================================================================
40 const int gReceiveTimeout = -1; /* in ms, negative value for infinite */
41 const int gResponseTimeout = 500; /* in ms */
44 * must be same as GraphicalObject::INVALID_ID, but this is defined in C++
45 * and can not be used here
47 #define INVALID_ID 0xFFFFFFFF
49 /* queue names for incoming notifications and messages */
50 #define NOTIFICATION_QUEUE_NAME "/ilmClient%dNotification"
51 #define INCOMING_QUEUE_NAME "/ilmClient%dIncoming"
54 *=============================================================================
55 * Implementation of thread-safe circular queue for local use
56 *=============================================================================
60 pthread_mutex_t queueMutex;
61 sem_t readBlockSemaphore;
68 t_ilm_message* messages;
72 static void init_msg_queue(t_ilm_msg_queue* pQueue, t_ilm_uint maxSize)
74 pQueue->maxSize = maxSize;
75 pQueue->messages = malloc(sizeof(t_ilm_message) * maxSize);
81 pthread_mutex_init(&pQueue->queueMutex, NULL);
82 sem_init(&pQueue->readBlockSemaphore, 0, 0);
85 static t_ilm_bool msg_enqueue(t_ilm_msg_queue* pQueue, t_ilm_message message)
87 pthread_mutex_lock(&pQueue->queueMutex);
89 if (pQueue->size < pQueue->maxSize)
92 pQueue->messages[pQueue->writePos] = message;
93 pQueue->writePos = (pQueue->writePos + 1) % pQueue->maxSize;
95 /* wakeup a blocked dequeue reqquest */
96 sem_post(&pQueue->readBlockSemaphore);
98 pthread_mutex_unlock(&pQueue->queueMutex);
102 pthread_mutex_unlock(&pQueue->queueMutex);
106 static t_ilm_message msg_dequeue(t_ilm_msg_queue* pQueue)
108 t_ilm_message result = NULL;
109 /* wait until a message is available */
110 sem_wait(&pQueue->readBlockSemaphore);
112 pthread_mutex_lock(&pQueue->queueMutex);
114 if (pQueue->size > 0)
117 result = pQueue->messages[pQueue->readPos];
118 pQueue->readPos = (pQueue->readPos + 1) % pQueue->maxSize;
121 pthread_mutex_unlock(&pQueue->queueMutex);
126 static void destroy_msg_queue(t_ilm_msg_queue* pQueue)
128 if (pQueue->maxSize > 0)
132 free(pQueue->messages);
138 *=============================================================================
140 *=============================================================================
142 extern char *__progname; /* automatically gets assigned argv[0] */
144 static struct IpcModule gIpcModule;
146 static pthread_t gReceiveThread;
147 static pthread_mutex_t gSendReceiveLock;
148 static pthread_t gNotificationThread;
150 static const int maxQueueSize = 1024;
151 static t_ilm_msg_queue incomingQueue;
152 static t_ilm_msg_queue notificationQueue;
154 static t_ilm_bool gInitialized = ILM_FALSE;
157 *=============================================================================
158 * notification management
159 *=============================================================================
161 #define MAX_CALLBACK_COUNT 64
165 layerNotificationFunc callback;
166 } gLayerNotificationCallbacks[MAX_CALLBACK_COUNT];
171 surfaceNotificationFunc callback;
172 } gSurfaceNotificationCallbacks[MAX_CALLBACK_COUNT];
174 void initNotificationCallbacks()
177 for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
179 gLayerNotificationCallbacks[i].id = INVALID_ID;
180 gLayerNotificationCallbacks[i].callback = NULL;
181 gSurfaceNotificationCallbacks[i].id = INVALID_ID;
182 gSurfaceNotificationCallbacks[i].callback = NULL;
186 layerNotificationFunc getLayerNotificationCallback(t_ilm_layer layer)
189 for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
191 if (gLayerNotificationCallbacks[i].id == layer)
193 return gLayerNotificationCallbacks[i].callback;
199 surfaceNotificationFunc getSurfaceNotificationCallback(t_ilm_surface surface)
202 for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
204 if (gSurfaceNotificationCallbacks[i].id == surface)
206 return gSurfaceNotificationCallbacks[i].callback;
212 t_ilm_bool findLayerCallback(t_ilm_layer layer)
216 /* try to overwrite existing entry for layer id */
217 for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
219 if (gLayerNotificationCallbacks[i].id == layer)
227 t_ilm_bool addLayerCallback(t_ilm_layer layer, layerNotificationFunc func)
231 if (findLayerCallback(layer))
236 /* find free slot and store callback */
237 for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
239 if (gLayerNotificationCallbacks[i].id == INVALID_ID)
241 gLayerNotificationCallbacks[i].id = layer;
242 gLayerNotificationCallbacks[i].callback = func;
246 printf("DbusIpcModule: addLayerCallback() failed. no free slots.");
250 t_ilm_bool findSurfaceCallback(t_ilm_surface surface)
254 /* try to overwrite existing entry for layer id */
255 for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
257 if (gSurfaceNotificationCallbacks[i].id == surface)
265 t_ilm_bool addSurfaceCallback(t_ilm_surface surface, surfaceNotificationFunc func)
269 if (findSurfaceCallback(surface))
274 /* find free slot and store callback */
275 for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
277 if (gSurfaceNotificationCallbacks[i].id == INVALID_ID)
279 gSurfaceNotificationCallbacks[i].id = surface;
280 gSurfaceNotificationCallbacks[i].callback = func;
284 printf("DbusIpcModule: addSurfaceCallback() failed. no free slots.");
288 void removeLayerCallback(t_ilm_layer layer)
291 for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
293 if (gLayerNotificationCallbacks[i].id == layer)
295 gLayerNotificationCallbacks[i].id = INVALID_ID;
296 gLayerNotificationCallbacks[i].callback = NULL;
302 void removeSurfaceCallback(t_ilm_surface layer)
305 for (i = 0; i < MAX_CALLBACK_COUNT; ++i)
307 if (gSurfaceNotificationCallbacks[i].id == layer)
309 gSurfaceNotificationCallbacks[i].id = INVALID_ID;
310 gSurfaceNotificationCallbacks[i].callback = NULL;
318 *=============================================================================
319 * handling of internal notification thread for dispatching notifications
320 * Note: notification callbacks may be blocked by client, but receive thread
321 * must not be blocked
322 *=============================================================================
324 void* notificationThreadLoop(void* param)
326 t_ilm_message notification;
330 while (NULL != (notification = msg_dequeue(¬ificationQueue)))
332 t_ilm_const_string name = gIpcModule.getMessageName(notification);
334 /* this depends on message name, but it is fast */
339 struct ilmLayerProperties properties;
340 layerNotificationFunc func;
342 gIpcModule.getUint(notification, &id);
343 gIpcModule.getUint(notification, &mask);
344 gIpcModule.getDouble(notification, &properties.opacity);
345 gIpcModule.getUint(notification, &properties.sourceX);
346 gIpcModule.getUint(notification, &properties.sourceY);
347 gIpcModule.getUint(notification, &properties.sourceWidth);
348 gIpcModule.getUint(notification, &properties.sourceHeight);
349 gIpcModule.getUint(notification, &properties.origSourceWidth);
350 gIpcModule.getUint(notification, &properties.origSourceHeight);
351 gIpcModule.getUint(notification, &properties.destX);
352 gIpcModule.getUint(notification, &properties.destY);
353 gIpcModule.getUint(notification, &properties.destWidth);
354 gIpcModule.getUint(notification, &properties.destHeight);
355 gIpcModule.getUint(notification, &properties.orientation);
356 gIpcModule.getBool(notification, &properties.visibility);
357 gIpcModule.getUint(notification, &properties.type);
358 gIpcModule.getBool(notification, &properties.chromaKeyEnabled);
359 gIpcModule.getUint(notification, &properties.chromaKeyRed);
360 gIpcModule.getUint(notification, &properties.chromaKeyGreen);
361 gIpcModule.getUint(notification, &properties.chromaKeyBlue);
362 gIpcModule.getInt(notification, &properties.creatorPid);
364 func = getLayerNotificationCallback(id);
367 (*func)(id, &properties, mask);
371 fprintf(stderr, "notification for layer %d received, but no callback set\n", id);
379 struct ilmSurfaceProperties properties;
380 surfaceNotificationFunc func;
382 gIpcModule.getUint(notification, &id);
383 gIpcModule.getUint(notification, &mask);
384 gIpcModule.getDouble(notification, &properties.opacity);
385 gIpcModule.getUint(notification, &properties.sourceX);
386 gIpcModule.getUint(notification, &properties.sourceY);
387 gIpcModule.getUint(notification, &properties.sourceWidth);
388 gIpcModule.getUint(notification, &properties.sourceHeight);
389 gIpcModule.getUint(notification, &properties.origSourceWidth);
390 gIpcModule.getUint(notification, &properties.origSourceHeight);
391 gIpcModule.getUint(notification, &properties.destX);
392 gIpcModule.getUint(notification, &properties.destY);
393 gIpcModule.getUint(notification, &properties.destWidth);
394 gIpcModule.getUint(notification, &properties.destHeight);
395 gIpcModule.getUint(notification, &properties.orientation);
396 gIpcModule.getBool(notification, &properties.visibility);
397 gIpcModule.getUint(notification, &properties.frameCounter);
398 gIpcModule.getUint(notification, &properties.drawCounter);
399 gIpcModule.getUint(notification, &properties.updateCounter);
400 gIpcModule.getUint(notification, &properties.pixelformat);
401 gIpcModule.getUint(notification, &properties.nativeSurface);
402 gIpcModule.getUint(notification, &properties.inputDevicesAcceptance);
403 gIpcModule.getBool(notification, &properties.chromaKeyEnabled);
404 gIpcModule.getUint(notification, &properties.chromaKeyRed);
405 gIpcModule.getUint(notification, &properties.chromaKeyGreen);
406 gIpcModule.getUint(notification, &properties.chromaKeyBlue);
407 gIpcModule.getInt(notification, &properties.creatorPid);
409 func = getSurfaceNotificationCallback(id);
412 (*func)(id, &properties, mask);
416 fprintf(stderr, "notification for surface %d received, but no callback set\n", id);
419 gIpcModule.destroyMessage(notification);
426 *=============================================================================
427 * handling of internal receive thread for event handling
428 *=============================================================================
430 void* receiveThreadLoop(void* param)
432 t_ilm_bool running = ILM_TRUE;
438 t_ilm_message message = gIpcModule.receive(gReceiveTimeout);
439 t_ilm_message_type messageType = gIpcModule.getMessageType(message);
442 case IpcMessageTypeNotification:
443 if (ILM_FALSE == msg_enqueue(¬ificationQueue, message))
447 printf("Notification queue full, dropped notification %s\n", gIpcModule.getMessageName(message));
452 case IpcMessageTypeCommand:
453 case IpcMessageTypeError:
454 if (ILM_FALSE == msg_enqueue(&incomingQueue, message))
458 printf("Incoming queue full, dropped message %s\n", gIpcModule.getMessageName(message));
463 case IpcMessageTypeNone:
467 printf("ilmClient: discarded unexpected message (type: %d)\n", (int)messageType);
468 gIpcModule.destroyMessage(message);
476 void calculateTimeout(struct timeval* currentTime, int giventimeout, struct timespec* timeout)
478 /* nanoseconds is old value in nanoseconds + the given milliseconds as nanoseconds */
479 t_ilm_ulong newNanoSeconds = currentTime->tv_usec * 1000 + giventimeout * (1000 * 1000);
481 /* only use non full seconds, otherwise overflow! */
482 timeout->tv_nsec = newNanoSeconds % (1000000000);
484 /* new seconds are old seconds + full seconds from new nanoseconds part */
485 timeout->tv_sec = currentTime->tv_sec + (newNanoSeconds / 1000000000 );
488 t_ilm_bool sendAndWaitForResponse(t_ilm_message command, t_ilm_message* response, int timeoutInMs, ilmErrorTypes* error)
490 t_ilm_message_type responseType = IpcMessageTypeNone;
495 (void)timeoutInMs; /* suppress warning */
497 gettimeofday(&tv, NULL);
498 calculateTimeout(&tv, 1000000, &ts);
502 /* send / receive may only be performed by one thread at a time */
503 pthread_mutex_lock(&gSendReceiveLock);
505 if (gIpcModule.sendToService(command))
507 if (NULL == (*response = msg_dequeue(&incomingQueue)))
509 *error = ILM_ERROR_ON_CONNECTION;
513 responseType = gIpcModule.getMessageType(*response);
514 switch (responseType)
516 case IpcMessageTypeCommand:
519 case IpcMessageTypeError:
520 gIpcModule.getUint(*response, error);
526 fprintf(stderr,"waitForResponse: LayerManagerService returned unexpected message type %d\n", responseType);
529 *error = ILM_ERROR_UNEXPECTED_MESSAGE;
534 pthread_mutex_unlock(&gSendReceiveLock);
536 return (0 != *response);
541 *=============================================================================
543 *=============================================================================
545 ilmErrorTypes ilm_init()
547 ilmErrorTypes result = ILM_FAILED;
548 t_ilm_message response = 0;
549 t_ilm_message command;
553 printf("ilm_init() was called, but ilmClientLib is already initialized. returning success, but initialization was skipped this time.\n");
557 initNotificationCallbacks();
559 if (loadIpcModule(&gIpcModule))
563 if (gIpcModule.initClientMode())
565 pthread_attr_t notificationThreadAttributes;
568 result = ILM_SUCCESS;
570 init_msg_queue(¬ificationQueue, maxQueueSize);
572 init_msg_queue(&incomingQueue, maxQueueSize);
574 if (notificationQueue.maxSize == 0)
576 printf("failed to allocate queue\n");
580 pthread_mutex_init(&gSendReceiveLock, NULL);
582 pthread_attr_init(¬ificationThreadAttributes);
583 pthread_attr_setdetachstate(¬ificationThreadAttributes,
584 PTHREAD_CREATE_JOINABLE);
586 ret = pthread_create(&gReceiveThread,
587 ¬ificationThreadAttributes,
593 printf("Failed to start internal receive thread. returned %d = %s\n", ret, (ret == EAGAIN ? "EAGAIN" : "EINVAL"));
597 ret = pthread_create(&gNotificationThread,
598 ¬ificationThreadAttributes,
599 notificationThreadLoop,
604 printf("Failed to start internal notification thread. returned %d = %s\n", ret, (ret == EAGAIN ? "EAGAIN" : "EINVAL"));
611 printf("Failed to initialize Client Ipc Module");
615 command = gIpcModule.createMessage("ServiceConnect");
617 && gIpcModule.appendUint(command, pid)
618 && gIpcModule.appendString(command, __progname)
619 && sendAndWaitForResponse(command, &response, gResponseTimeout, &result))
621 result = ILM_SUCCESS;
625 printf("Failed to connect to LayerManagerService.");
627 gIpcModule.destroyMessage(response);
628 gIpcModule.destroyMessage(command);
631 gInitialized = (result == ILM_SUCCESS) ? ILM_TRUE : ILM_FALSE;
636 ilmErrorTypes ilm_destroy()
638 ilmErrorTypes result = ILM_FAILED;
639 void* threadReturnValue = NULL;
641 t_ilm_message response = 0;
642 t_ilm_message command = gIpcModule.createMessage("ServiceDisconnect");
644 && gIpcModule.appendUint(command, getpid())
645 && sendAndWaitForResponse(command, &response, gResponseTimeout, &result))
647 result = ILM_SUCCESS;
649 gIpcModule.destroyMessage(response);
650 gIpcModule.destroyMessage(command);
652 /* cancel worker threads */
653 pthread_cancel(gReceiveThread);
654 pthread_cancel(gNotificationThread);
656 pthread_join(gReceiveThread, &threadReturnValue);
657 pthread_join(gNotificationThread, &threadReturnValue);
659 pthread_mutex_unlock(&gSendReceiveLock);
661 pthread_mutex_destroy(&gSendReceiveLock);
663 gIpcModule.destroy();
665 destroy_msg_queue(¬ificationQueue);
666 destroy_msg_queue(&incomingQueue);
668 gInitialized = ILM_FALSE;
673 ilmErrorTypes ilm_getPropertiesOfSurface(t_ilm_uint surfaceID, struct ilmSurfaceProperties* pSurfaceProperties)
675 ilmErrorTypes returnValue = ILM_FAILED;
677 t_ilm_message response = 0;
678 t_ilm_message command = gIpcModule.createMessage("GetPropertiesOfSurface");
680 if (pSurfaceProperties
682 && gIpcModule.appendUint(command, surfaceID)
683 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
684 && gIpcModule.getDouble(response, &pSurfaceProperties->opacity)
685 && gIpcModule.getUint(response, &pSurfaceProperties->sourceX)
686 && gIpcModule.getUint(response, &pSurfaceProperties->sourceY)
687 && gIpcModule.getUint(response, &pSurfaceProperties->sourceWidth)
688 && gIpcModule.getUint(response, &pSurfaceProperties->sourceHeight)
689 && gIpcModule.getUint(response, &pSurfaceProperties->origSourceWidth)
690 && gIpcModule.getUint(response, &pSurfaceProperties->origSourceHeight)
691 && gIpcModule.getUint(response, &pSurfaceProperties->destX)
692 && gIpcModule.getUint(response, &pSurfaceProperties->destY)
693 && gIpcModule.getUint(response, &pSurfaceProperties->destWidth)
694 && gIpcModule.getUint(response, &pSurfaceProperties->destHeight)
695 && gIpcModule.getUint(response, &pSurfaceProperties->orientation)
696 && gIpcModule.getBool(response, &pSurfaceProperties->visibility)
697 && gIpcModule.getUint(response, &pSurfaceProperties->frameCounter)
698 && gIpcModule.getUint(response, &pSurfaceProperties->drawCounter)
699 && gIpcModule.getUint(response, &pSurfaceProperties->updateCounter)
700 && gIpcModule.getUint(response, &pSurfaceProperties->pixelformat)
701 && gIpcModule.getUint(response, &pSurfaceProperties->nativeSurface)
702 && gIpcModule.getUint(response, &pSurfaceProperties->inputDevicesAcceptance)
703 && gIpcModule.getBool(response, &pSurfaceProperties->chromaKeyEnabled)
704 && gIpcModule.getUint(response, &pSurfaceProperties->chromaKeyRed)
705 && gIpcModule.getUint(response, &pSurfaceProperties->chromaKeyGreen)
706 && gIpcModule.getUint(response, &pSurfaceProperties->chromaKeyBlue)
707 && gIpcModule.getInt(response, &pSurfaceProperties->creatorPid))
709 returnValue = ILM_SUCCESS;
711 gIpcModule.destroyMessage(response);
712 gIpcModule.destroyMessage(command);
716 ilmErrorTypes ilm_getPropertiesOfLayer(t_ilm_uint layerID, struct ilmLayerProperties* pLayerProperties)
718 ilmErrorTypes returnValue = ILM_FAILED;
720 t_ilm_message response = 0;
721 t_ilm_message command = gIpcModule.createMessage("GetPropertiesOfLayer");
724 && gIpcModule.appendUint(command, layerID)
725 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
726 && gIpcModule.getDouble(response, &pLayerProperties->opacity)
727 && gIpcModule.getUint(response, &pLayerProperties->sourceX)
728 && gIpcModule.getUint(response, &pLayerProperties->sourceY)
729 && gIpcModule.getUint(response, &pLayerProperties->sourceWidth)
730 && gIpcModule.getUint(response, &pLayerProperties->sourceHeight)
731 && gIpcModule.getUint(response, &pLayerProperties->origSourceWidth)
732 && gIpcModule.getUint(response, &pLayerProperties->origSourceHeight)
733 && gIpcModule.getUint(response, &pLayerProperties->destX)
734 && gIpcModule.getUint(response, &pLayerProperties->destY)
735 && gIpcModule.getUint(response, &pLayerProperties->destWidth)
736 && gIpcModule.getUint(response, &pLayerProperties->destHeight)
737 && gIpcModule.getUint(response, &pLayerProperties->orientation)
738 && gIpcModule.getBool(response, &pLayerProperties->visibility)
739 && gIpcModule.getUint(response, &pLayerProperties->type)
740 && gIpcModule.getBool(response, &pLayerProperties->chromaKeyEnabled)
741 && gIpcModule.getUint(response, &pLayerProperties->chromaKeyRed)
742 && gIpcModule.getUint(response, &pLayerProperties->chromaKeyGreen)
743 && gIpcModule.getUint(response, &pLayerProperties->chromaKeyBlue)
744 && gIpcModule.getInt(response, &pLayerProperties->creatorPid))
746 returnValue = ILM_SUCCESS;
748 gIpcModule.destroyMessage(response);
749 gIpcModule.destroyMessage(command);
753 ilmErrorTypes ilm_getNumberOfHardwareLayers(t_ilm_uint screenID, t_ilm_uint* pNumberOfHardwareLayers)
755 ilmErrorTypes returnValue = ILM_FAILED;
757 t_ilm_message response = 0;
758 t_ilm_message command = gIpcModule.createMessage("GetNumberOfHardwareLayers");
759 if (pNumberOfHardwareLayers
761 && gIpcModule.appendUint(command, screenID)
762 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
763 && gIpcModule.getUint(response, pNumberOfHardwareLayers))
765 returnValue = ILM_SUCCESS;
767 gIpcModule.destroyMessage(response);
768 gIpcModule.destroyMessage(command);
772 ilmErrorTypes ilm_getScreenResolution(t_ilm_uint screenID, t_ilm_uint* pWidth, t_ilm_uint* pHeight)
774 ilmErrorTypes returnValue = ILM_FAILED;
776 t_ilm_message response = 0;
777 t_ilm_message command = gIpcModule.createMessage("GetScreenResolution");
778 if (pWidth && pHeight
780 && gIpcModule.appendUint(command, screenID)
781 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
782 && gIpcModule.getUint(response, pWidth)
783 && gIpcModule.getUint(response, pHeight))
785 returnValue = ILM_SUCCESS;
787 gIpcModule.destroyMessage(response);
788 gIpcModule.destroyMessage(command);
792 ilmErrorTypes ilm_getLayerIDs(t_ilm_int* pLength, t_ilm_layer** ppArray)
794 ilmErrorTypes returnValue = ILM_FAILED;
796 t_ilm_message response = 0;
797 t_ilm_message command = gIpcModule.createMessage("ListAllLayerIDS");
798 if (pLength && ppArray
800 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
801 && gIpcModule.getUintArray(response, ppArray, pLength))
803 returnValue = ILM_SUCCESS;
805 gIpcModule.destroyMessage(response);
806 gIpcModule.destroyMessage(command);
810 ilmErrorTypes ilm_getLayerIDsOnScreen(t_ilm_uint screenId, t_ilm_int* pLength, t_ilm_layer** ppArray)
812 ilmErrorTypes returnValue = ILM_FAILED;
814 t_ilm_message response = 0;
815 t_ilm_message command = gIpcModule.createMessage("ListAllLayerIDsOnScreen");
816 if (pLength && ppArray
818 && gIpcModule.appendUint(command, screenId)
819 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
820 && gIpcModule.getUintArray(response, ppArray, pLength))
822 returnValue = ILM_SUCCESS;
824 gIpcModule.destroyMessage(response);
825 gIpcModule.destroyMessage(command);
829 ilmErrorTypes ilm_getSurfaceIDs(t_ilm_int* pLength, t_ilm_surface** ppArray)
831 ilmErrorTypes returnValue = ILM_FAILED;
833 t_ilm_message response = 0;
834 t_ilm_message command = gIpcModule.createMessage("ListAllSurfaceIDS");
835 if (pLength && ppArray
837 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
838 && gIpcModule.getUintArray(response, ppArray, pLength))
840 returnValue = ILM_SUCCESS;
842 gIpcModule.destroyMessage(response);
843 gIpcModule.destroyMessage(command);
847 ilmErrorTypes ilm_getSurfaceIDsOnLayer(t_ilm_layer layer, t_ilm_int* pLength, t_ilm_surface** ppArray)
849 ilmErrorTypes returnValue = ILM_FAILED;
851 t_ilm_message response = 0;
852 t_ilm_message command = gIpcModule.createMessage("ListSurfaceofLayer");
853 if (pLength && ppArray
855 && gIpcModule.appendUint(command, layer)
856 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
857 && gIpcModule.getUintArray(response, ppArray, pLength))
859 returnValue = ILM_SUCCESS;
861 gIpcModule.destroyMessage(response);
862 gIpcModule.destroyMessage(command);
866 ilmErrorTypes ilm_layerCreate(t_ilm_layer* pLayerId)
868 ilmErrorTypes returnValue = ILM_FAILED;
870 if (pLayerId && (INVALID_ID != *pLayerId))
872 t_ilm_message response = 0;
873 t_ilm_message command = gIpcModule.createMessage("CreateLayerFromId");
875 && gIpcModule.appendUint(command, *pLayerId)
876 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
877 && gIpcModule.getUint(response, pLayerId))
879 returnValue = ILM_SUCCESS;
881 gIpcModule.destroyMessage(response);
882 gIpcModule.destroyMessage(command);
886 t_ilm_message response = 0;
887 t_ilm_message command = gIpcModule.createMessage("CreateLayer");
889 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
890 && gIpcModule.getUint(response, pLayerId))
892 returnValue = ILM_SUCCESS;
894 gIpcModule.destroyMessage(response);
895 gIpcModule.destroyMessage(command);
900 ilmErrorTypes ilm_layerCreateWithDimension(t_ilm_layer* pLayerId, t_ilm_uint width, t_ilm_uint height)
902 ilmErrorTypes returnValue = ILM_FAILED;
904 if (pLayerId && (INVALID_ID != *pLayerId))
906 t_ilm_message response = 0;
907 t_ilm_message command = gIpcModule.createMessage("CreateLayerFromIdWithDimension");
909 && gIpcModule.appendUint(command, *pLayerId)
910 && gIpcModule.appendUint(command, width)
911 && gIpcModule.appendUint(command, height)
912 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
913 && gIpcModule.getUint(response, pLayerId))
915 returnValue = ILM_SUCCESS;
917 gIpcModule.destroyMessage(response);
918 gIpcModule.destroyMessage(command);
922 t_ilm_message response = 0;
923 t_ilm_message command = gIpcModule.createMessage("CreateLayerWithDimension");
925 && gIpcModule.appendUint(command, width)
926 && gIpcModule.appendUint(command, height)
927 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
928 && gIpcModule.getUint(response, pLayerId))
930 returnValue = ILM_SUCCESS;
932 gIpcModule.destroyMessage(response);
933 gIpcModule.destroyMessage(command);
938 ilmErrorTypes ilm_layerRemove(t_ilm_layer layerId)
940 ilmErrorTypes returnValue = ILM_FAILED;
942 t_ilm_message response = 0;
943 t_ilm_message command = gIpcModule.createMessage("RemoveLayer");
945 && gIpcModule.appendUint(command, layerId)
946 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
948 returnValue = ILM_SUCCESS;
950 gIpcModule.destroyMessage(response);
951 gIpcModule.destroyMessage(command);
955 ilmErrorTypes ilm_layerAddSurface(t_ilm_layer layerId, t_ilm_surface surfaceId)
957 ilmErrorTypes returnValue = ILM_FAILED;
959 t_ilm_message response = 0;
960 t_ilm_message command = gIpcModule.createMessage("AddSurfaceToLayer");
962 && gIpcModule.appendUint(command, surfaceId)
963 && gIpcModule.appendUint(command, layerId)
964 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
966 returnValue = ILM_SUCCESS;
968 gIpcModule.destroyMessage(response);
969 gIpcModule.destroyMessage(command);
973 ilmErrorTypes ilm_layerRemoveSurface(t_ilm_layer layerId, t_ilm_surface surfaceId)
975 ilmErrorTypes returnValue = ILM_FAILED;
977 t_ilm_message response = 0;
978 t_ilm_message command = gIpcModule.createMessage("RemoveSurfaceFromLayer");
980 && gIpcModule.appendUint(command, surfaceId)
981 && gIpcModule.appendUint(command, layerId)
982 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
984 returnValue = ILM_SUCCESS;
986 gIpcModule.destroyMessage(response);
987 gIpcModule.destroyMessage(command);
991 ilmErrorTypes ilm_layerGetType(t_ilm_layer layerId, ilmLayerType* pLayerType)
993 ilmErrorTypes returnValue = ILM_FAILED;
995 t_ilm_message response = 0;
996 t_ilm_message command = gIpcModule.createMessage("GetLayerType");
999 && gIpcModule.appendUint(command, layerId)
1000 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1001 && gIpcModule.getUint(response, pLayerType))
1003 returnValue = ILM_SUCCESS;
1005 gIpcModule.destroyMessage(response);
1006 gIpcModule.destroyMessage(command);
1010 ilmErrorTypes ilm_layerSetVisibility(t_ilm_layer layerId, t_ilm_bool newVisibility)
1012 ilmErrorTypes returnValue = ILM_FAILED;
1014 t_ilm_message response = 0;
1015 t_ilm_message command = gIpcModule.createMessage("SetLayerVisibility");
1017 && gIpcModule.appendUint(command, layerId)
1018 && gIpcModule.appendBool(command, newVisibility)
1019 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1021 returnValue = ILM_SUCCESS;
1023 gIpcModule.destroyMessage(response);
1024 gIpcModule.destroyMessage(command);
1028 ilmErrorTypes ilm_layerGetVisibility(t_ilm_layer layerId, t_ilm_bool *pVisibility)
1030 ilmErrorTypes returnValue = ILM_FAILED;
1032 t_ilm_message response = 0;
1033 t_ilm_message command = gIpcModule.createMessage("GetLayerVisibility");
1036 && gIpcModule.appendUint(command, layerId)
1037 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1038 && gIpcModule.getBool(response, pVisibility))
1040 returnValue = ILM_SUCCESS;
1042 gIpcModule.destroyMessage(response);
1043 gIpcModule.destroyMessage(command);
1047 ilmErrorTypes ilm_layerSetOpacity(t_ilm_layer layerId, t_ilm_float opacity)
1049 ilmErrorTypes returnValue = ILM_FAILED;
1051 t_ilm_message response = 0;
1052 t_ilm_message command = gIpcModule.createMessage("SetLayerOpacity");
1054 && gIpcModule.appendUint(command, layerId)
1055 && gIpcModule.appendDouble(command, opacity)
1056 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1058 returnValue = ILM_SUCCESS;
1060 gIpcModule.destroyMessage(response);
1061 gIpcModule.destroyMessage(command);
1065 ilmErrorTypes ilm_layerGetOpacity(t_ilm_layer layerId, t_ilm_float *pOpacity)
1067 ilmErrorTypes returnValue = ILM_FAILED;
1069 t_ilm_message response = 0;
1070 t_ilm_message command = gIpcModule.createMessage("GetLayerOpacity");
1073 && gIpcModule.appendUint(command, layerId)
1074 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1075 && gIpcModule.getDouble(response, pOpacity))
1077 returnValue = ILM_SUCCESS;
1079 gIpcModule.destroyMessage(response);
1080 gIpcModule.destroyMessage(command);
1084 ilmErrorTypes ilm_layerSetSourceRectangle(t_ilm_layer layerId, t_ilm_uint x, t_ilm_uint y, t_ilm_uint width, t_ilm_uint height)
1086 ilmErrorTypes returnValue = ILM_FAILED;
1088 t_ilm_message response = 0;
1089 t_ilm_message command = gIpcModule.createMessage("SetLayerSourceRegion");
1091 && gIpcModule.appendUint(command, layerId)
1092 && gIpcModule.appendUint(command, x)
1093 && gIpcModule.appendUint(command, y)
1094 && gIpcModule.appendUint(command, width)
1095 && gIpcModule.appendUint(command, height)
1096 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1098 returnValue = ILM_SUCCESS;
1100 gIpcModule.destroyMessage(response);
1101 gIpcModule.destroyMessage(command);
1105 ilmErrorTypes ilm_layerSetDestinationRectangle(t_ilm_layer layerId, t_ilm_int x, t_ilm_int y, t_ilm_int width, t_ilm_int height)
1107 ilmErrorTypes returnValue = ILM_FAILED;
1109 t_ilm_message response = 0;
1110 t_ilm_message command = gIpcModule.createMessage("SetLayerDestinationRegion");
1112 && gIpcModule.appendUint(command, layerId)
1113 && gIpcModule.appendUint(command, x)
1114 && gIpcModule.appendUint(command, y)
1115 && gIpcModule.appendUint(command, width)
1116 && gIpcModule.appendUint(command, height)
1117 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1119 returnValue = ILM_SUCCESS;
1121 gIpcModule.destroyMessage(response);
1122 gIpcModule.destroyMessage(command);
1126 ilmErrorTypes ilm_layerGetDimension(t_ilm_layer layerId, t_ilm_uint *pDimension)
1128 ilmErrorTypes returnValue = ILM_FAILED;
1130 t_ilm_message response = 0;
1131 t_ilm_message command = gIpcModule.createMessage("GetLayerDimension");
1134 && gIpcModule.appendUint(command, layerId)
1135 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1136 && gIpcModule.getUint(response, &pDimension[0])
1137 && gIpcModule.getUint(response, &pDimension[1]))
1139 returnValue = ILM_SUCCESS;
1141 gIpcModule.destroyMessage(response);
1142 gIpcModule.destroyMessage(command);
1146 ilmErrorTypes ilm_layerSetDimension(t_ilm_layer layerId, t_ilm_uint *pDimension)
1148 ilmErrorTypes returnValue = ILM_FAILED;
1150 t_ilm_message response = 0;
1151 t_ilm_message command = gIpcModule.createMessage("SetLayerDimension");
1154 && gIpcModule.appendUint(command, layerId)
1155 && gIpcModule.appendUint(command, pDimension[0])
1156 && gIpcModule.appendUint(command, pDimension[1])
1157 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1159 returnValue = ILM_SUCCESS;
1161 gIpcModule.destroyMessage(response);
1162 gIpcModule.destroyMessage(command);
1166 ilmErrorTypes ilm_layerGetPosition(t_ilm_layer layerId, t_ilm_uint *pPosition)
1168 ilmErrorTypes returnValue = ILM_FAILED;
1170 t_ilm_message response = 0;
1171 t_ilm_message command = gIpcModule.createMessage("GetLayerPosition");
1174 && gIpcModule.appendUint(command, layerId)
1175 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1176 && gIpcModule.getUint(response, &pPosition[0])
1177 && gIpcModule.getUint(response, &pPosition[1]))
1179 returnValue = ILM_SUCCESS;
1181 gIpcModule.destroyMessage(response);
1182 gIpcModule.destroyMessage(command);
1186 ilmErrorTypes ilm_layerSetPosition(t_ilm_layer layerId, t_ilm_uint *pPosition)
1188 ilmErrorTypes returnValue = ILM_FAILED;
1190 t_ilm_message response = 0;
1191 t_ilm_message command = gIpcModule.createMessage("SetLayerPosition");
1194 && gIpcModule.appendUint(command, layerId)
1195 && gIpcModule.appendUint(command, pPosition[0])
1196 && gIpcModule.appendUint(command, pPosition[1])
1197 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1199 returnValue = ILM_SUCCESS;
1201 gIpcModule.destroyMessage(response);
1202 gIpcModule.destroyMessage(command);
1206 ilmErrorTypes ilm_layerSetOrientation(t_ilm_layer layerId, ilmOrientation orientation)
1208 ilmErrorTypes returnValue = ILM_FAILED;
1210 t_ilm_message response = 0;
1211 t_ilm_message command = gIpcModule.createMessage("SetLayerOrientation");
1213 && gIpcModule.appendUint(command, layerId)
1214 && gIpcModule.appendUint(command, orientation)
1215 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1217 returnValue = ILM_SUCCESS;
1219 gIpcModule.destroyMessage(response);
1220 gIpcModule.destroyMessage(command);
1224 ilmErrorTypes ilm_layerGetOrientation(t_ilm_layer layerId, ilmOrientation *pOrientation)
1226 ilmErrorTypes returnValue = ILM_FAILED;
1228 t_ilm_message response = 0;
1229 t_ilm_message command = gIpcModule.createMessage("GetLayerOrientation");
1232 && gIpcModule.appendUint(command, layerId)
1233 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1234 && gIpcModule.getUint(response, pOrientation))
1236 returnValue = ILM_SUCCESS;
1238 gIpcModule.destroyMessage(response);
1239 gIpcModule.destroyMessage(command);
1243 ilmErrorTypes ilm_layerSetChromaKey(t_ilm_layer layerId, t_ilm_int* pColor)
1245 ilmErrorTypes returnValue = ILM_FAILED;
1247 t_ilm_message response = 0;
1248 t_ilm_message command = gIpcModule.createMessage("SetLayerChromaKey");
1250 && gIpcModule.appendUint(command, layerId))
1252 t_ilm_bool comResult = ILM_TRUE;
1254 /* Checking pColor has a content, otherwise chromakey is disabled */
1257 const t_ilm_uint number = 3;
1258 comResult = gIpcModule.appendUintArray(command, (t_ilm_uint *)pColor, number);
1261 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1263 returnValue = ILM_SUCCESS;
1265 gIpcModule.destroyMessage(response);
1267 gIpcModule.destroyMessage(command);
1271 ilmErrorTypes ilm_layerSetRenderOrder(t_ilm_layer layerId, t_ilm_layer *pSurfaceId, t_ilm_int number)
1273 ilmErrorTypes returnValue = ILM_FAILED;
1275 t_ilm_message response = 0;
1276 t_ilm_message command = gIpcModule.createMessage("SetSurfaceRenderOrderWithinLayer");
1279 && gIpcModule.appendUint(command, layerId)
1280 && gIpcModule.appendUintArray(command, pSurfaceId, number)
1281 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1283 returnValue = ILM_SUCCESS;
1285 gIpcModule.destroyMessage(response);
1286 gIpcModule.destroyMessage(command);
1290 ilmErrorTypes ilm_layerGetCapabilities(t_ilm_layer layerId, t_ilm_layercapabilities *pCapabilities)
1292 ilmErrorTypes returnValue = ILM_FAILED;
1294 t_ilm_message response = 0;
1295 t_ilm_message command = gIpcModule.createMessage("GetLayerCapabilities");
1298 && gIpcModule.appendUint(command, layerId)
1299 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1300 && gIpcModule.getUint(response, pCapabilities))
1302 returnValue = ILM_SUCCESS;
1304 gIpcModule.destroyMessage(response);
1305 gIpcModule.destroyMessage(command);
1309 ilmErrorTypes ilm_layerTypeGetCapabilities(ilmLayerType layerType, t_ilm_layercapabilities *pCapabilities)
1311 ilmErrorTypes returnValue = ILM_FAILED;
1313 t_ilm_message response = 0;
1314 t_ilm_message command = gIpcModule.createMessage("GetLayertypeCapabilities");
1317 && gIpcModule.appendUint(command, layerType)
1318 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1319 && gIpcModule.getUint(response, pCapabilities))
1321 returnValue = ILM_SUCCESS;
1323 gIpcModule.destroyMessage(response);
1324 gIpcModule.destroyMessage(command);
1328 ilmErrorTypes ilm_surfaceCreate(t_ilm_nativehandle nativehandle, t_ilm_int width, t_ilm_int height, ilmPixelFormat pixelFormat, t_ilm_surface* pSurfaceId)
1330 ilmErrorTypes returnValue = ILM_FAILED;
1332 if (pSurfaceId && (INVALID_ID != *pSurfaceId))
1334 t_ilm_message response = 0;
1335 t_ilm_message command = gIpcModule.createMessage("CreateSurfaceFromId");
1337 && gIpcModule.appendUint(command, nativehandle)
1338 && gIpcModule.appendUint(command, width)
1339 && gIpcModule.appendUint(command, height)
1340 && gIpcModule.appendUint(command, pixelFormat)
1341 && gIpcModule.appendUint(command, *pSurfaceId)
1342 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1343 && gIpcModule.getUint(response, pSurfaceId))
1345 returnValue = ILM_SUCCESS;
1347 gIpcModule.destroyMessage(response);
1348 gIpcModule.destroyMessage(command);
1352 t_ilm_message response = 0;
1353 t_ilm_message command = gIpcModule.createMessage("CreateSurface");
1355 && gIpcModule.appendUint(command, nativehandle)
1356 && gIpcModule.appendUint(command, width)
1357 && gIpcModule.appendUint(command, height)
1358 && gIpcModule.appendUint(command, pixelFormat)
1359 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1360 && gIpcModule.getUint(response, pSurfaceId))
1362 returnValue = ILM_SUCCESS;
1364 gIpcModule.destroyMessage(response);
1365 gIpcModule.destroyMessage(command);
1370 ilmErrorTypes ilm_surfaceInitialize(t_ilm_surface *pSurfaceId)
1372 ilmErrorTypes returnValue = ILM_FAILED;
1374 if (pSurfaceId && (INVALID_ID != *pSurfaceId))
1376 t_ilm_message response = 0;
1377 t_ilm_message command = gIpcModule.createMessage("InitializeSurfaceFromId");
1379 && gIpcModule.appendUint(command, *pSurfaceId)
1380 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1381 && gIpcModule.getUint(response, pSurfaceId))
1383 returnValue = ILM_SUCCESS;
1385 gIpcModule.destroyMessage(response);
1386 gIpcModule.destroyMessage(command);
1390 t_ilm_message response = 0;
1391 t_ilm_message command = gIpcModule.createMessage("InitializeSurface");
1393 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1394 && gIpcModule.getUint(response, pSurfaceId))
1396 returnValue = ILM_SUCCESS;
1398 gIpcModule.destroyMessage(response);
1399 gIpcModule.destroyMessage(command);
1404 ilmErrorTypes ilm_surfaceSetNativeContent(t_ilm_nativehandle nativehandle, t_ilm_int width, t_ilm_int height, ilmPixelFormat pixelFormat, t_ilm_surface surfaceId)
1406 ilmErrorTypes returnValue = ILM_FAILED;
1408 t_ilm_message response = 0;
1409 t_ilm_message command = gIpcModule.createMessage("SetSurfaceNativeContent");
1411 && gIpcModule.appendUint(command, surfaceId)
1412 && gIpcModule.appendUint(command, nativehandle)
1413 && gIpcModule.appendUint(command, width)
1414 && gIpcModule.appendUint(command, height)
1415 && gIpcModule.appendUint(command, pixelFormat)
1416 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1418 returnValue = ILM_SUCCESS;
1420 gIpcModule.destroyMessage(response);
1421 gIpcModule.destroyMessage(command);
1425 ilmErrorTypes ilm_surfaceRemoveNativeContent(t_ilm_surface surfaceId)
1427 ilmErrorTypes returnValue = ILM_FAILED;
1429 t_ilm_message response = 0;
1430 t_ilm_message command = gIpcModule.createMessage("RemoveSurfaceNativeContent");
1432 && gIpcModule.appendUint(command, surfaceId)
1433 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1435 returnValue = ILM_SUCCESS;
1437 gIpcModule.destroyMessage(response);
1438 gIpcModule.destroyMessage(command);
1442 ilmErrorTypes ilm_surfaceRemove(t_ilm_surface surfaceId)
1444 ilmErrorTypes returnValue = ILM_FAILED;
1446 t_ilm_message response = 0;
1447 t_ilm_message command = gIpcModule.createMessage("RemoveSurface");
1449 && gIpcModule.appendUint(command, surfaceId)
1450 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1452 returnValue = ILM_SUCCESS;
1454 gIpcModule.destroyMessage(response);
1455 gIpcModule.destroyMessage(command);
1459 ilmErrorTypes ilm_surfaceSetVisibility(t_ilm_surface surfaceId, t_ilm_bool newVisibility)
1461 ilmErrorTypes returnValue = ILM_FAILED;
1463 t_ilm_message response = 0;
1464 t_ilm_message command = gIpcModule.createMessage("SetSurfaceVisibility");
1466 && gIpcModule.appendUint(command, surfaceId)
1467 && gIpcModule.appendBool(command, newVisibility)
1468 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1470 returnValue = ILM_SUCCESS;
1472 gIpcModule.destroyMessage(response);
1473 gIpcModule.destroyMessage(command);
1477 ilmErrorTypes ilm_surfaceGetVisibility(t_ilm_surface surfaceId, t_ilm_bool *pVisibility)
1479 ilmErrorTypes returnValue = ILM_FAILED;
1481 t_ilm_message response = 0;
1482 t_ilm_message command = gIpcModule.createMessage("GetSurfaceVisibility");
1485 && gIpcModule.appendUint(command, surfaceId)
1486 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1487 && gIpcModule.getBool(response, pVisibility))
1489 returnValue = ILM_SUCCESS;
1491 gIpcModule.destroyMessage(response);
1492 gIpcModule.destroyMessage(command);
1496 ilmErrorTypes ilm_surfaceSetOpacity(t_ilm_surface surfaceId, t_ilm_float opacity)
1498 ilmErrorTypes returnValue = ILM_FAILED;
1500 t_ilm_message response = 0;
1501 t_ilm_message command = gIpcModule.createMessage("SetSurfaceOpacity");
1503 && gIpcModule.appendUint(command, surfaceId)
1504 && gIpcModule.appendDouble(command, opacity)
1505 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1507 returnValue = ILM_SUCCESS;
1509 gIpcModule.destroyMessage(response);
1510 gIpcModule.destroyMessage(command);
1514 ilmErrorTypes ilm_surfaceGetOpacity(t_ilm_surface surfaceId, t_ilm_float *pOpacity)
1516 ilmErrorTypes returnValue = ILM_FAILED;
1518 t_ilm_message response = 0;
1519 t_ilm_message command = gIpcModule.createMessage("GetSurfaceOpacity");
1522 && gIpcModule.appendUint(command, surfaceId)
1523 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1524 && gIpcModule.getDouble(response, pOpacity))
1526 returnValue = ILM_SUCCESS;
1528 gIpcModule.destroyMessage(response);
1529 gIpcModule.destroyMessage(command);
1533 ilmErrorTypes ilm_surfaceSetSourceRectangle(t_ilm_surface surfaceId, t_ilm_int x, t_ilm_int y, t_ilm_int width, t_ilm_int height)
1535 ilmErrorTypes returnValue = ILM_FAILED;
1537 t_ilm_message response = 0;
1538 t_ilm_message command = gIpcModule.createMessage("SetSurfaceSourceRegion");
1540 && gIpcModule.appendUint(command, surfaceId)
1541 && gIpcModule.appendUint(command, x)
1542 && gIpcModule.appendUint(command, y)
1543 && gIpcModule.appendUint(command, width)
1544 && gIpcModule.appendUint(command, height)
1545 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1547 returnValue = ILM_SUCCESS;
1549 gIpcModule.destroyMessage(response);
1550 gIpcModule.destroyMessage(command);
1554 ilmErrorTypes ilm_surfaceSetDestinationRectangle(t_ilm_surface surfaceId, t_ilm_int x, t_ilm_int y, t_ilm_int width, t_ilm_int height)
1556 ilmErrorTypes returnValue = ILM_FAILED;
1558 t_ilm_message response = 0;
1559 t_ilm_message command = gIpcModule.createMessage("SetSurfaceDestinationRegion");
1561 && gIpcModule.appendUint(command, surfaceId)
1562 && gIpcModule.appendUint(command, x)
1563 && gIpcModule.appendUint(command, y)
1564 && gIpcModule.appendUint(command, width)
1565 && gIpcModule.appendUint(command, height)
1566 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1568 returnValue = ILM_SUCCESS;
1570 gIpcModule.destroyMessage(response);
1571 gIpcModule.destroyMessage(command);
1575 ilmErrorTypes ilm_surfaceGetDimension(t_ilm_surface surfaceId, t_ilm_uint *pDimension)
1577 ilmErrorTypes returnValue = ILM_FAILED;
1579 t_ilm_message response = 0;
1580 t_ilm_message command = gIpcModule.createMessage("GetSurfaceDimension");
1583 && gIpcModule.appendUint(command, surfaceId)
1584 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1585 && gIpcModule.getUint(response, &pDimension[0])
1586 && gIpcModule.getUint(response, &pDimension[1]))
1588 returnValue = ILM_SUCCESS;
1590 gIpcModule.destroyMessage(response);
1591 gIpcModule.destroyMessage(command);
1595 ilmErrorTypes ilm_surfaceSetDimension(t_ilm_surface surfaceId, t_ilm_uint *pDimension)
1597 ilmErrorTypes returnValue = ILM_FAILED;
1599 t_ilm_message response = 0;
1600 t_ilm_message command = gIpcModule.createMessage("SetSurfaceDimension");
1603 && gIpcModule.appendUint(command, surfaceId)
1604 && gIpcModule.appendUint(command, pDimension[0])
1605 && gIpcModule.appendUint(command, pDimension[1])
1606 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1608 returnValue = ILM_SUCCESS;
1610 gIpcModule.destroyMessage(response);
1611 gIpcModule.destroyMessage(command);
1615 ilmErrorTypes ilm_surfaceGetPosition(t_ilm_surface surfaceId, t_ilm_uint *pPosition)
1617 ilmErrorTypes returnValue = ILM_FAILED;
1619 t_ilm_message response = 0;
1620 t_ilm_message command = gIpcModule.createMessage("GetSurfacePosition");
1623 && gIpcModule.appendUint(command, surfaceId)
1624 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1625 && gIpcModule.getUint(response, &pPosition[0])
1626 && gIpcModule.getUint(response, &pPosition[1]))
1628 returnValue = ILM_SUCCESS;
1630 gIpcModule.destroyMessage(response);
1631 gIpcModule.destroyMessage(command);
1635 ilmErrorTypes ilm_surfaceSetPosition(t_ilm_surface surfaceId, t_ilm_uint *pPosition)
1637 ilmErrorTypes returnValue = ILM_FAILED;
1639 t_ilm_message response = 0;
1640 t_ilm_message command = gIpcModule.createMessage("SetSurfacePosition");
1643 && gIpcModule.appendUint(command, surfaceId)
1644 && gIpcModule.appendUint(command, pPosition[0])
1645 && gIpcModule.appendUint(command, pPosition[1])
1646 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1648 returnValue = ILM_SUCCESS;
1650 gIpcModule.destroyMessage(response);
1651 gIpcModule.destroyMessage(command);
1655 ilmErrorTypes ilm_surfaceSetOrientation(t_ilm_surface surfaceId, ilmOrientation orientation)
1657 ilmErrorTypes returnValue = ILM_FAILED;
1659 t_ilm_message response = 0;
1660 t_ilm_message command = gIpcModule.createMessage("SetSurfaceOrientation");
1662 && gIpcModule.appendUint(command, surfaceId)
1663 && gIpcModule.appendUint(command, orientation)
1664 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1666 returnValue = ILM_SUCCESS;
1668 gIpcModule.destroyMessage(response);
1669 gIpcModule.destroyMessage(command);
1673 ilmErrorTypes ilm_surfaceGetOrientation(t_ilm_surface surfaceId, ilmOrientation *pOrientation)
1675 ilmErrorTypes returnValue = ILM_FAILED;
1677 t_ilm_message response = 0;
1678 t_ilm_message command = gIpcModule.createMessage("GetSurfaceOrientation");
1681 && gIpcModule.appendUint(command, surfaceId)
1682 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1683 && gIpcModule.getUint(response, pOrientation))
1685 returnValue = ILM_SUCCESS;
1687 gIpcModule.destroyMessage(response);
1688 gIpcModule.destroyMessage(command);
1692 ilmErrorTypes ilm_surfaceGetPixelformat(t_ilm_layer surfaceId, ilmPixelFormat *pPixelformat)
1694 ilmErrorTypes returnValue = ILM_FAILED;
1696 t_ilm_message response = 0;
1697 t_ilm_message command = gIpcModule.createMessage("GetSurfacePixelformat");
1700 && gIpcModule.appendUint(command, surfaceId)
1701 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1702 && gIpcModule.getUint(response, pPixelformat))
1704 returnValue = ILM_SUCCESS;
1706 gIpcModule.destroyMessage(response);
1707 gIpcModule.destroyMessage(command);
1711 ilmErrorTypes ilm_surfaceSetChromaKey(t_ilm_surface surfaceId, t_ilm_int* pColor)
1713 ilmErrorTypes returnValue = ILM_FAILED;
1715 t_ilm_message response = 0;
1716 t_ilm_message command = gIpcModule.createMessage("SetSurfaceChromaKey");
1718 && gIpcModule.appendUint(command, surfaceId))
1720 t_ilm_bool comResult = ILM_TRUE;
1722 /* Checking pColor has a content, otherwise chromakey is disabled */
1725 const t_ilm_uint number = 3;
1726 comResult = gIpcModule.appendUintArray(command, (t_ilm_uint *)pColor, number);
1729 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1731 returnValue = ILM_SUCCESS;
1734 gIpcModule.destroyMessage(response);
1735 gIpcModule.destroyMessage(command);
1739 ilmErrorTypes ilm_displaySetRenderOrder(t_ilm_display display, t_ilm_layer *pLayerId, const t_ilm_uint number)
1741 ilmErrorTypes returnValue = ILM_FAILED;
1743 t_ilm_message response = 0;
1744 t_ilm_message command = gIpcModule.createMessage("SetRenderOrderOfLayers");
1747 && gIpcModule.appendUintArray(command, pLayerId, number)
1748 && gIpcModule.appendUint(command, display)
1749 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1751 returnValue = ILM_SUCCESS;
1753 gIpcModule.destroyMessage(response);
1754 gIpcModule.destroyMessage(command);
1758 ilmErrorTypes ilm_getScreenIDs(t_ilm_uint* pNumberOfIDs, t_ilm_uint** ppIDs)
1760 ilmErrorTypes returnValue = ILM_FAILED;
1762 t_ilm_message response = 0;
1763 t_ilm_message command = gIpcModule.createMessage("GetScreenIDs");
1764 if (pNumberOfIDs && ppIDs
1766 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1767 && gIpcModule.getUintArray(response, ppIDs, (t_ilm_int *)pNumberOfIDs))
1769 returnValue = ILM_SUCCESS;
1771 gIpcModule.destroyMessage(response);
1772 gIpcModule.destroyMessage(command);
1776 ilmErrorTypes ilm_takeScreenshot(t_ilm_uint screen, t_ilm_const_string filename)
1778 ilmErrorTypes returnValue = ILM_FAILED;
1780 t_ilm_message response = 0;
1781 t_ilm_message command = gIpcModule.createMessage("ScreenShot");
1783 && gIpcModule.appendUint(command, screen)
1784 && gIpcModule.appendString(command, filename)
1785 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1787 returnValue = ILM_SUCCESS;
1789 gIpcModule.destroyMessage(response);
1790 gIpcModule.destroyMessage(command);
1794 ilmErrorTypes ilm_takeLayerScreenshot(t_ilm_const_string filename, t_ilm_layer layerid)
1796 ilmErrorTypes returnValue = ILM_FAILED;
1798 t_ilm_message response = 0;
1799 t_ilm_message command = gIpcModule.createMessage("ScreenShotOfLayer");
1801 && gIpcModule.appendString(command, filename)
1802 && gIpcModule.appendUint(command, layerid)
1803 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1805 returnValue = ILM_SUCCESS;
1807 gIpcModule.destroyMessage(response);
1808 gIpcModule.destroyMessage(command);
1812 ilmErrorTypes ilm_takeSurfaceScreenshot(t_ilm_const_string filename, t_ilm_surface surfaceid)
1814 ilmErrorTypes returnValue = ILM_FAILED;
1816 t_ilm_message response = 0;
1817 t_ilm_message command = gIpcModule.createMessage("ScreenShotOfSurface");
1819 && gIpcModule.appendString(command, filename)
1820 && gIpcModule.appendUint(command, surfaceid)
1821 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1823 returnValue = ILM_SUCCESS;
1825 gIpcModule.destroyMessage(response);
1826 gIpcModule.destroyMessage(command);
1830 ilmErrorTypes ilm_SetKeyboardFocusOn(t_ilm_surface surfaceId)
1832 ilmErrorTypes returnValue = ILM_FAILED;
1834 t_ilm_message response = 0;
1835 t_ilm_message command = gIpcModule.createMessage("SetKeyboardFocusOn");
1837 && gIpcModule.appendUint(command, surfaceId)
1838 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1840 returnValue = ILM_SUCCESS;
1842 gIpcModule.destroyMessage(response);
1843 gIpcModule.destroyMessage(command);
1847 ilmErrorTypes ilm_GetKeyboardFocusSurfaceId(t_ilm_surface* pSurfaceId)
1849 ilmErrorTypes returnValue = ILM_FAILED;
1851 t_ilm_message response = 0;
1852 t_ilm_message command = gIpcModule.createMessage("GetKeyboardFocusSurfaceId");
1854 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1855 && gIpcModule.getUint(response, pSurfaceId))
1857 returnValue = ILM_SUCCESS;
1859 gIpcModule.destroyMessage(response);
1860 gIpcModule.destroyMessage(command);
1864 ilmErrorTypes ilm_UpdateInputEventAcceptanceOn(t_ilm_surface surfaceId, ilmInputDevice devices, t_ilm_bool acceptance)
1866 ilmErrorTypes returnValue = ILM_FAILED;
1868 t_ilm_message response = 0;
1869 t_ilm_message command = gIpcModule.createMessage("UpdateInputEventAcceptanceOn");
1871 && gIpcModule.appendUint(command, surfaceId)
1872 && gIpcModule.appendUint(command, devices)
1873 && gIpcModule.appendBool(command, acceptance)
1874 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1876 returnValue = ILM_SUCCESS;
1878 gIpcModule.destroyMessage(response);
1879 gIpcModule.destroyMessage(command);
1883 ilmErrorTypes ilm_SetOptimizationMode(ilmOptimization id, ilmOptimizationMode mode)
1885 ilmErrorTypes returnValue = ILM_FAILED;
1887 t_ilm_message response = 0;
1888 t_ilm_message command = gIpcModule.createMessage("SetOptimizationMode");
1890 && gIpcModule.appendUint(command,id)
1891 && gIpcModule.appendUint(command,mode)
1892 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1894 returnValue = ILM_SUCCESS;
1896 gIpcModule.destroyMessage(response);
1897 gIpcModule.destroyMessage(command);
1901 ilmErrorTypes ilm_GetOptimizationMode(ilmOptimization id, ilmOptimizationMode* pMode)
1903 ilmErrorTypes returnValue = ILM_FAILED;
1904 t_ilm_message response = 0;
1905 t_ilm_message command = gIpcModule.createMessage("GetOptimizationMode");
1907 && gIpcModule.appendUint(command,id)
1908 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
1909 && gIpcModule.getUint(response, pMode))
1911 returnValue = ILM_SUCCESS;
1913 gIpcModule.destroyMessage(response);
1914 gIpcModule.destroyMessage(command);
1918 ilmErrorTypes ilm_commitChanges()
1920 ilmErrorTypes returnValue = ILM_FAILED;
1922 t_ilm_message response = 0;
1923 t_ilm_message command = gIpcModule.createMessage("CommitChanges");
1926 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1928 returnValue = ILM_SUCCESS;
1930 gIpcModule.destroyMessage(response);
1931 gIpcModule.destroyMessage(command);
1935 ilmErrorTypes ilm_layerAddNotification(t_ilm_layer layer, layerNotificationFunc callback)
1937 ilmErrorTypes returnValue = ILM_FAILED;
1938 t_ilm_message response;
1939 t_ilm_message command;
1941 if (findLayerCallback(layer))
1943 return ILM_ERROR_INVALID_ARGUMENTS;
1947 command = gIpcModule.createMessage("LayerAddNotification");
1949 && gIpcModule.appendUint(command, layer)
1950 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1952 addLayerCallback(layer, callback);
1953 returnValue = ILM_SUCCESS;
1955 gIpcModule.destroyMessage(response);
1956 gIpcModule.destroyMessage(command);
1960 ilmErrorTypes ilm_layerRemoveNotification(t_ilm_layer layer)
1962 ilmErrorTypes returnValue = ILM_FAILED;
1963 t_ilm_message response;
1964 t_ilm_message command;
1966 if (!findLayerCallback(layer))
1968 return ILM_ERROR_INVALID_ARGUMENTS;
1972 command = gIpcModule.createMessage("LayerRemoveNotification");
1974 && gIpcModule.appendUint(command, layer)
1975 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
1977 removeLayerCallback(layer);
1978 returnValue = ILM_SUCCESS;
1980 gIpcModule.destroyMessage(response);
1981 gIpcModule.destroyMessage(command);
1985 ilmErrorTypes ilm_surfaceAddNotification(t_ilm_surface surface, surfaceNotificationFunc callback)
1987 ilmErrorTypes returnValue = ILM_FAILED;
1988 t_ilm_message response;
1989 t_ilm_message command;
1991 if (findSurfaceCallback(surface))
1993 return ILM_ERROR_INVALID_ARGUMENTS;
1997 command = gIpcModule.createMessage("SurfaceAddNotification");
1999 && gIpcModule.appendUint(command, surface)
2000 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
2002 addSurfaceCallback(surface, callback);
2003 returnValue = ILM_SUCCESS;
2005 gIpcModule.destroyMessage(response);
2006 gIpcModule.destroyMessage(command);
2010 ilmErrorTypes ilm_surfaceRemoveNotification(t_ilm_surface surface)
2012 ilmErrorTypes returnValue = ILM_FAILED;
2013 t_ilm_message response;
2014 t_ilm_message command;
2016 if (!findSurfaceCallback(surface))
2018 return ILM_ERROR_INVALID_ARGUMENTS;
2022 command = gIpcModule.createMessage("SurfaceRemoveNotification");
2024 && gIpcModule.appendUint(command, surface)
2025 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue))
2027 removeSurfaceCallback(surface);
2028 returnValue = ILM_SUCCESS;
2030 gIpcModule.destroyMessage(response);
2031 gIpcModule.destroyMessage(command);
2035 ilmErrorTypes ilm_getPropertiesOfScreen(t_ilm_display screenID, struct ilmScreenProperties* pScreenProperties)
2037 ilmErrorTypes returnValue = ILM_FAILED;
2039 t_ilm_message response = 0;
2040 t_ilm_message command = gIpcModule.createMessage("GetPropertiesOfScreen");
2041 if (pScreenProperties
2043 && gIpcModule.appendUint(command, screenID)
2044 && sendAndWaitForResponse(command, &response, gResponseTimeout, &returnValue)
2045 && gIpcModule.getUintArray(response, &pScreenProperties->layerIds, (int*)(&pScreenProperties->layerCount))
2046 && gIpcModule.getUint(response, &pScreenProperties->harwareLayerCount)
2047 && gIpcModule.getUint(response, &pScreenProperties->screenWidth)
2048 && gIpcModule.getUint(response, &pScreenProperties->screenHeight))
2050 returnValue = ILM_SUCCESS;
2054 pScreenProperties->layerCount = 0;
2055 pScreenProperties->harwareLayerCount = 0;
2056 pScreenProperties->layerIds = NULL;
2057 pScreenProperties->screenWidth = 0;
2058 pScreenProperties->screenHeight = 0;
2061 gIpcModule.destroyMessage(response);
2062 gIpcModule.destroyMessage(command);