📄 pxff2.cpp
字号:
{ PXEffect* pEffect = NULL; UINT32 ulTimeStamp = 0; retVal = m_pPacketScheduler->GetEffectInfo(pEffect, ulTimeStamp); if (SUCCEEDED(retVal)) { IHXPacket* pPacket = NULL; retVal = m_pWireFormatManager->SetEffectInfo(pEffect, ulTimeStamp, pPacket); if (SUCCEEDED(retVal)) {#ifdef XXXMEH_OUTPUT_DEBUG_STRING char szDbgStr[128]; /* Flawfinder: ignore */ sprintf(szDbgStr, "Sending Effect Packet (type=%lu,start=%lu,target=%lu)\n", /* Flawfinder: ignore */ pEffect->GetEffectType(), pEffect->GetStart(), pEffect->GetTarget()); OutputDebugString(szDbgStr);#endif // Tell the scheduler we've sent the packet m_pPacketScheduler->PacketSent(m_pWireFormatManager->GetPacketSize(pPacket)); // Set the state (actually keep it the same) m_ulState = kStateAwaitingGetPacket; // Send the packet m_pFileFormatResponse->PacketReady(HXR_OK, pPacket); } HX_RELEASE(pPacket); } HX_RELEASE(pEffect); } else { retVal = HXR_FAIL; } } } else { // Scheduler says stream is done, so set the state m_ulState = kStateStreamDone; // Call the response interface m_pFileFormatResponse->StreamDone(0); } } else { retVal = HXR_INVALID_PARAMETER; } if (FAILED(retVal)) { SendFailPacket(retVal); } } else { retVal = HXR_UNEXPECTED; } return retVal;}STDMETHODIMP CRealPixFileFormat::Seek(UINT32 ulRequestedTime){#ifdef XXXMEH_DEBUG_LOG DEBUG_OUTF("c:\\pxff.log", (s, "CRealPixFileFormat::Seek(0x%08X,%lu)\n", this, ulRequestedTime));#endif HX_RESULT retVal = HXR_OK; if (m_ulState == kStateAwaitingGetPacket || m_ulState == kStateReadingImageFile || m_ulState == kStateStreamDone) { retVal = m_pPacketScheduler->SeekSetup(ulRequestedTime); if (SUCCEEDED(retVal)) { // Set the state m_ulState = kStateAwaitingGetPacket; } // Inform the response interface m_pFileFormatResponse->SeekDone(retVal); } else { retVal = HXR_UNEXPECTED; } return retVal;}STDMETHODIMP_(BOOL) CRealPixFileFormat::IsInterruptSafe(){ return TRUE;}STDMETHODIMP CRealPixFileFormat::ReadRPFileDone(HX_RESULT status, IHXBuffer* pBuffer){#ifdef XXXMEH_DEBUG_LOG DEBUG_OUTF("c:\\pxff.log", (s, "CRealPixFileFormat::ReadRPFileDone(0x%08X,0x%08X,0x%08X)\n", this, status, pBuffer));#endif HX_RESULT retVal = HXR_OK; if (m_ulState == kStateReadingRPFile) { if (SUCCEEDED(status)) { // Create a PXRealPixFile object HX_RELEASE(m_pRealPixFile); retVal = PXRealPixFile::CreateObject(&m_pRealPixFile); if (SUCCEEDED(retVal)) { // Addref the object m_pRealPixFile->AddRef(); // Set the URL from the IHXRequest into the filename // of the PXRealPixFile const char* pszURL = NULL; m_pRequest->GetURL(pszURL); if (pszURL) { m_pRealPixFile->SetFileName(pszURL); } // Parse the file retVal = ParseRealPixFile(pBuffer, m_pRealPixFile, m_ulStrictnessLevel); if (SUCCEEDED(retVal)) { // If we have all the sizes OK from the .rp file, then there's no // reason to do the image stat()'s. if (m_pRealPixFile->AllImageSizesInitialized() && m_pRealPixFile->AllImageSizesOK()) { // We got all the image sizes from the .rp file, so we // can go head and do the rest of our initialization. retVal = InitFromRPFile(); if (SUCCEEDED(retVal)) { // Set state m_ulState = kStateFileFormatInitialized; // Call back to the response interface m_pFileFormatResponse->InitDone(HXR_OK); } } else { // Set the size of pointer array m_pFileHandlerArray->SetSize(m_pRealPixFile->GetNumImagesWithNoSize()); // NULL out all the pointers UINT32 i = 0; UINT32 ulNumHandlers = (UINT32) m_pFileHandlerArray->GetSize(); for (i = 0; i < ulNumHandlers; i++) { m_pFileHandlerArray->SetAt(i, NULL); } // Set the state m_ulState = kStateImageStat; // Loop through the images, kicking off a stat for each void* pItr = NULL; retVal = m_pRealPixFile->GetImageIterator(pItr); if (SUCCEEDED(retVal)) { i = 0; UINT32 ulHandle = 0; HX_RESULT rv = m_pRealPixFile->GetNextImageHandle(pItr, ulHandle); while (SUCCEEDED(rv) && SUCCEEDED(retVal)) { if (!m_pRealPixFile->IsImageSizeInitialized(ulHandle)) { // Create a file handler PXFileHandler* pHandler = new PXFileHandler(); if (pHandler) { // AddRef the object pHandler->AddRef(); // Init the handler retVal = pHandler->Init(m_pContext, m_pRPFileObject, this); if (SUCCEEDED(retVal)) { // Get the name of this image IHXBuffer* pNameStr = NULL; retVal = m_pRealPixFile->GetImageName(ulHandle, pNameStr); if (SUCCEEDED(retVal)) { AllowPoolPathAdjustment (pNameStr); // Put the handler in the array pHandler->AddRef(); m_pFileHandlerArray->SetAt(i, (void*) pHandler); // Increment the index i++; // Kick off a stat on this image retVal = pHandler->StatImageFile(ulHandle, pNameStr); } HX_RELEASE(pNameStr); } } else { retVal = HXR_OUTOFMEMORY; } HX_RELEASE(pHandler); } if (SUCCEEDED(retVal)) { // Get the next image rv = m_pRealPixFile->GetNextImageHandle(pItr, ulHandle); } } } } } } } else { m_ulState = kStateError; m_pFileFormatResponse->InitDone(status); } if (FAILED(retVal)) { m_ulState = kStateError; m_pFileFormatResponse->InitDone(retVal); } } else { retVal = HXR_UNEXPECTED; } return retVal;}//// IHXPoolPathAdjustment::AllowPoolPathAdjustment//// If the .rp file object came from a filesystem which // implements IHXPoolPathAdjustment, the filesystem may need// to alter absolute local URLs opened from the same pool// via IHXGetFileFromSamePool. IHXPoolPathAdjustment::AdjustAbsolutePath()// allows the filesystem to alter the path.//HX_RESULT CRealPixFileFormat::AllowPoolPathAdjustment (REF(IHXBuffer*) pNameStr){ if (m_pPoolPathAdjustment) { IHXBuffer* pNewNameStr = NULL; m_pPoolPathAdjustment->AdjustAbsolutePath(pNameStr, pNewNameStr); if (pNewNameStr) { pNameStr->Release(); pNameStr = pNewNameStr; return HXR_OK; } } return HXR_FAIL;}STDMETHODIMP CRealPixFileFormat::StatImageFileDone(HX_RESULT status, UINT32 ulInstance, UINT32 ulSize, IHXBuffer* pMimeTypeStr){#ifdef XXXMEH_DEBUG_LOG DEBUG_OUTF("c:\\pxff.log", (s, "CRealPixFileFormat::StatImageFileDone(0x%08X,0x%08X,%lu,%lu,%s)\n", this, status, ulInstance, ulSize, (pMimeTypeStr ? (const char*) pMimeTypeStr->GetBuffer() : NULL)));#endif HX_RESULT retVal = HXR_OK; if (m_ulState == kStateImageStat) { if (SUCCEEDED(status)) { // Set the image size m_pRealPixFile->SetImageSize(ulInstance, ulSize); // Set the image file mime type if (pMimeTypeStr) { m_pRealPixFile->SetImageFileMimeType(ulInstance, pMimeTypeStr); } } else { // Set an error in the PXRealPixFile m_pRealPixFile->SetImageErrorStatus(ulInstance, status); } if (SUCCEEDED(retVal)) { // Have all the stat's reported back yet? if (m_pRealPixFile->AllImageSizesInitialized()) { // Now we check if there were any error in the stat's if (m_pRealPixFile->AllImageSizesOK()) { // None of the images were zero-sized. Therefore, all of // the stats returned OK retVal = InitFromRPFile(); if (SUCCEEDED(retVal)) { // Set state m_ulState = kStateFileFormatInitialized; // Call back to the response interface m_pFileFormatResponse->InitDone(HXR_OK); } } else { // Get the name of the image which failed IHXBuffer* pFailedNameStr = NULL; HX_RESULT rv = m_pRealPixFile->GetFailedImageName(pFailedNameStr); if (SUCCEEDED(rv)) { ReportError(IDS_ERR_PIX_MISSINGFILE, (const char*) pFailedNameStr->GetBuffer(), NULL, HXLOG_CRIT, HXR_FAIL); retVal = HXR_FAIL; } HX_RELEASE(pFailedNameStr); } } } if (FAILED(retVal)) { retVal = m_pFileFormatResponse->InitDone(retVal); } } else { retVal = HXR_UNEXPECTED; } return retVal;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -