HX_RESULT CBaseArchiver2::UpdateStatusULONG32(HX_RESULT status, const char* pValueName, ULONG32 ulValue) { IHXValues* pStatus = NULL; HX_RESULT retVal; retVal = m_pClassFactory->CreateInstance(IID_IHXValues, (void**) &pStatus); if (SUCCEEDED(retVal)) { retVal = pStatus->SetPropertyULONG32(pValueName, ulValue); } if (SUCCEEDED(retVal)) { retVal = m_pMonitor->OnStatus(status, pStatus); } else { retVal = m_pMonitor->OnStatus(HXR_OUTOFMEMORY, NULL); } HX_RELEASE(pStatus); return retVal; }
HX_RESULT CBaseArchiver2::NotifyTempFileCreated(const char* pszTempFileName) { // Need to notify clients of the writer of the name of the temp file // This is a feature for the player team that enables them to play // back the temp files while encoding/writing the files. HX_RESULT res = HXR_OK; if(pszTempFileName) { IHXValues* pStatusInfo = NULL; CreateValuesCCF(pStatusInfo, m_pClassFactory); HX_ASSERT(pStatusInfo); if(pStatusInfo) { IHXBuffer* pBufTempFile = NULL; CreateBufferCCF(pBufTempFile, m_pContext); HX_ASSERT(pBufTempFile); if(pBufTempFile) { res = pBufTempFile->Set((UCHAR*)pszTempFileName, strlen(pszTempFileName) + 1); HX_ASSERT(SUCCEEDED(res)); if(SUCCEEDED(res)) { res = pStatusInfo->SetPropertyCString("TempFileName", pBufTempFile); HX_ASSERT(SUCCEEDED(res)); if(SUCCEEDED(res)) { // Send back the name of the temp file created m_pMonitor->OnStatus(HXR_OK, pStatusInfo); } } HX_RELEASE(pBufTempFile); } else { res = HXR_OUTOFMEMORY; } HX_RELEASE(pStatusInfo); } else { res = HXR_OUTOFMEMORY; } } else { res = HXR_POINTER; } return res; }
// helper static bool IsRealNetworksPlugin(HXPlugin* pPlugin) { bool isRNPlugin = false; HX_ASSERT(pPlugin); IHXValues* pval = 0; if (SUCCEEDED(pPlugin->GetPluginInfo(pval))) { IHXBuffer* pbuff = 0; if (SUCCEEDED(pval->GetPropertyCString(PLUGIN_DESCRIPTION2, pbuff))) { isRNPlugin = (0 != strstr((const char*)pbuff->GetBuffer(), "RealNetworks")); HX_RELEASE(pbuff); } HX_RELEASE(pval); } return isRNPlugin; }
void PlayerDriver::SetConfig(const char* pPropName, UINT16 bValue) { IHXCommonClassFactory* pCCF = NULL; m_pContext->QueryInterface(IID_IHXCommonClassFactory, (void**)&pCCF); if (pCCF) { IHXValues* pValues = NULL; pCCF->CreateInstance(CLSID_IHXValues, (void**)&pValues); if (pValues) { pValues->SetPropertyULONG32(pPropName, bValue); if (m_pClientState) { m_pClientState->SetConfig(pValues); } HX_RELEASE(pValues); } HX_RELEASE(pCCF); } }
/* * returns TRUE if it finds the rule under propID * propID should be the ID for "config.Multicast.ControlList.???" */ BOOL MulticastRuleChain::_findRule(ULONG32 propID) { IHXValues* props = NULL; const char* propName = NULL; if (SUCCEEDED(m_registry->GetPropList(propID, props, m_proc))) { if (SUCCEEDED(props->GetFirstPropertyULONG32(propName, propID))) { // no need for a default HX_RELEASE(props); return TRUE; } else { // <Var Allow="???"/> is missing... } } HX_RELEASE(props); return FALSE; }
void DataRevertController::CleanStreamHeaders() { IHXValues* pHeader; if (m_pStreamHeaders) { while (!m_pStreamHeaders->IsEmpty()) { pHeader = (IHXValues*)m_pStreamHeaders->RemoveHead(); pHeader->Release(); } delete m_pStreamHeaders; } if (m_pRevertedStreamHeaders) { while (!m_pRevertedStreamHeaders->IsEmpty()) { pHeader = (IHXValues*)m_pRevertedStreamHeaders->RemoveHead(); pHeader->Release(); } delete m_pRevertedStreamHeaders; } }
void GetHTTPPaths(HXRegistry* hxreg, char* pCharListName, char**& pHTTPablePaths) { IHXValues* pHTTPPath = 0; HX_RESULT res = HXR_OK; if (HXR_OK == hxreg->GetPropListByName(pCharListName, pHTTPPath)) { const char* name; UINT32 id; UINT32 ulCount = 0; res = pHTTPPath->GetFirstPropertyULONG32(name, id); while(res == HXR_OK) { ulCount++; res = pHTTPPath->GetNextPropertyULONG32(name, id); } pHTTPablePaths = new char*[ulCount + 1]; UINT32 i = 0; res = pHTTPPath->GetFirstPropertyULONG32(name, id); while(res == HXR_OK) { IHXBuffer* pBuf = 0; if(HXR_OK == hxreg->GetStrById(id, pBuf)) { pHTTPablePaths[i] = new_string((const char *)pBuf->GetBuffer()); i++; HX_RELEASE(pBuf); } res = pHTTPPath->GetNextPropertyULONG32(name, id); } pHTTPablePaths[i] = 0; pHTTPPath->Release(); } }
HX_RESULT MulticastRuleChain::_createMulticastRuleChain() { HX_RESULT res = HXR_OK; IHXValues* props = 0; const char* propName = 0; // here it represents the rule number ULONG32 propID = 0; MulticastACRule* rule = 0; int i = 0; // if we need to, make a default rule in the registry, so the rest of the // process can take place. _makeDefaultRule(); res = m_registry->GetPropList("config.Multicast.ControlList", props, m_proc); /* * XXXAAK -- remember to change ServerRegistry::_getPropList() * to return NULL (IHXValues *) in case the property does not exist */ if (SUCCEEDED(res) && props) { props->GetFirstPropertyULONG32(propName, propID); if (!propName || !propID) { res = HXR_FAIL; goto endInit; } // printf("creating rule chain\n"); while(propName && propID) { // printf("rule %d detected\n", m_numRules); rule = _parseRule(propName, propID); if (rule) m_rules[m_numRules++] = rule; propName = 0; propID = 0; props->GetNextPropertyULONG32(propName, propID); } // printf("total %d rules\n", m_numRules); if (m_numRules) { ::qsort(m_rules, m_numRules, sizeof(MulticastACRule *), _mcastRuleCompare); m_beginIdx = m_numRules; m_endIdx = 0; } } else { // now that we are making a default, it shouldn't get here HX_ASSERT(!"ControlList missing..."); res = HXR_FAIL; } endInit: // printf("_createMulticastRuleChain() returns %lu\n", res); HX_RELEASE(props); return res; }
/************************************************************************ * IHXActivePropUser::SetActiveStr * * Async request to set string pName to string in pBuffer. */ STDMETHODIMP HTTPDeliverablePrefController::SetActiveStr(const char* pName, IHXBuffer* pBuffer, IHXActivePropUserResponse* pResponse) { /* * Get everything under HTTPDeliverable. */ IHXValues* pHTTPPath = 0; IHXBuffer* pBuf = 0; char** pNewHTTPD; HX_RESULT res; const char* name; UINT32 ul; int i; /* * If the list is already in the reg, then we have to merge * our new stuff to set with the stuff from the reg. */ if (HXR_OK == m_proc->pc->registry->GetPropList( m_pCharListName, pHTTPPath, m_proc)) { UINT32 ulNumPaths = 0; res = pHTTPPath->GetFirstPropertyULONG32(name, ul); while (res == HXR_OK) { ulNumPaths++; res = pHTTPPath->GetNextPropertyULONG32(name, ul); } /* * If we are changing one that is already there... */ if (HXR_OK == pHTTPPath->GetPropertyULONG32( pName, ul)) { pNewHTTPD = new char* [ulNumPaths+1]; i = 0; res = pHTTPPath->GetFirstPropertyULONG32(name, ul); while (res == HXR_OK) { pBuf = 0; /* * If this is the one we are changing... */ if (!strcasecmp(name, pName)) { pNewHTTPD[i] = new_string( (const char*)pBuffer->GetBuffer()); } else { m_proc->pc->registry->GetStr(name, pBuf, m_proc); if (!pBuf) { i--; } else { pNewHTTPD[i] = new_string( (const char*)pBuf->GetBuffer()); pBuf->Release(); } } i++; res = pHTTPPath->GetNextPropertyULONG32(name, ul); } pNewHTTPD[i] = 0; } /* * We must be adding one... */ else { pNewHTTPD = new char* [ulNumPaths+2]; i = 0; res = pHTTPPath->GetFirstPropertyULONG32(name, ul); while (res == HXR_OK) { pBuf = 0; m_proc->pc->registry->GetStr(name, pBuf, m_proc); if (pBuf) { pNewHTTPD[i] = new_string( (const char*)pBuf->GetBuffer()); pBuf->Release(); i++; } res = pHTTPPath->GetNextPropertyULONG32(name, ul); } pNewHTTPD[i++] = new_string((const char*)pBuffer->GetBuffer()); pNewHTTPD[i] = 0; } } /* * It was not in the reg, so this is the only one. */ else { pNewHTTPD = new char* [2]; pNewHTTPD[0] = new_string((const char*)pBuffer->GetBuffer()); pNewHTTPD[1] = 0; } /* * Clean up the old one. */ if (m_HTTP_paths && *m_HTTP_paths) { i = 0; while ((*m_HTTP_paths)[i]) { delete[] (*m_HTTP_paths)[i]; i++; } delete[] (*m_HTTP_paths); } *m_HTTP_paths = pNewHTTPD; pResponse->SetActiveStrDone(HXR_OK, pName, pBuffer, 0, 0); return HXR_OK; }
/************************************************************************ * IHXActivePropUser::DeleteActiveProp * * Async request to delete the active property. */ STDMETHODIMP HTTPDeliverablePrefController::DeleteActiveProp(const char* pName, IHXActivePropUserResponse* pResponse) { IHXValues* pHTTPPath; char** pNewHTTPD = 0; const char* name; UINT32 ul; UINT32 ulNumPaths = 0; HX_RESULT res; int i; IHXBuffer* pBuf = 0; if (HXR_OK == m_proc->pc->registry->GetPropList( m_pCharListName, pHTTPPath, m_proc)) { if (HXR_OK == pHTTPPath->GetPropertyULONG32(pName, ul)) { /* * Count the number of current paths. */ res = pHTTPPath->GetFirstPropertyULONG32(name, ul); while (res == HXR_OK) { ulNumPaths++; res = pHTTPPath->GetNextPropertyULONG32(name, ul); } pNewHTTPD = new char* [ulNumPaths]; i = 0; res = pHTTPPath->GetFirstPropertyULONG32(name, ul); while (res == HXR_OK) { pBuf = 0; /* * If this is the one we want to delete, then just * skip over it in the copy. */ if (strcasecmp(name, pName)) { m_proc->pc->registry->GetStr(name, pBuf, m_proc); if (pBuf) { pNewHTTPD[i] = new_string( (const char*)pBuf->GetBuffer()); pBuf->Release(); i++; } } res = pHTTPPath->GetNextPropertyULONG32(name, ul); } pNewHTTPD[i] = 0; /* * Clean up the old one and set it to the new one. */ if (m_HTTP_paths && *m_HTTP_paths) { i = 0; while ((*m_HTTP_paths)[i]) { delete[] (*m_HTTP_paths)[i]; i++; } delete[] (*m_HTTP_paths); } *m_HTTP_paths = pNewHTTPD; pNewHTTPD = 0; } } pResponse->DeleteActivePropDone(HXR_OK, pName, 0, 0); return HXR_OK; }
HXASMStream::HXASMStream(HXStream* pStream, HXSource* pSource) : m_bTimeStampDeliveryMode(FALSE) , m_bInitialSubscribe(TRUE) , m_bHasExpression(FALSE) , m_bEndOneRuleEndAll(FALSE) , m_ulLastLimitBandwidth(0xffffffff) , m_lRefCount(0) , m_nNumRules(0) , m_pAtomicRuleChange(0) , m_pRuleBook(0) , m_pLossCB(0) , m_ulLossCBHandle(0) , m_ulBandwidthAllocation(0) , m_ulFixedBandwidth(0) , m_pSubInfo(0) , m_ulRuleBw(0) , m_ulRulePreData(0) , m_ulCurrentPreData(0) , m_ulCurrentBandwidth(0) , m_ulLastBandwidth(0) , m_bRuleTimeStampDelivery(0) , m_ulSubscribedBw(0) , m_lBias(0) , m_bStartRecalc(FALSE) , m_pSubList(0) , m_pSubscriptionVariables(0) , m_pRuleSubscribeStatus(NULL) , m_pASMRuleState(NULL) , m_pRuleEnableState(NULL) , m_bSubsLocked(FALSE) #ifndef GOLD , m_pEM(0) #endif { m_pStreamSinkMap = new CHXMapPtrToPtr; UINT32 ulStreamID; IHXPlayer* pPlayer; pStream->GetID(ulStreamID); m_pSource = pSource; m_pSource->AddRef(); m_pHeader = pStream->GetHeader(); m_uStreamNumber = pStream->GetStreamNumber(); /* Hold onto some useful interfaces */ m_pSource->GetPlayer(pPlayer); pPlayer->QueryInterface(IID_IHXRegistry, (void **)&m_pRegistry); pPlayer->QueryInterface(IID_IHXScheduler, (void **)&m_pScheduler); pPlayer->QueryInterface(IID_IHXCommonClassFactory, (void **)&m_pCCF); pPlayer->Release(); /* * WARNING! You must update all interfaces queried off the source * in ResetASMSource(). */ m_pSource->QueryInterface(IID_IHXASMSource, (void **)&m_pASMSource); m_pSource->QueryInterface(IID_IHXAtomicRuleChange, (void **)&m_pAtomicRuleChange); #ifndef GOLD pPlayer->QueryInterface(IID_IHXErrorMessages, (void **)&m_pEM); #endif UINT32 ulEndOneruleEndAll = 0; if (m_pHeader->GetPropertyULONG32("EndOneRuleEndAll", ulEndOneruleEndAll) == HXR_OK) { m_bEndOneRuleEndAll = (ulEndOneruleEndAll == 1); } /* temporary hack to properly shut down RA and RV streams with end time */ else { IHXBuffer* pMimeType = NULL; m_pHeader->GetPropertyCString("MimeType", pMimeType); if (pMimeType && ((::strcasecmp((const char*) pMimeType->GetBuffer(), REALAUDIO_MIME_TYPE) == 0) || (::strcasecmp((const char*) pMimeType->GetBuffer(), REALAUDIO_MULTIRATE_MIME_TYPE) == 0) || (::strcasecmp((const char*) pMimeType->GetBuffer(), REALVIDEO_MIME_TYPE) == 0) || (::strcasecmp((const char*) pMimeType->GetBuffer(), REALVIDEO_MULTIRATE_MIME_TYPE) == 0))) { m_bEndOneRuleEndAll = TRUE; } HX_RELEASE(pMimeType); } /* Extract RuleBook from the stream header */ IHXBuffer* pRuleBook = NULL; m_pHeader->GetPropertyCString("ASMRuleBook", pRuleBook); if (pRuleBook) { m_pRuleBook = new ASMRuleBook (m_pCCF, (const char *)pRuleBook->GetBuffer()); m_nNumRules = m_pRuleBook->GetNumRules(); m_ulRuleBw = new UINT32[m_nNumRules]; m_ulRulePreData = new UINT32[m_nNumRules]; m_bRuleTimeStampDelivery = new HXBOOL[m_nNumRules]; m_pSubInfo = new HXBOOL[m_nNumRules]; m_pRuleSubscribeStatus = new HXBOOL[m_nNumRules]; m_pRuleEnableState = new RuleEnableState[m_nNumRules]; for (UINT16 i = 0; i < m_nNumRules; i++) { IHXValues* pValues; IHXBuffer* pBuffer; m_pRuleBook->GetProperties(i, pValues); m_ulRuleBw[i] = 0; m_ulRulePreData[i] = 0; m_bRuleTimeStampDelivery[i] = FALSE; m_pRuleEnableState[i] = resEnabled; if (HXR_OK == pValues->GetPropertyCString("PreData", pBuffer)) { m_ulRulePreData[i] = atoi((char*)pBuffer->GetBuffer()); pBuffer->Release(); } if (HXR_OK == pValues->GetPropertyCString("AverageBandwidth", pBuffer)) { m_ulRuleBw[i] = atoi((char*)pBuffer->GetBuffer()); pBuffer->Release(); } else if (HXR_OK == pValues->GetPropertyCString("TimeStampDelivery", pBuffer)) { if ((pBuffer->GetBuffer()[0] == 'T') || (pBuffer->GetBuffer()[0] == 't')) { // Handle TimeStamp Delivery (i.e. assume significant bandwidth) m_ulRuleBw[i] = 0; m_bRuleTimeStampDelivery[i] = TRUE; } pBuffer->Release(); } else { /* XXXSMP Temporary hack for invalid rulebooks */ if (i == 0) { IHXValues* pHeader = 0; HX_VERIFY(pHeader = pStream->GetHeader()); pHeader->GetPropertyULONG32("AvgBitRate",m_ulRuleBw[i]); pHeader->Release(); } else { m_ulRuleBw[i] = 0; } } pValues->Release(); m_pSubInfo[i] = 0; m_pRuleSubscribeStatus[i] = FALSE; } HXBOOL bFixed = TRUE; m_bHasExpression = m_pRuleBook->HasExpression(); if (m_bHasExpression == FALSE) { UINT16 i; for (i = 0; i < m_nNumRules; i++) { if (m_bRuleTimeStampDelivery[i] == FALSE) { bFixed = FALSE; break; } } if (bFixed) { m_ulFixedBandwidth = 1; } else { m_ulCurrentBandwidth = 0; for (i = 0; i < m_nNumRules; i++) { m_ulCurrentBandwidth += m_ulRuleBw[i]; } m_ulFixedBandwidth = m_ulCurrentBandwidth; } } } else { IHXValues* pHeader = 0; HX_VERIFY(pHeader = pStream->GetHeader()); HX_VERIFY(HXR_OK == pHeader->GetPropertyULONG32("AvgBitRate", m_ulFixedBandwidth)); m_ulCurrentBandwidth = m_ulFixedBandwidth; pHeader->Release(); } /* Get Registry ID's for interesting properties */ IHXBuffer* pPropName = 0; // init. memset(m_szRecv, 0, MAX_DISPLAY_NAME); memset(m_szLost, 0, MAX_DISPLAY_NAME); memset(m_szClipBandwidth, 0, MAX_DISPLAY_NAME); if( m_pRegistry ) { m_pRegistry->GetPropName(ulStreamID, pPropName); } if (pPropName) { SafeSprintf(m_szRecv, MAX_DISPLAY_NAME, "%s.received", pPropName->GetBuffer()); m_ulIDRecv = m_pRegistry->GetId(m_szRecv); SafeSprintf(m_szLost, MAX_DISPLAY_NAME, "%s.lost", pPropName->GetBuffer()); m_ulIDLost = m_pRegistry->GetId(m_szLost); SafeSprintf(m_szClipBandwidth, MAX_DISPLAY_NAME, "%s.ClipBandwidth", pPropName->GetBuffer()); m_ulIDClipBandwidth = m_pRegistry->GetId(m_szClipBandwidth); pPropName->Release(); } /* * We consider Local source as a Network source IFF someone uses core * for simulated network playback (used for Preview mode in the Encoder) */ if (pSource->IsLocalSource() && !pSource->IsSimulatedNetworkPlayback()) { /* Some large bandwidth */ m_ulBandwidthAllocation = 0x7FFFFFFF; HXBOOL b; SetBandwidthUsage(m_ulBandwidthAllocation, b); } else if (pSource->IsPNAProtocol()) { IHXBuffer* pMimeType = NULL; m_pHeader->GetPropertyCString("MimeTYpe", pMimeType); if (pMimeType && ::strcasecmp((const char*) pMimeType->GetBuffer(), "audio/x-pn-realaudio") == 0) { /* Some large bandwidth */ m_ulBandwidthAllocation = 0x7FFFFFFF; HXBOOL b; SetBandwidthUsage(m_ulBandwidthAllocation, b); } HX_RELEASE(pMimeType); } else if (pRuleBook) { m_pLossCB = new LossCheckCallback(this); m_pLossCB->AddRef(); m_ulLossCBHandle = m_pScheduler->RelativeEnter(m_pLossCB, 1000); } HX_RELEASE(pRuleBook); }
/* * IHXBroadcastMapperResponse */ STDMETHODIMP BasicSourceFinder::BroadcastTypeFound(HX_RESULT status, const char* pType) { if (SF_CLOSED == m_findState) { return HXR_OK; } m_CurrentSourceType = pType; HX_ASSERT(m_pBroadcastMapper); HX_RELEASE(m_pBroadcastMapper); PluginHandler::BroadcastFormat* broadcast_handler; PluginHandler::Errors plugin_result; PluginHandler::Plugin* plugin; broadcast_handler = m_pProc->pc->plugin_handler->m_broadcast_handler; plugin_result = broadcast_handler->Find(pType, plugin); if(PluginHandler::NO_ERRORS != plugin_result) { ERRMSG(m_pProc->pc->error_handler, "No live handler for %s\n", pType?pType:"(null)"); return HXR_FAIL; } /* * Depending on a request */ HX_RESULT theErr = HXR_FAIL; IHXPSourceControl* pSource = NULL; IHXValues* pVal = NULL; IHXBuffer* pBuf = NULL; const char* pFileName = m_pURL->name + m_pFSManager->m_mount_point_len - 1; UINT32 bUseSourceContainer = FALSE; BOOL bUseMediaDeliveryPipeline = FALSE; /* XXDWL * For live (broadcast) sessions, the media delivery pipeline needs to be turned off. * This is a temporary solution until a number of issues dealing with timestamp * dependent media, and ASM rule handling are worked out. * See also: server/engine/session/player.cpp:1947 bUseMediaDeliveryPipeline = m_pPlayerSession->m_bUseMediaDeliveryPipeline; */ #if NOTYET /* XXTDM * According to ghori, this was an attempt to merge the various source * finding code into one place. Due to time constraints, it was never * finished. Therefore, this code is currently unused and untested. */ theErr = m_pRequest->GetRequestHeaders(FS_HEADERS, pVal); if (HXR_OK == theErr) { theErr = pVal->GetPropertyULONG32("UseSourceContainer", bUseSourceContainer); if (HXR_OK != theErr) { bUseSourceContainer = FALSE; } theErr = pVal->GetPropertyCString("BroadcastAlias", pBuf); if (HXR_OK == theErr) { pFileName = (const char*)pBuf->GetBuffer(); } } #endif /* NOTYET */ HX_ASSERT(pFileName); theErr = m_pProc->pc->broadcast_manager->GetStream(pType, pFileName, pSource, m_pProc, bUseMediaDeliveryPipeline, m_pPlayerSession ? m_pPlayerSession->GetSessionStats() : NULL); if (HXR_OK == theErr) { if (bUseSourceContainer) { SourceContainer* pContainer = new SourceContainer(m_pProc->pc->server_context, pSource); if (pContainer) { pContainer->AddRef(); FindSourceDone(HXR_OK, (IUnknown*)(IHXPSinkPackets*)pContainer); pContainer->Release(); } else { theErr = HXR_OUTOFMEMORY; HX_RELEASE(pSource); } } } FindSourceDone(theErr, pSource); HX_RELEASE(pSource); HX_RELEASE(pVal); HX_RELEASE(pBuf); return HXR_OK; }
void WebkitClientAdviseSink::GetClipInfo() { // Get HXSource and try to get clip infor. UINT32 sourceCount = m_pPlayer->GetSourceCount(); for (UINT32 sourceID = 0; sourceID < sourceCount; sourceID ++) { // get HXSource IUnknown* pUnkSource = NULL; IHXStreamSource* pStreamSrc = NULL; if (HXR_OK != m_pPlayer->GetSource (sourceID, pUnkSource)) { continue; } IHXValues* pFileHeader = NULL; if ( HXR_OK == pUnkSource->QueryInterface( IID_IHXValues, ( void ** )&pFileHeader ) ) { /* IHXBuffer* pAutoLoopingBuf = NULL; if ( HXR_OK == pFileHeader->GetPropertyBuffer( "Webkit_LOOP", pAutoLoopingBuf ) ) { if ( 0 == strcmp( pAutoLoopingBuf->GetBuffer(), "true" ) ) { m_pWebkitContext->SetAutoLooping( TRUE ); } } HX_RELEASE( pAutoLoopingBuf ); */ static const char * PROPERTY_NAMES[] = { "LiveStream", "HttpLiveStream", "AdaptiveHTTP" }; UINT32 ulTmp = 0; for (int i = 0; i < sizeof(PROPERTY_NAMES)/sizeof(const char *); ++i) { pFileHeader->GetPropertyULONG32(PROPERTY_NAMES[i], ulTmp); if (ulTmp) { m_bIsLiveOrAdaptiveHTTP = TRUE; break; } } } HX_RELEASE( pFileHeader ); pUnkSource->QueryInterface(IID_IHXStreamSource, (void **)&pStreamSrc); HX_RELEASE(pUnkSource); if (!pStreamSrc) { continue; } UINT32 num_streams = pStreamSrc->GetStreamCount(); // get information from Streams for (UINT32 streamID = 0; streamID < num_streams ; streamID++) { IUnknown* pUnkStream = NULL; if (HXR_OK == pStreamSrc->GetStream(streamID, pUnkStream)) { IHXStream* pStream = NULL; if (HXR_OK == pUnkStream->QueryInterface(IID_IHXStream, (void**)&pStream)) { IHXValues* pStreamHdr = pStream->GetHeader(); if (pStreamHdr) { SendClipProperties(pStreamHdr); } HX_RELEASE(pStreamHdr); } HX_RELEASE(pStream); } HX_RELEASE(pUnkStream); } HX_RELEASE(pStreamSrc); } }
/************************************************************************ * Method: * IHXSiteManager::AddSite */ STDMETHODIMP CHXSiteManager::AddSite(IHXSite* pSite) { IHXValues* pProps = NULL; IHXBuffer* pValue = NULL; char* pActualString = NULL; HRESULT hresTemp; HRESULT hresFinal = HXR_OK; HXBOOL bIsPersistent = FALSE; if (m_pContext) { // Give sites the same context as the site manager to allow sites to obtain // services specific to the environment in which they are managed (e.g. IHXCientEngine). IHXObjectConfiguration* pObjectConfiguration = NULL; if (HXR_OK == pSite->QueryInterface(IID_IHXObjectConfiguration, (void**) &pObjectConfiguration)) { pObjectConfiguration->SetContext(m_pContext); } HX_RELEASE(pObjectConfiguration); } /* * We need to get the IHXValues for the site so we know it * its for by LSGName or for by plattofrom use. If this is not * available then barf up an error. */ hresTemp = pSite->QueryInterface(IID_IHXValues,(void**)&pProps); if (HXR_OK != hresTemp) { hresFinal = hresTemp; goto exit; } /* * let's see if this is a persistent site... */ hresTemp = pProps->GetPropertyCString("Persistent",pValue); if(HXR_OK == hresTemp) { bIsPersistent = TRUE; HX_RELEASE(pValue); } /* * Now let's determine if it's by LSGName or by playtofrom. * If one of these is not available then barf up an error. */ /* * If the "LayoutGroup" property exists than this is * a site for layout groups by LSGName. */ hresTemp = pProps->GetPropertyCString("LayoutGroup",pValue); if (HXR_OK == hresTemp) { pActualString = (char*)pValue->GetBuffer(); if(bIsPersistent) { hresFinal = AddSiteByStringHelper(pActualString, pSite, m_PersistentLSGNamesToLists); } else { hresFinal = AddSiteByStringHelper(pActualString, pSite, m_LSGNamesToLists); } goto exit; } /* * If the "channel" property exists than this is * a site for renderers playing to a channel. */ hresTemp = pProps->GetPropertyCString("channel",pValue); if (HXR_OK == hresTemp) { pActualString = (char*)pValue->GetBuffer(); if(bIsPersistent) { hresFinal = AddSiteByStringHelper(pActualString, pSite, m_PersistentChannelsToLists); } else { hresFinal = AddSiteByStringHelper(pActualString, pSite, m_ChannelsToLists); } goto exit; } #if 0 ////// NOT YET SUPPORTED //////// /* * If the "playfrom" property exists than this is * a site for renderers playing from a source/stream combo. * Notice that more properties than just "playfrom" are needed * to do the actual hookup so we pass the properties in as well. */ hresTemp = pProps->GetPropertyCString("playfrom",pValue); if (HXR_OK == hresTemp) { hresFinal = AddSiteByPlayFrom(pProperties,pSite); goto exit; } #endif exit: /* * Cleanup any temporary objects.... */ HX_RELEASE(pProps); HX_RELEASE(pValue); // hookup any leftover orphan value/sites (pending)... // first process the LSG list HookupHelper(&m_PendingValueToSULSG, pActualString, bIsPersistent, SITE_USER_SUPPLIER, HOOKUP_BY_LSGNAMEWITHSTRING); // next process the Single LSG list HookupHelper(&m_PendingValueToSUSingleLSG, pActualString, bIsPersistent, SITE_USER, HOOKUP_SINGLESITE_BY_LSGNAMEWITHSTRING); // next process play to list HookupHelper(&m_PendingValueToSUPlayTo, pActualString, bIsPersistent, SITE_USER_SUPPLIER, HOOKUP_BY_PLAYTOFROMWITHSTRING); // next process the Single LSG list HookupHelper(&m_PendingValueToSUSinglePlayTo, pActualString, bIsPersistent, SITE_USER, HOOKUP_SINGLESITE_BY_PLAYTOFROMWITHSTRING); #ifdef _WINDOWS if (m_bNeedFocus && pSite) { IHXSiteWindowless* pWindowLess = NULL; IHXSiteWindowed* pWindowed = NULL; pSite->QueryInterface(IID_IHXSiteWindowless, (void**) &pWindowLess); if (pWindowLess) { pWindowLess->QueryInterface(IID_IHXSiteWindowed, (void**) &pWindowed); } if (pWindowed) { HXxWindow* pWindow = pWindowed->GetWindow(); if (pWindow && pWindow->window) { // same logic exists in pnvideo/win/winsite.cpp: _SetFocus() HWND hTmp = ::GetForegroundWindow(); if( ::IsChild(hTmp, (HWND)pWindow->window )) { ::SetFocus((HWND)pWindow->window); } } } HX_RELEASE(pWindowLess); HX_RELEASE(pWindowed); } #endif return hresFinal; }
/* * Make a default rule of "any" if necessary. * It assumes "config.Multicast.ControlList" is present in the registy */ HX_RESULT MulticastRuleChain::_makeDefaultRule() { HX_RESULT res = HXR_OK; IHXValues* props = 0; const char* propName = 0; ULONG32 propID = 0; IHXBuffer* pBuf = 0; UINT32 ul = 0; CHXString str; /* * This is how it looks like... <List Name="Multicast"> <List Name="ControlList"> <List Name="100"> <Var Allow="any"/> </List> </List> </List> */ // create the right registry entry if we need to. Figoure out if we need to // do this at all as well! if (SUCCEEDED(m_registry->GetPropList("config.Multicast.ControlList", props, m_proc))) { // we need to make sure there is at least one good entry in the list if (SUCCEEDED(props->GetFirstPropertyULONG32(propName, propID))) { if (_findRule(propID)) { // found a rule...no need for a default. HX_RELEASE(props); res = HXR_OK; goto bail; } else { // try to see if there is any other entry under ControlList while (SUCCEEDED(props->GetNextPropertyULONG32(propName, propID))) { if (_findRule(propID)) { HX_RELEASE(props); res = HXR_OK; goto bail; } } } } HX_RELEASE(props); } else { // need to see what's in the registry if (FAILED(m_registry->GetPropList("config.Multicast", props, m_proc))) { HX_ASSERT(!props); // there is no Multicast section....Add it if (!m_registry->AddComp("config.Multicast", m_proc)) { // there is nothing we can do... res = HXR_FAIL; goto bail; } } HX_RELEASE(props); if (FAILED(m_registry->GetPropList("config.Multicast.ControlList", props, m_proc))) { HX_ASSERT(!props); if (!m_registry->AddComp("config.Multicast.ControlList", m_proc)) { // there is nothing we can do... res = HXR_FAIL; goto bail; } } HX_RELEASE(props); } // shouldn't make a default if there is a list HX_ASSERT(!m_numRules); // put a default entry in a registry, so the rest of the process can take // place. Try at most 100 times do { ul += 100; str.Format("config.Multicast.ControlList.%u", ul); } while (!m_registry->AddComp(str, m_proc) && ul <= 10000); str += ".Allow"; res = _addDefaultRule((const char*)str); bail: HX_RELEASE(props); HX_RELEASE(pBuf); return res; }
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; }
void DataRevertController::RevertHeaders(IHXValues* pFileHeader, CHXSimpleList* pStreamHeaders, IHXValues* pResponseHeaders) { IHXBuffer* pMimeType = 0; IHXValues* pHeader; CHXSimpleList::Iterator i; char* pConversionType = NULL; IUnknown* pUnkReverter = NULL; HX_RELEASE(m_pDataRevert); i = pStreamHeaders->Begin(); if (i != pStreamHeaders->End()) { pHeader = (IHXValues*)(*i); pHeader->GetPropertyCString("MimeType", pMimeType); if (!pMimeType) { HX_ASSERT(0); goto exit; } if (strncasecmp((const char*)pMimeType->GetBuffer(), HX_CONVERT_MIME_TYPE, (int)strlen(HX_CONVERT_MIME_TYPE))) { goto exit; } pConversionType = (char*)pMimeType->GetBuffer() + strlen(HX_CONVERT_MIME_TYPE); if (m_pPlugin2Handler && HXR_OK == m_pPlugin2Handler->FindPluginUsingStrings( PLUGIN_CLASS, PLUGIN_REVERTER_TYPE, PLUGIN_REVERTER_MIME, pConversionType, NULL, NULL, pUnkReverter)) { pUnkReverter->QueryInterface(IID_IHXDataRevert, (void**)&m_pDataRevert); pUnkReverter->Release(); } if (!m_pDataRevert) { goto exit; } IHXPlugin* pPlugin; m_pDataRevert->QueryInterface(IID_IHXPlugin, (void**)&pPlugin); pPlugin->InitPlugin(m_pContext); pPlugin->Release(); HX_RELEASE(pMimeType); m_pStreamHeaders = new CHXSimpleList; m_pRevertedStreamHeaders = new CHXSimpleList; IHXBuffer* pConvertHeader = 0; for (i = pStreamHeaders->Begin(); i != pStreamHeaders->End(); ++i) { pHeader = (IHXValues*)(*i); /* * If this stream header was converted and flattened then * the one we want to give to the plugin is the result * of re-inflating that. If not, then just give the plugin * the one we already got. */ if (HXR_OK == pHeader->GetPropertyBuffer("DataConvertStreamHeader", pConvertHeader)) { pHeader = InflateConvertHeader(pConvertHeader); pConvertHeader->Release(); } else { IHXBuffer* pPreConvertMimeType; if (HXR_OK == pHeader->GetPropertyCString("PreConvertMimeType", pPreConvertMimeType)) { pHeader->SetPropertyCString("MimeType", pPreConvertMimeType); pPreConvertMimeType->Release(); } pHeader->AddRef(); } m_pStreamHeaders->AddTail((void*)pHeader); } m_pResponseHeaders = pResponseHeaders; m_pResponseHeaders->AddRef(); /* * If playing through an old proxy which does not support * initiate-session then the DataConvertBuffer will come in here. * This is not an ideal situation because only one can come in * at this point, but it's better then nothing. */ IHXBuffer* pConvertBuffer = 0; if (HXR_OK == pFileHeader->GetPropertyBuffer("DataConvertBuffer", pConvertBuffer)) { const char* pContent = (const char*)pConvertBuffer->GetBuffer(); IHXBuffer* pNewBuffer = NULL; if (HXR_OK == CreateBufferCCF(pNewBuffer, m_pContext)) { int contentLen = pConvertBuffer->GetSize(); pNewBuffer->SetSize(contentLen); int offset = BinFrom64(pContent, contentLen, (unsigned char*)pNewBuffer->GetBuffer()); pNewBuffer->SetSize(offset); ControlBufferReady(pNewBuffer); HX_RELEASE(pNewBuffer); } HX_RELEASE(pConvertBuffer); } /* * Again for file header, if the header was converted and * flattened then give to plugin the inflated version of that. * If not, then give the straight old header that we already * have. */ if (HXR_OK == pFileHeader->GetPropertyBuffer("DataConvertFileHeader", pConvertHeader)) { m_pFileHeaders = InflateConvertHeader(pConvertHeader); pConvertHeader->Release(); } else { m_pFileHeaders = pFileHeader; m_pFileHeaders->AddRef(); } m_pDataRevert->DataRevertInit(this); return; } exit:; HX_RELEASE(pMimeType); m_pControlResp->RevertHeadersDone(pFileHeader, pStreamHeaders, pResponseHeaders, FALSE); }
/************************************************************************ * Method: * IHXSiteSupplier::SitesNeeded * Purpose: * Called to inform the site supplier that a site with a particular * set of characteristics is needed. If the site supplier can * fulfill the request it should call the site manager and add one * or more new sites. * Note that the request for sites is associated with a Request ID * the client core will inform the site supplier when this requested * site is no longer needed. */ STDMETHODIMP ExampleSiteSupplier::SitesNeeded ( UINT32 uRequestID, IHXValues* pProps ) { /* * Don't create a site if the -NULL_RENDER command line option * was given. - jfarr */ if (GetGlobal()->g_bNullRender) { return (HXR_OK); } /* * If there are no properties, then we can't really create a * site, because we have no idea what type of site is desired! */ if (!pProps) { return HXR_INVALID_PARAMETER; } HRESULT hres = HXR_OK; IHXValues* pSiteProps = NULL; IHXSiteWindowed* pSiteWindowed = NULL; IHXBuffer* pValue = NULL; UINT32 style = 0; IHXSite* pSite = NULL; // Just let the RMA client core create a windowed site for us. hres = m_pCCF->CreateInstance(CLSID_IHXSiteWindowed,(void**)&pSiteWindowed); if (HXR_OK != hres) { goto exit; } hres = pSiteWindowed->QueryInterface(IID_IHXSite,(void**)&pSite); if (HXR_OK != hres) { goto exit; } if( !m_pSite ) { m_pSite = pSite; m_pSite->AddRef(); } hres = pSiteWindowed->QueryInterface(IID_IHXValues,(void**)&pSiteProps); if (HXR_OK != hres) { goto exit; } /* * We need to figure out what type of site we are supposed to * to create. We need to "switch" between site user and site * properties. So look for the well known site user properties * that are mapped onto sites... */ hres = pProps->GetPropertyCString("playto",pValue); if (HXR_OK == hres) { pSiteProps->SetPropertyCString("channel",pValue); HX_RELEASE(pValue); } else { hres = pProps->GetPropertyCString("name",pValue); if (HXR_OK == hres) { pSiteProps->SetPropertyCString("LayoutGroup",pValue); HX_RELEASE(pValue); } } #ifdef _WINDOWS style = WS_OVERLAPPED | WS_VISIBLE | WS_CLIPCHILDREN; #endif hres = pSiteWindowed->Create(NULL, style); if (HXR_OK != hres) { goto exit; } /* * We need to wait until we have set all the properties before * we add the site. */ hres = m_pSiteManager->AddSite(pSite); if (HXR_OK != hres) { goto exit; } #ifdef _WINDOWS { HXxWindow* pWindow = pSiteWindowed->GetWindow(); if (pWindow && pWindow->window) ::SetForegroundWindow( (HWND)(pWindow->window) ); } #endif m_CreatedSites.SetAt((void*)uRequestID,pSite); pSite->AddRef(); exit: HX_RELEASE(pSiteProps); HX_RELEASE(pSiteWindowed); HX_RELEASE(pSite); return hres; }
/* * Copyright (c) 1996, 1997, 1998 Real Networks * * Function Name: MulticastRuleChain::_parseRule * Input Params: const char* ruleNumStr, ULONG32 regId * Return Value: MulticastACRule* * Description: * This method takes a rule number (registry Composite property) * and the id and retrieves all the properties under it. it then * parses the info and puts it into a access rule structure which * gets returned back to the caller. * In case an error occurs while parsing, a NULL pointer is returned. */ MulticastACRule* MulticastRuleChain::_parseRule(const char* ruleNumStr, ULONG32 regId) { IHXValues* props = 0; const char* propName = 0; // here it represents the rule number ULONG32 propID = 0; MulticastACRule* rule = 0; char* ruleVar = 0; INT32 ruleNum = 0; char* strValue = 0; IHXBuffer* fromAddr = 0; IHXBuffer* netmask = 0; IHXBuffer* value = 0; ULONG32 netLongFromAddr = 0L; ULONG32 netLongFromNetmask = 0L; ULONG32 netLongFromLowerLimit = 0L; ULONG32 netLongFromUpperLimit = 0L; BOOL fromAddrIsAny = FALSE; int numProps = 0; ruleVar = (char*)strrchr(ruleNumStr, '.'); if (!ruleVar || !*ruleVar) { // printf("invalid Access rule # -- %s\n", ruleNumStr); goto fin; } ruleVar++; // advance past the '.' ruleNum = atoi(ruleVar); m_registry->GetPropList(regId, props, m_proc); if (!props) { // printf("invalid Access rule # -- %s - !props\n", ruleNumStr); goto fin; } props->GetFirstPropertyULONG32(propName, propID); if (!propName || !propID) { // printf("invalid Access rule # -- %s - !propName||!propID\n", // ruleNumStr); goto fin; } while (propName && propID) { ruleVar = (char*)strrchr(propName, '.'); if (!ruleVar || !*ruleVar) { // printf("invalid Access rule # -- %s - !ruleVar||!*ruleVar\n", ruleNumStr); break; } ruleVar++; // advance past the '.' // printf("%s ", ruleVar); if (!strcasecmp(ruleVar, "Allow")) { if (HXR_OK != m_registry->GetStr(propID, fromAddr, m_proc)) break; // printf("= %s", (const char *)fromAddr->GetBuffer()); if (!strcasecmp("any", (const char *)fromAddr->GetBuffer())) { netLongFromNetmask = 0xffffffff; netLongFromLowerLimit = 0L; netLongFromUpperLimit = netLongClassCULimit; fromAddrIsAny = TRUE; } else { // This is an error, INADDR_NONE was returned from parsing // the address and this caused a fail result to be returned // To handle gracefully, log an error to let know that the // error has occurred and specify all addresses allowed if (HXR_OK != _parseAddr( (const char *)fromAddr->GetBuffer(), fromAddr->GetSize(), netLongFromAddr, netLongFromNetmask)) { char szMsg[128]; snprintf(szMsg, 128, g_zcszInvalidAddressMsg, fromAddr->GetSize(), (const char*) fromAddr->GetBuffer()); // If this is not a valid ip address, then // report an error and default to any m_pErrorHandler->Report(HXLOG_ERR, 0, 0, szMsg, 0); netLongFromNetmask = 0xffffffff; netLongFromLowerLimit = 0L; netLongFromUpperLimit = netLongClassCULimit; fromAddrIsAny = TRUE; } else { // If INADDR_ANY '0.0.0.0' then should be the same as specifying Any // and this is not considered an error if(netLongFromAddr == INADDR_ANY) { netLongFromNetmask = 0xffffffff; netLongFromLowerLimit = 0L; netLongFromUpperLimit = netLongClassCULimit; fromAddrIsAny = TRUE; } else { /* * ToAddr ==> 172.16.2.0 * Netmask => 255.255.255.0 * UpperLimit => 172.16.2.255 */ netLongFromLowerLimit = netLongFromAddr; netLongFromUpperLimit = netLongFromAddr | ~netLongFromNetmask; } } } /**** printf(" -- addr(%lu), lower(%lu), upper(%lu)\n", netLongFromAddr, netLongFromLowerLimit, netLongFromUpperLimit); ****/ numProps++; } else { // printf("erroneous property under rule # %s\n", ruleNumStr); } propName = 0; propID = 0; props->GetNextPropertyULONG32(propName, propID); } // printf("\n"); if (numProps == 1) { rule = new MulticastACRule; rule->nRuleNum = ruleNum; rule->pFromAddr = fromAddr; rule->pFromAddr->AddRef(); if (netmask) { rule->pNetmask = netmask; rule->pNetmask->AddRef(); } rule->ulFromAddr = netLongFromAddr; rule->ulFromNetmask = netLongFromNetmask; rule->ulFromAddrLowerLimit = netLongFromLowerLimit; rule->ulFromAddrUpperLimit = netLongFromUpperLimit; rule->bFromAddrIsAny = fromAddrIsAny; // printf("all of 1 rule parts detected\n"); } fin: return rule; }
STDMETHODIMP HXCloakedV2TCPSocket::ResponseReady( HX_RESULT res, IHXRequest* pRequestResponse) { IHXCommonClassFactory* pCCF = NULL; IHXRegistry* pRegistry = NULL; IHXValues* pHeaders = NULL; const char* pName = NULL; IHXBuffer* pBuf = NULL; CHXString key = ""; IHXBuffer* pTmpBuffer = NULL; if( SUCCEEDED(res) ) { //Extract the authentication info, again, this is a real waste to just //get a username password. See comment in _DoProxyAuthentication. res = m_pContext->QueryInterface(IID_IHXCommonClassFactory, (void**)&pCCF); if( SUCCEEDED(res) ) { res = m_pContext->QueryInterface(IID_IHXRegistry, (void**)&pRegistry); if( SUCCEEDED(res) ) { res = pRequestResponse->GetRequestHeaders(pHeaders); if( SUCCEEDED(res) ) { res = pHeaders->GetFirstPropertyCString(pName, pBuf); while( SUCCEEDED(res) && pBuf ) { if( !strcasecmp(pName, "Proxy-Authorization") ) { CHXString key = "proxy-authentication.http:"; key += m_pszProxyName; key += ":"; res = pRegistry->GetStrByName( "proxy-authentication.http.realm.recent", pTmpBuffer); if( SUCCEEDED(res) ) { key += CHXString((const char*)pTmpBuffer->GetBuffer(), pTmpBuffer->GetSize()); } HX_RELEASE(pTmpBuffer); res = pCCF->CreateInstance(CLSID_IHXBuffer, (void**)&pTmpBuffer); if( SUCCEEDED(res) ) { pTmpBuffer->Set(pBuf->GetBuffer(), pBuf->GetSize()); UINT32 regid = pRegistry->GetId((const char*)key); if (!regid) { pRegistry->AddStr((const char*)key, pTmpBuffer); } else { pRegistry->SetStrByName((const char*)key, pTmpBuffer); } } HX_RELEASE(pTmpBuffer); break; } // get next header name value line HX_RELEASE(pBuf); res = pHeaders->GetNextPropertyCString(pName, pBuf); } HX_RELEASE(pBuf); HX_RELEASE(pHeaders); } } HX_RELEASE(pRegistry); } HX_RELEASE(pCCF); } HX_RELEASE(pRequestResponse); //We need to start over connting again.... m_CloakingState = csDisconnected; if( m_pTCPSocket) { m_pTCPSocket->Close(); HX_RELEASE(m_pTCPSocket); } res = m_pNetworkServices->CreateSocket(&m_pTCPSocket); if(m_pTCPSocket && SUCCEEDED(res) ) { res = m_pTCPSocket->SetResponse(this); if( SUCCEEDED(res) ) { res = m_pTCPSocket->Init(m_family, m_type, m_protocol); m_pTCPSocket->SetOption( HX_SOCKOPT_APP_BUFFER_TYPE, HX_SOCKBUF_DEFAULT); m_pTCPSocket->SelectEvents(HX_SOCK_EVENT_READ| HX_SOCK_EVENT_CONNECT| HX_SOCK_EVENT_CLOSE); res = m_pTCPSocket->ConnectToOne(m_pDestAddr); } } return res; }
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:` * IHXSiteManager::RemoveSite */ STDMETHODIMP CHXSiteManager::RemoveSite(IHXSite* pSite) { void* pVoid = NULL; CHXMapPtrToPtr* pSiteCollection = NULL; IHXValues* pProps = NULL; IHXBuffer* pValue = NULL; HXBOOL bIsPersistent = FALSE; /* * This site must have been previously added and therefore * should be in the master list of sites. */ if (!m_MasterListOfSites.Lookup(pSite,pVoid)) { return HXR_INVALID_PARAMETER; } /* * determine whether the site is persistent, and get the name of * the site so it can be removed from the channel list */ if(HXR_OK == pSite->QueryInterface(IID_IHXValues,(void**)&pProps)) { if(HXR_OK == pProps->GetPropertyCString("Persistent", pValue)) { bIsPersistent = TRUE; HX_RELEASE(pValue); } HX_RELEASE(pProps); } /* * */ /* If we are unhooking all sites, we do not want to unhook site here */ if (!m_bInUnHookAll) { UnhookSite(pSite, bIsPersistent); } /* * We need to remove the site from whatever collection of * sites it is in. This means we are removing it from the * collection of sites for it's LSGName if that is how it * was added. Instead of determining the properties supported * by the site to determine which collection to remove it from * we stored the site collection in our master list. Cool, eh? */ pSiteCollection = (CHXMapPtrToPtr*)pVoid; HX_ASSERT(pSiteCollection->Lookup(pSite,pVoid)); pSiteCollection->RemoveKey(pSite); /* * Of course we also need to remove it from the master site * list as well. */ m_MasterListOfSites.RemoveKey(pSite); return HXR_OK; }
/************************************************************************ * 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; }
HX_RESULT HXFileSystemManager::AddMountPoint(const char* pszShortName, const char* pszMountPoint, IHXValues* pOptions, IUnknown* pContext) { #if defined(HELIX_CONFIG_NOSTATICS) CHXSimpleList& zm_CacheList = HXGlobalList::Get(&HXFileSystemManager::zm_CacheList); CHXMapStringToOb& zm_ShortNameMap = HXGlobalMapStringToOb::Get(&HXFileSystemManager::zm_ShortNameMap); CHXMapStringToOb& zm_ProtocolMap = HXGlobalMapStringToOb::Get(&HXFileSystemManager::zm_ProtocolMap); #endif HX_RESULT result = HXR_OK; IHXPlugin2Handler* pPlugin2Handler = NULL; CCacheInstance* pCCacheInstance = NULL; if (HXR_OK != pContext->QueryInterface(IID_IHXPlugin2Handler, (void**) &pPlugin2Handler)) return HXR_FAIL; if (!pszShortName) { result = HXR_FAIL; goto cleanup; } UINT32 nIndex; if (HXR_OK != pPlugin2Handler->FindIndexUsingStrings(PLUGIN_FILESYSTEMSHORT, (char*)pszShortName, NULL, NULL, NULL, NULL, nIndex)) { result = HXR_FAIL; goto cleanup; } IHXValues* pValues; IHXBuffer* pProtocol; pPlugin2Handler->GetPluginInfo(nIndex, pValues); pValues->GetPropertyCString(PLUGIN_FILESYSTEMPROTOCOL, pProtocol); char* pszProtocol; pszProtocol = (char*)pProtocol->GetBuffer(); pCCacheInstance = new CCacheInstance; pCCacheInstance->m_mount_point = pszMountPoint; pCCacheInstance->m_szProtocol = pszProtocol; pCCacheInstance->m_szShortName = pszShortName; pCCacheInstance->m_pOptions = pOptions; zm_ShortNameMap.SetAt(pszMountPoint, pCCacheInstance); zm_ProtocolMap.SetAt(pszMountPoint, pCCacheInstance); zm_CacheList.AddTail((void*)pCCacheInstance); cleanup: return result; }
void CoreProcessInitCallback::func(Process* proc) { Config* config = NULL; DistributedLicenseRequester* license_requester = NULL; ServerRegistry* registry = NULL; int backlog = 0; int setegid_err = 0; int seteuid_err = 0; INT32 nUseRegistryForStats = 0; printf ("Starting %s %d.%d Core...\n", ServerVersion::ProductName(), ServerVersion::MajorVersion(), ServerVersion::MinorVersion()); proc->pc = new CoreContainer(proc); proc->pc->process_type = PTCore; proc->pc->lbound_tcp_listenRTSPResponse = NULL; proc->pc->dispatchq = dispatch_queue; proc->pc->dispatchq->init(proc); MulticastAccessControl* mcast_ctrl = new MulticastAccessControl(); /* * Must create the ErrorSinkHandler before accessing Config */ proc->pc->error_sink_handler = new ErrorSinkHandler(); progname = GetProgName(argv[0]); os_init(); registry = new ServerRegistry(proc); proc->pc->registry = registry; registry->AddComp("Client", proc); registry->AddComp("Server", proc); // Add system composite to the registry registry->AddComp("system", proc); // Add startuplog info to the registry ServerBuffer* pBuf = new ServerBuffer((UCHAR*)g_szStartupLog, strlen(g_szStartupLog)); if (g_szStartupLog) registry->AddStr("Server.StartupLogPath", pBuf, proc); config = new Config(proc, g_pszConfigFile, g_pszImportKey, registry); if (!config->valid()) { ERRMSG(proc->pc->error_handler, "Invalid configuration.\n"); terminate(1); } if (g_pszImportKey && g_pszImportKey[0]) { terminate(1); } proc->pc->client_stats_manager = new ClientStatsManager; //proc->pc->client_stats_manager->AddRef(); if (SUCCEEDED(registry->GetInt("config.ClientStats.UseRegistry", &nUseRegistryForStats, proc))) { proc->pc->client_stats_manager->SetUseRegistryForStats(nUseRegistryForStats ? TRUE : FALSE); } proc->pc->license_requester = new DistributedLicenseRequester; /* * Now that the proc->pc and the registry are established, it is safe to * initialize the IHXNetworkServicesContext */ proc->pc->network_services->Init(proc->pc->server_context, proc->pc->engine, NULL); proc->pc->net_services->Init(proc->pc->server_context); // MulticastManager needs MulticastAddressPool! proc->pc->mcst_addr_pool = new MulticastAddressPool(); proc->pc->mcst_addr_pool->AddRef(); /* * CSapManager and MulticastManager both needs * plugin hander which will be avilable in * _main CoreTransferCallback::func */ // will be Init'ed in _main CoreTransferCallback::func proc->pc->sap_mgr = new CSapManager(); proc->pc->sap_mgr->AddRef(); // addtional Init will be done in _main CoreTransferCallback::func proc->pc->multicast_mgr = new MulticastManager(proc->pc->server_context); /* */ proc->pc->alt_server_proxy_cfg_mgr = new AltServerProxyConfigHandler(proc, registry); proc->pc->alt_server_proxy_cfg_mgr->AddRef(); if (HXR_FAIL == proc->pc->alt_server_proxy_cfg_mgr->Init()) { HX_RELEASE(proc->pc->alt_server_proxy_cfg_mgr); } /* setup QoS core */ proc->pc->qos_prof_select = new QoSProfileSelector(proc); proc->pc->qos_prof_select->AddRef(); proc->pc->qos_bus_ctl = new QoSSignalBusController(); proc->pc->qos_bus_ctl->AddRef(); proc->pc->qos_sig_src = new QoSSignalSource(proc, proc->pc->qos_bus_ctl); proc->pc->qos_sig_src->AddRef(); /* setup capex profile cache */ proc->pc->capex_static_cache = new StaticProfileCache(); proc->pc->capex_static_cache->AddRef(); proc->pc->capex_profile_cache = new HTTPProfileCache(); proc->pc->capex_profile_cache->AddRef(); Config_error* error_result = 0; backlog = config->GetInt(proc, "config.ListenBacklog"); if (backlog < CONFIG_BACKLOG) backlog = CONFIG_BACKLOG; #ifdef DEBUG debug_level() = g_ulDebugFlags ? g_ulDebugFlags : config->GetInt(proc, "config.Debug"); debug_func_level() = g_ulDebugFuncFlags ? g_ulDebugFuncFlags : config->GetInt(proc, "config.DebugFunc"); #endif ((CoreContainer*)proc->pc)->m_pListenResponseList = new CHXSimpleList; HXRegistry* hxreg = new HXRegistry(registry, proc); HX_RESULT res = HXR_OK; hxreg->AddRef(); char** pHTTPablePaths = NULL; char** pHTTPpostablePaths = NULL; ::GetHTTPPaths(hxreg, (char*)"config.HTTPDeliverable", pHTTPablePaths); ::GetHTTPPaths(hxreg, (char*)"config.HTTPPostable", pHTTPpostablePaths); /* * Add key for broadcast plugins to register their connections */ hxreg->AddComp("LiveConnections"); hxreg->AddInt("LiveConnections.Index", 0); hxreg->AddInt("LiveConnections.Count", 0); proc->pc->named_lock_manager->CreateNamedLock("LiveConnectionsLock"); INT32* pEncoders = new INT32; IHXBuffer* pIHXBuf = new ServerBuffer(TRUE); HX_ASSERT(pIHXBuf); *pEncoders = 0; pIHXBuf->SetSize(sizeof(void*)); *((void**)pIHXBuf->GetBuffer()) = (void*)pEncoders; hxreg->AddBuf("EncoderConnections.Index", pIHXBuf); HX_RELEASE(pIHXBuf); /* * Add key for monitor plugins to register their connections */ hxreg->AddComp("Monitors"); hxreg->AddInt("Monitors.Count", 0); /* * Add key for splitters to register their connections */ hxreg->AddComp("Splitters"); hxreg->AddInt("Splitters.Index", 0); hxreg->AddInt("Splitters.Count", 0); mcast_ctrl->Init(proc); proc->pc->mcast_ctrl = mcast_ctrl; IHXValues* pAddrList = NULL; IHXBuffer* pAddrBuf = NULL; const char* pAddrStr = NULL; BOOL bBindToLocalHost = FALSE; TimeZoneCheckCallback* tzcb = new TimeZoneCheckCallback(proc); tzcb->SetTimeZone(); tzcb->ScheduleFirstCheckCallback(); HX_RESULT pn_res = hxreg->GetPropListByName("config.IPBindings", pAddrList); if (pn_res != HXR_OK) { pn_res = hxreg->GetPropListByName("config.IPBinding", pAddrList); } INT32 sbind_id = hxreg->AddComp("server.ipbinding"); HX_ASSERT(sbind_id); int num_props = 0; switch (pn_res) { case HXR_OK: { const char* addr_prop_name; UINT32 addr_prop_id; res = pAddrList->GetFirstPropertyULONG32(addr_prop_name, addr_prop_id); while(res == HXR_OK) { char str[64]; if (HXR_OK == hxreg->GetStrById(addr_prop_id, pAddrBuf)) { const char* strAddr = (const char*)pAddrBuf->GetBuffer(); if (!strcmp(strAddr, "*")) { //XXXJJ "*" means any interfaces(including ipv4 and ipv6) // will be handled in "default:". //if we have "*", we shouldn't have other entries in the list. HX_ASSERT(num_props == 0); break; } else if (!strcmp(strAddr, "127.0.0.1") || !strcmp(strAddr, "0.0.0.0")) { bBindToLocalHost = TRUE; } ++num_props; sprintf(str, "server.ipbinding.addr_%.2d", num_props); hxreg->AddStr(str, pAddrBuf); HX_RELEASE(pAddrBuf); } res = pAddrList->GetNextPropertyULONG32(addr_prop_name, addr_prop_id); } pAddrList->Release(); if (num_props) break; } // Three cases fall into here: no ipbinding list, empty list, or only "*" // in the list default: { ServerBuffer::FromCharArray("*", &pAddrBuf); hxreg->AddStr("server.ipbinding.addr_01", pAddrBuf); pAddrBuf->Release(); bBindToLocalHost = TRUE; break; } }; if(!g_pHeartBeatIP) { // heartbeat ip not specified if(!bBindToLocalHost) { //localhost is not in the binding list, we need to manually add it // for heartbeat connection to succeed. char str[64]; ++num_props; sprintf(str, "server.ipbinding.addr_%.2d", num_props); ServerBuffer::FromCharArray("127.0.0.1", &pAddrBuf); hxreg->AddStr(str, pAddrBuf); pAddrBuf->Release(); } } _initializeListenRespObjects(proc, config, registry, backlog); hxreg->Release(); // This used to set g_pCPUCount based on config.ProcessorCount but // setting StreamerCount is the way to do this now. *g_pCPUCount = g_bSkipCPUTest ? 1 : CPUDetect(); // // This just gives the "Linux22Compat" code a platform-neutral // name for testing/debugging on other platforms. // UINT32 ulLessParallel = config->GetInt(proc, "config.LessParallel"); if (ulLessParallel) { printf("Note: Configuration specified LessParallel mode.\n"); *g_bLimitParallelism = TRUE; } #ifdef _UNIX const char* pPIDPath; if ((pPIDPath = config->GetString(proc, "config.PidPath"))) { FILE* f = fopen(pPIDPath, "w"); if (f > 0) { #if defined PTHREADS_SUPPORTED fprintf(f, "%d\n", getpid()); #else fprintf(f, "%d\n", proc->procid(PROC_RM_CONTROLLER)); #endif fclose(f); } else { ERRMSG(proc->pc->error_handler, "Couldn't open PID File %s", pPIDPath); } } int gid = GetGIDFromConfig(proc, config); int uid = GetUIDFromConfig(proc, config); if (pPIDPath && gid >= 0 && uid >= 0) { if (chown(pPIDPath, uid, gid) < 0) perror("could not set the PIDPath's ownership\n"); } if (gid >= 0) { #ifdef _AIX if (setregid(-1, gid) < 0) #elif defined _HPUX if (setresgid(-1, gid, gid) < 0) #else if (setegid(gid) < 0) #endif { setegid_err = errno; perror("setegid() failed(1)"); *return_gid = (UINT32)-1; } else *return_gid = gid; } if (uid >= 0) { #if defined _AIX || defined _HPUX if (setreuid(-1, uid) < 0) #else if (seteuid(uid) < 0) #endif { seteuid_err = errno; perror("seteuid() failed(1)"); *return_uid = (UINT32)-1; } else { *return_uid = uid; } } fflush(0); #endif proc->pc->config = config; /* * Handle streamer_info creation and overriding of capacity defaults * from the config file. */ UINT32 ul; proc->pc->streamer_info = new StreamerInfo; if (HXR_OK == proc->pc->registry->GetInt("config.StreamerSessionCapacity", (INT32*)&ul, proc)) { proc->pc->streamer_info->SetSessionCapacity(ul); } if (HXR_OK == proc->pc->registry->GetInt("config.MaxSockCapacity", (INT32*)&ul, proc)) { SOCK_CAPACITY_VALUE = ul; } if ((HXR_OK == proc->pc->registry->GetInt("config.MaxDescCapacity", (INT32*)&ul, proc)) || (HXR_OK == proc->pc->registry->GetInt("config.MaxDescriptorCapacity", (INT32*)&ul, proc))) { DESCRIPTOR_CAPACITY_VALUE = ul; } proc->pc->conn_id_table = new CHXTSID(config->GetInt(proc, "config.Capacity")); proc->pc->resolver_info = new ResolverInfo; proc->pc->rdispatch = new ResolverDispatch(proc); proc->pc->scheduler = new ServerScheduler(proc); proc->pc->server_prefs = new ServerPreferences(proc); proc->pc->server_info = new ServerInfo(proc); proc->pc->loadinfo = new LoadInfo(proc); //XXXTDM: Where's all the AddRef() calls??? proc->pc->net_services->AddRef(); proc->pc->scheduler->AddRef(); // Tell mem routines where to find a regularly-updated timestamp in shared memory SharedMemory::SetTimePtr(&proc->pc->engine->now); #ifdef PAULM_LEAKCHECK if (g_bLeakCheck) new MemChecker(proc); #endif /* PAULM_LEAKCHECK */ proc->pc->misc_plugins = new CHXMapPtrToPtr(); proc->pc->allowance_plugins = new CHXMapPtrToPtr(); proc->pc->server_fork = new ServerFork(proc); proc->pc->global_server_control = new GlobalServerControl(proc); proc->pc->data_convert_con = new DataConvertController; #if defined _UNIX proc->pc->m_pResMUX = new ResolverMUX(RESOLVER_CAPACITY_VALUE, MAX_RESOLVERS, proc->pc->server_fork, proc->pc->async_io, proc->pc->error_handler); #endif proc->pc->HTTP_deliver_paths = new char**; if (pHTTPablePaths) { *proc->pc->HTTP_deliver_paths= pHTTPablePaths; } else { *proc->pc->HTTP_deliver_paths = NULL; } new HTTPDeliverablePrefController(proc, (char*)"config.HTTPDeliverable", proc->pc->HTTP_deliver_paths); proc->pc->HTTP_postable_paths = new char**; if (pHTTPpostablePaths) { *proc->pc->HTTP_postable_paths= pHTTPpostablePaths; } else { *proc->pc->HTTP_postable_paths = NULL; } new HTTPDeliverablePrefController(proc, (char*)"config.HTTPPostable", proc->pc->HTTP_postable_paths); proc->pc->cloaked_guid_dict = new CloakedGUIDDict(); proc->pc->broadcast_manager = new BroadcastManager(); proc->pc->load_listen_mgr = new LoadBalancedListenerManager(proc); /* * Setup the global mimetype dictionary. */ proc->pc->mime_type_dict = new Dict(); hxreg = new HXRegistry(proc->pc->registry, proc); hxreg->AddRef(); IHXValues* pTypeList; if(HXR_OK == hxreg->GetPropListByName("config.MimeTypes", pTypeList)) { HX_RESULT res; const char* mimeTypeRegname; UINT32 mime_id; res = pTypeList->GetFirstPropertyULONG32(mimeTypeRegname, mime_id); while(HXR_OK == res) { HXPropType mimetypetype = hxreg->GetTypeById(mime_id); if(mimetypetype != PT_COMPOSITE) res = HXR_FAIL; else { const char* mimeType = strrchr(mimeTypeRegname, '.'); if(!mimeType) mimeType = mimeTypeRegname; else mimeType++; IHXValues* pExtList; if(HXR_OK == hxreg->GetPropListById(mime_id, pExtList)) { const char* ext; UINT32 ext_id; res = pExtList->GetFirstPropertyULONG32(ext, ext_id); while(res == HXR_OK) { if(PT_STRING == hxreg->GetTypeById(ext_id) || PT_BUFFER == hxreg->GetTypeById(ext_id)) { IHXBuffer* extBuffer; if(HXR_OK == hxreg->GetStrById(ext_id, extBuffer)) { proc->pc->mime_type_dict->enter( (const char*)extBuffer->GetBuffer(), new_string(mimeType)); HX_RELEASE(extBuffer); } } res = pExtList->GetNextPropertyULONG32(ext, ext_id); } HX_RELEASE(pExtList); } res = pTypeList->GetNextPropertyULONG32(mimeTypeRegname, mime_id); } } HX_RELEASE(pTypeList); } HX_RELEASE(hxreg); proc->pc->rtspstats_manager = new RTSPEventsManager(); proc->pc->sdpstats_manager = new SDPAggregateStats(); proc->pc->sdpstats_manager->AddRef(); // If a default mime type doesn't yet exist, add one so that // we will always send some mime type Dict_entry* ent = proc->pc->mime_type_dict->find("*"); if(!ent) { proc->pc->mime_type_dict->enter("*", new_string("application/octet-stream")); } new MimeTypesPrefController(proc); ((CoreContainer *)proc->pc)->cdispatch = new ConnDispatch(proc); /* * AddRef() all objects handed out by ServerContext */ proc->pc->server_prefs->AddRef(); proc->pc->server_fork->AddRef(); *core_proc = proc; *controller_waiting_on_core = 0; // Signal Controller to continue while (!(*controller_ready)) microsleep(1); // Busy Wait for the Controller delete controller_ready; CoreTransferCallback* cb = new CoreTransferCallback; cb->core_proc = proc; #ifdef DEBUG cb->m_debug_level = debug_level(); cb->m_debug_func_level = debug_func_level(); #endif int* volatile core_waiting_for_refresh; cb->core_waiting_for_refresh = new int; *cb->core_waiting_for_refresh = 1; core_waiting_for_refresh = cb->core_waiting_for_refresh; #ifdef _WIN32 MaybeNotifyServiceUp(); #endif proc->pc->dispatchq->send(proc, cb, PROC_RM_CONTROLLER); /* * Wait here for the controller to get the plugins loaded. */ while (*core_waiting_for_refresh) microsleep(1); delete core_waiting_for_refresh; /* * NOTE: Both NT and mac have servers that run to completion in * os_start() */ os_start(); fflush(0); // add the global var ptr into the registry, so that the mmap managers in // each process can then access and modify the var using atomic // operations. g_pMemoryMappedDataSize is used to report the amount of // mmapped data that is read via the local file system (smplfsys). registry->AddIntRef("server.MMappedDataSize", (INT32 *)g_pMemoryMappedDataSize, proc); proc->pc->engine->mainloop(); // NEVER REACHED! #if 0 delete this; #endif PANIC(("Internal Error cp/737\n")); }
HX_RESULT HXCloakedV2TCPSocket::_DoProxyAuthentication(HTTPResponseMessage* pMess) { HX_RESULT res = HXR_FAIL; IHXCommonClassFactory* pCCF = NULL; CHXString getStr = ""; IHXKeyValueList* pRespHeaders = NULL; MIMEHeaderValue* pHeaderValue = NULL; MIMEHeader* pHeader = NULL; CHXString strHeader = ""; CHXString strTemp = ""; IHXBuffer* pBuffer = NULL; IHXRequest* pRequest = NULL; IHXValues* pValues = NULL; IHXClientAuthConversation* pClientAuth = NULL; IUnknown* pUnkConfig = NULL; IHXObjectConfiguration* pConfig = NULL; ////////////////////// // // XXXgfw I really don't think we need all this authentication // garbage. It really seems we only need to TLC to just give us a // dialog to do a user/pass request. It sure seems like this code // below is way overkill. Just check out ResponseReady(), the only // thing is needs from all this is just that one string. Oh well, // until I have time to figure out exactly how this all works (all // the calls through the core and into the TLC from here) I will // just leave it like the original cloaking. // ////////////////////// res = m_pContext->QueryInterface(IID_IHXCommonClassFactory, (void**)&pCCF); if( SUCCEEDED(res) ) { //pRequest will be freed in the ResponseReady() method. res = pCCF->CreateInstance(CLSID_IHXRequest, (void**)&pRequest); if( SUCCEEDED(res) ) { getStr = _GenerateGetRequest(); pRequest->SetURL((const char*)getStr); //Always returns HXR_OK; res = pCCF->CreateInstance(CLSID_IHXKeyValueList, (void**)&pRespHeaders); if( SUCCEEDED(res) ) { pHeader = pMess->getFirstHeader(); while (pHeader) { pHeaderValue = pHeader->getFirstHeaderValue(); strHeader = ""; while( pHeaderValue ) { pHeaderValue->asString(strTemp); strHeader += strTemp; pHeaderValue = pHeader->getNextHeaderValue(); if (pHeaderValue) { strHeader += ", "; } } pBuffer = NULL; CHXBuffer::FromCharArray((const char*)strHeader, &pBuffer); if( pBuffer ) { pRespHeaders->AddKeyValue(pHeader->name(), pBuffer); } HX_RELEASE(pBuffer); pHeader = pMess->getNextHeader(); } pValues = NULL; if (HXR_OK == pRespHeaders->QueryInterface(IID_IHXValues, (void**)&pValues)) { pRequest->SetResponseHeaders(pValues); } HX_RELEASE(pValues); } HX_RELEASE(pRespHeaders); if (HXR_OK == pRequest->GetResponseHeaders(pValues)) { res = pCCF->CreateInstance(CLSID_IHXBuffer, (void**)&pBuffer); if (SUCCEEDED(res)) { pBuffer->Set((UCHAR*)m_pszProxyName, strlen(m_pszProxyName)+1); pValues->SetPropertyCString("_server", pBuffer); HX_RELEASE(pBuffer); } // Add the protocol to the response headers because TLC needs it if (SUCCEEDED(pCCF->CreateInstance(CLSID_IHXBuffer, (void**)&pBuffer))) { pBuffer->Set((UCHAR*)"http", strlen("http") + 1); pValues->SetPropertyCString("_protocol", pBuffer); HX_RELEASE(pBuffer); } HX_RELEASE(pValues); } //We now need a CCF from the cloaking context, not our core's context. HX_RELEASE(pCCF); res = m_pCloakContext->QueryInterface(IID_IHXCommonClassFactory, (void**)&pCCF); if(SUCCEEDED(res)) { res = pCCF->CreateInstance( CLSID_CHXClientAuthenticator, (void**)&pUnkConfig ); if(SUCCEEDED(res)) { res = pUnkConfig->QueryInterface(IID_IHXClientAuthConversation, (void**)&pClientAuth); if (SUCCEEDED(res)) { res = pUnkConfig->QueryInterface(IID_IHXObjectConfiguration, (void**)&pConfig); if (SUCCEEDED(res)) { pConfig->SetContext(m_pCloakContext); HX_RELEASE(pConfig); } if ( pClientAuth && !pClientAuth->IsDone() ) { HX_ASSERT(pRequest); //After this if/else, we continue in ResponseReady() after //the TLC calls us back. if (pRequest) { res = pClientAuth->MakeResponse(this, pRequest); } else { // Auth Failed! pClientAuth->Authenticated(FALSE); res = HXR_NOT_AUTHORIZED; res = ResponseReady(res, pRequest); } } } HX_RELEASE(pUnkConfig); } HX_RELEASE(pCCF); } } } //We return this in all cases. the connection will be started over in //the ResponseReady() method. res = HXR_NOT_AUTHORIZED; return res; }