Parent Directory
|
Revision Log
Pass/store rtp information in RtpIpInfo objects. These include the media direction in addition to the ip address and port number.
1 /* 2 * This file is part of Project DiaStar Server. 3 * 4 * More information about this project can be found at: 5 * http://www.projectdiastar.org. 6 * 7 * Copyright (C) 2009,2010 Dialogic Corp. 8 * 9 * This program is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public License 11 * as published by the Free Software Foundation; either version 2 12 * of the License, or (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 22 * 02110-1301, USA. 23 * Alternatively see <http://www.gnu.org/licenses/>. 24 * Or see the LICENSE file included within the source tree. 25 * 26 */ 27 28 /*! 29 * \file dialogicchannelmanager.h 30 * \brief Channel manager for Dialogic devices. 31 * \author Antony Martin <antony.martin@dialogic.com> 32 * \author John Tarlton <john.tarlton@dialogic.com> 33 * \version 30-MAR-2009 34 */ 35 36 #ifndef _DIALOGICCHANNELMANAGER_H 37 #define _DIALOGICCHANNELMANAGER_H 38 39 /*-------------------------------- Dependencies ------------------------------*/ 40 41 #include <vector> 42 #include <map> 43 #include <queue> 44 45 #include "channelmanager.h" 46 #include "group.h" 47 #include "coders.h" 48 #include "tonedetector.h" 49 #include "voxdevice.h" 50 #include "ipmdevice.h" 51 #include "mmdevice.h" 52 #include "gcisdndevice.h" 53 #include "gciptboard.h" 54 #include "gciptdevice.h" 55 #include "mediafinder.h" 56 #include "confboard.h" 57 #include "confdevice.h" 58 #include "confpartydevice.h" 59 #include "m3gboard.h" 60 #include "m3gdevice.h" 61 #include "config.h" 62 #include "dialogicchannel.h" 63 #include "imagemakerthread.h" 64 #include "rtspconnector.h" 65 66 /*----------------------------------------------------------------------------*/ 67 68 class Conference; 69 class ConfDevice; 70 class ConfPartyDevice; 71 72 73 /*! 74 * \class DialogicChannelManager 75 * Responsible for lifecycle of DialogicChannel objects and the allocation 76 * of the devices that are used by them. 77 */ 78 class DialogicChannelManager : public ChannelManager 79 { 80 public: 81 82 /*! 83 * ctor 84 * \param client - event handler callbacks. 85 * \param config - configuration manager. 86 */ 87 DialogicChannelManager( ChannelManagerClient& client, Config& config ); 88 89 /*! 90 * dtor, this will close any connections. 91 */ 92 virtual ~DialogicChannelManager(); 93 94 /*! 95 * Initialise Dialogic libraries. 96 */ 97 bool init(); 98 99 /*! 100 * Init all devices. 101 * \param config - configuration file. 102 */ 103 virtual bool start( const std::string& config ); 104 105 /*! 106 * Close all devices and stop the Global Call library. 107 */ 108 virtual void shutdown(); 109 110 /*! 111 * Call stats. 112 */ 113 unsigned int getTotalCalls() const { return total_; } 114 115 unsigned int getActiveCalls() const { return channels_.size(); } 116 117 /*! 118 * Conference devices are added after they have been opened. 119 * \param device - device object 120 */ 121 void addDevice( DialogicDevice* device ) 122 { 123 deviceMap_.insert(device_map_t::value_type(device->getDeviceName(), device)); 124 } 125 126 /*! 127 * Add an id => conference device mapping. This is the public id defined by 128 * the config and not the device name. 129 * \param confDevice - device object 130 */ 131 void addConference( ConfDevice* confDevice ) 132 { 133 confs_.insert(conf_map_t::value_type(confDevice->getDeviceName(), confDevice)); 134 } 135 136 /*! 137 * Allocate an ipm device (rtsp). 138 */ 139 IpmDevice* allocIpmDevice(); 140 141 /*! 142 * Free an ipm device. 143 */ 144 void freeIpmDevice( IpmDevice* ipm ); 145 146 /*! 147 * Allocate a Multi-Media device (for each play/record). 148 */ 149 MmDevice* allocMmDevice(); 150 151 /*! 152 * Free a Multi-Media device. 153 */ 154 void freeMmDevice( MmDevice* mm ); 155 156 /*! 157 * Create a channel object using a dti device allocated from a specific group. 158 * \param group - outbound group name. 159 * \param protocol - signalling ISDN or SS7. 160 * \return a channel object or 0 on failure. 161 */ 162 DialogicChannel* createIsdnChannel( const std::string& group, 163 Protocol protocol); 164 165 /*! 166 * Create a channel object for a specific dti device. 167 * \param gc - isdn device. 168 * \return a channel object or 0 on failure. 169 */ 170 DialogicChannel* createIsdnChannel( GcIsdnDevice* gc ); 171 172 /*! 173 * Create a channel object for a SIP call. 174 * \param group - outbound group name (future). 175 * \return a channel object or 0 on failure. 176 */ 177 DialogicChannel* createSipChannel( const std::string& group ); 178 179 /*! 180 * Create a channel object for a SIP call using a specific ipt device. 181 * \param gc - ipt device. 182 * \return a channel object or 0 on failure. 183 */ 184 DialogicChannel* createSipChannel( GcIptDevice* gc ); 185 186 /*! 187 * Create a channel object for a conference. 188 * \param conf_id - conference identifier. 189 * \return a channel object or 0 on failure. 190 */ 191 DialogicChannel* createConfChannel( const std::string& conf_id ); 192 193 /*! 194 * Delete a channel object. 195 * \param channel - channel to destroy. 196 */ 197 void destroyChannel( DialogicChannel* channel ); 198 199 /*! 200 * Lookup a channel object using its conference party device. 201 * \param party - party device 202 * \return a channel object or 0 on failure. 203 */ 204 DialogicChannel* findChannel( const ConfPartyDevice* party ) const; 205 206 /*! 207 * Lookup a channel object using its ipm device's local rtp. 208 * \param rtp_audio 209 * \param rtp_video 210 * \return a channel object or 0 on failure. 211 */ 212 DialogicChannel* findChannel( const RtpIpInfo& rtp_audio, 213 const RtpIpInfo& rtp_video ) const; 214 215 /*! 216 * Forward an event to its device object. 217 * \param event - a Dialogic event 218 */ 219 int dispatchEvent( METAEVENT& event ); 220 221 /*! 222 * Get available audio codecs in order of preference. 223 */ 224 const Coders::audio_coders_t& getAudioCoders() const 225 { 226 return coders_.getAudioCoders(); 227 } 228 229 /*! 230 * Get available video codecs in order of preference. 231 */ 232 const Coders::video_coders_t& getVideoCoders() const 233 { 234 return coders_.getVideoCoders(); 235 } 236 237 /*! 238 * Get the name of the audio codec used for the client rtp. 239 */ 240 const std::string& getClientAudioFormat() const 241 { 242 return config_.getClientAudioFormat(); 243 } 244 245 /*! 246 * Get the name of the video codec used for the client rtp. 247 */ 248 const std::string& getClientVideoFormat() const 249 { 250 return config_.getClientVideoFormat(); 251 } 252 253 /*! 254 * Get the configuration object. 255 */ 256 const Config& getConfig() const 257 { 258 return config_; 259 } 260 261 /*! 262 * Get the coders object. 263 */ 264 const Coders& getCoders() const 265 { 266 return coders_; 267 } 268 269 /*! 270 * Get the application's client callback object. 271 */ 272 ChannelManagerClient& getClient() const 273 { 274 return client_; 275 } 276 277 /*! 278 * Get the ToneDetector object. 279 */ 280 const ToneDetector& getToneDetector() const 281 { 282 return toneDetector_; 283 } 284 285 /*! 286 * Get the MediaFinder object. 287 */ 288 const MediaFinder& getMediaFinder() const 289 { 290 return mediaFinder_; 291 } 292 293 /*! 294 * Get the ImageMakerThread object. 295 */ 296 ImageMakerThread& getImageMakerThread() 297 { 298 return imageMakerThread_; 299 } 300 301 /*! 302 * Get the RtspConnector object. 303 */ 304 RtspConnector& getRtspConnector() 305 { 306 return rtspConnector_; 307 } 308 309 private: 310 311 /*! 312 * Open all devices. 313 */ 314 bool openDevices(); 315 316 bool openDtiDevices(); 317 bool openIpmDevices(); 318 bool openVoxDevices(); 319 bool openIptDevices(); 320 bool openMmDevices(); 321 bool openM3gDevices(); 322 323 /*! 324 * Close all devices. 325 */ 326 void closeDevices(); 327 328 /*! 329 * Set the client (woomera) rtp coders using configuration data. 330 * \param ipm - device to modify. 331 */ 332 void setClientCoders( IpmDevice* ipm ); 333 334 private: 335 336 ChannelManagerClient& client_; 337 338 Config& config_; 339 340 typedef std::vector<DialogicChannel*> channel_t; 341 channel_t channels_; 342 343 /* Map of names to _open_ board objects. 344 */ 345 typedef std::map<std::string, DialogicBoard*> board_map_t; 346 board_map_t boardMap_; 347 348 /* Map names to _open_ device objects. 349 * Used to route Dialogic events to their controlling objects. 350 */ 351 typedef std::map<std::string, DialogicDevice*> device_map_t; 352 device_map_t deviceMap_; 353 354 /* Containers for free devices. 355 */ 356 std::list<GcIptDevice*> iptDevices_; 357 std::queue<IpmDevice*> ipmDevices_; 358 std::queue<VoxDevice*> voxDevices_; 359 std::queue<MmDevice*> mmDevices_; 360 std::queue<M3gDevice*> m3gDevices_; 361 362 /* Conferences have a public id, defined by configuration, this map relates 363 * them to their device object. 364 */ 365 typedef std::map<std::string, ConfDevice*> conf_map_t; 366 conf_map_t confs_; 367 368 /* Common objects. 369 */ 370 Coders coders_; 371 ToneDetector toneDetector_; 372 MediaFinder mediaFinder_; 373 ImageMakerThread imageMakerThread_; 374 RtspConnector rtspConnector_; 375 StateMachine mediaStateMachine_; /* each channel has its own context */ 376 377 /* Call stats. 378 */ 379 unsigned long total_; 380 }; 381 382 383 384 /*! 385 * Overload << for printing DEV_ERRINFO structs. 386 */ 387 inline std::ostream& operator << ( std::ostream &os, const DEV_ERRINFO& errorInfo ) 388 { 389 os << "DEV_ERRINFO: "; 390 switch ( errorInfo.dev_ErrValue ) 391 { 392 case DEV_SUCCESS: 393 os << "No error." << std::endl; 394 break; 395 case EDEV_INVALIDDEVICEHANDLE: 396 os << "Invalid handle." << std::endl; 397 break; 398 case EDEV_INVALIDMODE: 399 os << "Invalid mode." << std::endl; 400 break; 401 case EDEV_EVENTTIMEOUT: 402 os << "Event timeout." << std::endl; 403 break; 404 case EDEV_DEVICEBUSY: 405 os << "Device busy." << std::endl; 406 break; 407 case EDEV_INVALIDCONNTYPE: 408 os << "Invalid connection type." << std::endl; 409 break; 410 case EDEV_IPM_SUBSYSTEMERR: 411 os << "IPM subsystem error: " << errorInfo.dev_SubSystemErrValue << std::endl; 412 break; 413 case EDEV_FAX_SUBSYSTEMERR: 414 os << "FAX subsystem error: " << errorInfo.dev_SubSystemErrValue << std::endl; 415 break; 416 case EDEV_IPM_INTERNALERR: 417 os << "IPM internal error: " << errorInfo.dev_SubSystemErrValue << std::endl; 418 break; 419 case EDEV_MM_SUBSYSTEMERR: 420 os << "MM subsystem error: " << errorInfo.dev_SubSystemErrValue << std::endl; 421 break; 422 case EDEV_SUBSYSTEMERR: 423 os << "Subsystem error: " << errorInfo.dev_SubSystemErrValue << std::endl; 424 break; 425 case EDEV_INVALIDSTATE: 426 os << "Invalid state." << std::endl; 427 break; 428 case EDEV_NOTCONNECTED: 429 os << "Not connected." << std::endl; 430 break; 431 case EDEV_INVALID_PARM: 432 os << "Invalid parameter." << std::endl; 433 break; 434 default: 435 os << "Error: " << errorInfo.dev_ErrValue << std::endl; 436 break; 437 } 438 os << " \"" << errorInfo.dev_Msg << "\"" << std::endl; 439 return os; 440 } 441 442 443 #endif // _DIALOGICCHANNELMANAGER_H 444 445 /* vim:ts=4:set nu: 446 * EOF 447 */
| No admin address has been configured | ViewVC Help |
| Powered by ViewVC 1.0.8 |