Ejemplo n.º 1
0
/********************************************************
 * ConsumeBroadcastToken
 *   Check and consume a token for conference watcher
 ********************************************************/
Participant* MultiConf::ConsumeParticipantOutputToken(const std::wstring &token)
{
	//Check token
	ParticipantTokens::iterator it = outputTokens.find(token);

	//Check we found one
	if (it==outputTokens.end())
		//Broadcast not found
		return NULL;

	//Get participant id
	int partId = it->second;

	//Remove token
	outputTokens.erase(it);

	//Get it
	Participants::iterator itPart = participants.find(partId);

	//Check if not found
	if (itPart==participants.end())
		//Not found
		return NULL;

	//Get it
	Participant* part = itPart->second;

	//Asert correct tipe
	if (part->GetType()!=Participant::RTMP)
		//Esit
		return NULL;

	//return it
	return part;
}
Ejemplo n.º 2
0
RTMPMediaStream::Listener* MultiConf::ConsumeParticipantInputToken(const std::wstring &token)
{
	//Check token
	ParticipantTokens::iterator it = inputTokens.find(token);

	//Check we found one
	if (it==inputTokens.end())
	{
		//Error
		Error("Participant token not found\n");
		//Broadcast not found
		return NULL;
	}

	//Get participant id
	int partId = it->second;

	//Remove token
	inputTokens.erase(it);

	//Get it
	Participants::iterator itPart = participants.find(partId);

	//Check if not found
	if (itPart==participants.end())
	{
		//Error
		Error("Participant not found\n");
		//Broadcast not found
		return NULL;
	}

	//Get it
	Participant* part = itPart->second;

	//Asert correct tipe
	if (part->GetType()!=Participant::RTMP)
	{
		//Error
		Error("Participant type not RTMP");

		//Broadcast not found
		return NULL;
	}

	//return it
	return (RTMPMediaStream::Listener*)(RTMPParticipant*)part;
}
Ejemplo n.º 3
0
Participant *MultiConf::GetParticipant(int partId,Participant::Type type)
{
	//Find participant
	Participant *part = GetParticipant(partId);

	//If no participant
	if (!part)
		//Exit
		return NULL;

	//Ensure it is from the correct type
	if (part->GetType()!=type)
		//Error
		return (Participant *)Error("Participant is not of desired type");
	
	//Return it
	return part;
}
Ejemplo n.º 4
0
/************************
* StopSendingVideo
* 	StopSendingVideo
*************************/
int MultiConf::StopSendingVideo(int id)
{
	int ret = 0;

	Log("-StopSendingVideo [%d]\n",id);

	//Use list
	participantsLock.IncUse();

	 //El iterator
        Participants::iterator it = participants.find(id);

	//Si no esta
	if (it == participants.end()) {
		Log("Participant is not of RTP type, may be from rtsp.\n");
		m_GroupVideo.StopSending(id);
		participantsLock.DecUse();
		return 1;
	}
	
	//Get the participant
        Participant *part = (*it).second;

	//Ensure it is from the correct type
	if (part->GetType()!=Participant::RTP)
		//Not possible
		Log("Participant is not of RTP type, may be from rtsp.\n");

	
	m_GroupVideo.StopSending(id);
	//Unlock
	participantsLock.DecUse();

	return 1;
	//Stop sending the video
	//return ((RTPParticipant*)part)->StopSendingVideo();
}
Ejemplo n.º 5
0
/************************
* StartSendingVideo
* 	StartSendingVideo
*************************/
RTPSession *MultiConf::StartSendingVideo(int id,char *sendVideoIp,int sendVideoPort,VideoCodec::RTPMap& rtpMap)
{
	int ret = 0;

	Log("-StartSendingVideo [%d]\n",id);
	//Use list
	participantsLock.IncUse();
	Participants::iterator it = participants.find(id);
	RTPSession *rtp = NULL;
	//Si no esta
	if (it == participants.end()) {
		Log("Participant is not of RTP type, may be from rtsp.\n");
		rtp = m_GroupVideo.StartSending(id,sendVideoIp,sendVideoPort,rtpMap, NULL);
		SendIdrPacket(rtp);
		participantsLock.DecUse();
		return rtp;
	}
	
	 //Get the participant
        Participant *part = (*it).second;

	//Ensure it is from the correct type
	if (part->GetType()!=Participant::RTP)
		//Not possible
		Log("Participant is not of RTP type, may be from rtsp.\n");

	rtp = ((RTPParticipant*)part)->GetVideoRTPSession();
	m_GroupVideo.StartSending(id,sendVideoIp,sendVideoPort,rtpMap, rtp);
	if(m_CurrentBroadCaster != id)
		SendIdrPacket(rtp);

	//Unlock
	participantsLock.DecUse();
	//Start sending the video
	//return ((RTPParticipant*)part)->StartSendingVideo(sendVideoIp,sendVideoPort,rtpMap);
	return rtp;
}
Ejemplo n.º 6
0
/************************
* StartSendingAudio
* 	StartSendingAudio
*************************/
RTPSession *MultiConf::StartSendingAudio(int id,char *sendAudioIp,int sendAudioPort,AudioCodec::RTPMap& rtpMap)
{
	int ret = 0;

	Log("-StartSendingAudio [%d]\n",id);

	//Use list
	participantsLock.IncUse();

	//El iterator
        Participants::iterator it = participants.find(id);

	//Si no esta
	if (it == participants.end()) {
		Log("Participant is not of RTP type, may be from rtsp.\n");
		RTPSession *rtp = m_GroupAudio.StartSending(id,sendAudioIp,sendAudioPort,rtpMap, NULL);
		participantsLock.DecUse();
		return rtp;
	}

 	//Get the participant
        Participant *part = (*it).second;

	//Ensure it is from the correct type
	if (part->GetType()!=Participant::RTP)
		//Not possible
		Log("Participant is not of RTP type, may be from rtsp.\n");
	
	//Unlock
	participantsLock.DecUse();
	((RTPParticipant*)part)->StartSendingAudio(sendAudioIp,sendAudioPort,rtpMap);
	//m_GroupAudio.StartSending(id,sendAudioIp,sendAudioPort,rtpMap, ((RTPParticipant*)part)->GetAudioRTPSession());
	
	//return 1;
	//Start sending the video
	return ((RTPParticipant*)part)->GetAudioRTPSession();
}