?? mcu.cxx
字號:
/*
* mcu.cxx
*
* Main MCU process routines for a simple MCU
*
* Copyright (C) 2000 Equivalence Pty. Ltd.
* Copyright (C) 2004 Post Increment
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Portions of ths code were written by by Post Increment (http://www.postincrement.com)
* with the assistance of funding from Stonevoice, slc. http://www.stonevoice.com
*
* Portions of this code were written by Post Increment (http://www.postincrement.com)
* with the assistance of funding from Citron Networks (http://www.citron.com.tw)
*
* Contributor(s): Derek J Smithies (derek@indranet.co.nz)
* Craig Southeren (craig@postincrement.com)
*
* $Log: mcu.cxx,v $
* Revision 1.2 2007/10/20 12:04:57 shorne
* Fix small compile error with ptlib v1.12
*
* Revision 1.1 2007/10/17 19:44:31 shorne
* Initial Commit
*
* Revision 2.2.2.1 2007/08/16 20:29:01 shorne
* Better Gatekeeper anf Gateway prefix support
*
* Revision 2.3 2007/02/12 23:36:23 csoutheren
* Applied 1636260 - OpenMCU patch to have return link in web UI
* Thanks to RM Fleming
*
* Revision 2.2 2006/07/14 05:28:01 csoutheren
* Removed old code
*
* Revision 2.1 2006/06/09 04:39:59 csoutheren
* Migrated VideoBranch to main trunk
*
* Revision 1.1.2.5 2006/04/26 13:09:08 csoutheren
* Fix problem when connecting file not available
* Add optional time limit for rooms
*
* Revision 1.1.2.4 2006/04/18 00:32:41 csoutheren
* Removed dependence on custom.h
*
* Revision 1.1.2.3 2006/04/06 01:11:16 csoutheren
* Latest sources include
* - premedia blanking and optional image display
* - ablity to defer conference join for authentication if required
* - more bulletproofing on conference join
* - new video copy/fill functions
*
* Revision 1.1.2.2 2006/04/06 00:50:30 csoutheren
* Latest changes (more to come)
*
* Revision 1.1.2.1 2006/03/28 05:13:38 csoutheren
* Normalised file headers
* Fixed problem with QCIF video
* Seperated H.323 and MCU process functions into seperate files
*
*/
#include <ptlib.h>
#include "version.h"
#include "mcu.h"
#include "h323.h"
const WORD DefaultHTTPPort = 1420;
extern PHTTPServiceProcess::Info ProductInfo;
static const char LogLevelKey[] = "Log Level";
static const char UserNameKey[] = "Username";
static const char PasswordKey[] = "Password";
static const char HttpPortKey[] = "HTTP Port";
static const char CallLogFilenameKey[] = "Call log filename";
#if P_SSL
static const char HTTPCertificateFileKey[] = "HTTP Certificate";
#endif
static const char DefaultRoomKey[] = "Default room";
static const char DefaultRoomTimeLimitKey[] = "Room time limit";
static const char DefaultCallLogFilename[] = "mcu_log.txt";
static const char DefaultRoom[] = "room101";
#if OPENMCU_VIDEO
static const char ForceSplitVideoKey[] = "Force split screen video";
#endif
#define new PNEW
///////////////////////////////////////////////////////////////
class MainStatusPage : public PServiceHTTPString
{
// PCLASSINFO(MainStatusPage, PServiceHTTPString);
public:
MainStatusPage(OpenMCU & app, PHTTPAuthority & auth);
virtual BOOL Post(
PHTTPRequest & request,
const PStringToString &,
PHTML & msg
);
private:
OpenMCU & app;
};
class InvitePage : public PServiceHTTPString
{
// PCLASSINFO(InvitePage, PServiceHTTPString);
public:
InvitePage(OpenMCU & app, PHTTPAuthority & auth);
virtual BOOL Post(
PHTTPRequest & request, // Information on this request.
const PStringToString & data, // Variables in the POST data.
PHTML & replyMessage // Reply message for post.
);
private:
OpenMCU & app;
};
///////////////////////////////////////////////////////////////
// This really isn't the default count only a counter
// for sending aliases and prefixes to the gatekeeper
int OpenMCU::defaultRoomCount = 5;
OpenMCU::OpenMCU()
: OpenMCUProcessAncestor(ProductInfo)
{
endpoint = NULL;
}
void OpenMCU::Main()
{
Suspend();
}
BOOL OpenMCU::OnStart()
{
// change to the default directory to the one containing the executable
PDirectory exeDir = GetFile().GetDirectory();
#if defined(_WIN32) && defined(_DEBUG)
// Special check to aid in using DevStudio for debugging.
if (exeDir.Find("\\Debug\\") != P_MAX_INDEX)
exeDir = exeDir.GetParent();
#endif
exeDir.Change();
httpNameSpace.AddResource(new PHTTPDirectory("data", "data"));
httpNameSpace.AddResource(new PServiceHTTPDirectory("html", "html"));
manager = CreateConferenceManager();
endpoint = CreateEndPoint(*manager);
return PHTTPServiceProcess::OnStart();
}
void OpenMCU::OnStop()
{
delete endpoint;
endpoint = NULL;
delete manager;
manager = NULL;
PHTTPServiceProcess::OnStop();
}
void OpenMCU::OnControl()
{
// This function get called when the Control menu item is selected in the
// tray icon mode of the service.
PStringStream url;
url << "http://";
PString host = PIPSocket::GetHostName();
PIPSocket::Address addr;
if (PIPSocket::GetHostAddress(host, addr))
url << host;
else
url << "localhost";
url << ':' << DefaultHTTPPort;
PURL::OpenBrowser(url);
}
BOOL OpenMCU::Initialise(const char * initMsg)
{
PConfig cfg("Parameters");
// Set log level as early as possible
// SetLogLevel((PSystemLog::Level)cfg.GetInteger(LogLevelKey, GetLogLevel()));
#if PTRACING
SetLogLevel(PSystemLog::Debug6);
PTrace::Initialise(6,"c:\\trace.txt");
/* if (GetLogLevel() >= PSystemLog::Warning)
PTrace::SetLevel(GetLogLevel()-PSystemLog::Warning);
else
PTrace::SetLevel(0);
PTrace::ClearOptions(PTrace::Timestamp);
PTrace::SetOptions(PTrace::DateAndTime); */
#endif
// Get the HTTP basic authentication info
PString adminUserName = cfg.GetString(UserNameKey);
PString adminPassword = PHTTPPasswordField::Decrypt(cfg.GetString(PasswordKey));
PHTTPSimpleAuth authority(GetName(), adminUserName, adminPassword);
// Create the parameters URL page, and start adding fields to it
PConfigPage * rsrc = new PConfigPage(*this, "Parameters", "Parameters", authority);
// HTTP authentication username/password
rsrc->Add(new PHTTPStringField(UserNameKey, 25, adminUserName));
rsrc->Add(new PHTTPPasswordField(PasswordKey, 25, adminPassword));
// Log level for messages
rsrc->Add(new PHTTPIntegerField(LogLevelKey,
PSystemLog::Fatal, PSystemLog::NumLogLevels-1,
GetLogLevel(),
"1=Fatal only, 2=Errors, 3=Warnings, 4=Info, 5=Debug"));
#if P_SSL
// SSL certificate file.
PString certificateFile = cfg.GetString(HTTPCertificateFileKey, "server.pem");
rsrc->Add(new PHTTPStringField(HTTPCertificateFileKey, 25, certificateFile));
if (!SetServerCertificate(certificateFile, TRUE)) {
PSYSTEMLOG(Fatal, "MCU\tCould not load certificate \"" << certificateFile << '"');
return FALSE;
}
#endif
// HTTP Port number to use.
WORD httpPort = (WORD)cfg.GetInteger(HttpPortKey, DefaultHTTPPort);
rsrc->Add(new PHTTPIntegerField(HttpPortKey, 1, 32767, httpPort));
endpoint->Initialise(cfg, rsrc);
// get default "room" (conference) name
defaultRoomName = cfg.GetString(DefaultRoomKey, DefaultRoom);
rsrc->Add(new PHTTPStringField(DefaultRoomKey, 25, defaultRoomName));
// get conference time limit
roomTimeLimit = cfg.GetInteger(DefaultRoomTimeLimitKey, 0);
rsrc->Add(new PHTTPIntegerField(DefaultRoomTimeLimitKey, 0, 10800, roomTimeLimit));
OnCreateConfigPage(cfg, *rsrc);
// default log file name
logFilename = cfg.GetString(CallLogFilenameKey, DefaultCallLogFilename);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -