int CHikParser2::Deinit() { if (m_pOutBuff != NULL) { delete m_pOutBuff; m_pOutBuff = NULL; } WLock(m_rwLocker); /*if (m_aacHandle != NULL) { //faacEncClose(m_aacHandle); m_aacHandle = NULL; }*/ if (m_pAudioCache != NULL) { delete m_pAudioCache; m_pAudioCache = NULL; } RWUnlock(m_rwLocker); return J_OK; }
int CHikv3Parser::InputData(const char *pData, int nLen) { WLock(m_rwLocker); HIKANA_InputData(m_hNewHandle, (unsigned char *)pData, nLen); //m_nDataSize += nLen; RWUnlock(m_rwLocker); return J_MEMORY_ERROR; }
int CLiveParser::InputData(const char *pData, int nLen) { WLock(m_rwLocker); if (m_dateType == J_VideoMjpeg) { *((int *)(m_pDataBuff + m_nDataSize)) = nLen; m_nDataSize += sizeof(int); } memcpy(m_pDataBuff + m_nDataSize, pData, nLen); m_nDataSize += nLen; RWUnlock(m_rwLocker); return J_OK; }
int cd_closedevice (void *ioreq) { struct FSReq *fsreq = ioreq; struct BlkReq blkreq; struct CDSB *cdsb; KPRINTF ("cd_closedevice()"); cdsb = fsreq->unitp; RWWriteLock (&mountlist_rwlock); if (cdsb->reference_cnt == 0) { KSignal (cdsb->pid, SIG_TERM); WaitPid (cdsb->pid, NULL, 0); blkreq.device = cdsb->device; blkreq.unitp = cdsb->unitp; CloseDevice (&blkreq); cd_device.reference_cnt --; RemMount (cdsb->device_mount); FreeBuf (cdsb->buf); KFree (cdsb); fsreq->error = 0; fsreq->rc = 0; } else { fsreq->error = EBUSY; fsreq->rc = -1; } RWUnlock (&mountlist_rwlock); KPRINTF ("cd_closedevice() +"); return 0; }
int cd_opendevice (int unit, void *ioreq, uint32 flags) { struct FSReq *fsreq = ioreq; struct CDSB *cdsb; struct MountEnviron *me; struct BlkReq blkreq; KPRINTF ("cd_opendevice ()"); if ((cdsb = KMalloc (sizeof (struct CDSB))) != NULL) { me = fsreq->me; if (OpenDevice (me->device_name, me->device_unit, &blkreq, me->device_flags) == 0) { /* FIXME: Shouldn't need it (also in fat handler) */ MemSet (cdsb, 0, sizeof (struct CDSB)); /* Need it as cdsb->validated isn't initialized */ cdsb->device = blkreq.device; cdsb->unitp = blkreq.unitp; cdsb->me = fsreq->me; cdsb->reference_cnt = 0; LIST_INIT (&cdsb->node_list); LIST_INIT (&cdsb->active_filp_list); LIST_INIT (&cdsb->invalid_filp_list); cdsb->root_node.flags = ISO_DIRECTORY; cdsb->root_node.cdsb = cdsb; cdsb->root_node.reference_cnt = 0; if ((cdsb->buf = CreateBuf (cdsb->device, cdsb->unitp, me->buffer_cnt, me->block_size, me->partition_start, me->partition_end, me->writethru_critical, me->writeback_delay, me->max_transfer)) != NULL) { if (KSpawn (CDTask, cdsb, 10, "cd.handler") != -1) { KWait (SIGF_INIT); RWWriteLock (&mountlist_rwlock); cd_device.reference_cnt ++; cdsb->device_mount = MakeMount (cdsb->me, &cd_device, cdsb); AddMount (cdsb->device_mount); RWUnlock (&mountlist_rwlock); fsreq->unitp = cdsb; fsreq->error = 0; fsreq->rc = 0; return 0; } } CloseDevice (&blkreq); } KFree (cdsb); } fsreq->error = IOERR_OPENFAIL; fsreq->rc = -1; KPANIC ("CD OpenDevice FAIL"); return -1; }
int CLiveParser::GetOnePacket(char *pData, J_StreamHeader &streamHeader) { WLock(m_rwLocker); if (m_dateType == J_VideoMjpeg) { if (m_nDataSize < (int)sizeof(int)) { streamHeader.dataLen = 0; RWUnlock(m_rwLocker); return J_NOT_COMPLATE; } int nOffset = 0; int nLen = *((int *)(m_pDataBuff)); nOffset += sizeof(int); memcpy(pData, m_pDataBuff + nOffset, nLen); nOffset += nLen; memmove(m_pDataBuff, m_pDataBuff + nOffset, m_nDataSize - nOffset); m_nDataSize -= nOffset; streamHeader.timeStamp = CTime::Instance()->GetLocalTime(0); streamHeader.dataLen = nLen; streamHeader.frameType = J_VideoIFrame; } else { int iDataLen = 640 * 480; if (m_nDataSize < iDataLen * 2) { streamHeader.dataLen = 0; RWUnlock(m_rwLocker); return J_NOT_COMPLATE; } streamHeader.timeStamp = CTime::Instance()->GetLocalTime(0); int nOffset = 0; YUV422To420((uint8_t *)m_pDataBuff, m_pPicIn->img.plane[0], m_pPicIn->img.plane[1], m_pPicIn->img.plane[2], 640, 480); nOffset = iDataLen * 2; m_pPicIn->i_pts = 0;//streamHeader.timeStamp * 90; //m_pPicIn->i_dts = streamHeader.timeStamp * 90; //++g_uiPTSFactor; encode(m_pX264Handle, m_pPicIn, m_pPicOut); memmove(m_pDataBuff, m_pDataBuff + nOffset, m_nDataSize - nOffset); m_nDataSize -= nOffset; nOffset = 0; for (int i = 0; i < m_iNal; ++i) { /*static FILE *fp = NULL; if (fp == NULL) fp = fopen("test.h264", "wb+"); fwrite(m_pNals[i].p_payload, 1, m_pNals[i].i_payload, fp);*/ memcpy(pData + nOffset, m_pNals[i].p_payload, m_pNals[i].i_payload); nOffset += m_pNals[i].i_payload; } streamHeader.dataLen = nOffset; streamHeader.frameType = J_VideoIFrame; } RWUnlock(m_rwLocker); return J_OK; }