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(); } }
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")); }
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(); }