Пример #1
0
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;
}
Пример #2
0
void* QTSSCallbacks::Easy_GetHLSessions()
{
	OSRefTable* hlsMap = QTSServerInterface::GetServer()->GetHLSSessionMap();

	EasyMsgSCHLSessionListACK ack;
	ack.SetHeaderValue(EASY_TAG_VERSION, "1.0");
	ack.SetHeaderValue(EASY_TAG_CSEQ, "1");	
	char count[16] = { 0 };
	sprintf(count,"%d", hlsMap->GetNumRefsInTable());
	ack.SetBodyValue(EASY_TAG_SESSION_COUNT, count );

	OSRef* theSesRef = NULL;

	UInt32 uIndex= 0;
	OSMutexLocker locker(hlsMap->GetMutex());
	for (OSRefHashTableIter theIter(hlsMap->GetHashTable()); !theIter.IsDone(); theIter.Next())
	{
		OSRef* theRef = theIter.GetCurrent();
		EasyHLSSession* theSession = (EasyHLSSession*)theRef->GetObject();

		EasyDarwinHLSession session;
		session.index = uIndex;
		session.SessionName = string(theSession->GetSessionID()->Ptr);
		session.HlsUrl = string(theSession->GetHLSURL());
		session.sourceUrl = string(theSession->GetSourceURL());
		session.bitrate = theSession->GetLastStatBitrate();
		ack.AddSession(session);
		uIndex++;
	}   

	string msg = ack.GetMsg();

	UInt32 theMsgLen = strlen(msg.c_str());
	char* retMsg = new char[theMsgLen+1];
	retMsg[theMsgLen] = '\0';
	strncpy(retMsg, msg.c_str(), strlen(msg.c_str()));
	return (void*)retMsg;
}
Пример #3
0
QTSS_Error EasyHLSOpen(Easy_HLSOpen_Params* inParams)
{	
	OSRefTable* sHLSSessionMap =  QTSServerInterface::GetServer()->GetHLSSessionMap();

	OSMutexLocker locker (sHLSSessionMap->GetMutex());

	EasyHLSSession* session = NULL;
	//首先查找MAP里面是否已经有了对应的流
	StrPtrLen streamName(inParams->inStreamName);
	OSRef* clientSesRef = sHLSSessionMap->Resolve(&streamName);
	if(clientSesRef != NULL)
	{
		session = (EasyHLSSession*)clientSesRef->GetObject();
	}
	else
	{
		session = NEW EasyHLSSession(&streamName);

		OS_Error theErr = sHLSSessionMap->Register(session->GetRef());
		Assert(theErr == QTSS_NoErr);

		//增加一次对RelaySession的无效引用,后面会统一释放
		OSRef* debug = sHLSSessionMap->Resolve(&streamName);
		Assert(debug == session->GetRef());
	}
	
	//到这里,肯定是有一个EasyHLSSession可用的
	session->HLSSessionStart(inParams->inRTSPUrl, inParams->inTimeout);

	if(inParams->outHLSUrl)
		qtss_sprintf(inParams->outHLSUrl,"%s",session->GetHLSURL());

	sHLSSessionMap->Release(session->GetRef());

	return QTSS_NoErr;
}