void RemoveOutput(ReflectorOutput* inOutput, ReflectorSession* inSession, Bool16 killClients) { //This function removes the output from the ReflectorSession, then Assert(inSession); if (inSession != NULL) { if (inOutput != NULL) { inSession->RemoveOutput(inOutput,true); //qtss_printf("QTSSReflectorModule.cpp:RemoveOutput it is a client session\n"); } else { // it is a Broadcaster session //qtss_printf("QTSSReflectorModule.cpp:RemoveOutput it is a broadcaster session\n"); //SourceInfo* theInfo = inSession->GetSourceInfo(); //Assert(theInfo); // //if (theInfo->IsRTSPControlled()) //{ // FileDeleter(inSession->GetSourcePath()); //} // //if (killClients || 1) //{ inSession->TearDownAllOutputs(); //} } //qtss_printf("QTSSReflectorModule.cpp:RemoveOutput refcount =%lu\n", inSession->GetRef()->GetRefCount()); //check if the ReflectorSession should be deleted //(it should if its ref count has dropped to 0) OSMutexLocker locker (sSessionMap->GetMutex()); OSRef* theSessionRef = inSession->GetRef(); if (theSessionRef != NULL) { if (theSessionRef->GetRefCount() == 0) { RTSPRelaySession* proxySession = (RTSPRelaySession*)inSession->GetRTSPRelaySession(); if(proxySession != NULL) { proxySession->SetReflectorSession(NULL); sClientSessionMap->UnRegister(proxySession->GetRef()); proxySession->Signal(Task::kKillEvent); } inSession->SetRTSPRelaySession(NULL); sSessionMap->UnRegister(theSessionRef); delete inSession; } //else if (theSessionRef->GetRefCount() == 1) //{ // //qtss_printf("QTSSReflector.cpp:RemoveOutput Delete SESSION=%lu\n",(UInt32)inSession); // RTSPRelaySession* proxySession = (RTSPRelaySession*)inSession->GetRelaySession(); // if(proxySession != NULL) // { // proxySession->SetReflectorSession(NULL); // sClientSessionMap->UnRegister(proxySession->GetRef()); // proxySession->Signal(Task::kKillEvent); // } // inSession->SetRelaySession(NULL); // sSessionMap->UnRegister(theSessionRef); // delete inSession; //} else { qtss_printf("QTSSReflector.cpp:RemoveOutput Release SESSION=%lu RefCount=%d\n",(UInt64)inSession,theSessionRef->GetRefCount()); sSessionMap->Release(theSessionRef); // one of the sessions on the ref is ending just decrement the count } } } delete inOutput; }