1 /*
2  * main.h
3  *
4  * Copyright (C) 2009 Post Increment
5  *
6  * The contents of this file are subject to the Mozilla Public License
7  * Version 1.0 (the "License"); you may not use this file except in
8  * compliance with the License. You may obtain a copy of the License at
9  * http://www.mozilla.org/MPL/
10  *
11  * Software distributed under the License is distributed on an "AS IS"
12  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
13  * the License for the specific language governing rights and limitations
14  * under the License.
15  *
16  * The Original Code is Opal
17  *
18  * The Initial Developer of the Original Code is Post Increment
19  *
20  * Contributor(s): ______________________________________.
21  *
22  * $Revision:$
23  * $Author:$
24  * $Date:$
25  */
26 
27 #ifndef _OpalEcho_MAIN_H
28 #define _OpalEcho_MAIN_H
29 
30 class EchoConnection;
31 
32 class EchoEndPoint : public OpalLocalEndPoint
33 {
34   PCLASSINFO(EchoEndPoint, OpalLocalEndPoint);
35   public:
EchoEndPoint(OpalManager & manager)36     EchoEndPoint(OpalManager & manager)
37       : OpalLocalEndPoint(manager, "echo")
38     { }
39 
40     virtual OpalLocalConnection * CreateConnection(
41       OpalCall & call,    ///<  Owner of connection
42       void * userData,     ///<  Arbitrary data to pass to connection
43       unsigned options,
44       OpalConnection::StringOptions * stringOptions
45     );
46 
47     bool OnReadMediaFrame(
48       const OpalLocalConnection & connection, ///<  Connection for media
49       const OpalMediaStream & mediaStream,    ///<  Media stream data is required for
50       RTP_DataFrame & frame                   ///<  RTP frame for data
51     );
52 
53     virtual bool OnWriteMediaFrame(
54       const OpalLocalConnection & connection, ///<  Connection for media
55       const OpalMediaStream & mediaStream,    ///<  Media stream data is required for
56       RTP_DataFrame & frame                   ///<  RTP frame for data
57     );
58 };
59 
60 class MyManager : public OpalManager
61 {
62   PCLASSINFO(MyManager, OpalManager);
63 
64   public:
65     MyManager();
66     ~MyManager();
67 
68     PBoolean Initialise(PConfig & cfg, PConfigPage * rsrc);
69 
70   protected:
71     SIPEndPoint      * sipEP;
72     EchoEndPoint     * echoEP;
73 
74   friend class OpalEcho;
75 };
76 
77 
78 class OpalEcho : public PHTTPServiceProcess
79 {
80   PCLASSINFO(OpalEcho, PHTTPServiceProcess)
81 
82   public:
83     OpalEcho();
84     virtual void Main();
85     virtual PBoolean OnStart();
86     virtual void OnStop();
87     virtual void OnControl();
88     virtual void OnConfigChanged();
89     virtual PBoolean Initialise(const char * initMsg);
90 
Current()91     static OpalEcho & Current() { return (OpalEcho &)PProcess::Current(); }
92 
93     MyManager manager;
94 };
95 
96 #endif  // _OpalEcho_MAIN_H
97 
98 
99 // End of File ///////////////////////////////////////////////////////////////
100