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

📄 main.cxx

📁 开源的openh323的v1.18.0版,有1.19.0版无法编译过的朋友可以用这版
💻 CXX
📖 第 1 页 / 共 2 页
字号:
  };

  cout << "  Capability type:     ";
  if (defn.h323CapabilityType < (sizeof(capabilityNames) / sizeof(capabilityNames[0])))
    cout << capabilityNames[defn.h323CapabilityType];
  else
    cout << "Unknown capability code " << defn.h323CapabilityType;

  switch (defn.h323CapabilityType) {
    case PluginCodec_H323Codec_undefined:
      break;

    case PluginCodec_H323Codec_nonStandard:
      if (defn.h323CapabilityData == NULL)
        cout << ", no data" << endl;
      else {
        struct PluginCodec_H323NonStandardCodecData * data =
            (struct PluginCodec_H323NonStandardCodecData *)defn.h323CapabilityData;
        if (data->objectId != NULL) 
          cout << ", objectID=" << data->objectId;
        else
          cout << ", t35=" << (int)data->t35CountryCode << "," << (int)data->t35Extension << "," << (int)data->manufacturerCode;
        if ((data->data == NULL) || (data->dataLength == 0))
          cout << ", empty data";
        else {
          BOOL printable = TRUE;
          for (unsigned i = 0; i < data->dataLength; ++i) 
            printable = printable && (0x20 <= data->data[i] && data->data[i] < 0x7e);
          if (printable)
            cout << ", data=" << PString((const char *)data->data, data->dataLength);
          else
            cout << ", " << (int)data->dataLength << " bytes";
        }
        if (data->capabilityMatchFunction != NULL) 
          cout << ", match function provided";
        cout << endl;
      }
      break;

    case PluginCodec_H323Codec_programmed:
    case PluginCodec_H323Codec_generic:
    case PluginCodec_H323AudioCodec_g711Alaw_64k:
    case PluginCodec_H323AudioCodec_g711Alaw_56k:
    case PluginCodec_H323AudioCodec_g711Ulaw_64k:
    case PluginCodec_H323AudioCodec_g711Ulaw_56k:
    case PluginCodec_H323AudioCodec_g722_64k:
    case PluginCodec_H323AudioCodec_g722_56k:
    case PluginCodec_H323AudioCodec_g722_48k:
    case PluginCodec_H323AudioCodec_g728:
    case PluginCodec_H323AudioCodec_g729:
    case PluginCodec_H323AudioCodec_g729AnnexA:
    case PluginCodec_H323AudioCodec_g729wAnnexB:
    case PluginCodec_H323AudioCodec_g729AnnexAwAnnexB:
      if (defn.h323CapabilityData != NULL)
        cout << (void *)defn.h323CapabilityData << endl;
      break;

    case PluginCodec_H323AudioCodec_g7231:
      cout << "silence supression " << ((defn.h323CapabilityData > 0) ? "on" : "off") << endl;
      break;

    case PluginCodec_H323AudioCodec_is11172:
    case PluginCodec_H323AudioCodec_is13818Audio:
    case PluginCodec_H323AudioCodec_g729Extensions:
      cout << "ignored";
      break;

    case PluginCodec_H323AudioCodec_g7231AnnexC:
      if (defn.h323CapabilityData == NULL)
        cout << ", no data" << endl;
      else 
        cout << "not displayed" << endl;
      break;

    case PluginCodec_H323AudioCodec_gsmFullRate:
    case PluginCodec_H323AudioCodec_gsmHalfRate:
    case PluginCodec_H323AudioCodec_gsmEnhancedFullRate:
      if (defn.h323CapabilityData == NULL)
        cout << ", no data -> default comfortNoise=0, scrambled=0" << endl;
      else {
        struct PluginCodec_H323AudioGSMData * data =
            (struct PluginCodec_H323AudioGSMData *)defn.h323CapabilityData;
        cout << ", comfort noise=" << data->comfortNoise << ", scrambled=" << data->scrambled;
        cout << endl;
      }
      break;

    case PluginCodec_H323VideoCodec_h261:
    case PluginCodec_H323VideoCodec_h262:
    case PluginCodec_H323VideoCodec_h263:
    case PluginCodec_H323VideoCodec_is11172:
      if (defn.h323CapabilityData == NULL)
        cout << ", no data" << endl;
      else 
        cout << "not displayed" << endl;
      break;

    default:
      break;
  }
}

void DisplayMediaFormats(const OpalMediaFormat::List & mediaList)
{
  PINDEX i;
  PINDEX max_len = 0;
  for (i = 0; i < mediaList.GetSize(); i++) {
    PINDEX len = mediaList[i].GetLength();
    if (len > max_len)
      max_len = len;
  }

  for (i = 0; i < mediaList.GetSize(); i++) {
    OpalMediaFormat & fmt = mediaList[i];
    cout << setw(max_len+2) << fmt << "  ";
    switch (fmt.GetDefaultSessionID()) {
      case OpalMediaFormat::DefaultAudioSessionID:
        cout << "audio, rate=" << fmt.GetBandwidth() << ", RTP=" << fmt.GetPayloadType() << endl;
        break;
      case OpalMediaFormat::DefaultVideoSessionID:
        cout << "video, rate=" << fmt.GetBandwidth() << ", RTP=" << fmt.GetPayloadType() << endl;
        break;
      case OpalMediaFormat::DefaultDataSessionID:
        cout << "data" << endl;;
        break;
      default:
        cout << "unknown type " << mediaList[i].GetDefaultSessionID() << endl;
    }
  }
}

void CodecInfo::Main()
{
  cout << GetName()
       << " Version " << GetVersion(TRUE)
       << " by " << GetManufacturer()
       << " on " << GetOSClass() << ' ' << GetOSName()
       << " (" << GetOSVersion() << '-' << GetOSHardware() << ")\n\n";

  // Get and parse all of the command line arguments.
  PArgList & args = GetArguments();
  args.Parse(
             "t-trace."
             "o-output:"
             "c-codecs."
             "h-help."
             "i-info:"
             "m-mediaformats."
             "p-pluginlist."
             "a-capabilities:"
             "C-caps:"
             "f-factory"
             , FALSE);


  PTrace::Initialise(args.GetOptionCount('t'),
                     args.HasOption('o') ? (const char *)args.GetOptionString('o') : NULL,
         PTrace::Blocks | PTrace::Timestamp | PTrace::Thread | PTrace::FileAndLine);

  OpalMediaFormat::List mediaList = OpalMediaFormat::GetRegisteredMediaFormats();
  H323PluginCodecManager & codecMgr = *(H323PluginCodecManager *)PFactory<PPluginModuleManager>::CreateInstance("H323PluginCodecManager");
  PPluginModuleManager::PluginListType pluginList = codecMgr.GetPluginList();
  OpalMediaFormat::List stdCodecList = H323PluginCodecManager::GetMediaFormats();
  H323CapabilityFactory::KeyList_T keyList = H323CapabilityFactory::GetKeyList();

  if (args.HasOption('a')) {
    cout << "Registered capabilities:" << endl
         << setfill(',') << PStringArray(keyList) << setfill(' ')
         << endl;
    return;
  }

  if (args.HasOption('C')) {
    PString spec = args.GetOptionString('C');
    H323Capabilities caps;
    caps.AddAllCapabilities(0, 0, spec);
    cout << "Standard capability set:" << caps << endl;
    for (PINDEX i = 0; i < stdCodecList.GetSize(); i++) {
      PString fmt = stdCodecList[i];
      caps.FindCapability(fmt);
    }
    return;
  }


  if (args.HasOption('c')) {
    cout << "Standard codecs:" << endl;
    DisplayMediaFormats(stdCodecList);
    return;
  }

  if (args.HasOption('m')) {
    cout << "Registered media formats:" << endl;
    DisplayMediaFormats(mediaList);
    return;
  }

  if (args.HasOption('p')) {
    cout << "Plugin codecs:" << endl;
    for (int i = 0; i < pluginList.GetSize(); i++) {
      cout << "   " << pluginList.GetKeyAt(i) << endl;
    }
    return;
  }

  if (args.HasOption('i')) {
    PString name = args.GetOptionString('i');
    if (name.IsEmpty()) {
      cout << "error: -i must specify name of plugin" << endl;
      return;
    }
    for (int i = 0; i < pluginList.GetSize(); i++) {
      if (pluginList.GetKeyAt(i) == name) {
        PDynaLink & dll = pluginList.GetDataAt(i);
        PluginCodec_GetCodecFunction getCodecs;
        if (!dll.GetFunction(PLUGIN_CODEC_GET_CODEC_FN_STR, (PDynaLink::Function &)getCodecs)) {
          cout << "error: " << name << " is missing the function " << PLUGIN_CODEC_GET_CODEC_FN_STR << endl;
          return;
        }
        unsigned int count;
        PluginCodec_Definition * codecs = (*getCodecs)(&count, PLUGIN_CODEC_VERSION);
        if (codecs == NULL || count == 0) {
          cout << "error: " << name << " does not define any codecs for this version of the plugin API" << endl;
          return;
        } 
        cout << name << " contains " << count << " coders:" << endl;
        for (unsigned j = 0; j < count; j++) {
          cout << "---------------------------------------" << endl
               << "Coder " << j+1 << endl;
          DisplayCodecDefn(codecs[j]);
        }
        return;
      }
    }
    cout << "error: plugin \"" << name << "\" not found" << endl;
    return;
  }

  if (args.HasOption('f')) {
    PFactory<OpalFactoryCodec>::KeyList_T list = PFactory<OpalFactoryCodec>::GetKeyList();
    cout << "Codec factories:" << endl;
    for (PFactory<OpalFactoryCodec>::KeyList_T::const_iterator r = list.begin(); r != list.end(); ++r)
      cout << *r << endl;
    PFactory<OpalFactoryCodec>::CreateInstance("G.711-uLaw-64k|L16");
    return;
  }

  cout << "available options:" << endl
       << "  -c --codecs         display standard codecs\n"
       << "  -h --help           display this help message\n"
       << "  -i --info name      display info about a plugin\n"
       << "  -m --mediaformats   display media formats\n"
       << "  -p --pluginlist     display codec plugins\n"
       << "  -C --caps spec      display capabilities that match the specification\n"
       << "  -f --factory        display codec conversion factories\n"
  ;
}

⌨️ 快捷键说明

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