📄 conferencecontrol.cxx
字号:
/* Copyright (C) 2004-2006 the Minisip Team This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *//* Copyright (C) 2004 * * Authors: Erik Eliasson <eliasson@it.kth.se> * Johan Bilien <jobi@via.ecp.fr>*/#include<config.h>#include<libminisip/conference/ConferenceControl.h>#include<assert.h>#include<stdio.h>#include<vector>#include<libminisip/conference/ConfMessageRouter.h>#include<libminisip/gui/Gui.h>#include<libmutil/MemObject.h>#include<libmutil/trim.h>#include<libmutil/termmanip.h>#include<libmutil/CommandString.h>#include<libmsip/SipCommandString.h>#ifdef _WIN32_WCE# include<libminisip/minisip_wce_extra_includes.h>#endifusing namespace std;ConferenceControl::ConferenceControl(){ numPending = 0;}ConferenceControl::ConferenceControl(string configUri, string cid, bool islocal){ confId=cid; size_t i = (uint32_t)configUri.find("@"); assert(i!=string::npos); myUri=configUri.substr(0,i); myDomain=trim(configUri.substr(i)); //cerr<<"my Uri and domain: "+myUri+" "+myDomain<<endl; incoming=islocal; numPending = 0;}minilist<ConfMember> * ConferenceControl::getConnectedList(){ return &connectedList;}void ConferenceControl::setCallback(ConfCallback *cb){ this->callback=cb;}ConfCallback *ConferenceControl::getCallback(){ return callback;}void ConferenceControl::setPendingList(string user){ user=addDomainToPrefix(user); pendingList.push_back((ConfMember(user, ""))); //pendingList[numPending]=user; numPending++;}/*string[10] ConferenceControl::getPendingList(){ return pendingList;}*/void ConferenceControl::setConnectedList(string user){ connectedList.push_back((ConfMember(user, ""))); /* connectedList.uris[connectedList.numUser]=user; connectedList.numUser++; */}/*string[10] ConferenceControl::getConnectedList(){ return connectedList.uris;}*/void ConferenceControl::handleGuiCommand(string){ //cerr << "CC: from MR -> CC: handleGuiCommand"<< endl; //string uri = trim(cmd.substr(5)); //displayMessage(cmd); }void ConferenceControl::handleGuiCommand(const CommandString &command){ //cerr << "CC: from MR -> CC: handleGuiCommand command"<< endl; if(command.getOp()==SipCommandString::accept_invite) { //pendingList[numPending]=command.getParam(); //pendingListCallIds[numPending]=command.getDestinationId(); string remote=addDomainToPrefix(command.getParam()); pendingList.push_back((ConfMember(remote, command.getDestinationId()))); //cerr<<"call is accepted=>pending list: "<<endl; //printList(&pendingList); numPending++; string users; for(int t=0;t<connectedList.size();t++) users=users+ ((connectedList[t]).uri) + ";"; //was connectedList.uris[t]+";"; //cerr<<"users "+users<<endl; CommandString cmd(command); cmd.setParam2(users); cmd.setParam3(confId); //command.setParam2((string) &connectedList); //cerr<<"(string) &connectedList************** "+(&connectedList)<<endl; callback->confcb_handleSipCommand(cmd); } if(command.getOp()==SipCommandString::hang_up) { int t; for(t=0;t<connectedList.size();t++) { CommandString hup(connectedList[t].callid, SipCommandString::hang_up); callback->confcb_handleSipCommand(hup); } for(t=0;t<pendingList.size();t++) { CommandString hup(pendingList[t].callid, SipCommandString::hang_up); callback->confcb_handleSipCommand(hup); } ((ConfMessageRouter *)(callback))->removeConferenceController(this); } if(command.getOp()=="join") { bool done=false; string sip_url=command.getParam(); sip_url=addDomainToPrefix(sip_url); int t; for(t=0;t<connectedList.size()&&!done;t++) if(connectedList[t].uri==sip_url) { done=true; } for(t=0;t<pendingList.size()&&!done;t++) if(pendingList[t].uri==sip_url) { done=true; } if(done) { CommandString cmd("","error_message","user already added "); callback->confcb_handleGuiCommand(cmd); } else { callId = callback->confcb_doJoin(sip_url, &connectedList, confId); pendingList.push_back((ConfMember(sip_url, callId))); sendUpdatesToGui(); } //cerr <<"conf "+callId<< endl; } //string uri = trim(cmd.substr(5)); //displayMessage(cmd); }void ConferenceControl::handleGuiDoInviteCommand(string sip_url){ //cerr << "CC: from MR -> CC: handleGuiDoInviteCommand"<< endl; /*cerr <<"conf "+sip_url<< endl; cerr <<"conf "+confId<< endl; //BM pendingList[numPending]=sip_url; printList(&connectedList);*/ //numPending++; callId = callback->confcb_doJoin(sip_url, &connectedList, confId); //cerr <<"conf "+callId<< endl; sip_url=addDomainToPrefix(sip_url); pendingList.push_back((ConfMember(sip_url, callId))); sendUpdatesToGui(); if (callId=="malformed"){ //state="IDLE"; //setPrompt(state); //displayMessage("The URI is not a valid SIP URI", red); //callId=""; }else{ //state="TRYING"; //setPrompt(state); //cerr <<"Created call with id="+callId<<endl; } //string uri = trim(cmd.substr(5)); //displayMessage(cmd); }void ConferenceControl::handleSipCommand( const CommandString &cmd){ //cerr << "CC: from MR -> CC: handleSipCommand"<< endl; if (cmd.getOp()=="invite_ok"){ //state="INCALL"; //gui->setPrompt(state); cerr << "CC: PROGRESS: remote participant accepted to join the conference..."<< endl; //cerr<<"print connected list-------------"<<endl; //printList(&connectedList); //cerr<<"print pending list-------------"<<endl; //printList(&pendingList); int i=0; string line=""; string users=cmd.getParam(); minilist<ConfMember> receivedList; while (users.length()!=0 &&!((uint32_t)i>(users.length()-1))){ line+=users[i++]; if(users[i]==';') { receivedList.push_back((ConfMember(line, ""))); //connectedList[numConnected]=line; //cerr<< "CC------line: " + line << endl; line=""; i++; } } handleOkAck(cmd.getDestinationId() ,&receivedList); //cerr<<"print connected list-------------"<<endl; //printList(&connectedList); //cerr<<"print pending list-------------"<<endl; //printList(&pendingList); } if (cmd.getOp()=="invite_ack"){ //state="INCALL"; //gui->setPrompt(state); //cerr << "CC: PROGRESS: ack received..."<< endl; //cerr<<"print connected list-------------"<<endl; //printList(&connectedList); //cerr<<"print pending list-------------"<<endl; //printList(&pendingList); int i=0; string line=""; string users=cmd.getParam(); //cerr<<"users-------------"+users<<endl; minilist<ConfMember> receivedList; while (users.length()!=0 &&!((uint32_t)i>(users.length()-1))){ line+=users[i++]; if(users[i]==';') { receivedList.push_back((ConfMember(line, ""))); //connectedList[numConnected]=line; //cerr<< "CC------line: " + line << endl; line=""; i++; } } handleOkAck(cmd.getDestinationId() ,&receivedList); //cerr<<"print connected list-------------"<<endl; //printList(&connectedList); //cerr<<"print pending list-------------"<<endl; //printList(&pendingList); } if (cmd.getOp()=="remote_ringing"){ //state="REMOTE RINGING"; //setPrompt(state); cerr << "CC: PROGRESS: the remove UA is ringing..."<< endl; //displayMessage("PROGRESS: the remove UA is ringing...", blue); } if (cmd.getOp()=="myuri"){ myUri=cmd.getParam(); //cerr << "my URI is "+myUri<< endl; //displayMessage("PROGRESS: the remove UA is ringing...", blue); } /*if (autoanswer && cmd.getOp()==SipCommandString::incoming_available){ CommandString command(callId, SipCommandString::accept_invite); callback->guicb_handleCommand(command); state="INCALL"; setPrompt(state); displayMessage("Autoanswered call from "+ cmd.getParam()); return; }*/ if (cmd.getOp()==SipCommandString::remote_user_not_found){ //state="IDLE"; //setPrompt(state); cerr << "CC: User "+cmd.getDestinationId()+" not found."<< endl; removeMember(cmd.getDestinationId()); sendUpdatesToGui(); //displayMessage("User "+cmd.getParam()+" not found.",red); callId=""; //FIXME: should check the callId of cmd. } if (cmd.getOp()==SipCommandString::security_failed){ //state="IDLE"; //setPrompt(state); cerr << "CC: Security failed with user "+cmd.getDestinationId()<< endl; removeMember(cmd.getDestinationId()); sendUpdatesToGui(); //displayMessage("User "+cmd.getParam()+" not found.",red); callId=""; //FIXME: should check the callId of cmd. } if (cmd.getOp()==SipCommandString::remote_unacceptable){ //state="IDLE"; //setPrompt(state); cerr << "CC: User "+cmd.getDestinationId()+" unacceptable."<< endl; removeMember(cmd.getDestinationId()); sendUpdatesToGui(); //displayMessage("User "+cmd.getParam()+" not found.",red); callId=""; //FIXME: should check the callId of cmd. } if (cmd.getOp()==SipCommandString::remote_cancelled_invite){ //state="IDLE"; //setPrompt(state); cerr << "CC: User "+cmd.getDestinationId()+" cancelled invite"<< endl; removeMember(cmd.getDestinationId()); sendUpdatesToGui(); //displayMessage("User "+cmd.getParam()+" not found.",red); callId=""; //FIXME: should check the callId of cmd.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -