1 /*
2  * Copyright (C) 2011 Raphael Coeffic
3  *
4  * This file is part of SEMS, a free SIP media server.
5  *
6  * SEMS is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version. This program is released under
10  * the GPL with the additional exemption that compiling, linking,
11  * and/or using OpenSSL is allowed.
12  *
13  * For a license to use the SEMS software under conditions
14  * other than those described here, or to purchase support for this
15  * software, please contact iptel.org by e-mail at the following addresses:
16  *    info@iptel.org
17  *
18  * SEMS is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26  */
27 
28 #ifndef _Rtmp_h_
29 #define _Rtmp_h_
30 
31 #include "RtmpServer.h"
32 #include "AmApi.h"
33 #include "AmEventProcessingThread.h"
34 
35 #define MOD_NAME "rtmp"
36 #define FACTORY_Q_NAME (MOD_NAME "_ev_proc")
37 
38 class RtmpConnection;
39 
40 struct RtmpConfig
41 {
42   // RTMP server params
43   string ListenAddress;
44   unsigned int ListenPort;
45 
46   // Outbound call params
47   string FromName;
48   string FromDomain;
49 
50   // Registration related params
51   bool   AllowExternalRegister;
52   string ImplicitRegistrar;
53 
54   RtmpConfig();
55 };
56 
57 class RtmpFactory
58   : public AmSessionFactory,
59     public AmEventProcessingThread
60 {
61   // Global module configuration
62   RtmpConfig cfg;
63 
64   // Container keeping trace of registered RTMP connections
65   // to enable inbound calls to RTMP clients
66   map<string,RtmpConnection*> connections;
67   AmMutex                     m_connections;
68 
69   // registrar_client instance pointer
70   AmDynInvoke* di_reg_client;
71 
72 protected:
73 
74 public:
75   RtmpFactory();
76   ~RtmpFactory();
77 
78   // from AmPluginFactory
79   int onLoad();
80 
81   // from AmSessionFactory
82   AmSession* onInvite(const AmSipRequest& req, const string& app_name,
83 		      const map<string,string>& app_params);
84 
getConfig()85   const RtmpConfig* getConfig() { return &cfg; }
getRegClient()86   AmDynInvoke* getRegClient() { return di_reg_client; }
87 
88   int addConnection(const string& ident, RtmpConnection*);
89   void removeConnection(const string& ident);
90 };
91 
92 // declare the RtmpFactory as a singleton
93 typedef singleton<RtmpFactory> RtmpFactory_impl;
94 
95 #endif
96