RTPFileSession::~RTPFileSession() { // Check to see if we should destroy this file OSMutexLocker locker (sOpenFileMap.GetMutex()); #if RTPFILESESSIONDEBUG qtss_printf("Dropping refcount on file\n"); #endif if (fFile == NULL) return; sOpenFileMap.Release(fFile->GetRef()); if (fFile->GetRef()->GetRefCount() == 0) { #if RTPFILESESSIONDEBUG qtss_printf("Refcount dropped to 0. Deleting file\n"); #endif sOpenFileMap.UnRegister(fFile->GetRef()); delete fFile; } // Delete our data buffer delete [] fDataBuffer; delete [] fTrackInfo; }
QTSS_Error EasyHLSClose(Easy_HLSClose_Params* inParams) { OSRefTable* sHLSSessionMap = QTSServerInterface::GetServer()->GetHLSSessionMap(); OSMutexLocker locker (sHLSSessionMap->GetMutex()); //首先查找Map里面是否已经有了对应的流 StrPtrLen streamName(inParams->inStreamName); OSRef* clientSesRef = sHLSSessionMap->Resolve(&streamName); if(NULL == clientSesRef) return QTSS_RequestFailed; EasyHLSSession* session = (EasyHLSSession*)clientSesRef->GetObject(); session->HLSSessionRelease(); sHLSSessionMap->Release(session->GetRef()); if (session->GetRef()->GetRefCount() == 0) { qtss_printf("EasyHLSModule.cpp:EasyHLSClose UnRegister and delete session =%p refcount=%"_U32BITARG_"\n", session->GetRef(), session->GetRef()->GetRefCount() ) ; sHLSSessionMap->UnRegister(session->GetRef()); delete session; } return QTSS_NoErr; }
QTSS_Error EasyHLSOpen(Easy_RecordOpen_Params* inParams) { OSRefTable* sHLSSessionMap = QTSServerInterface::GetServer()->GetRecordSessionMap(); OSMutexLocker locker (sHLSSessionMap->GetMutex()); EasyRecordSession* session = NULL; //首先查找MAP里面是否已经有了对应的流 StrPtrLen streamName(inParams->inStreamName); OSRef* clientSesRef = sHLSSessionMap->Resolve(&streamName); if(clientSesRef != NULL) { session = (EasyRecordSession*)clientSesRef->GetObject(); } else { session = NEW EasyRecordSession(&streamName); OS_Error theErr = sHLSSessionMap->Register(session->GetRef()); Assert(theErr == QTSS_NoErr); //增加一次对RelaySession的无效引用,后面会统一释放 OSRef* debug = sHLSSessionMap->Resolve(&streamName); Assert(debug == session->GetRef()); } //到这里,肯定是有一个EasyRecordSession可用的 session->HLSSessionStart(inParams->inRTSPUrl, inParams->inTimeout); sHLSSessionMap->Release(session->GetRef()); return QTSS_NoErr; }
char* GetHLSUrl(char* inSessionName) { OSRefTable* sHLSSessionMap = QTSServerInterface::GetServer()->GetHLSSessionMap(); OSMutexLocker locker (sHLSSessionMap->GetMutex()); char* hlsURL = NULL; //首先查找Map里面是否已经有了对应的流 StrPtrLen streamName(inSessionName); OSRef* clientSesRef = sHLSSessionMap->Resolve(&streamName); if(NULL == clientSesRef) return NULL; EasyHLSSession* session = (EasyHLSSession*)clientSesRef->GetObject(); hlsURL = session->GetHLSURL(); sHLSSessionMap->Release(session->GetRef()); return hlsURL; }