1 /* 2 * Copyright (C) 2002-2003 Fhg Fokus 3 * Copyright (C) 2006 iptego GmbH 4 * 5 * This file is part of SEMS, a free SIP media server. 6 * 7 * SEMS is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. This program is released under 11 * the GPL with the additional exemption that compiling, linking, 12 * and/or using OpenSSL is allowed. 13 * 14 * For a license to use the SEMS software under conditions 15 * other than those described here, or to purchase support for this 16 * software, please contact iptel.org by e-mail at the following addresses: 17 * info@iptel.org 18 * 19 * SEMS is distributed in the hope that it will be useful, 20 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * GNU General Public License for more details. 23 * 24 * You should have received a copy of the GNU General Public License 25 * along with this program; if not, write to the Free Software 26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA test01()27 */ 28 29 #include "AmApi.h" 30 #include "log.h" 31 #include "AmSession.h" 32 #include "AmB2BMedia.h" // just because of statistics in reply to OPTIONS 33 34 AmDynInvoke::AmDynInvoke() {} 35 AmDynInvoke::~AmDynInvoke() {} main()36 37 void AmDynInvoke::invoke(const string& method, const AmArg& args, AmArg& ret) 38 { 39 throw NotImplemented(method); 40 } 41 42 AmDynInvokeFactory::AmDynInvokeFactory(const string& name) 43 : AmPluginFactory(name) 44 { 45 } 46 47 AmSessionFactory::AmSessionFactory(const string& name) 48 : AmPluginFactory(name) 49 { 50 } 51 52 AmSession* AmSessionFactory::onInvite(const AmSipRequest& req, const string& app_name, 53 AmArg& session_params) { 54 WARN(" discarding session parameters to new session.\n"); 55 map<string,string> app_params; 56 return onInvite(req,app_name,app_params); 57 } 58 59 AmSession* AmSessionFactory::onRefer(const AmSipRequest& req, const string& app_name, const map<string,string>& app_params) 60 { 61 throw AmSession::Exception(488, SIP_REPLY_NOT_ACCEPTABLE_HERE); 62 } 63 64 AmSession* AmSessionFactory::onRefer(const AmSipRequest& req, const string& app_name, 65 AmArg& session_params) 66 { 67 WARN(" discarding session parameters to new session.\n"); 68 map<string,string> app_params; 69 return onRefer(req,app_name,app_params); 70 } 71 72 int AmSessionFactory::configureModule(AmConfigReader& cfg) { 73 return 0;//mod_conf.readFromConfig(cfg); 74 } 75 76 void AmSessionFactory::configureSession(AmSession* sess) { 77 //SessionTimer::sess->configureSessionTimer(mod_conf); 78 } 79 80 void AmSessionFactory::onOoDRequest(const AmSipRequest& req) 81 { 82 83 if (req.method == SIP_METH_OPTIONS) { 84 replyOptions(req); 85 return; 86 } 87 88 INFO("sorry, we don't support beginning a new session with " 89 "a '%s' message\n", req.method.c_str()); 90 91 AmSipDialog::reply_error(req,501,"Not Implemented"); 92 return; 93 } 94 95 void AmSessionFactory::replyOptions(const AmSipRequest& req) { 96 string hdrs; 97 if (!AmConfig::OptionsTranscoderInStatsHdr.empty()) { 98 string usage; 99 B2BMediaStatistics::instance()->reportCodecReadUsage(usage); 100 101 hdrs += AmConfig::OptionsTranscoderInStatsHdr + ": "; 102 hdrs += usage; 103 hdrs += CRLF; 104 } 105 if (!AmConfig::OptionsTranscoderOutStatsHdr.empty()) { 106 string usage; 107 B2BMediaStatistics::instance()->reportCodecWriteUsage(usage); 108 109 hdrs += AmConfig::OptionsTranscoderOutStatsHdr + ": "; 110 hdrs += usage; 111 hdrs += CRLF; 112 } 113 114 // Basic OPTIONS support 115 if (AmConfig::OptionsSessionLimit && 116 (AmSession::getSessionNum() >= AmConfig::OptionsSessionLimit)) { 117 // return error code if near to overload 118 AmSipDialog::reply_error(req, 119 AmConfig::OptionsSessionLimitErrCode, 120 AmConfig::OptionsSessionLimitErrReason, 121 hdrs); 122 return; 123 } 124 125 if (AmConfig::ShutdownMode) { 126 // return error code if in shutdown mode 127 AmSipDialog::reply_error(req, 128 AmConfig::ShutdownModeErrCode, 129 AmConfig::ShutdownModeErrReason, 130 hdrs); 131 return; 132 } 133 134 AmSipDialog::reply_error(req, 200, "OK", hdrs); 135 136 } 137 138 // void AmSessionFactory::postEvent(AmEvent* ev) { 139 // ERROR("unhandled Event in %s module\n", getName().c_str()); 140 // delete ev; 141 // } 142 143 AmSessionEventHandlerFactory::AmSessionEventHandlerFactory(const string& name) 144 : AmPluginFactory(name) 145 { 146 } 147 148 bool AmSessionEventHandlerFactory::onInvite(const AmSipRequest& req, 149 AmArg& session_params, 150 AmConfigReader& cfg) { 151 WARN("discarding session parameters for new session.\n"); 152 return onInvite(req, cfg); 153 } 154 155 156 AmLoggingFacility::AmLoggingFacility(const string& name) 157 : AmPluginFactory(name) 158 { 159 } 160