AmMediaProcessor.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
00062 void run();
00063 void on_stop();
00064
00065
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
1.5.1