即日起在codingBlog上分享您的技术经验即可获得积分,积分可兑换现金哦。

darwin 读取xml流程

编程语言 sunxiaopengsun 23℃ 0评论

    QTSSModule* theReflectorModule = new QTSSModule("QTSSReflectorModule");
    (void)theReflectorModule->SetupModule(&sCallbacks, &QTSSReflectorModule_Main);
    (void)AddModule(theReflectorModule);






1.在QTSSModule构造函数QTSSModule::QTSSModule(char* inName, char* inPath)中,将thePrefs成员变量写入数据字典

   this->SetVal(qtssModPrefs,      &fPrefs,            sizeof(fPrefs));


2.在Bool16 QTSServer::AddModule(QTSSModule* inModule)中,将QTSSPrefs* thePrefs传入模块中,从而实现了fPrefs成员的赋值。thePrefs内部保存了xml信息。

   thePrefs->RereadPreferences()将xml写入到数据字典

 // Give the module object a prefs dictionary. Instance attributes are allowed for these objects.


   QTSSPrefs* thePrefs = NEW QTSSPrefs( sPrefsSource, inModule->GetValue(qtssModName), QTSSDictionaryMap::GetMap(QTSSDictionaryMap::kModulePrefsDictIndex), true);


   thePrefs->RereadPreferences();


   inModule->SetPrefsDict(thePrefs);



3.在每个模块内部,通过sPrefs = QTSSModuleUtils::GetModulePrefsObject(inParams->inModule);来获取到对应模块的sPrefs,利用sPrefs就可以获取到xml的配置信息了

QTSS_ModulePrefsObject QTSSModuleUtils::GetModulePrefsObject(QTSS_ModuleObject inModObject)
{
    QTSS_ModulePrefsObject thePrefsObject = NULL;
    UInt32 theLen = sizeof(thePrefsObject);
    QTSS_Error theErr = QTSS_GetValue(inModObject, qtssModPrefs, 0, &thePrefsObject, &theLen);
    Assert(theErr == QTSS_NoErr);
    
    return thePrefsObject;
}


GetAttribute从数据字典取出之前保存的数据

QTSSModuleUtils::GetAttribute(sPrefs, "disable_rtp_play_info",  qtssAttrDataTypeBool16,
                                &sRTPInfoDisabled, &sDefaultRTPInfoDisabled, sizeof(sDefaultRTPInfoDisabled));

    QTSSModuleUtils::GetAttribute(sPrefs, "allow_non_sdp_urls",     qtssAttrDataTypeBool16,
                                &sAllowNonSDPURLs, &sDefaultAllowNonSDPURLs, sizeof(sDefaultAllowNonSDPURLs));
                                                                
    QTSSModuleUtils::GetAttribute(sPrefs, "enable_broadcast_announce",  qtssAttrDataTypeBool16,
                                &sAnnounceEnabled, &sDefaultAnnounceEnabled, sizeof(sDefaultAnnounceEnabled));
    QTSSModuleUtils::GetAttribute(sPrefs, "enable_broadcast_push",  qtssAttrDataTypeBool16,
                                &sBroadcastPushEnabled, &sDefaultBroadcastPushEnabled, sizeof(sDefaultBroadcastPushEnabled));
    QTSSModuleUtils::GetAttribute(sPrefs, "max_broadcast_announce_duration_secs",   qtssAttrDataTypeUInt32,
                                &sMaxBroadcastAnnounceDuration, &sDefaultMaxBroadcastAnnounceDuration, sizeof(sDefaultMaxBroadcastAnnounceDuration));
    QTSSModuleUtils::GetAttribute(sPrefs, "allow_duplicate_broadcasts",     qtssAttrDataTypeBool16,
                                &sAllowDuplicateBroadcasts, &sDefaultAllowDuplicateBroadcasts, sizeof(sDefaultAllowDuplicateBroadcasts));





转载请注明:CodingBlog » darwin 读取xml流程

喜欢 (0)or分享 (0)
发表我的评论
取消评论

*

表情