예제 #1
0
/************************
* CreateParticipant
* 	A�ade un participante
*************************/
int MultiConf::CreateParticipant(int mosaicId,std::wstring name,Participant::Type type)
{
	Participant *part = NULL;

	Log(">CreateParticipant [mosaic:%d]\n",mosaicId);

	//SI no tamos iniciados pasamos
	if (!inited)
		return Error("Not inited\n");

	//Get lock
	participantsLock.WaitUnusedAndLock();

	//Obtenemos el id
	int partId = maxId++;

	//Unlock
	participantsLock.Unlock();

	//Le creamos un mixer
	if (!videoMixer.CreateMixer(partId))
		return Error("Couldn't set video mixer\n");

	//Y el de audio
	if (!audioMixer.CreateMixer(partId))
	{
		//Borramos el de video
		videoMixer.DeleteMixer(partId);
		//Y salimos
		return Error("Couldn't set audio mixer\n");
	}

	//And text
	if (!textMixer.CreateMixer(partId,name))
	{
		//Borramos el de video y audio
		videoMixer.DeleteMixer(partId);
		audioMixer.DeleteMixer(partId);
		//Y salimos
		return Error("Couldn't set text mixer\n");
	}

	//Depending on the type
	switch(type)
	{
		case Participant::RTP:
			//Create RTP Participant
			part = new RTPParticipant(partId, m_ConfId);
			break;
		case Participant::RTMP:
			part = new RTMPParticipant(partId, m_ConfId);
			//Create RTP Participant
			break;
	}

	//Set inputs and outputs
	part->SetVideoInput(videoMixer.GetInput(partId));
	part->SetVideoOutput(videoMixer.GetOutput(partId));
	part->SetAudioInput(audioMixer.GetInput(partId));
	part->SetAudioOutput(audioMixer.GetOutput(partId));
	part->SetTextInput(textMixer.GetInput(partId));
	part->SetTextOutput(textMixer.GetOutput(partId));

	//Init participant
	part->Init();

	//E iniciamos el mixer
	videoMixer.InitMixer(partId,mosaicId);
	audioMixer.InitMixer(partId);
	textMixer.InitMixer(partId);

	//Get lock
	participantsLock.WaitUnusedAndLock();

	//Lo insertamos en el map
	participants[partId] = part;

	//add for rtsp watcher by liuhong start
	if (m_CurrentBroadCaster == 0)
	{
		part->SetGroupVideoStream(&m_GroupVideo);
		m_CurrentBroadCaster = partId;
		videoMixer.SetSlot(mosaicId,0,partId);
	}
	else
	{
		Log("BroadCaster already exist send fpu everybody\n");
		//Participants::iterator it = participants.find(m_CurrentBroadCaster);
		//if (it == participants.end())
		//{
		//	return Error("Participant not found\n");
		//}
		//it->second->SendVideoFPU();
	}
	//add for rtsp watcher by end

	//Unlock
	participantsLock.Unlock();

	//Set us as listener
	part->SetListener(this);

	Log("<CreateParticipant [%d]\n",partId);

	return partId;
}
예제 #2
0
/************************
* CreateParticipant
* 	A�ade un participante
*************************/
int MultiConf::CreateParticipant(int mosaicId,int sidebarId,const std::wstring &name,const std::wstring &token,Participant::Type type)
{
	wchar_t uuid[1024];
	Participant *part = NULL;

	Log(">CreateParticipant [mosaic:%d]\n",mosaicId);

	//SI no tamos iniciados pasamos
	if (!inited)
		return Error("Not inited\n");

	//Get lock
	participantsLock.WaitUnusedAndLock();

	//Obtenemos el id
	int partId = maxId++;

	//Create uuid
	swprintf(uuid,1024,L"%ls@%d",tag.c_str(),partId);

	//Unlock
	participantsLock.Unlock();

	//Le creamos un mixer
	if (!videoMixer.CreateMixer(partId,name))
		return Error("Couldn't set video mixer\n");

	//Y el de audio
	if (!audioMixer.CreateMixer(partId))
	{
		//Borramos el de video
		videoMixer.DeleteMixer(partId);
		//Y salimos
		return Error("Couldn't set audio mixer\n");
	}

	//And text
	if (!textMixer.CreateMixer(partId,name))
	{
		//Borramos el de video y audio
		videoMixer.DeleteMixer(partId);
		audioMixer.DeleteMixer(partId);
		//Y salimos
		return Error("Couldn't set text mixer\n");
	}

	//Depending on the type
	switch(type)
	{
		case Participant::RTP:
			//Create RTP Participant
			part = new RTPParticipant(partId,token,std::wstring(uuid));
			break;
		case Participant::RTMP:
			part = new RTMPParticipant(partId,token);
			//Create RTP Participant
			break;
	}
	
	//Set name
	part->SetName(name);

	//Set inputs and outputs
	part->SetVideoInput(videoMixer.GetInput(partId));
	part->SetVideoOutput(videoMixer.GetOutput(partId));
	part->SetAudioInput(audioMixer.GetInput(partId));
	part->SetAudioOutput(audioMixer.GetOutput(partId));
	part->SetTextInput(textMixer.GetInput(partId));
	part->SetTextOutput(textMixer.GetOutput(partId));

	//Init participant
	part->Init();

	//E iniciamos el mixer
	videoMixer.InitMixer(partId,mosaicId);
	audioMixer.InitMixer(partId,sidebarId);
	textMixer.InitMixer(partId);

	//Get lock
	participantsLock.WaitUnusedAndLock();

	//Lo insertamos en el map
	participants[partId] = part;

	//Unlock
	participantsLock.Unlock();

	//Set us as listener
	part->SetListener(this);

	Log("<CreateParticipant [%d]\n",partId);

	return partId;
}