⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mcu.cxx

📁 这是一个OPENH323中的MCU程序
💻 CXX
📖 第 1 页 / 共 2 页
字号:
  rsrc->Add(new PHTTPStringField(CallLogFilenameKey, 50, logFilename));

#if OPENMCU_VIDEO
  forceScreenSplit = cfg.GetBoolean(ForceSplitVideoKey, FALSE);
  rsrc->Add(new PHTTPBooleanField(ForceSplitVideoKey, forceScreenSplit));
#endif

  // Finished the resource to add, generate HTML for it and add to name space
  PServiceHTML html("System Parameters");
  rsrc->BuildHTML(html);
  httpNameSpace.AddResource(rsrc, PHTTPSpace::Overwrite);

  // Create the status page
  httpNameSpace.AddResource(new MainStatusPage(*this, authority), PHTTPSpace::Overwrite);

  // Create invite conference page
  httpNameSpace.AddResource(new InvitePage(*this, authority), PHTTPSpace::Overwrite);

  // Add log file links
  if (!systemLogFileName && (systemLogFileName != "-")) {
    httpNameSpace.AddResource(new PHTTPFile("logfile.txt", systemLogFileName, authority));
    httpNameSpace.AddResource(new PHTTPTailFile("tail_logfile", systemLogFileName, authority));
  }

  //  create the home page
  static const char welcomeHtml[] = "welcome.html";
  if (PFile::Exists(welcomeHtml))
    httpNameSpace.AddResource(new PServiceHTTPFile(welcomeHtml, TRUE), PHTTPSpace::Overwrite);
  else {
    PHTML html;
    html << PHTML::Title("Welcome to OpenMCU")
         << PHTML::Body()
         << GetPageGraphic()
         << PHTML::Paragraph() << "<center>"

         << PHTML::HotLink("Parameters") << "Parameters" << PHTML::HotLink()
         << PHTML::Paragraph()
         << PHTML::HotLink("Status") << "MCU Status" << PHTML::HotLink()
         << PHTML::Paragraph()
         << PHTML::HotLink("Invite") << "Invite user to conference" << PHTML::HotLink()
         << PHTML::Paragraph();

    if (!systemLogFileName && systemLogFileName != "-")
      html << PHTML::HotLink("logfile.txt") << "Full Log File" << PHTML::HotLink()
           << PHTML::BreakLine()
           << PHTML::HotLink("tail_logfile") << "Tail Log File" << PHTML::HotLink()
           << PHTML::Paragraph();
 
    html << PHTML::HRule()
         << GetCopyrightText()
         << PHTML::Body();
    httpNameSpace.AddResource(new PServiceHTTPString("welcome.html", html), PHTTPSpace::Overwrite);
  }

  // create monitoring page
  PString monitorText = "<!--#equival monitorinfo-->"
                        "<!--#equival mcuinfo-->";
  httpNameSpace.AddResource(new PServiceHTTPString("monitor.txt", monitorText, "text/plain", authority), PHTTPSpace::Overwrite);


  // set up the HTTP port for listening & start the first HTTP thread
  if (ListenForHTTP(httpPort))
    PSYSTEMLOG(Info, "Opened master socket for HTTP: " << httpListeningSocket->GetPort());
  else {
    PSYSTEMLOG(Fatal, "Cannot run without HTTP port: " << httpListeningSocket->GetErrorText());
    return FALSE;
  }

  PSYSTEMLOG(Info, "Service " << GetName() << ' ' << initMsg);
  return TRUE;
}

PCREATE_SERVICE_MACRO(mcuinfo,P_EMPTY,P_EMPTY)
{
  return OpenMCU::Current().GetEndpoint().GetMonitorText();
}

void OpenMCU::OnConfigChanged()
{
}

PString OpenMCU::GetNewRoomNumber()
{
  static PAtomicInteger number = 100;
  return PString(PString::Unsigned, ++number);
}

void OpenMCU::LogMessage(const PString & str)
{
  static PMutex logMutex;
  static PTextFile logFile;

  PTime now;
  PString msg = now.AsString("dd/MM/yyyy") & str;
  logMutex.Wait();

  if (!logFile.IsOpen()) {
    logFile.Open(logFilename, PFile::ReadWrite);
    logFile.SetPosition(0, PFile::End);
  }

  logFile.WriteLine(msg);
  logFile.Close();
  logMutex.Signal();
}

ConferenceManager * OpenMCU::CreateConferenceManager()
{
  return new ConferenceManager();
}

OpenMCUH323EndPoint * OpenMCU::CreateEndPoint(ConferenceManager & manager)
{
  return new OpenMCUH323EndPoint(manager);
}

//////////////////////////////////////////////////////////////////////////////////////////////

PCREATE_SERVICE_MACRO_BLOCK(RoomStatus,P_EMPTY,P_EMPTY,block)
{
  return OpenMCU::Current().GetEndpoint().GetRoomStatus(block);
}

MainStatusPage::MainStatusPage(OpenMCU & _app, PHTTPAuthority & auth)
  : PServiceHTTPString("Status", "", "text/html; charset=UTF-8", auth),
    app(_app)
{
  PHTML html;

  html << PHTML::Title("OpenH323 MCU Status")
       << "<meta http-equiv=\"Refresh\" content=\"30\">\n"
       << PHTML::Body()
       << app.GetPageGraphic()
       << PHTML::Paragraph() << "<center>"

       //<< PHTML::Form("POST")

       << PHTML::TableStart("border=1")
       << PHTML::TableRow()
       << PHTML::TableHeader()
       << "&nbsp;Room&nbsp;Name&nbsp;"
       << PHTML::TableHeader()
       << "&nbsp;Room&nbsp;Members&nbsp;"
       << PHTML::TableHeader()

       << "<!--#macrostart RoomStatus-->"
         << PHTML::TableRow()
         << PHTML::TableData()
         << "<!--#status RoomName-->"
         << PHTML::TableData()
         << "<!--#status RoomMembers-->"
       << "<!--#macroend RoomStatus-->"

       << PHTML::TableEnd()

       << PHTML::Paragraph()

       //<< PHTML::Form()

       << PHTML::HRule()

       << app.GetCopyrightText()
       << PHTML::Body();

  string = html;
}


BOOL MainStatusPage::Post(PHTTPRequest & request,
                          const PStringToString & data,
                          PHTML & msg)
{
  /*
  PTRACE(2, "VGGK\tClear call POST received " << data);

  msg << PHTML::Title() << "Accepted Control Command" << PHTML::Body()
      << PHTML::Heading(1) << "Accepted Control Command" << PHTML::Heading(1);

  PWaitAndSignal m(app.endpointMutex);

  std::vector<MyGatekeeperH323EndPoint *>::iterator r;
  for (r = app.endpointList.begin(); r != app.endpointList.end(); ++r) {
    if ((*r)->OnPostControl(data, msg))
      msg << PHTML::Heading(2) << "No calls or endpoints!" << PHTML::Heading(2);
    PServiceHTML::ProcessMacros(request, msg, "html/status.html",
                                PServiceHTML::LoadFromFile|PServiceHTML::NoSignatureForFile);
  }

  msg << PHTML::Paragraph()
      << PHTML::HotLink(request.url.AsString()) << "Reload page" << PHTML::HotLink()
      << "&nbsp;&nbsp;&nbsp;&nbsp;"
      << PHTML::HotLink("/") << "Home page" << PHTML::HotLink();

*/
  return TRUE;
}


///////////////////////////////////////////////////////////////

InvitePage::InvitePage(OpenMCU & _app, PHTTPAuthority & auth)
  : PServiceHTTPString("Invite", "", "text/html; charset=UTF-8", auth),
    app(_app)
{
  PHTML html;

  html << PHTML::Title("Invite user to conference")
       << PHTML::Body()
       << app.GetPageGraphic()
       << PHTML::Paragraph() << "<center>"

       << PHTML::Form("POST")

       << PHTML::TableStart("border=1")
         << PHTML::TableRow()
          << PHTML::TableHeader()
          << "&nbsp;Room&nbsp;Name&nbsp;"
          << PHTML::TableData()
          << PHTML::InputText("room", 20)
         << PHTML::TableRow()
          << PHTML::TableHeader()
          << "&nbsp;Address&nbsp;"
          << PHTML::TableData()
          << PHTML::InputText("address", 40)
       << PHTML::TableEnd()
       << PHTML::Paragraph()
       << PHTML::SubmitButton("Invite")
       << PHTML::Form()
       << PHTML::HRule()
       << app.GetCopyrightText()
       << PHTML::Body();

  string = html;
}


BOOL InvitePage::Post(PHTTPRequest & request,
                          const PStringToString & data,
                          PHTML & msg)
{
  PString room    = data("room");
  PString address = data("address");

  if (room.IsEmpty() || address.IsEmpty()) {
    msg << PHTML::Title() << "Invite failed" << PHTML::Body()
        << PHTML::Heading(1) << "Insufficient information to perform INVITE" << PHTML::Heading(1);
    return TRUE;
  }

  OpenMCUH323EndPoint & ep = app.GetEndpoint();
  BOOL created = ep.OutgoingConferenceRequest(room);

  if (!created) {
    msg << PHTML::Title() << "Invite failed" << PHTML::Body()
        << PHTML::Heading(1) << "Cannot create room " << room << PHTML::Heading(1);
    return TRUE;
  }

  PString h323Token;
  PString * userData = new PString(room);
  if (ep.MakeCall(address, h323Token, userData) == NULL) {
    msg << PHTML::Title() << "Invite failed" << PHTML::Body()
        << PHTML::Heading(1) << "Cannot create make call to " << address << PHTML::Heading(1);
    ep.GetConferenceManager().RemoveConference(room);
    return TRUE;
  }

  msg << PHTML::Title() << "Invite succeeded" << PHTML::Body()
      << PHTML::Heading(1) << "Inviting " << address << " to room " << room << PHTML::Heading(1);

  return TRUE;
}


// End of File ///////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -