Ejemplo n.º 1
0
MultiConf::ParticipantStatistics* MultiConf::GetParticipantStatistic(int partId)
{
	//Create statistics map
	ParticipantStatistics *stats = new ParticipantStatistics();

	//Lock
	participantsLock.IncUse();

	//Find participant
	Participant* part = GetParticipant(partId);

	//Check participant
	if (part)
	{
		//Append
		(*stats)["audio"] = part->GetStatistics(MediaFrame::Audio);
		(*stats)["video"] = part->GetStatistics(MediaFrame::Video);
		(*stats)["text"]  = part->GetStatistics(MediaFrame::Text);
	}

	//Unlock
	participantsLock.DecUse();

	//Return stats
	return stats;
}
Ejemplo n.º 2
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.º 3
0
/************************
* SetAudioCodec
* 	SetAudioCodec
*************************/
int MultiConf::SetAudioCodec(int id,int codec)
{
	int ret = 0;

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

	//Use list
	participantsLock.IncUse();

	//Get the participant
	Participant *part = GetParticipant(id);

	//Check particpant
	if (part)
		//Set video codec
		ret = part->SetAudioCodec((AudioCodec::Type)codec);
	if (!m_GroupAudio.IsInited())
	{
		m_GroupAudio.SetAudioCodec((AudioCodec::Type)codec);
	}

	//Unlock
	participantsLock.DecUse();

	//Exit
	return ret;
}
Ejemplo n.º 4
0
int MultiConf::SendFPU(int partId)
{
	int ret = 0;
	
	Log("-SendFPU [id:%d]\n",partId);
	
	//Lock
	participantsLock.IncUse();

	//Get participant
	Participant *part = GetParticipant(partId);

	//Check participant
	if (part)
		//Send FPU
		ret = part->SendVideoFPU();
	if(m_CurrentBroadCaster != 0)
	{
		Log("-RequestFPU [id:%d]\n",m_CurrentBroadCaster);
		listener->onParticipantRequestFPU(this,m_CurrentBroadCaster,this->param);
		listener->onParticipantRequestFPU(this,partId,this->param);
	}
	//Unlock
	participantsLock.DecUse();

	//Exit
	return ret;
}
Ejemplo n.º 5
0
/************************
* SetVideoCodec
* 	SetVideoCodec
*************************/
int MultiConf::SetVideoCodec(int id,int codec,int mode,int fps,int bitrate,int quality, int fillLevel,int intraPeriod)
{
	int ret = 0;

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

	//Use list
	participantsLock.IncUse();

	//Get the participant
	Participant *part = GetParticipant(id);

	if (!m_GroupVideo.IsInited())
	{
		m_GroupVideo.SetVideoCodec((VideoCodec::Type)codec,mode,fps,bitrate,quality,fillLevel,intraPeriod);
	}

	//Check particpant
	if (part)
		//Set video codec
		ret = part->SetVideoCodec((VideoCodec::Type)codec,mode,fps,bitrate,quality,fillLevel,intraPeriod);

	//Unlock
	participantsLock.DecUse();

	//Exit
	return ret;
}
Ejemplo n.º 6
0
std::shared_ptr<XmlNode> DptfStatus::getArbitratorXmlForLoadedParticipants()
{
	auto root = XmlNode::createRoot();
	root->addChild(XmlNode::createComment("format_id=" + ArbitratorStatusFormatId.toString()));

	auto arbitratorRoot = XmlNode::createWrapperElement("arbitrator_status");
	auto participantIndexList = m_participantManager->getParticipantIndexes();
	auto numberOfUniqueDomains = 0;
	for (auto participantIndex = participantIndexList.begin(); participantIndex != participantIndexList.end(); ++participantIndex)
	{
		try
		{
			Participant* participant = m_participantManager->getParticipantPtr(*participantIndex);
			numberOfUniqueDomains = numberOfUniqueDomains + participant->getDomainCount();
		}
		catch (...)
		{
			// Participant not available
		}
	}

	arbitratorRoot->addChild(XmlNode::createDataElement("number_of_domains", StatusFormat::friendlyValue(numberOfUniqueDomains)));

	auto policyIndexes = m_policyManager->getPolicyIndexes();
	for (auto policyIndex = policyIndexes.begin(); policyIndex != policyIndexes.end(); ++policyIndex)
	{
		try
		{
			Policy* policy = m_policyManager->getPolicyPtr(*policyIndex);
			std::string name = policy->getName();
			auto policyRoot = XmlNode::createWrapperElement("policy");
			auto policyName = XmlNode::createDataElement("policy_name", name);
			policyRoot->addChild(policyName);

			for (auto participantIndex = participantIndexList.begin(); participantIndex != participantIndexList.end(); ++participantIndex)
			{
				try
				{
					Participant* participant = m_participantManager->getParticipantPtr(*participantIndex);
					policyRoot->addChild(participant->getArbitrationXmlForPolicy(*policyIndex));
				}
				catch (...)
				{
					// Participant not available
				}
			}

			arbitratorRoot->addChild(policyRoot);
		}
		catch (...)
		{
			// Policy not available, do not add.
		}
	}

	root->addChild(arbitratorRoot);
	return root;
}
Ejemplo n.º 7
0
// surcharge de l'operateur < pour le tri des participants lors
// de la generation du classement
bool
Participant::operator<(Participant &p) const{

    // en cas de score identique, l'ordre alphabetique fait foi
    if (this->getScore() == p.getScore())
        return (this->getParticipantName() < p.getParticipantName());
    else
        return this->getScore() < p.getScore();
}
Ejemplo n.º 8
0
void MainScreen::handleParticipantAdded(Participant p)
{
	QVariantMap map;
	map["name"] = p.getName();
	map["email"] = p.getEmail();
	map["exl"] = p.getExList();

	m_participants << map;
	m_mainPage->setProperty("numParticipants", m_participants.size());
}
Ejemplo n.º 9
0
/************************
* 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;
}
Ejemplo n.º 10
0
void Tournament::GetWinner(){
	int max = -1;
	Participant* winner;
	for(int i = 0; i < number_of_participants; i++){
		if(Participants[i]->GetPoints() > max){
			max = Participants[i]->GetPoints();
			winner = Participants[i];
		}
	}

	cout << winner->GetName() << " " << winner->GetPoints() << endl;

}
Ejemplo n.º 11
0
Archivo: rtp.cpp Proyecto: dyfet/ccrtp
void RTPAudio::onGotHello(const SyncSource &src)
{
	RTPEvent *event = RTPEvent::first;

	slog(Slog::levelDebug) << "hello(" << src.getID() << ") ";
        Participant* p = src.getParticipant();
	slog() << p->getSDESItem(SDESItemTypeCNAME) << std::endl;

	while(event)
	{
		event->gotHello(src);
		event = event->next;
	}
}
Ejemplo n.º 12
0
Archivo: rtp.cpp Proyecto: dyfet/ccrtp
void RTPAudio::onGotGoodbye(const SyncSource &src, const string& reason)
{
	RTPEvent *event = RTPEvent::first;

	slog(Slog::levelDebug) << "bye(" << src.getID() << ") ";
	Participant* p = src.getParticipant();
	slog() << p->getSDESItem(SDESItemTypeCNAME) << "; " << reason;
	slog() << std::endl;

	while(event)
	{
		event->gotGoodbye(src, reason);
		event = event->next;
	}
}
Ejemplo n.º 13
0
void WIDptfConnectedStandbyEntry::execute(void)
{
	writeWorkItemStartingInfoMessage();

	// First let all policies know that we are entering connected standby

	auto policyManager = getPolicyManager();
	auto policyIndexes = policyManager->getPolicyIndexes();

	for (auto i = policyIndexes.begin(); i != policyIndexes.end(); ++i)
	{
		try
		{
			Policy* policy = policyManager->getPolicyPtr(*i);
			policy->executeConnectedStandbyEntry();
		}
		catch (policy_index_invalid& ex)
		{
			// do nothing.  No item in the policy list at this index.
		}
		catch (std::exception& ex)
		{
			writeWorkItemErrorMessagePolicy(ex, "Policy::executeConnectedStandbyEntry", *i);
		}
	}

	// Now let all participants know

	auto participantManager = getParticipantManager();
	auto participantIndexList = participantManager->getParticipantIndexes();

	for (auto i = participantIndexList.begin(); i != participantIndexList.end(); ++i)
	{
		try
		{
			Participant* participant = participantManager->getParticipantPtr(*i);
			participant->connectedStandbyEntry();
		}
		catch (participant_index_invalid& ex)
		{
			// do nothing.  No item in the participant list at this index.
		}
		catch (std::exception& ex)
		{
			writeWorkItemErrorMessageParticipant(ex, "Participant::connectedStandbyEntry", *i);
		}
	}
}
Ejemplo n.º 14
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.º 15
0
Archivo: battle.cpp Proyecto: ejrh/hex
void Battle::step_participant(Participant& participant) {
    if (!participant.can_move())
        return;

    BOOST_LOG_TRIVIAL(trace) << "Participant " << participant;
    make_move(participant);
}
Ejemplo n.º 16
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.º 17
0
void QtChatRoomInviteDlg::removeFromConference() 
{
	QList<QListWidgetItem *>selectList = _inviteListWidget->selectedItems();
	QList<QListWidgetItem *>::iterator it;

	for (it= selectList.begin(); it!= selectList.end(); it++ ) 
	{
		QtChatRoomListWidgetItem* item = dynamic_cast<QtChatRoomListWidgetItem *>((*it));

		Participant p = item->getParticipant();

		if ( !p.isAlreadyInChat() )
		{
			_candidates.setInvitedToChat( p, false );
		}
	}

	updateListCtrls();
}
Ejemplo n.º 18
0
std::shared_ptr<XmlNode> DptfStatus::getXmlForFrameworkLoadedParticipants()
{
	auto participantsRoot = XmlNode::createWrapperElement("participants");

	auto participantIndexList = m_participantManager->getParticipantIndexes();
	for (auto i = participantIndexList.begin(); i != participantIndexList.end(); ++i)
	{
		try
		{
			Participant* participant = m_participantManager->getParticipantPtr(*i);
			participantsRoot->addChild(participant->getXml(Constants::Invalid));
		}
		catch (...)
		{
			// Participant not available
		}
	}

	return participantsRoot;
}
Ejemplo n.º 19
0
void ParticipantTest::testPayer()
{
	int somme = 120;
	Participant* crediteur = new Participant();
	CPPUNIT_ASSERT(_participant->SommeBillets() == 0);

	BilletManager* billetManager = new BilletManager();
	billetManager->Ajouter(1, BILLET1);
	billetManager->Ajouter(1, BILLET5);
	billetManager->Ajouter(1, BILLET10);
	billetManager->Ajouter(1, BILLET20);
	billetManager->Ajouter(1, BILLET50);
	billetManager->Ajouter(1, BILLET100);
	billetManager->Ajouter(1, BILLET500);

	_participant->Crediter(billetManager);

	BilletManager* result = _participant->Payer(somme);
	crediteur->Crediter(result);
	CPPUNIT_ASSERT(crediteur->SommeBillets() == somme);
}
Ejemplo n.º 20
0
Participant* DialogCreateParticipant::GetGeneratedParticipant()
{
    QGeoAddress adresse;
    adresse.setCity(this->ui->liVille->text());
    adresse.setStreet(this->ui->liRue->text() + this->ui->liComplement->text());
    adresse.setPostalCode(this->ui->liCP->text());

    Disponibility * dispoParticipant = new Disponibility(
                adresse,
                this->ui->timeEditStart->time(),
                this->ui->timeEditEnd->time());

    Participant *participant = new Participant(
                this->ui->leFirstName->text(),
                this->ui->leLastName->text(),
                this->ui->checkBox->isChecked() ? this->ui->spinBox->value() : 0);

    participant->AddDisponnibility(dispoParticipant);

    return participant;
}
Ejemplo n.º 21
0
std::string DptfStatus::getXmlForParticipant(UInt32 mappedIndex, eEsifError* returnCode)
{
	auto participantIndexList = m_participantManager->getParticipantIndexes();
	UIntN totalDomainCount = 0;

	// Total # of participants + domains for error checking
	for (auto i = participantIndexList.begin(); i != participantIndexList.end(); ++i)
	{
		try
		{
			Participant* participant = m_participantManager->getParticipantPtr(*i);
			totalDomainCount += participant->getDomainCount();
		}
		catch (...)
		{
			// If participant pointer couldn't be returned or couldn't get domain count
			// Most likely, a participant was removed and left bind a null pointer
		}
	}

	if (mappedIndex >= totalDomainCount)
	{
		*returnCode = ESIF_E_UNSPECIFIED;
		throw dptf_exception("Invalid participant status requested.");
	}

	try
	{
		auto participantData = m_participantStatusMap->getStatusAsXml(mappedIndex);
		std::string s = participantData->toString();

		return s;
	}
	catch (...)
	{
		*returnCode = ESIF_E_UNSPECIFIED;
		throw;
	}
}
Ejemplo n.º 22
0
void ParticipantList::populate( const Contacts& rContacts, IMChatSession& imChatSession )
{
	Participant participant;
	IMContact*  imContact = NULL;
	bool		bAlreadyInChat = false;

	for ( Contacts::const_iterator it = rContacts.begin(); it != rContacts.end(); it++ )
	{
		if ( includeInCandidateList( (*it).second, imChatSession, bAlreadyInChat ) )
		{
			Contact c = (*it).second;
			imContact = c.getPreferredIMContact();

			participant.setIMContact      ( *imContact			 );
			participant.setDisplayName	  ( c.getDisplayName()   );
			participant.setIsAlreadyInChat( bAlreadyInChat		 );
			participant.setPixmap		  ( determineStatus( c ) );

			Add( &participant );
		}
	}
}
Ejemplo n.º 23
0
/************************
* SetAudioCodec
* 	SetAudioCodec
*************************/
int MultiConf::SetAudioCodec(int id,int codec,const Properties& properties)
{
	int ret = 0;

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

	//Use list
	participantsLock.IncUse();

	//Get the participant
	Participant *part = GetParticipant(id);

	//Check particpant
	if (part)
		//Set video codec
		ret = part->SetAudioCodec((AudioCodec::Type)codec,properties);

	//Unlock
	participantsLock.DecUse();

	//Exit
	return ret;
}
Ejemplo n.º 24
0
/************************
* SetVideoCodec
* 	SetVideoCodec
*************************/
int MultiConf::SetVideoCodec(int id,int codec,int mode,int fps,int bitrate,int intraPeriod,const Properties &properties)
{
	int ret = 0;

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

	//Use list
	participantsLock.IncUse();

	//Get the participant
	Participant *part = GetParticipant(id);

	//Check particpant
	if (part)
		//Set video codec
		ret = part->SetVideoCodec((VideoCodec::Type)codec,mode,fps,bitrate,intraPeriod,properties);

	//Unlock
	participantsLock.DecUse();

	//Exit
	return ret;
}
Ejemplo n.º 25
0
/********************************************************
 * SetMute
 *   Set participant mute
 ********************************************************/
int MultiConf::SetMute(int partId,MediaFrame::Type media,bool isMuted)
{
	int ret = 0;

	Log("-SetMute [id:%d,media:%d,muted:%d]\n",partId,media,isMuted);

	//Lock
	participantsLock.IncUse();

	//Get participant
	Participant *part = GetParticipant(partId);

	//Check participant
	if (part)
		//Send FPU
		ret = part->SetMute(media,isMuted);

	//Unlock
	participantsLock.DecUse();

	//Exit
	return ret;
}
Ejemplo n.º 26
0
int MultiConf::SendFPU(int partId)
{
	int ret = 0;

	Log("-SendFPU [id:%d]\n",partId);

	//Lock
	participantsLock.IncUse();

	//Get participant
	Participant *part = GetParticipant(partId);

	//Check participant
	if (part)
		//Send FPU
		ret = part->SendVideoFPU();

	//Unlock
	participantsLock.DecUse();

	//Exit
	return ret;
}
Ejemplo n.º 27
0
/************************
* SetTextCodec
* 	SetTextCodec
*************************/
int MultiConf::SetTextCodec(int id,int codec)
{
	int ret = 0;

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

	//Use list
	participantsLock.IncUse();

	//Get the participant
	Participant *part = GetParticipant(id);

	//Check particpant
	if (part)
		//Set video codec
		ret = part->SetTextCodec((TextCodec::Type)codec);

	//Unlock
	participantsLock.DecUse();

	//Exit
	return ret;
}
Ejemplo n.º 28
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.º 29
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.º 30
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();
}