#ifndef _MSGQUEUE_H #define _MSGQUEUE_H #include #include #include #include #include #include #include #include //03/08/2012 added by cdlin to build for new tool chain. #include //~cdlin #define SHM_EPG_CH_LIST (0xf001) #define SHM_EPG_CUR_EVENT (0xf002) #define SHM_UMF_CH_LIST (0xf003) #define SHM_EPG_CH_SERVICE (0xf004) #define SHM_EPG_RRT (0xf005) #define SHM_CECDEVICE_LIST (0xf006) #define SHM_OSD_String (0xf007) #define SHM_REC_DATAINFO (0xf008) #define TASK_QUEUE_EPG (0xf001) #define TASK_QUEUE_FC (0xf002) #define TASK_QUEUE_UMF2JPEG (0xf003) #define TASK_QUEUE_JPEG2UMF (0xf004) #define TASK_QUEUE_UMFtoTT (0xf005) #define TASK_QUEUE_TTtoUMF (0xf006) #define TASK_QUEUE_UMFtoCECD (0xf007) #define TASK_QUEUE_CECDtoUMF (0xf008) #define TASK_QUEUE_UMF2MUSIC (0xf009) #define TASK_QUEUE_MUSIC2UMF (0xf00a) #define TASK_QUEUE_UMF2TS (0xf00b) #define TASK_QUEUE_TS2UMF (0xf00c) #define TASK_QUEUE_UMF2KOK (0xf00d) #define TASK_QUEUE_KOK2UMF (0xf00e) #define TASK_QUEUE_UMF2MEDIA (0xf00f) #define TASK_QUEUE_MEDIA2UMF (0xf010) #define TASK_QUEUE_UMF2ANYPLEX (0xf011) #define TASK_QUEUE_ANYPLEX2UMF (0xf012) // nina for media message Q #define TASK_QUEUE_MEDIA2MediaQueue (0xf013) #define TASK_QUEUE_MEDIA2MediaReturnQueue (0xf014) #define TASK_QUEUE_WhoIsCurrentScreenQueue (0xf015) #define TASK_QUEUE_MEDIA2PVRQueue (0xf016) // ~nina for media message Q // for GJ PVR Msg Q #define TASK_QUEUE_UMF2PVR (0xf017) #define TASK_QUEUE_PVR2UMF (0xf018) #define TASK_QUEUE_PVR2MediaReturnQueue (0xf019) #define TASK_QUEUE_PVR2PVRQueue (0xf01A) // ~for GJ PVR Msg Q // for KOK Msg Q #define TASK_QUEUE_MINI2KOK (0xf01B) #define TASK_QUEUE_KOKTOMINI (0xf01C) #ifdef CONFIG_SUPPORT_MIRACAST #define TASK_QUEUE_UMF2MIRACAST (0xf01d) #define TASK_QUEUE_MIRACAST2UMF (0xf01e) #endif // ~for KOK PVR Msg Q #define MSGTYPE_FC (0x1) //Flow Control #define MSGTYPE_EPG (0x2) #define MSGTYPE_PSIP (0x3) #define MSGTYPE_SI (0x4) #define MSGTYPE_CI (0x5) #define MSGTYPE_SELF (0x6) #define MSGTYPE_EAM (0x7) #define MSGTYPE_UMF2JPEG (0x8) #define MSGTYPE_JPEG2UMF (0x9) #define MSGTYPE_TT (0xa) #define MSGTYPE_UMF2MUSIC (0xb) #define MSGTYPE_MUSIC2UMF (0xc) #define MSGTYPE_UMF2TS (0xd) #define MSGTYPE_TS2UMF (0xe) #define MSGTYPE_UMF2KOK (0xf) #define MSGTYPE_KOK2UMF (0x10) #define MSGTYPE_UMF2MEDIA (0x11) #define MSGTYPE_MEDIA2UMF (0x12) #define MSGTYPE_UMF2ANYPLEX (0x13) #define MSGTYPE_ANYPLEX2UMF (0x14) //media for pre message Q #define MSGTYPE_MEDIA2MediaQueue (0x15) #define MSGTYPE_MEDIA2MediaReturnQueueFail (0x16) #define MSGTYPE_WhoIsCurrentScreenQueue (0x17) #define MSGTYPE_UMF2PVR (0x18) #define MSGTYPE_MEDIA2MediaReturnQueueSuccess (0x19) #define MSGTYPE_NoticesTimeOut (0x1a) #define MSGTYPE_PVR2UMF (0x1b) //-media for pre message Q #define TASK_QUEUE_UMF2MEDIA_MENU (0x1c) #ifdef CONFIG_SUPPORT_MIRACAST #define MSGTYPE_UMF2MIRACAST (0x1d) #define MSGTYPE_MIRACAST2UMF (0x1e) #endif inline static bool CreateMessageQueue(int* pMsqid, uint nQueue) { int iMsqid; iMsqid= msgget(nQueue, 0); if( iMsqid!=-1 ) msgctl(iMsqid, IPC_RMID, 0); iMsqid= msgget(nQueue, 0666|IPC_CREAT); if( iMsqid==-1 ) { perror("CreateMessageQueue fail: "); return false; } *pMsqid= iMsqid; return true; } inline static bool ConnectMessageQueue(int* pMsqid, uint nQueue) { int iMsqid,iLoop=100; do{ usleep(50000); iMsqid= msgget(nQueue, 0); } while(iMsqid==-1 && iLoop-->0); *pMsqid= iMsqid; return (iMsqid>=0)?true:false; } inline static bool DeleteMessageQueue(int iMsqid) { if( -1==msgctl(iMsqid, IPC_RMID, 0) ) return false; else return true; } inline static uint GetMessageNodeCount(int iMsqid) { struct msqid_ds buf; if( -1==msgctl(iMsqid, IPC_STAT, &buf) ) return 0; return buf.msg_qnum; } inline static int CreateSharedMemory(key_t key, size_t size) { return shmget(key, size, 0666|IPC_CREAT); } inline static void DeleteSharedMemory(int iShmId) { if( iShmId!=-1 ) shmctl( iShmId, IPC_RMID, 0); } inline static bool CopyToSharedMemory(int iShmId, void* p, size_t size) { bool bResult= false; void* shared_memory= shmat(iShmId, (void*) 0, 0); if( shared_memory!=(void*)(-1) ) { memcpy(shared_memory, p, size); shmdt(shared_memory); bResult= true; } return bResult; } inline static bool CopyFromSharedMemory(int iShmId, void* p, size_t size) { bool bResult= false; void* shared_memory= shmat(iShmId, (void*) 0, 0); if( shared_memory!=(void*)(-1) ) { memcpy(p, shared_memory, size); shmdt(shared_memory); bResult= true; } return bResult; } #endif //_MSGQUEUE_H