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

📄 main.cxx

📁 openh323_1.1.2.2.zip; 2. 把pwlib_1.52.zip 、openh323_1.1.2.2.zip分别展开到目录e:h323sourcepwlib及e:h323sourc
💻 CXX
📖 第 1 页 / 共 5 页
字号:
  if (verbose >= 3)
    cout << GetName() << " ended." << endl;

#if PTRACING
  if (args.GetOptionCount('t') > 0) {
    PTrace::ClearOptions(0);
    PTrace::SetLevel(0);
  }
#endif

}


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

void MyH323EndPoint::SetCodecFrames(const PString & fmt, unsigned frames)
{
  H323Capability * cap = capabilities.FindCapability(fmt);
  if (cap == NULL) {
    cout << "Cannot find codec " << fmt << endl;
  }
  else if (frames < 1)
    cout << "Cannot set frames per packet for code " << *cap << " to 0" << endl;
  else {
    cout << "Setting frames per packet for " << *cap << " to " << frames << endl;
    cap->SetTxFramesInPacket(frames);
  }
}

BOOL MyH323EndPoint::Initialise(PConfigArgs & args, int _verbose, BOOL _hasMenu)
{
  PTRACE(3, "H323ep\tInitialise program. Arguments are " << args);

  PINDEX i;

  verbose = _verbose;
  hasMenu = _hasMenu;
  uiState = uiDialtone;

  channelsOpenLimit = 2;   //Guaranteed to have 2 open audio channels.

  localVideoChannel = NULL;

  // get local username
  if (args.HasOption('u')) {
    PStringArray aliases = args.GetOptionString('u').Lines();
    SetLocalUserName(aliases[0]);
    for (i = 1; i < aliases.GetSize(); i++)
      AddAliasName(aliases[i]);
  }

  // Let the user set port ranges
  if (args.HasOption("portbase")) {
    SetRtpIpPorts(args.GetOptionString("portbase").AsInteger(),
                  args.GetOptionString("portmax").AsInteger());
    SetTCPPorts(args.GetOptionString("portbase").AsInteger(),
                args.GetOptionString("portmax").AsInteger());
    SetUDPPorts(args.GetOptionString("portbase").AsInteger(),
                args.GetOptionString("portmax").AsInteger());
  }
  
  if (args.HasOption("stun")) {
    SetSTUNServer(args.GetOptionString("stun"));
  }

  if (verbose >= 3)
    cout << "Incoming channel port ranges " << GetRtpIpPortBase() << " to " << GetRtpIpPortMax()<<endl;
  
  // get ports
  WORD port = H323EndPoint::DefaultTcpPort;
  WORD listenPort = port;
  if (!args.GetOptionString("port").IsEmpty())
    port = (WORD)args.GetOptionString("port").AsInteger();


#if 0
  PSoundChannel::writeDebug = TRUE;
  PSoundChannel::readDebug  = TRUE;
  OpalIxJDevice::writeDebug = TRUE;
  OpalIxJDevice::readDebug  = TRUE;
#endif

  defaultCallOptions.minJitter   = GetMinAudioJitterDelay();
  defaultCallOptions.maxJitter   = GetMaxAudioJitterDelay();
  defaultCallOptions.connectPort = port;
  defaultCallOptions.connectRing = 0;

  if (!defaultCallOptions.Initialise(args))
    return FALSE;

  currentCallOptions = defaultCallOptions;

  //////////

  terminateOnHangup    = !args.HasOption('l');
  autoAnswer           = args.HasOption('a');
  alwaysForwardParty   = args.GetOptionString('F');
  busyForwardParty     = args.GetOptionString('B');
  noAnswerForwardParty = args.GetOptionString('N');
  noAnswerTime         = args.GetOptionString("answer-timeout", "30").AsUnsigned();
  dialAfterHangup      = args.HasOption("dial-after-hangup");
  setupParameter       = args.GetOptionString("setup-param");

  noAnswerTimer.SetNotifier(PCREATE_NOTIFIER(OnNoAnswerTimeout));

  if (args.HasOption("tos"))
    SetRtpIpTypeofService(args.GetOptionString("tos").AsUnsigned());

  if (args.HasOption('b')) {
    initialBandwidth = args.GetOptionString('b').AsUnsigned();
    if (initialBandwidth == 0) {
      cout << "Illegal bandwidth specified." << endl;
      return FALSE;
    }
  }

  numberPrefix = args.GetOptionString("number-prefix");
  proxy        = args.GetOptionString('p');

  if (args.HasOption("sound-buffers")) {
    soundChannelBuffers = args.GetOptionString("sound-buffers", "3").AsUnsigned();
    if (soundChannelBuffers < 2 || soundChannelBuffers > 99) {
      cout << "Illegal sound buffers specified." << endl;
      return FALSE;
    }
  }

  if (verbose >= 3) {
    cout << "Local username: " << GetLocalUserName() << "\n"
         << "TerminateOnHangup is " << terminateOnHangup << "\n"
         << "Auto answer is " << autoAnswer << "\n"
         << "DialAfterHangup is " << dialAfterHangup << "\n"
         << defaultCallOptions
         << endl;

  }
  if (args.HasOption("autodial")) {
    autoDial = args.GetOptionString("autodial");
    if (verbose >= 3)
      cout << "Autodial is set to "  << autoDial << "\n";
  }


  if (args.HasOption("h261")) {
    cout << "warning: --h261 option has been replaced by --videoreceive and --videotransmit" << endl;
    return FALSE;
  } 
  
  videoReceiveDriver = args.GetOptionString("videoreceive");
  if (!videoReceiveDriver.IsEmpty()) {
    channelsOpenLimit ++;     //we expect to have another channel open, for video receive.
    PStringList list = PVideoOutputDevice::GetDriverNames();
    if (list.GetStringsIndex(videoReceiveDriver) == P_MAX_INDEX)  {
      cout << "Unknown video output driver \"" << videoReceiveDriver << "\"" << endl
           << "Must be one of " << setfill(',') << list << setfill(' ') << endl;
      return FALSE;
    }

    videoReceiveDevice = args.GetOptionString("videorxdevice");
    if (videoReceiveDevice.IsEmpty()) {
      list = PVideoOutputDevice::GetDriversDeviceNames(videoReceiveDevice);
      if (list.GetSize() != 0)
        videoReceiveDevice = list[0];
    }
  }

  if (!args.HasOption("videoquality")) 
    videoQuality = -1;
  else {
    videoQuality = args.GetOptionString("videoquality").AsInteger();
    videoQuality = PMAX(0, PMIN(31, videoQuality));
  }

  videoPIP   = FALSE;
  videoSize = 0; //Default is small.

  autoStartTransmitVideo = args.HasOption("videotransmit") || args.HasOption("videotest");

  if (autoStartTransmitVideo) {
    channelsOpenLimit ++;     //we expect to have another channel open, for video transmit.

    videoTransmitDriver = args.GetOptionString("videotransmit");
    if (!videoTransmitDriver.IsEmpty()) {
      PStringList list = PVideoInputDevice::GetDriverNames();
      if (list.GetStringsIndex(videoTransmitDriver) == P_MAX_INDEX)  {
        cout << "Unknown video capture driver \"" << videoTransmitDriver << "\"" << endl
              << "Must be one of " << setfill(',') << list << setfill(' ') << endl;
        return FALSE;
      }

      videoTransmitDevice = args.GetOptionString("videotxdevice");
      if (videoTransmitDevice.IsEmpty()) {
        PStringList list = PVideoInputDevice::GetDriverNames();
        if (list.GetSize() != 0)
          videoTransmitDevice = list[0];
      }

      if (args.GetOptionString("videosize") *= "large")
        videoSize = 1;
      if (verbose >= 3)
        cout << "Set video size to be " << (videoSize == 0 ? "small" : "large") << endl;

      videoInput = 0;
      if (args.HasOption("videoinput"))
        videoInput = args.GetOptionString("videoinput").AsInteger();

      videoIsPal = TRUE;
      if (args.HasOption("videoformat"))
        videoIsPal = args.GetOptionString("videoformat") *= "pal";

      if (args.HasOption("videocolorfmt"))
        pfdColourFormat = args.GetOptionString("videocolorfmt");

      videoLocal = args.HasOption("videolocal");
      if (args.HasOption("videopip")) {
        videoPIP   = TRUE;
        videoLocal = TRUE;
      }

      videoTxQuality = 0; // disable setting video quality
      if (args.HasOption("videotxquality"))
        videoTxQuality = args.GetOptionString("videotxquality").AsInteger();

      videoTxMinQuality = 0; // disable setting minimum video quality
      if (args.HasOption("videotxminquality"))
        videoTxMinQuality = args.GetOptionString("videotxminquality").AsInteger();

      videoFill = 2; // default video fill value
      if (args.HasOption("videofill")) {
        videoFill = args.GetOptionString("videofill").AsInteger();
        videoFill = PMAX(2, PMIN(99, videoFill));
      }

      if (args.HasOption("videocu30stats")) {
        videoCu30Stats = args.GetOptionString("videocu30stats").AsInteger();
        videoCu30Stats = PMAX(10, PMIN(10000, videoCu30Stats));
      } else
        videoCu30Stats = 0; // Dont record stats.

      if (args.HasOption("videotxfps")) {
        videoFramesPS = args.GetOptionString("videotxfps").AsInteger();
        videoFramesPS = PMAX(0, PMIN(30,videoFramesPS));
      } else
        videoFramesPS=0; //default value.

      frameTimeMs = 0; //disable setting frameTimeMs.
      if (args.HasOption("videosendfps")) {
        double videoSendFPS;
        videoSendFPS = args.GetOptionString("videosendfps").AsReal();
        if (0.0 < videoSendFPS) {
          frameTimeMs = (unsigned)(1000.0/videoSendFPS);
          frameTimeMs = PMAX(33, PMIN(1000000,frameTimeMs)); // 5 ms to 16.7 minutes
        }
      }

      videoBitRate = 0; //disable setting videoBitRate.
      if (args.HasOption("videobitrate")) {
        videoBitRate = args.GetOptionString("videobitrate").AsInteger();
        videoBitRate = 1024 * PMAX(16, PMIN(2048, videoBitRate));
      }
    }
  }

  if (verbose >= 3) {
    if (videoReceiveDevice.IsEmpty())
      cout << "Video receive disabled" << endl << endl;
    else {
      cout << "Video receive using driver : " << videoReceiveDriver << endl;
      if (!videoReceiveDevice.IsEmpty())
        cout << "Video receive using device : " << videoReceiveDevice << endl;
      cout << "Video receive quality hint : " << videoQuality << endl << endl;
    }
    if (!autoStartTransmitVideo)
      cout << "Video transmit disabled" << endl << endl;
    else {
      cout << "Video transmit using driver : " << videoTransmitDriver << endl;
      if (!videoTransmitDevice.IsEmpty())
        cout << "Video transmit using device : " << videoTransmitDevice << endl;
      cout << "Video transmit enabled with local video window " << (videoLocal ? "en" : "dis") << "abled" << endl;
      cout << "Video transmit size is " << ((videoSize == 1) ? "large" : "small") << endl;
      cout << "Video capture using input " << videoInput << endl;
      cout << "Video capture using format " << (videoIsPal ? "PAL" : "NTSC") << endl;
      cout << "Video picture in picture of local video "<< (videoPIP ? "en" : "dis") << "abled" << endl;
      cout << "Video transmit quality is "<< videoTxQuality<<endl;
      cout << "Video background fill blocks "<< videoFill<<endl;
      cout << "Video transmit frames per sec "<< videoFramesPS<< (videoFramesPS==0 ? " (default) " : "") <<endl;
      cout << "Video bitrate "<<videoBitRate<<" bps" << endl;
    }
#ifdef DEPRECATED_CU30
    if (args.HasOption("videocu30") || args.HasOption("videocu30stats")) {
      cout << "Video codec Cu30 enabled."<<endl;
      cout << "Video Cu30 statitistics " ;
      if (videoCu30Stats>0)
        cout << "enabled. " << videoCu30Stats << " frames." << endl;
      else
  cout << "disabled" << endl;
    }
#endif
    cout << endl;
  }

#ifdef HAS_LIDDEVICE
  isXJack = FALSE;
  lidDevice = NULL;
#endif

#ifdef HAS_VBLASTER
  if (args.HasOption('V')) {
    PString vbDevice = args.GetOptionString('V');
    lidDevice = new OpalVoipBlasterDevice;
    if (lidDevice->Open(vbDevice)) {
      if (verbose >= 3)
        cout << "Using VoIPBlaster " << lidDevice->GetName() << '\n';
    }
    autoHook = FALSE;
  }
#endif

#ifdef HAS_IXJ
  if (args.HasOption('q')) {
    lidDevice = new OpalIxJDevice;
    PString ixjDevice = args.GetOptionString('q');
    if (lidDevice->Open(ixjDevice)) {
      if (verbose >= 3)
        cout << "Using Quicknet " << lidDevice->GetName() << '\n';
      isXJack = TRUE;
      lidDevice->SetLineToLineDirect(0, 1, FALSE);
      lidDevice->EnableAudio(0, TRUE);

      callerIdEnable = args.HasOption("callerid");
      if (verbose >= 3)
        cout << "Caller ID set to " << callerIdEnable << endl;

      callerIdCallWaitingEnable = args.HasOption("calleridcw");
      if (verbose >= 3)
        cout << "Caller ID on call waiting set to " << callerIdCallWaitingEnable << endl;

      if (args.HasOption('C'))
        lidDevice->SetCountryCodeName(args.GetOptionString('C'));
      if (verbose >= 3)
        cout << "Country set to " << lidDevice->GetCountryCodeName() << endl;

      int aec = 0;
      if (args.HasOption("aec")) {

⌨️ 快捷键说明

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