bool HLXIHXFileTest::HandleWriteCmd(const UTVector<UTString>& info) { bool bRetVal = false; if (m_pIHXDataFile) { IHXBuffer* pHXBuffer = new CHXBuffer(); if (pHXBuffer) { pHXBuffer->AddRef(); if (pHXBuffer->Set((const UINT8*) ((const char*) info[1]), strlen(info[1])) == HXR_OK) { ULONG32 ulRetSize; ULONG32 ulInSize; ulInSize = pHXBuffer->GetSize(); ulRetSize = m_pIHXDataFile->Write(pHXBuffer); bRetVal = (ulRetSize == ulInSize); bRetVal = (bRetVal == CFileTestUtil::ParseResultString(info[2])); } pHXBuffer->Release(); } } return bRetVal; }
void HSPErrorSink::ConvertErrorToString(const ULONG32 ulHXCode, char* pszBuffer, UINT32 ulBufLen) { IHXErrorMessages* pErrMsg = NULL; if( !pszBuffer) return; pszBuffer[0]='\0'; HX_ASSERT(m_pPlayer); if( m_pPlayer) { m_pPlayer->QueryInterface(IID_IHXErrorMessages, (void**)&pErrMsg); if( pErrMsg ) { IHXBuffer* pMessage = pErrMsg->GetErrorText(ulHXCode); if( pMessage ) { SafeStrCpy( pszBuffer, (const char*)pMessage->GetBuffer(), (int)ulBufLen); pMessage->Release(); } } } HX_RELEASE(pErrMsg); if( strlen(pszBuffer)==0 ) { SafeSprintf( pszBuffer, (int) ulBufLen, "Can't convert error code %p - please find corresponding HXR code in common/include/hxresult.h", ulHXCode ); } }
/* add "any" at pName */ HX_RESULT MulticastRuleChain::_addDefaultRule(const char* pName) { IHXBuffer* pBuf = new ServerBuffer(TRUE); pBuf->Set((const UCHAR*)"any", sizeof("any")); m_registry->AddStr(pName, pBuf, m_proc); pBuf->Release(); return HXR_OK; }
void DataRevertController::CleanControlBuffers() { IHXBuffer* pBuffer; if (m_pControlBufferList) { while (!m_pControlBufferList->IsEmpty()) { pBuffer = (IHXBuffer*)m_pControlBufferList->RemoveHead(); pBuffer->Release(); } delete m_pControlBufferList; } }
int main(int argc, char* argv[]) { if (argc != 3) { fprintf(stderr, "Usage : %s <sdp version> <sdp file>\n", argv[0]); } else { IUnknown* pContext = new CHXMiniCCF(); if (pContext) { pContext->AddRef(); IHXCommonClassFactory* pCCF = 0; if (HXR_OK == pContext->QueryInterface(IID_IHXCommonClassFactory, (void**)&pCCF)) { IHXBuffer* pSDP = ReadSDPFile(pCCF, argv[2]); if (pSDP) { if (HXR_OK != Parse(pContext, strtoul(argv[1], 0, 10), pSDP)) { fprintf(stderr, "Failed to parse SDP\n", argv[1]); } pSDP->Release(); pSDP = 0; } else { fprintf(stderr, "Failed to read SDP file '%s'\n", argv[2]); } pCCF->Release(); pCCF = 0; } pContext->Release(); pContext = 0; } } return 0; }
void ClientRegTree::InitRegistry(IHXBuffer* pStartTime) { IHXBuffer* pValue; char str[128]; sprintf(str, "client.%ld", m_ulRegistryConnId); m_ulRegId[CLIENT] = m_pRegistry->AddComp(str); sprintf(str, "client.%ld.ConnID", m_ulRegistryConnId); // should this be conn_id from client obj?? m_ulRegId[CONN_ID] = m_pRegistry->AddInt(str, m_ulRegistryConnId); if (pStartTime) { m_ulRegId[TIME] = m_pRegistry->AddStr(str, pStartTime); } else // Proxy. { time_t start_time; char start_time_string[MAX_TIME_STRING_LEN]; //ok struct tm start_time_struct; time(&start_time); hx_localtime_r(&start_time, &start_time_struct); strftime(start_time_string, MAX_TIME_STRING_LEN, "%d/%b/%Y:%H:%M:%S", &start_time_struct); sprintf(str, "client.%ld.StartTime", m_ulRegistryConnId); m_pClassFactory->CreateInstance(CLSID_IHXBuffer, (void**)&pValue); pValue->Set((const BYTE*)start_time_string, strlen(start_time_string)+1); m_ulRegId[TIME] = m_pRegistry->AddStr(str, pValue); pValue->Release(); } sprintf(str, "client.%ld.Session", m_ulRegistryConnId); m_ulRegId[SESSION] = m_pRegistry->AddComp(str); sprintf(str, "client.%ld.SessionCount", m_ulRegistryConnId); m_ulRegId[SESSION_COUNT] = m_pRegistry->AddInt(str, 0); sprintf(str, "client.%ld.ControlBytesSent", m_ulRegistryConnId); m_ulRegId[CTRL_BYTES_SENT] = m_pRegistry->AddInt(str, 0); }
/************************************************************************ * IHXDataRevertResponse */ STDMETHODIMP DataRevertController::DataRevertInitDone(HX_RESULT status) { m_bInited = TRUE; if (m_pControlBufferList) { IHXBuffer* pBuffer; while (!m_pControlBufferList->IsEmpty()) { pBuffer = (IHXBuffer*)m_pControlBufferList->RemoveHead(); m_pDataRevert->ControlBufferReady(pBuffer); pBuffer->Release(); } } m_pDataRevert->RevertFileHeader(m_pFileHeaders); return HXR_OK; }
CMediaPacket* CPCMAudioFormat::CreateAssembledPacket(IHXPacket* pPacket) { CMediaPacket* pRet = NULL; if (pPacket) { IHXBuffer* pBuffer = pPacket->GetBuffer(); if (pBuffer) { UINT32 ulFlags = MDPCKT_USES_IHXBUFFER_FLAG; pRet = new CMediaPacket(pBuffer, (UINT8*) pBuffer->GetBuffer(), pBuffer->GetSize(), pBuffer->GetSize(), pPacket->GetTime(), ulFlags, NULL); pBuffer->Release(); } } return pRet; }
IHXBuffer* ReadSDPFile(IHXCommonClassFactory* pCCF, const char* pFilename) { IHXBuffer* pBuf = 0; FILE* pFile = ::fopen(pFilename, "rb"); if (pFile) { if (!fseek(pFile, 0, SEEK_END)) { long fileSize = ftell(pFile); if (HXR_OK == pCCF->CreateInstance(CLSID_IHXBuffer,(void**)&pBuf)) { HXBOOL bFailed = TRUE; if ((HXR_OK == pBuf->SetSize(fileSize)) && (!fseek(pFile, 0, SEEK_SET)) && (fread(pBuf->GetBuffer(), fileSize, 1, pFile) == 1)) { bFailed = FALSE; } if (bFailed) { pBuf->Release(); pBuf = 0; } } } ::fclose(pFile); } return pBuf; }
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 CBaseArchiver2::ExtractMetaInfo(IHXValues* pHeader, IHXValues* &pMetaInfo, const char** ppRestrictedFields, ULONG32 ulNumRestrictedFields, IUnknown* pContext) { HX_RESULT hResult = HXR_OK; const char* pPropName = NULL; IHXBuffer* pBuffer = NULL; UINT32 ulValue = 0; HXBOOL bRestricted = FALSE; UINT32 i = 0; HX_ASSERT(pHeader); if (pMetaInfo == NULL) { CreateValuesCCF(pMetaInfo, pContext); } // Iterate through all CStrings in the header hResult = pHeader->GetFirstPropertyCString(pPropName, pBuffer); while (SUCCEEDED(hResult)) { bRestricted = FALSE; for (i = 0; i < ulNumRestrictedFields; i++) { if (!strcasecmp(pPropName, ppRestrictedFields[i])) { bRestricted = TRUE; break; } } // If this value is one that we recognize as NOT being meta // information, don't add it to the new IHXValues. Otherwise, // we will assume it's meta info and add it to the archive if (!bRestricted) { pMetaInfo->SetPropertyCString(pPropName, pBuffer); } pBuffer->Release(); hResult = pHeader->GetNextPropertyCString(pPropName, pBuffer); } // Iterate through all ULONG32s in the header hResult = pHeader->GetFirstPropertyULONG32(pPropName, ulValue); while (SUCCEEDED(hResult)) { bRestricted = FALSE; for (i = 0; i < ulNumRestrictedFields; i++) { if (!strcasecmp(pPropName, ppRestrictedFields[i])) { bRestricted = TRUE; break; } } // If this value is one that we recognize as NOT being meta // information, don't add it to the new IHXValues. Otherwise, // we will assume it's meta info and add it to the archive if (!bRestricted) { pMetaInfo->SetPropertyULONG32(pPropName, ulValue); } hResult = pHeader->GetNextPropertyULONG32(pPropName, ulValue); } // Iterate through all Buffers in the header hResult = pHeader->GetFirstPropertyBuffer(pPropName, pBuffer); while (SUCCEEDED(hResult)) { bRestricted = FALSE; for (i = 0; i < ulNumRestrictedFields; i++) { if (!strcasecmp(pPropName, ppRestrictedFields[i])) { bRestricted = TRUE; break; } } // If this value is one that we recognize as NOT being meta // information, don't add it to the new IHXValues. Otherwise, // we will assume it's meta info and add it to the archive if (!bRestricted) { pMetaInfo->SetPropertyBuffer(pPropName, pBuffer); } pBuffer->Release(); hResult = pHeader->GetNextPropertyBuffer(pPropName, pBuffer); } return HXR_OK; }
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); }
/************************************************************************ * 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; }
void CHTTPDemux::handleInput(IHXBuffer* pBuf) { UINT32 ulBufLen = 0; if (pBuf) { ulBufLen = pBuf->GetSize(); if (m_ulMsgLen+ulBufLen > MAX_HTTP_MSG_SIZE) { if (m_pSock) { IHXSockAddr* pAddr = 0; m_pSock->GetPeerAddr(&pAddr); if (pAddr) { IHXBuffer* pAddrBuf = 0; pAddr->GetAddr(&pAddrBuf); if (pAddrBuf) { fprintf(stderr, "W: Large HTTP message (greater than 64K) being received from addr <%s>.\n" " Possible DOS attack!\n", (const char *)pAddrBuf->GetBuffer()); pAddrBuf->Release(); } pAddr->Release(); } } Close(HXR_FAIL); return; } } if (m_pFragBuf == NULL) { pBuf->AddRef(); } else { IHXBuffer* pNewBuf = new CHXBuffer(); pNewBuf->AddRef(); pNewBuf->SetSize(m_pFragBuf->GetSize() + ulBufLen); memcpy(pNewBuf->GetBuffer(), m_pFragBuf->GetBuffer(), m_pFragBuf->GetSize()); memcpy(pNewBuf->GetBuffer()+m_pFragBuf->GetSize(), pBuf->GetBuffer(), ulBufLen); HX_RELEASE(m_pFragBuf); pBuf = pNewBuf; } while (pBuf != NULL && !m_bClosed) { BYTE* pData = pBuf->GetBuffer(); UINT32 uDataLen = pBuf->GetSize(); UINT32 uDataUsed = 0; IHXBuffer* pNewBuf = NULL; IHXBuffer* pContentBuf = NULL; BOOL bFirstRun = FALSE; BOOL bMsgTooLarge = FALSE; if (m_ReadState == DEMUX_READ_MSG) { HTTPMessage* pMsg = NULL; uDataUsed = uDataLen; pMsg = m_pParser->parse((const char*)pData, uDataUsed, bMsgTooLarge); if (pMsg == NULL) { if (bMsgTooLarge) { if (pBuf) pBuf->Release(); if (m_pSock) { IHXSockAddr* pAddr = 0; m_pSock->GetPeerAddr(&pAddr); if (pAddr) { IHXBuffer* pAddrBuf = 0; pAddr->GetAddr(&pAddrBuf); if (pAddrBuf) { fprintf(stderr, "W: Large amount of HTTP data being received from addr <%s>.\n" " Possible DOS attack!\n", (const char *)pAddrBuf->GetBuffer()); pAddrBuf->Release(); } pAddr->Release(); } } Close(HXR_FAIL); return; } break; } // Remove used data from the buffer if (uDataUsed == uDataLen) { HX_RELEASE(pBuf); } else { pNewBuf = new CHXStaticBuffer(pBuf, uDataUsed, uDataLen-uDataUsed); pNewBuf->AddRef(); HX_RELEASE(pBuf); pBuf = pNewBuf; } if (m_pResponse == NULL) { DetectHandler(pMsg); HX_ASSERT(m_pResponse != NULL); m_pResponse->Init(this); bFirstRun = TRUE; } if (m_pResponse->GetFeatureFlags() & HTTP_FEATURE_IGNORE_CONTENT_LENGTH) { // Cloaking V2. if (m_pResponse->GetFeatureFlags() & ( HTTP_FEATURE_V11_SUPPORT | HTTP_FEATURE_CHUNKED_ENCODING_SUPPORT)) { m_uContentRemain = 0; CHXString strEncoding = pMsg->getHeaderValue("Transfer-Encoding"); if (strEncoding == "chunked") { m_ReadState = DEMUX_READ_DATA; } } else // Far less strict for non-persistent HTTP/1.0 connections. { m_uContentRemain = 0; m_ReadState = DEMUX_READ_DATA; } } else { MIMEHeader* pHdr = pMsg->getHeader("Content-Length"); if (!pHdr) { m_uContentRemain = 0; } else { CHXString strLen; pHdr->asString(strLen); int iLen = atoi(strLen); if (iLen < 0 || iLen > 0xffff) { DPRINTF(D_ERROR, ("HTTP: Bad content length %d\n", iLen)); if (pBuf) pBuf->Release(); Close(HXR_FAIL); return; } m_uContentRemain = (UINT32)iLen; m_ReadState = DEMUX_READ_DATA; } } if (bFirstRun && m_pResponse->AutoDispatch()) { m_pSavedMessage = pMsg; static_cast<CHXServSocket*>(m_pSock)->Dispatch(); break; } DispatchMessage(pMsg); delete pMsg; } else if (m_ReadState == DEMUX_READ_DATA) { BOOL bEnforceContentLength = FALSE; if (m_pResponse->GetFeatureFlags() & HTTP_FEATURE_IGNORE_CONTENT_LENGTH) { HX_ASSERT(m_uContentRemain == 0); // This value not used. pContentBuf = pBuf; pBuf = NULL; } else { if (m_uContentRemain >= pBuf->GetSize()) { pContentBuf = pBuf; m_uContentRemain -= pBuf->GetSize(); pBuf = NULL; } else { pContentBuf = new CHXStaticBuffer(pBuf, 0, m_uContentRemain); pContentBuf->AddRef(); pNewBuf = new CHXStaticBuffer(pBuf, m_uContentRemain, pBuf->GetSize()-m_uContentRemain); pNewBuf->AddRef(); HX_RELEASE(pBuf); pBuf = pNewBuf; m_uContentRemain = 0; m_ReadState = DEMUX_READ_MSG; } } m_pResponse->OnData(pContentBuf); HX_RELEASE(pContentBuf); } } if (pBuf != NULL) { m_pFragBuf = pBuf; m_pFragBuf->AddRef(); } HX_RELEASE(pBuf); }
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); }
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(); }
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; }