void QTSServer::DoInitRole() { QTSS_RoleParams theInitParams; theInitParams.initParams.inServer = this; theInitParams.initParams.inPrefs = fSrvrPrefs; theInitParams.initParams.inMessages = fSrvrMessages; theInitParams.initParams.inErrorLogStream = &sErrorLogStream; QTSS_ModuleState theModuleState; theModuleState.curRole = QTSS_Initialize_Role; theModuleState.curTask = NULL; OSThread::SetMainThreadData(&theModuleState); for (UInt32 x = 0; x < QTSServerInterface::GetNumModulesInRole(QTSSModule::kInitializeRole); x++) { QTSSModule* theModule = QTSServerInterface::GetModule(QTSSModule::kInitializeRole, x); theInitParams.initParams.inModule = theModule; theModuleState.curModule = theModule; QTSS_Error theErr = theModule->CallDispatch(QTSS_Initialize_Role, &theInitParams); if (theErr != QTSS_NoErr) { // If the module reports an error when initializing itself, // delete the module and pretend it was never there. QTSSModuleUtils::LogError(qtssWarningVerbosity, qtssMsgInitFailed, theErr, theModule->GetValue(qtssModName)->Ptr); sModuleQueue.Remove(theModule->GetQueueElem()); delete theModule; } } OSThread::SetMainThreadData(NULL); }
void QTSServer::DoInitRole() { QTSS_RoleParams theInitParams; theInitParams.initParams.inServer = this; theInitParams.initParams.inPrefs = fSrvrPrefs; theInitParams.initParams.inMessages = fSrvrMessages; theInitParams.initParams.inErrorLogStream = &sErrorLogStream; QTSS_ModuleState theModuleState; theModuleState.curRole = QTSS_Initialize_Role; theModuleState.curTask = NULL; OSThread::SetMainThreadData(&theModuleState); // // Add the OPTIONS method as the one method the server handles by default (it handles // it internally). Modules that handle other RTSP methods will add QTSS_RTSPMethod theOptionsMethod = qtssOptionsMethod; (void)this->SetValue(qtssSvrHandledMethods, 0, &theOptionsMethod, sizeof(theOptionsMethod)); // For now just disable the SetParameter to be compatible with Real. It should really be removed only for clients that have problems with their SetParameter implementations like (Real Players). // At the moment it isn't necesary to add the option. // QTSS_RTSPMethod theSetParameterMethod = qtssSetParameterMethod; // (void)this->SetValue(qtssSvrHandledMethods, 0, &theSetParameterMethod, sizeof(theSetParameterMethod)); for (UInt32 x = 0; x < QTSServerInterface::GetNumModulesInRole(QTSSModule::kInitializeRole); x++) { QTSSModule* theModule = QTSServerInterface::GetModule(QTSSModule::kInitializeRole, x); theInitParams.initParams.inModule = theModule; theModuleState.curModule = theModule; QTSS_Error theErr = theModule->CallDispatch(QTSS_Initialize_Role, &theInitParams); if (theErr != QTSS_NoErr) { // If the module reports an error when initializing itself, // delete the module and pretend it was never there. QTSSModuleUtils::LogError(qtssWarningVerbosity, qtssMsgInitFailed, theErr, theModule->GetValue(qtssModName)->Ptr); sModuleQueue.Remove(theModule->GetQueueElem()); delete theModule; } } OSThread::SetMainThreadData(NULL); }
QTSS_Error QTSSCallbacks::QTSS_Authorize(QTSS_RTSPRequestObject inAuthRequestObject, char** outAuthRealm, Bool16* outAuthUserAllowed) { RTSPRequestInterface* request = (RTSPRequestInterface *) inAuthRequestObject; if (request == NULL) return QTSS_BadArgument; // Because this is a role being executed from inside a callback, we need to // make sure that QTSS_RequestEvent will not work. Task* curTask = NULL; QTSS_ModuleState* theState = (QTSS_ModuleState*)OSThread::GetMainThreadData(); if (OSThread::GetCurrent() != NULL) theState = (QTSS_ModuleState*)OSThread::GetCurrent()->GetThreadData(); if (theState != NULL) curTask = theState->curTask; QTSS_RoleParams theParams; theParams.rtspRequestParams.inRTSPSession = NULL; theParams.rtspRequestParams.inRTSPRequest = request; theParams.rtspRequestParams.inClientSession = NULL; QTSS_Error theErr = QTSS_RequestFailed; UInt32 x = 0; UInt32 numModules = QTSServerInterface::GetNumModulesInRole(QTSSModule::kRTSPAuthRole); QTSSModule* theModulePtr = NULL; Bool16 allowedDefault = QTSServerInterface::GetServer()->GetPrefs()->GetAllowGuestDefault(); *outAuthUserAllowed = allowedDefault; Bool16 allowed = allowedDefault; //server pref? Bool16 hasUser = false; Bool16 handled = false; // Call all the modules that are registered for the RTSP Authorize Role for ( ; x < numModules; x++) { request->SetAllowed(true); request->SetHasUser(false); request->SetAuthHandled(false); debug_printf(" QTSSCallbacks::QTSS_Authorize calling module module = %lu numModules=%lu\n", x,numModules); theModulePtr = QTSServerInterface::GetModule(QTSSModule::kRTSPAuthRole, x); theErr = QTSS_NoErr; if (theModulePtr) { if (__QTSSCALLBACKS_DEBUG__) theModulePtr->GetValue(qtssModName)->PrintStr("QTSSModule::CallDispatch ENTER module=", "\n"); theErr = theModulePtr->CallDispatch(QTSS_RTSPAuthorize_Role, &theParams); debug_printf(" QTSSCallbacks::QTSS_Authorize calling module module = %lu numModules=%lu ModuleError=%ld\n", x,numModules, theErr); } else { debug_printf(" QTSSCallbacks::QTSS_Authorize calling module module = %lu is NULL! numModules=%lu\n", x,numModules); continue; } allowed = request->GetAllowed(); hasUser = request->GetHasUser(); handled = request->GetAuthHandled(); debug_printf("QTSSCallbacks::QTSS_Authorize allowedDefault =%d allowed= %d hasUser = %d handled=%d \n",allowedDefault, allowed,hasUser, handled); *outAuthUserAllowed = allowed; //notes: //if (allowed && !handled) break; //old module //if (!allowed && handled) /new module handled the request but not authorized keep trying //if (allowed && handled) //new module allowed but keep trying in case someone denies. if (!allowed && !handled) //old module break on !allowed { debug_printf("RTSPSession.cpp::Run(kAuthorizingRequest) skipping other modules fCurrentModule = %lu numModules=%lu\n", x,numModules); break; } } // outAuthRealm is set to the realm that is given by the module that has denied authentication StrPtrLen* realm = request->GetValue(qtssRTSPReqURLRealm); *outAuthRealm = realm->GetAsCString(); return theErr; }