📄 pxff2.cpp
字号:
}STDMETHODIMP CRealPixFileFormat::ReadImageFileDone(HX_RESULT status, UINT32 ulInstance, IHXBuffer* pBuffer){#ifdef XXXMEH_DEBUG_LOG DEBUG_OUTF("c:\\pxff.log", (s, "CRealPixFileFormat::ReadImageFileDone(0x%08X,0x%08X,%lu,0x%08X)\n", this, status, ulInstance, pBuffer));#endif HX_RESULT retVal = HXR_OK; if (m_ulState == kStateReadingImageFile) { if (SUCCEEDED(status)) { // Get the image header info again UINT32 ulHandle = 0; UINT32 ulSize = 0; IHXBuffer* pFileMimeStr = NULL; IHXBuffer* pStreamMimeStr = NULL; IHXBuffer* pNameStr = NULL; UINT32 ulTime = 0; retVal = m_pPacketScheduler->GetImageHeaderInfo(ulHandle, ulSize, pFileMimeStr, pNameStr, pStreamMimeStr, ulTime); if (SUCCEEDED(retVal)) { AllowPoolPathAdjustment (pNameStr); // Get an interface to the proper codec to parse this buffer // Since we only parse one image at a time, then we will // save this pointer in a member variable. HX_RELEASE(m_pCodec); retVal = m_pCodecManager->GetCodec((const char*) (pFileMimeStr ? pFileMimeStr->GetBuffer() : NULL), (const char*) (pNameStr ? pNameStr->GetBuffer() : NULL), pBuffer, m_pCodec); if (SUCCEEDED(retVal)) { // Parse the image UINT32 ulNumPackets = 0; IHXValues* pParam = NULL; retVal = m_pCodec->ParseImage(pBuffer, ulNumPackets, pParam, m_ulSessionHandle); if (SUCCEEDED(retVal)) { // Set the flag saying we are holding packets in a codec m_bImageParseActive = TRUE; // Pass this info on to the scheduler retVal = m_pPacketScheduler->SetImageDataInfo(ulNumPackets, m_ulSessionHandle); if (SUCCEEDED(retVal)) { // Get the packet info for the image header packet IHXPacket* pPacket = NULL; retVal = m_pWireFormatManager->SetImageHeaderInfo(ulHandle, // image handle ulSize, // image file size 0, // flags pStreamMimeStr, // stream mime ulTime, // timestamp pPacket); if (SUCCEEDED(retVal)) {#ifdef XXXMEH_OUTPUT_DEBUG_STRING char szDbgStr[128]; /* Flawfinder: ignore */ sprintf(szDbgStr, "Sending Image Header Packet (handle=%lu)\n", ulHandle); /* Flawfinder: ignore */ OutputDebugString(szDbgStr);#endif // Tell the scheduler we've sent the packet m_pPacketScheduler->PacketSent(m_pWireFormatManager->GetPacketSize(pPacket)); // Set the state m_ulState = kStateAwaitingGetPacket; // Send the packet m_pFileFormatResponse->PacketReady(HXR_OK, pPacket); } HX_RELEASE(pPacket); } } HX_RELEASE(pParam); } } HX_RELEASE(pFileMimeStr); HX_RELEASE(pStreamMimeStr); HX_RELEASE(pNameStr); } else { retVal = status; } if (FAILED(retVal)) { SendFailPacket(retVal); } } else { retVal = HXR_UNEXPECTED; } return retVal;}STDMETHODIMP CRealPixFileFormat::ShutdownDone(HX_RESULT status, UINT32 ulInstance){#ifdef XXXMEH_DEBUG_LOG DEBUG_OUTF("c:\\pxff.log", (s, "CRealPixFileFormat::ShutdownDone(0x%08X,0x%08X,%lu) ", this, status, ulInstance));#endif HX_RESULT retVal = HXR_OK; if (m_ulState == kStateShutdown || m_ulState == kStateGetFileHeaderShutdown) { // Check to see if all the file handlers have been shutdown BOOL bAllShutdownDone = TRUE; if (m_pRPFileHandler && m_bShutdownRPFile) { bAllShutdownDone = m_pRPFileHandler->IsShutdownDone(); } if (m_pImageFileHandler && bAllShutdownDone) { bAllShutdownDone = m_pImageFileHandler->IsShutdownDone(); } if (m_pFileHandlerArray && bAllShutdownDone) { UINT32 ulNumHandlers = (UINT32) m_pFileHandlerArray->GetSize(); for (UINT32 i = 0; i < ulNumHandlers && bAllShutdownDone; i++) { // Get the file handler PXFileHandler* pHandler = (PXFileHandler*) m_pFileHandlerArray->GetAt(i); // Find out if it's done if (pHandler) { bAllShutdownDone = pHandler->IsShutdownDone(); } } } // If all the file handlers have been shutdown, then deallocate if (bAllShutdownDone) { if (m_ulState == kStateShutdown) {#ifdef XXXMEH_DEBUG_LOG DEBUG_OUTF("c:\\pxff.log", (s, "state = kStateShutdown - Calling Deallocate()"));#endif Deallocate(); } else if (m_ulState == kStateGetFileHeaderShutdown) {#ifdef XXXMEH_DEBUG_LOG DEBUG_OUTF("c:\\pxff.log", (s, "state = kStateGetFileHeaderShutdown - Sending file header"));#endif // Now we can release the .rp file handler if we shut it down if (m_bShutdownRPFile) { HX_RELEASE(m_pRPFileHandler); } // Now we can release the individual image file handler HX_RELEASE(m_pImageFileHandler); // Now release all the image file handlers ReleaseAllFileHandlers(); // Now get the file header from the wire format manager IHXValues* pFileHeader = NULL; const char* pszAcceptStr = (m_pAcceptMetaInfoStr ? (const char*) m_pAcceptMetaInfoStr->GetBuffer() : NULL); retVal = m_pWireFormatManager->GetFileHeader(pFileHeader, pszAcceptStr); if (SUCCEEDED(retVal)) { // Set the state m_ulState = kStateFileHeaderSent; // Send the file header m_pFileFormatResponse->FileHeaderReady(HXR_OK, pFileHeader); } HX_RELEASE(pFileHeader); } } } else { retVal = HXR_UNEXPECTED; }#ifdef XXXMEH_DEBUG_LOG DEBUG_OUTF("c:\\pxff.log", (s, "\n"));#endif return retVal;}HX_RESULT STDAPICALLTYPE CRealPixFileFormat::HXCreateInstance(IUnknown** ppIUnknown){ HX_RESULT retVal = HXR_OK; if (ppIUnknown) { // Set default *ppIUnknown = NULL; // Create the object CRealPixFileFormat* pObj = new CRealPixFileFormat(); if (pObj) { // QI for IUnknown retVal = pObj->QueryInterface(IID_IUnknown, (void**) ppIUnknown); } else { retVal = HXR_OUTOFMEMORY; } if (FAILED(retVal)) { HX_DELETE(pObj); } } else { retVal = HXR_FAIL; } return HXR_OK;}HX_RESULT CRealPixFileFormat::InitFromRPFile(){ HX_RESULT retVal = HXR_OK; if (m_pRealPixFile && m_pCodecManager && m_pWireFormatManager) { IHXBuffer* pImageNameStr = NULL; retVal = CheckForCodecs(pImageNameStr); if (SUCCEEDED(retVal)) { retVal = AddCodecsToWireFormatManager(); if (SUCCEEDED(retVal)) { // Now we can release inactive codecs retVal = m_pCodecManager->ReleaseInactiveComponents(); if (SUCCEEDED(retVal)) { // Create a PXScheduler object HX_RELEASE(m_pPacketScheduler); retVal = PXScheduler::CreateObject(&m_pPacketScheduler); if (SUCCEEDED(retVal)) { // AddRef the object m_pPacketScheduler->AddRef(); // Now since we know how big each of the images // are, we can schedule our packets retVal = m_pPacketScheduler->Init(m_pRealPixFile, m_pWireFormatManager); if (SUCCEEDED(retVal)) { // Now we need to set values in the wire format manager UINT32 ulPreroll = (m_pRealPixFile->GetPreroll() > m_pPacketScheduler->GetMinimumPreroll() ? m_pRealPixFile->GetPreroll() : m_pPacketScheduler->GetMinimumPreroll()); m_pWireFormatManager->SetBitrate(m_pRealPixFile->GetBitrate()); m_pWireFormatManager->SetDisplayWidth(m_pRealPixFile->GetDisplayWidth()); m_pWireFormatManager->SetDisplayHeight(m_pRealPixFile->GetDisplayHeight()); m_pWireFormatManager->SetDuration(m_pRealPixFile->GetDuration()); m_pWireFormatManager->SetLive(FALSE); m_pWireFormatManager->SetStreamMimeType(m_ppszStreamMimeTypes[0]); m_pWireFormatManager->SetPreroll(ulPreroll); m_pWireFormatManager->SetPreData(m_pRealPixFile->GetBitrate() * ulPreroll / 8000); m_pWireFormatManager->SetPreDataAtStart(TRUE); m_pWireFormatManager->SetPrerollAfterSeek(TRUE); m_pWireFormatManager->SetBackgroundColor(m_pRealPixFile->GetBackgroundColor()); m_pWireFormatManager->SetBackgroundOpacity(m_pRealPixFile->GetBackgroundOpacity()); // Set the default URL into the wire format manager IHXBuffer* pDefaultURLStr = NULL; m_pRealPixFile->GetDefaultURL(&pDefaultURLStr); if (pDefaultURLStr) { m_pWireFormatManager->SetDefaultURL(pDefaultURLStr); } HX_RELEASE(pDefaultURLStr); // Set the wire format stream and content version. Right now, we are driven only // by the content version of the .rp file. Therefore, we set both the // stream and content version to the content version of the .rp file. m_pWireFormatManager->SetStreamVersion(m_pRealPixFile->GetContentVersion()); m_pWireFormatManager->SetContentVersion(m_pRealPixFile->GetContentVersion()); // Set the ASM rule book char szASMRuleBook[256]; /* Flawfinder: ignore */ sprintf(szASMRuleBook, /* Flawfinder: ignore */ "Priority=5,AverageBandwidth=%lu;Priority=10,AverageBandwidth=0;", m_pRealPixFile->GetBitrate()); m_pWireFormatManager->SetASMRuleBook(szASMRuleBook); } } } } } else { // Report error for no codec ReportError(IDS_ERR_PIX_NOCODEC, (const char*) (pImageNameStr ? pImageNameStr->GetBuffer() : NULL), NULL, HXLOG_CRIT, HXR_FAIL); } HX_RELEASE(pImageNameStr); } else { retVal = HXR_UNEXPECTED; } return retVal;}void CRealPixFileFormat::ShutdownAllFileHandlers(BOOL bShutdownRPFile){ BOOL bShutdownCalled = FALSE; // Save whether or not we are shutting down the .rp file handler m_bShutdownRPFile = bShutdownRPFile; // Shutdown the .rp file handler if (m_pRPFileHandler && m_bShutdownRPFile) { bShutdownCalled = TRUE; m_pRPFileHandler->Shutdown(); } // Shutdown the individual image file handler if (m_pImageFileHandler) { bShutdownCalled = TRUE; m_pImageFileHandler->Shutdown(); } // Shutdown any file handler in the array if (m_pFileHandlerArray) { UINT32 ulNumHandlers = m_pFileHandlerArray->GetSize(); for (UINT32 i = 0; i < ulNumHandlers; i++) { // Get the file handler PXFileHandler* pHandler = (PXFileHandler*) m_pFileHandlerArray->GetAt(i); // Call Shutdown on the file handler if (pHandler)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -