本文整理汇总了C++中AmSession类的典型用法代码示例。如果您正苦于以下问题:C++ AmSession类的具体用法?C++ AmSession怎么用?C++ AmSession使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AmSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WebConferenceDialog
// outgoing calls
AmSession* WebConferenceFactory::onInvite(const AmSipRequest& req,
AmArg& session_params)
{
UACAuthCred* cred = NULL;
if (session_params.getType() == AmArg::AObject) {
ArgObject* cred_obj = session_params.asObject();
if (cred_obj)
cred = dynamic_cast<UACAuthCred*>(cred_obj);
}
AmSession* s = new WebConferenceDialog(prompts, getInstance(), cred);
AmSessionEventHandlerFactory* uac_auth_f =
AmPlugIn::instance()->getFactory4Seh("uac_auth");
if (uac_auth_f != NULL) {
DBG("UAC Auth enabled for new announcement session.\n");
AmSessionEventHandler* h = uac_auth_f->getHandler(s);
if (h != NULL )
s->addHandler(h);
} else {
ERROR("uac_auth interface not accessible. Load uac_auth for authenticated dialout.\n");
}
s->setUri(getAccessUri(req.user));
return s;
}
示例2: DBG
string DIDial::dialout_pin(const string& application,
const string& pin,
const string& user,
const string& to_user
) {
DBG("dialout application '%s', user '%s', to_user '%s', pin '%s'",
application.c_str(), user.c_str(), to_user.c_str(), pin.c_str());
// find pin
map<string, DIDialoutInfo>::iterator it = DIDialFactory::dialout_pins.find(pin);
if (it != DIDialFactory::dialout_pins.end()) {
AmArg* a = new AmArg();
a->setBorrowedPointer(new UACAuthCred(it->second.realm,
it->second.user,
it->second.pwd));
AmSession* s = AmUAC::dialout(user.c_str(), application,
"sip:"+to_user+"@"+it->second.realm,
"<sip:" + it->second.user+"@"+it->second.realm + ">",
"sip:"+it->second.user+"@"+it->second.realm,
"<sip:" + to_user+"@"+it->second.realm + ">",
string(""), // callid
a);
if (s)
return s->getLocalTag();
else
return "<failed>\n";
} else
return "incorrect dialout pin.\n";
}
示例3: addSession_unsafe
AmSession* AmSessionContainer::startSessionUAC(AmSipRequest& req) {
AmSession* session = NULL;
as_mut.lock();
try {
if((session = createSession(req)) != 0){
session->dlg.updateStatusFromLocalRequest(req); // sets local tag as well
session->setCallgroup(req.from_tag);
session->setNegotiateOnReply(true);
session->sendInvite();
session->start();
addSession_unsafe(req.callid,req.from_tag,req.from_tag,session);
// session does not get its own INVITE
// session->postEvent(new AmSipRequestEvent(req));
}
}
catch(const AmSession::Exception& e){
ERROR("%i %s\n",e.code,e.reason.c_str());
AmSipDialog::reply_error(req,e.code,e.reason);
}
catch(const string& err){
ERROR("startSession: %s\n",err.c_str());
AmSipDialog::reply_error(req,500,err);
}
catch(...){
ERROR("unexpected exception\n");
AmSipDialog::reply_error(req,500,"unexpected exception");
}
as_mut.unlock();
return session;
}
示例4: AnnouncementDialog
AmSession* AnnouncementFactory::onInvite(const AmSipRequest& req,
AmArg& session_params)
{
UACAuthCred* cred = NULL;
if (session_params.getType() == AmArg::AObject) {
ArgObject* cred_obj = session_params.asObject();
if (cred_obj)
cred = dynamic_cast<UACAuthCred*>(cred_obj);
}
AmSession* s = new AnnouncementDialog(getAnnounceFile(req), cred);
if (NULL == cred) {
WARN("discarding unknown session parameters.\n");
} else {
AmSessionEventHandlerFactory* uac_auth_f =
AmPlugIn::instance()->getFactory4Seh("uac_auth");
if (uac_auth_f != NULL) {
DBG("UAC Auth enabled for new announcement session.\n");
AmSessionEventHandler* h = uac_auth_f->getHandler(s);
if (h != NULL )
s->addHandler(h);
} else {
ERROR("uac_auth interface not accessible. "
"Load uac_auth for authenticated dialout.\n");
}
}
return s;
}
示例5: processDtmfEvents
/**
* process pending DTMF events
*/
void AmMediaProcessorThread::processDtmfEvents()
{
for(set<AmSession*>::iterator it = sessions.begin();
it != sessions.end(); it++)
{
AmSession* s = (*it);
s->processDtmfEvents();
}
}
示例6: ERROR
void AmMediaProcessorThread::process(AmEvent* e)
{
SchedRequest* sr = dynamic_cast<SchedRequest*>(e);
if(!sr){
ERROR("AmMediaProcessorThread::process: wrong event type\n");
return;
}
switch(sr->event_id){
case AmMediaProcessor::InsertSession:
DBG("Session inserted to the scheduler\n");
sessions.insert(sr->s);
break;
case AmMediaProcessor::RemoveSession:{
AmSession* s = sr->s;
set<AmSession*>::iterator s_it = sessions.find(s);
if(s_it != sessions.end()){
sessions.erase(s_it);
s->detached.set(true);
DBG("Session removed from the scheduler\n");
}
}
break;
case AmMediaProcessor::ClearSession:{
AmSession* s = sr->s;
set<AmSession*>::iterator s_it = sessions.find(s);
if(s_it != sessions.end()){
sessions.erase(s_it);
s->clearAudio();
s->detached.set(true);
DBG("Session removed from the scheduler\n");
}
}
break;
case AmMediaProcessor::SoftRemoveSession:{
AmSession* s = sr->s;
set<AmSession*>::iterator s_it = sessions.find(s);
if(s_it != sessions.end()){
sessions.erase(s_it);
DBG("Session removed softly from the scheduler\n");
}
}
break;
default:
ERROR("AmMediaProcessorThread::process: unknown event id.");
break;
}
}
示例7: assertArgCStr
void WebConferenceFactory::dialout(const AmArg& args, AmArg& ret) {
for (int i=0;i<6;i++)
assertArgCStr(args.get(1));
string room = args.get(0).asCStr();
string adminpin = args.get(1).asCStr();
string callee = args.get(2).asCStr();
string from_user = args.get(3).asCStr();
string domain = args.get(4).asCStr();
string auth_user = args.get(5).asCStr();
string auth_pwd = args.get(6).asCStr();
string from = "sip:" + from_user + "@" + domain;
string to = "sip:" + callee + "@" + domain;
// check adminpin
rooms_mut.lock();
ConferenceRoom* r = getRoom(room, adminpin);
rooms_mut.unlock();
if (NULL == r) {
ret.push(1);
ret.push("wrong adminpin");
ret.push("");
return;
}
DBG("dialout webconference room '%s', from '%s', to '%s'",
room.c_str(), from.c_str(), to.c_str());
AmArg* a = new AmArg();
a->setBorrowedPointer(new UACAuthCred("", auth_user, auth_pwd));
AmSession* s = AmUAC::dialout(room.c_str(), APP_NAME, to,
"<" + from + ">", from, "<" + to + ">",
string(""), // local tag
string(""), // hdrs
a);
if (s) {
string localtag = s->getLocalTag();
ret.push(0);
ret.push("OK");
ret.push(localtag.c_str());
newParticipant(room, localtag, to);
updateStatus(room, localtag,
ConferenceRoomParticipant::Connecting,
"INVITE");
}
else {
ret.push(1);
ret.push("internal error");
ret.push("");
}
}
示例8: DBG
void AmZRTP::on_zrtp_protocol_event(zrtp_stream_t *stream, zrtp_protocol_event_t event) {
DBG("on_zrtp_protocol_event(stream [%p])\n", stream);
if (NULL==stream) {
ERROR("event received without stream context.\n");
return;
}
void* udata = zrtp_stream_get_userdata(stream);
if (NULL == udata) {
ERROR("ZRTP on_send_packet without session set context.\n");
return;
}
AmSession* sess = reinterpret_cast<AmSession*>(udata);
sess->postEvent(new AmZRTPProtocolEvent(event, stream));
}
示例9: zrtp_event_callback
void zrtp_event_callback(zrtp_event_t event, zrtp_stream_ctx_t *stream_ctx)
{
if (NULL==stream_ctx) {
ERROR("event received without stream context.\n");
return;
}
AmSession* sess = reinterpret_cast<AmSession*>(stream_ctx->stream_usr_data);
if (NULL==sess) {
ERROR("event received without session set up.\n");
return;
}
sess->postEvent(new AmZRTPEvent(event, stream_ctx));
}
示例10: getSession
void AmSessionContainer::startSessionUAS(AmSipRequest& req)
{
as_mut.lock();
try {
AmSession* session = getSession(req.callid,req.from_tag);
if( session ){
// it's a forked-and-merged INVITE
// reply 482 Loop detected
throw AmSession::Exception(482, "Loop detected");
}
else {
// Call-ID and From-Tag are unknown: it's a new session
AmSession* session;
if((session = createSession(req)) != 0){
string local_tag = AmSession::getNewId();
session->setLocalTag(local_tag);
session->setCallgroup(local_tag);
session->start();
addSession_unsafe(req.callid,req.from_tag,local_tag,session);
session->postEvent(new AmSipRequestEvent(req));
}
//else
//throw AmSession::Exception(500,"internal error");
}
}
// catch(const AmSession::SessionTimerException& e){
// ERROR("%i %s\n",e.code,e.reason.c_str());
// AmSipDialog::reply_error(req,e.code,e.reason,e.getErrorHeaders());
// }
catch(const AmSession::Exception& e){
ERROR("%i %s\n",e.code,e.reason.c_str());
AmSipDialog::reply_error(req,e.code,e.reason);
}
catch(const string& err){
ERROR("startSession: %s\n",err.c_str());
AmSipDialog::reply_error(req,500,err);
}
catch(...){
ERROR("unexpected exception\n");
AmSipDialog::reply_error(req,500,"unexpected exception");
}
as_mut.unlock();
}
示例11: EchoDialog
AmSession* EchoFactory::onInvite(const AmSipRequest& req)
{
AmSession* s = new EchoDialog();
if (NULL != session_timer_f) {
AmSessionEventHandler* h = session_timer_f->getHandler(s);
if(h->configure(conf)){
ERROR("Could not configure the session timer: disabling session timers.\n");
delete h;
} else {
s->addHandler(h);
}
}
return s;
}
示例12: destroySession
void AmSessionContainer::destroySession(const string& local_tag)
{
as_mut.lock();
SessionMapIter sess_it = a_sessions.find(local_tag);
if(sess_it != a_sessions.end()){
AmSession* sess = sess_it->second;
as_id_lookup.erase(sess->getCallID() + sess->getRemoteTag());
a_sessions.erase(sess_it);
stopAndQueue(sess);
DBG("session stopped and queued for deletion (#sessions=%u)\n",
(unsigned int)a_sessions.size());
}
else {
DBG("could not remove session: id not found\n");
}
as_mut.unlock();
}
示例13: getSession
void AmSessionContainer::startSessionUAS(AmSipRequest& req)
{
as_mut.lock();
try {
AmSession* session = getSession(req.callid,req.from_tag);
if( session ){
// it's a forked-and-merged INVITE
// reply 482 Loop detected
throw AmSession::Exception(482, "Loop detected");
}
else {
// Call-ID and From-Tag are unknown: it's a new session
AmSession* session;
if((session = createSession(req)) != 0){
// update session's local tag (ID) if not already set
session->setLocalTag();
const string& local_tag = session->getLocalTag();
// by default each session is in its own callgroup
session->setCallgroup(local_tag);
if (AmConfig::LogSessions) {
INFO("Starting UAS session %s app %s\n",
session->getLocalTag().c_str(), req.cmd.c_str());
}
session->start();
addSession_unsafe(req.callid,req.from_tag,local_tag,session);
session->postEvent(new AmSipRequestEvent(req));
}
}
}
catch(const AmSession::Exception& e){
ERROR("%i %s\n",e.code,e.reason.c_str());
AmSipDialog::reply_error(req,e.code,e.reason);
}
catch(const string& err){
ERROR("startSession: %s\n",err.c_str());
AmSipDialog::reply_error(req,500,err);
}
catch(...){
ERROR("unexpected exception\n");
AmSipDialog::reply_error(req,500,"unexpected exception");
}
as_mut.unlock();
}
示例14: ERROR
AmSession* AmSessionContainer::startSessionUAC(AmSipRequest& req, AmArg* session_params) {
AmSession* session = NULL;
as_mut.lock();
try {
if((session = createSession(req, session_params)) != 0){
session->dlg.updateStatusFromLocalRequest(req); // sets local tag as well
session->setCallgroup(req.from_tag);
session->setNegotiateOnReply(true);
if (int err = session->sendInvite(req.hdrs)) {
ERROR("INVITE could not be sent: error code = %d.\n",
err);
delete session;
as_mut.unlock();
return NULL;
}
if (AmConfig::LogSessions) {
INFO("Starting UAC session %s app %s\n",
session->getLocalTag().c_str(), req.cmd.c_str());
}
session->start();
addSession_unsafe(req.callid,"",req.from_tag,session);
// session does not get its own INVITE
// session->postEvent(new AmSipRequestEvent(req));
}
}
catch(const AmSession::Exception& e){
ERROR("%i %s\n",e.code,e.reason.c_str());
AmSipDialog::reply_error(req,e.code,e.reason);
}
catch(const string& err){
ERROR("startSession: %s\n",err.c_str());
AmSipDialog::reply_error(req,500,err);
}
catch(...){
ERROR("unexpected exception\n");
AmSipDialog::reply_error(req,500,"unexpected exception");
}
as_mut.unlock();
return session;
}
示例15: switch
void AmMediaProcessorThread::processAudio(unsigned int ts)
{
for(set<AmSession*>::iterator it = sessions.begin();
it != sessions.end(); it++){
AmSession* s = (*it);
s->lockAudio();
AmAudio* input = s->getInput();
if(s->rtp_str.checkInterval(ts)){
//DBG("ts = %u\n",ts);
int ret = s->rtp_str.receive(ts);
if(ret < 0){
switch(ret){
case RTP_DTMF:
case RTP_UNKNOWN_PL:
case RTP_PARSE_ERROR:
break;
case RTP_TIMEOUT:
postRequest(new SchedRequest(AmMediaProcessor::RemoveSession,s));
s->postEvent(new AmRtpTimeoutEvent());
break;
case RTP_BUFFER_SIZE:
default:
ERROR("AmRtpAudio::receive() returned %i\n",ret);
postRequest(new SchedRequest(AmMediaProcessor::ClearSession,s));
break;
}
}
else {
unsigned int f_size = s->rtp_str.getFrameSize();
int size = s->rtp_str.get(ts,buffer,f_size);
if (input) {
int ret = input->put(ts,buffer,size);
if(ret < 0){
DBG("input->put() returned: %i\n",ret);
postRequest(new SchedRequest(AmMediaProcessor::ClearSession,s));
}
}
if (s->isDtmfDetectionEnabled())
s->putDtmfAudio(buffer, size, ts);
}
}
s->unlockAudio();
}
for(set<AmSession*>::iterator it = sessions.begin();
it != sessions.end(); it++){
AmSession* s = (*it);
s->lockAudio();
AmAudio* output = s->getOutput();
if(output && s->rtp_str.sendIntReached()){
int size = output->get(ts,buffer,s->rtp_str.getFrameSize());
if(size <= 0){
DBG("output->get() returned: %i\n",size);
postRequest(new SchedRequest(AmMediaProcessor::ClearSession,s)); //removeSession(s);
}
else if(!s->rtp_str.mute){
if(s->rtp_str.put(ts,buffer,size)<0)
postRequest(new SchedRequest(AmMediaProcessor::ClearSession,s));
// removeSession(s);
}
}
s->unlockAudio();
}
}