void HXFileSystemManager::InitMountPoints(IUnknown* pContext) { #if defined(HELIX_CONFIG_NOSTATICS) HXBOOL& zm_IsInited = (HXBOOL&)HXGlobalInt32::Get(&HXFileSystemManager::zm_IsInited); #endif if (zm_IsInited) return; zm_IsInited = TRUE; IHXBuffer* mount_point = 0; IHXBuffer* real_short_name = 0; const char* short_name = 0; IHXValues* options = 0; IHXRegistry* pRegistry; IHXValues* pNameList = NULL; if(HXR_OK != pContext->QueryInterface(IID_IHXRegistry, (void**)&pRegistry)) { return; } if(HXR_OK != pRegistry->GetPropListByName("config.FSMount", pNameList)) { pRegistry->Release(); return; } HX_RESULT res; const char* plugName; UINT32 plug_id; res = pNameList->GetFirstPropertyULONG32(plugName, plug_id); while(res == HXR_OK) { HXPropType plugtype = pRegistry->GetTypeById(plug_id); if(plugtype != PT_COMPOSITE) res = HXR_FAIL; else { short_name = strrchr(plugName, '.'); if(!short_name) short_name = plugName; else short_name++; IHXValues* pPropList; if(HXR_OK == pRegistry->GetPropListById(plug_id, pPropList)) { const char* propName; UINT32 prop_id; CreateValuesCCF(options, pContext); res = pPropList->GetFirstPropertyULONG32(propName, prop_id); while(res == HXR_OK) { HXPropType type = pRegistry->GetTypeById(prop_id); const char*propSubName = strrchr(propName, '.') + 1; switch(type) { case PT_INTEGER: { INT32 val; if(HXR_OK == pRegistry->GetIntById(prop_id, val)) { options->SetPropertyULONG32(propSubName, val); } break; } case PT_STRING: { IHXBuffer* pBuffer; if(HXR_OK == pRegistry->GetStrById(prop_id, pBuffer)) { options->SetPropertyBuffer(propSubName, pBuffer); pBuffer->Release(); } break; } case PT_BUFFER: { IHXBuffer* pBuffer; if(HXR_OK == pRegistry->GetBufById(prop_id, pBuffer)) { options->SetPropertyBuffer(propSubName, pBuffer); pBuffer->Release(); } break; } default: break; } res = pPropList->GetNextPropertyULONG32(propName, prop_id); } res = HXR_OK; } if(HXR_OK == options->GetPropertyBuffer("MountPoint", mount_point)) { if(HXR_OK == options->GetPropertyBuffer("ShortName", real_short_name)) short_name = (const char*) real_short_name->GetBuffer(); AddMountPoint(short_name,(const char*)mount_point->GetBuffer(), options, pContext); if(real_short_name) { real_short_name->Release(); real_short_name = 0; } mount_point->Release(); } res = pNameList->GetNextPropertyULONG32(plugName, plug_id); } } pNameList->Release(); pRegistry->Release(); }
/************************************************************************ * Method: * IHXPacketHookManager::StartHook * Purpose: * called by the top level client to start recording */ STDMETHODIMP PacketHookManager::StartHook () { HX_RESULT hr = HXR_OK; UINT16 i = 0; UINT16 j = 0; UINT16 k = 0; UINT16 ulSources = 0; UINT16 ulStreams = 0; UINT16 ulStreamIndex = 0; IHXBuffer* pTitle = NULL; IHXBuffer* pAuthor = NULL; IHXBuffer* pCopyright = NULL; IHXValues* pFileHeader = NULL; IHXValues* pStreamHeader = NULL; IUnknown* pUnknown = NULL; IHXPrivateStreamSource *pPrivateSource = NULL; // for IsSaveAllowed, take this out; XXXCP IHXStreamSource* pSource = NULL; IHXInfoLogger* pInfoLogger = NULL; // make sure everything has been initialized if (!m_pPlayer || !m_pPacketHook) { hr = HXR_FAILED; goto cleanup; } // caculate the total number of streams + TAC info. if (!(ulSources = m_pPlayer->GetSourceCount())) { hr = HXR_FAILED; goto cleanup; } m_ulTotalStreams = 0; for (i = 0; i < ulSources; i++) { if (HXR_OK != m_pPlayer->GetSource(i, pUnknown)) { continue; } if (HXR_OK != pUnknown->QueryInterface(IID_IHXStreamSource, (void**)&pSource)) { HX_RELEASE(pUnknown); continue; } if (HXR_OK == pUnknown->QueryInterface(IID_IHXPrivateStreamSource, (void**)&pPrivateSource)) { if (!(pPrivateSource->IsSaveAllowed())) { pPrivateSource->Release(); continue; } pPrivateSource->Release(); } m_ulTotalStreams += pSource->GetStreamCount(); HX_RELEASE(pSource); HX_RELEASE(pUnknown); } if (!m_ulTotalStreams) { hr = HXR_FAILED; goto cleanup; } // prepare the file header CreateBufferCCF(pTitle, m_pPlayer); CreateBufferCCF(pAuthor, m_pPlayer); CreateBufferCCF(pCopyright, m_pPlayer); // XXX HP: find better way to collect TAC info #define szTitle "title" #define szAuthor "author" #define szCopyright "copyright" pTitle->Set((const unsigned char*)szTitle, strlen(szTitle)+1); pAuthor->Set((const unsigned char*)szAuthor, strlen(szAuthor)+1); pCopyright->Set((const unsigned char*)szCopyright, strlen(szCopyright)+1); if (HXR_OK == CreateValuesCCF(pFileHeader, m_pPlayer)) { // set attributes(i.e. num. of streams + TAC) pFileHeader->SetPropertyBuffer("Title", pTitle); pFileHeader->SetPropertyBuffer("Author", pAuthor); pFileHeader->SetPropertyBuffer("Copyright", pCopyright); pFileHeader->SetPropertyULONG32("StreamCount", m_ulTotalStreams); } // signal the top level client of upcoming content m_pPacketHook->OnStart(); // send file header to its top level client hr = m_pPacketHook->OnFileHeader(pFileHeader); if (hr != HXR_OK) { HX_RELEASE(m_pPacketHook); goto cleanup; } // prepare the stream headers m_ulRecordableStreams = 0; ulStreamIndex = 0; for (i = 0; i < ulSources; i++) { if (HXR_OK != m_pPlayer->GetSource(i, pUnknown)) { HX_RELEASE(pUnknown); continue; } if (HXR_OK != pUnknown->QueryInterface(IID_IHXStreamSource, (void**)&pSource)) { HX_RELEASE(pSource); continue; } if (HXR_OK == pUnknown->QueryInterface(IID_IHXPrivateStreamSource, (void**)&pPrivateSource)) { if (!(pPrivateSource->IsSaveAllowed())) { pPrivateSource->Release(); continue; } pPrivateSource->Release(); } if (HXR_OK == pUnknown->QueryInterface(IID_IHXInfoLogger, (void**)&pInfoLogger)) { pInfoLogger->LogInformation("RECSTART", NULL); } HX_RELEASE(pInfoLogger); ulStreams = pSource->GetStreamCount(); for (j = 0; j < ulStreams; j++) { const char* pszPropName = NULL; UINT16 ulRenderers = 0; ULONG32 ulPropValue = 0; HXBOOL bRecordable = FALSE; IHXValues* pHeader = NULL; IHXBuffer* pPropValueSource = NULL; IHXBuffer* pPropValueTarget = NULL; IHXStream* pStream = NULL; // retrieve the stream info pSource->GetStream(j, (IUnknown*&)pStream); pHeader = pStream->GetHeader(); // make a copy of this stream header // XXX HP: this could be wrapped up into one method in CHXHeader CreateValuesCCF(pStreamHeader, m_pPlayer); // copy all the ULONG32 attributes if (HXR_OK == pHeader->GetFirstPropertyULONG32(pszPropName, ulPropValue)) { pStreamHeader->SetPropertyULONG32(pszPropName, ulPropValue); while (HXR_OK == pHeader->GetNextPropertyULONG32(pszPropName, ulPropValue)) { pStreamHeader->SetPropertyULONG32(pszPropName, ulPropValue); } } // copy all the buffer attributes if (HXR_OK == pHeader->GetFirstPropertyBuffer(pszPropName, (IHXBuffer*&)pPropValueSource)) { if (HXR_OK == CreateAndSetBufferCCF(pPropValueTarget, pPropValueSource->GetBuffer(), pPropValueSource->GetSize(), m_pPlayer)) { pStreamHeader->SetPropertyBuffer(pszPropName, pPropValueTarget); HX_RELEASE(pPropValueTarget); } HX_RELEASE(pPropValueSource); while (HXR_OK == pHeader->GetNextPropertyBuffer(pszPropName, (IHXBuffer*&)pPropValueSource)) { if (HXR_OK == CreateAndSetBufferCCF(pPropValueTarget, pPropValueSource->GetBuffer(), pPropValueSource->GetSize(), m_pPlayer)) { pStreamHeader->SetPropertyBuffer(pszPropName, pPropValueTarget); HX_RELEASE(pPropValueTarget); } HX_RELEASE(pPropValueSource); } } // copy all the CString attributes if (HXR_OK == pHeader->GetFirstPropertyCString(pszPropName, (IHXBuffer*&)pPropValueSource)) { if (HXR_OK == CreateAndSetBufferCCF(pPropValueTarget, pPropValueSource->GetBuffer(), pPropValueSource->GetSize(), m_pPlayer)) { pStreamHeader->SetPropertyCString(pszPropName, pPropValueTarget); HX_RELEASE(pPropValueTarget); } HX_RELEASE(pPropValueSource); while (HXR_OK == pHeader->GetNextPropertyCString(pszPropName, (IHXBuffer*&)pPropValueSource)) { if (HXR_OK == CreateAndSetBufferCCF(pPropValueTarget, pPropValueSource->GetBuffer(), pPropValueSource->GetSize(), m_pPlayer)) { pStreamHeader->SetPropertyCString(pszPropName, pPropValueTarget); HX_RELEASE(pPropValueTarget); } HX_RELEASE(pPropValueSource); } } HX_RELEASE(pHeader); // modify some values pStreamHeader->SetPropertyULONG32("StreamNumber", ulStreamIndex); // the stream is recordable as long as there is one renderer supports // IHXPacketHookHelper. Multiple renderers can serve the packets with // the same stream number on it, One solution for this is to choose the // first renderer which supports IHXPacketHookHelper as the only source ulRenderers = pStream->GetRendererCount(); for (k = 0; k < ulRenderers; k++) { IUnknown* pUnknown = NULL; IHXPacketHookHelper* pPacketHookHelper = NULL; pStream->GetRenderer(k, pUnknown); if (HXR_OK == pUnknown->QueryInterface(IID_IHXPacketHookHelper, (void**)&pPacketHookHelper)) { bRecordable = TRUE; pPacketHookHelper->StartHook(ulStreamIndex, 0, new PacketHookHelperResponse(this, ulStreamIndex)); } HX_RELEASE(pPacketHookHelper); HX_RELEASE(pUnknown); } if (bRecordable) { m_ulRecordableStreams++; } pStreamHeader->SetPropertyULONG32("Recordable", (ULONG32)bRecordable); /* * It's possible that StartHook will cause the m_pPacketHook to * be released */ if (!m_pPacketHook) { hr = HXR_UNEXPECTED; goto cleanup; } // send stream header to its top level client hr = m_pPacketHook->OnStreamHeader(pStreamHeader); if (hr != HXR_OK) { HX_RELEASE(m_pPacketHook); goto cleanup; } ulStreamIndex++; HX_RELEASE(pStreamHeader); HX_RELEASE(pStream); } HX_RELEASE(pSource); HX_RELEASE(pUnknown); } cleanup: HX_RELEASE(pTitle); HX_RELEASE(pAuthor); HX_RELEASE(pCopyright); HX_RELEASE(pFileHeader); return hr; }
IHXValues* DataRevertController::InflateConvertHeader(IHXBuffer* pInflate) { IHXValues* pNewHeader = NULL; IHXCommonClassFactory* pCCF; m_pContext->QueryInterface(IID_IHXCommonClassFactory, (void**)&pCCF); pCCF->CreateInstance(CLSID_IHXValues, (void**)&pNewHeader); ULONG32 ul; IHXBuffer* pBuffer; const char* p; IHXBuffer* pTemp; ULONG32 ulTemp; pCCF->CreateInstance(CLSID_IHXBuffer, (void**)&pTemp); UINT32 limit = pInflate->GetSize(); UINT32 i = 0; p = (const char*)pInflate->GetBuffer(); while (i < pInflate->GetSize() - 5) { if (p[i] == 'u') { i++; ulTemp = getlong((UINT8*) &(p[i])); i += 4; if (i + ulTemp > limit) { goto error; } pTemp->SetSize(ulTemp + 1); memcpy((char *)pTemp->GetBuffer(), &(p[i]), ulTemp); /* Flawfinder: ignore */ ((char*)pTemp->GetBuffer())[ulTemp] = 0; i += ulTemp; if (i + 4 > limit) { goto error; } ul = getlong((UINT8*) &(p[i])); i += 4; pNewHeader->SetPropertyULONG32((char*)pTemp->GetBuffer(), ul); } else if (p[i] == 's' || p[i] == 'b') { int at = i; i++; ulTemp = getlong((UINT8*) &(p[i])); i += 4; if (i + ulTemp > limit) { goto error; } pTemp->SetSize(ulTemp + 1); memcpy((char*)pTemp->GetBuffer(), &(p[i]), ulTemp); /* Flawfinder: ignore */ ((char*)pTemp->GetBuffer())[ulTemp] = 0; i += ulTemp; if (i + 4 > limit) { goto error; } ulTemp = getlong((UINT8*) &(p[i])); i += 4; if (i + ulTemp > limit) { goto error; } pCCF->CreateInstance(CLSID_IHXBuffer, (void**)&pBuffer); pBuffer->SetSize(ulTemp); memcpy((char*)pBuffer->GetBuffer(), &(p[i]), ulTemp); /* Flawfinder: ignore */ if (p[at] == 's') { pNewHeader->SetPropertyCString((const char*)pTemp->GetBuffer(), pBuffer); } else { pNewHeader->SetPropertyBuffer((const char*)pTemp->GetBuffer(), pBuffer); } pBuffer->Release(); i+= ulTemp; } else { goto error; } } if (i != pInflate->GetSize()) { goto error; } goto exit; error:; exit:; HX_RELEASE(pTemp); HX_RELEASE(pCCF); return pNewHeader; }