AmMediaProcessor.h

Go to the documentation of this file.
00001 /*
00002  * $Id: AmMediaProcessor.h 711 2008-02-10 18:52:44Z sayer $
00003  *
00004  * Copyright (C) 2002-2003 Fhg Fokus
00005  *
00006  * This file is part of sems, a free SIP media server.
00007  *
00008  * sems is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version
00012  *
00013  * For a license to use the ser software under conditions
00014  * other than those described here, or to purchase support for this
00015  * software, please contact iptel.org by e-mail at the following addresses:
00016  *    info@iptel.org
00017  *
00018  * sems is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License 
00024  * along with this program; if not, write to the Free Software 
00025  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  */
00028 #ifndef _AmMediaProcessor_h_
00029 #define _AmMediaProcessor_h_
00030 
00031 #include "AmSession.h"
00032 #include "AmEventQueue.h"
00033 
00034 #include <set>
00035 using std::set;
00036 #include <map>
00037 
00038 struct SchedRequest;
00039 
00047 class AmMediaProcessorThread :
00048   public AmThread,
00049   public AmEventHandler
00050 {
00051   AmEventQueue    events;
00052   unsigned char   buffer[AUDIO_BUFFER_SIZE];
00053   set<AmSession*> sessions;
00054   
00055   void processAudio(unsigned int ts);
00059   void processDtmfEvents();
00060 
00061   // AmThread interface
00062   void run();
00063   void on_stop();
00064     
00065   // AmEventHandler interface
00066   void process(AmEvent* e);
00067 public:
00068   AmMediaProcessorThread();
00069   ~AmMediaProcessorThread();
00070 
00071   inline void postRequest(SchedRequest* sr);
00072   
00073   unsigned int getLoad();
00074 };
00075 
00084 class AmMediaProcessor
00085 {
00086   static AmMediaProcessor* _instance;
00087 
00088   unsigned int num_threads; 
00089   AmMediaProcessorThread**  threads;
00090   
00091   std::map<string, unsigned int> callgroup2thread;
00092   std::multimap<string, AmSession*> callgroupmembers;
00093   std::map<AmSession*, string> session2callgroup;
00094   AmMutex group_mut;
00095 
00096   AmMediaProcessor();
00097   ~AmMediaProcessor();
00098         
00099   void removeFromProcessor(AmSession* s, unsigned int r_type);
00100 public:
00107   enum { InsertSession, RemoveSession, SoftRemoveSession, ClearSession };
00108 
00109   static AmMediaProcessor* instance();
00110 
00111   void init();
00113   void addSession(AmSession* s, const string& callgroup);
00115   void removeSession(AmSession* s);
00117   void clearSession(AmSession* s);
00119   void changeCallgroup(AmSession* s, 
00120                        const string& new_callgroup);
00121 
00122 };
00123 
00124 
00125 #endif
00126 
00127 
00128 
00129 
00130 
00131 

Generated on Fri May 16 12:02:05 2008 for SEMS by  doxygen 1.5.1
Home |  Recent changes |  Search |  Glossary |  Sitemap |  Login