Пример #1
0
void* QTSSCallbacks::Easy_GetRTSPPushSessions()
{
	OSRefTable* reflectorSessionMap = QTSServerInterface::GetServer()->GetReflectorSessionMap();

	EasyMsgSCRTSPPushSessionListACK ack;
	ack.SetHeaderValue(EASY_TAG_VERSION, "1.0");
	ack.SetHeaderValue(EASY_TAG_CSEQ, "1");

	UInt32 uIndex= 0;
	OSMutexLocker locker(reflectorSessionMap->GetMutex());

	for (OSRefHashTableIter theIter(reflectorSessionMap->GetHashTable()); !theIter.IsDone(); theIter.Next())
	{
		OSRef* theRef = theIter.GetCurrent();
		ReflectorSession* theSession = (ReflectorSession*)theRef->GetObject();

		EasyDarwinRTSPSession session;
		session.index = uIndex;
		char* fullRequestURL = NULL;

		RTPSession* clientSession = (RTPSession*) theSession->GetBroadcasterSession();

		if(clientSession == NULL) continue;

		clientSession->GetValueAsString(qtssCliSesFullURL,0,&fullRequestURL);
		session.Url = fullRequestURL;
		session.Name = theSession->GetSessionName();
		session.numOutputs = theSession->GetNumOutputs();
		ack.AddSession(session);
		uIndex++;
	}  

	char count[16] = { 0 };
	sprintf(count,"%d", uIndex);
	ack.SetBodyValue(EASY_TAG_SESSION_COUNT, count);

	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;
}