/************************ * DeleteParticipant * Borra un participante *************************/ int MultiConf::DeleteParticipant(int id) { Log(">DeleteParticipant [%d]\n",id); //Stop recording participant just in case StopRecordingParticipant(id); //Block participantsLock.WaitUnusedAndLock(); //El iterator Participants::iterator it = participants.find(id); //Si no esta if (it == participants.end()) { //Unlock participantsLock.Unlock(); //Exit return Error("Participant not found\n"); } //LO obtenemos Participant *part = it->second; part->SetGroupVideoStream(NULL); Log("-DeleteParticipant ending media [%d]\n",id); //Y lo quitamos del mapa participants.erase(it); //Unlock participantsLock.Unlock(); //Destroy participatn DestroyParticipant(id,part); //Terminamos el audio y el video if(m_CurrentBroadCaster == id && participants.size()) { Log("BroadCaster exist use the first coming user\n"); participants.begin()->second->SetGroupVideoStream(&m_GroupVideo); m_CurrentBroadCaster = participants.begin()->second->GetPartId(); participants.begin()->second->SendVideoFPU(); } else if(m_CurrentBroadCaster == id && participants.size() == 0) { Log("BroadCaster and no user left\n"); m_CurrentBroadCaster = 0; } Log("<DeleteParticipant [%d]\n",id); return 1; }
/************************ * 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; }