AmPromptCollection.h

Go to the documentation of this file.
00001 
00002 /*
00003  * $Id: AmPromptFileCollection.cpp 288 2007-03-28 16:32:02Z sayer $
00004  *
00005  * Copyright (C) 2007 iptego GmbH
00006  *
00007  * This file is part of sems, a free SIP media server.
00008  *
00009  * sems is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * For a license to use the sems software under conditions
00015  * other than those described here, or to purchase support for this
00016  * software, please contact iptel.org by e-mail at the following addresses:
00017  *    info@iptel.org
00018  *
00019  * sems is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  * GNU General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU General Public License 
00025  * along with this program; if not, write to the Free Software 
00026  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027  */
00029 #ifndef AM_PROMPT_COLLECTION_H
00030 #define AM_PROMPT_COLLECTION_H
00031 
00042 #define AM_PROMPT_START \
00043 {   \
00044   std::vector<std::pair<string, string> > _prompt_names
00045 
00046 #define AM_PROMPT_ADD(_name, _default_file) \
00047  _prompt_names.push_back(std::make_pair(_name, _default_file))
00048 
00049 #define AM_PROMPT_END(_prompts, _cfg, _MOD_NAME) \
00050   _prompts.configureModule(_cfg, _prompt_names, _MOD_NAME); \
00051  }
00052 
00053 #include <map>
00054 #include <string>
00055 #include <utility>
00056 using std::string;
00057 
00058 #include "AmCachedAudioFile.h"
00059 #include "AmPlaylist.h"
00060 #include "AmConfigReader.h"
00061 
00062 class AudioFileEntry;
00063 
00067 class AmPromptCollection {
00068 
00069   // loaded files
00070   std::map<string, AudioFileEntry*> store;
00071 
00072   // opened objects
00073   std::map<long, vector<AmCachedAudioFile*> > items;
00074   // mutex for the above
00075   AmMutex items_mut;
00076 
00077  public:
00078   AmPromptCollection();
00079   ~AmPromptCollection();
00080   
00086   int configureModule(AmConfigReader& cfg, 
00087                       vector<std::pair<string, string> >& announcements,
00088                       const char* mod_name); 
00092   int setPrompt(const string& name, 
00093                 const string& filename,
00094                 const char* mod_name);
00099   int addToPlaylist(const string& name, long sess_id, 
00100                     AmPlaylist& list, bool front=false);
00104   void cleanup(long sess_id);
00105 };
00106 
00111 class AudioFileEntry : public AmAudioFile {
00112   AmFileCache cache;
00113   bool isopen;
00114 
00115 public:
00116   AudioFileEntry();
00117   ~AudioFileEntry();
00118   
00119   int load(const std::string& filename);
00120   bool isOpen() { return isopen; }
00121 
00122   AmCachedAudioFile* getAudio();
00123 };
00124 
00125 #endif

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