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

📄 main.cxx

📁 softphone client for test
💻 CXX
📖 第 1 页 / 共 5 页
字号:
  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 override it
  if (args.HasOption("portbase"))
    SetRtpIpPorts(args.GetOptionString("portbase").AsInteger(),
                  args.GetOptionString("portmax").AsInteger());
  
  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;
    }
  }

  if (args.HasOption("sound-buffers")) {
    soundChannelBuffers = args.GetOptionString("sound-buffers", "2").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;
    videoReceiveDevice = args.GetOptionString("h261");
  } else if (args.HasOption("videoreceive"))
    videoReceiveDevice = args.GetOptionString("videoreceive");

  if (!videoReceiveDevice.IsEmpty()) {
    channelsOpenLimit ++;     //we expect to have another channel open, for video receive.
    if (  !(videoReceiveDevice *= "ppm")
        && !(videoReceiveDevice *= "null")
#ifdef HAS_VGALIB
        && !(videoReceiveDevice *= "svga")
        && !(videoReceiveDevice *= "svga256")
#endif
#ifdef P_SDL
        && !(videoReceiveDevice *= "sdl")
#endif
#ifdef HAS_X11
        && !(videoReceiveDevice *= "x1132")
        && !(videoReceiveDevice *= "x1124")
        && !(videoReceiveDevice *= "x1116")
        && !(videoReceiveDevice *= "x118")
        && !(videoReceiveDevice *= "x11")
        && !(videoReceiveDevice *= "x1132s")
        && !(videoReceiveDevice *= "x1124s")
        && !(videoReceiveDevice *= "x1116s")
        && !(videoReceiveDevice *= "x118s")
        && !(videoReceiveDevice *= "x11s")
#endif
#ifdef USE_SHM_VIDEO_DEVICES
	&& !(videoReceiveDevice *= "shm")
#endif
        ) {
        cout << "Unknown video receive device \"" << videoReceiveDevice << "\"" << endl;
        return FALSE;
    }
  
    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.

    videoDevice = DEFAULT_VIDEO;
    videoFake = FALSE;    
    if (args.HasOption("videodevice")) {      
      videoDevice = args.GetOptionString("videodevice");
      if (videoDevice == FICTITOUS_VIDEO)
        videoFake = TRUE;
    }

    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();
      if (videoInput<0) {
        cout << "User interface has changed.\n"
             << "Select fictitous video device with --videodevice "FICTITOUS_VIDEO"\n"
             << "Use videoinput argument of 0, 1, 2, ...\n"
             << "For backwards compatability, negative inputs are currently supported\n";
        videoFake = TRUE;
        videoInput= -1 - videoInput; //-1 ==> 0, -2 ==>1, etc
      }
    }

    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 device : " << videoReceiveDevice << endl;
      cout << "Video receive quality hint : " << videoQuality << endl << endl;
    }
    if (!autoStartTransmitVideo)
      cout << "Video transmit disabled" << endl << endl;
    else {
      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")) {
        aec = args.GetOptionString("aec").AsUnsigned();
        lidDevice->SetAEC(0, (OpalLineInterfaceDevice::AECLevels)aec);
        if (verbose >= 3)
          cout << "AEC set to " << AECLevelNames[aec] << endl;
      } else {
        lidDevice->SetAEC(0, OpalLineInterfaceDevice::AECMedium);
        if (verbose >= 3)
          cout << "AEC set to default" << endl;
      }

      PString volStr;

      if ((OpalLineInterfaceDevice::AECLevels)aec != OpalLineInterfaceDevice::AECAGC) {
        if (args.HasOption("quicknet-recvol"))
          volStr = args.GetOptionString("quicknet-recvol");
        else if (args.HasOption("recvol"))
          volStr = args.GetOptionString("recvol");

        unsigned recvol;
        if (!volStr.IsEmpty()) {
          recvol = volStr.AsInteger();
          lidDevice->SetRecordVolume(0, recvol);
        } else {
          lidDevice->GetRecordVolume(0, recvol);
        }
        if (verbose >= 3) {
          cout << "Recording volume set to " << recvol << endl;
        }
      }
      if (args.HasOption("quicknet-playvol"))
        volStr = args.GetOptionString("quicknet-playvol");
      else if (args.HasOption("playvol"))
        volStr = args.GetOptionString("playvol");

      unsigned playvol;
      if (!volStr.IsEmpty()) {
        playvol = volStr.AsInteger();
        lidDevice->SetPlayVolume(0, playvol);

⌨️ 快捷键说明

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