📄 main.cxx
字号:
/*
* main.cxx
*
* A simple H.323 "net telephone" application.
*
* 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 Open H323
*
* The Initial Developer of the Original Code is Post Increment
*
* Contributor(s): ______________________________________.
*
* $Log: main.cxx,v $
* Revision 1.13 2005/07/23 01:54:47 rjongbloed
* Fixed some compiler warnings
*
* Revision 1.12 2004/08/26 08:05:03 csoutheren
* Codecs now appear in abstract factory system
* Fixed Windows factory bootstrap system (again)
*
* Revision 1.11 2004/06/30 12:31:09 rjongbloed
* Rewrite of plug in system to use single global variable for all factories to avoid all sorts
* of issues with startup orders and Windows DLL multiple instances.
*
* Revision 1.10 2004/06/18 02:25:15 csoutheren
* Added display of RTP payload types to media format display
*
* Revision 1.9 2004/06/15 10:12:07 csoutheren
* Added -C option
*
* Revision 1.8 2004/06/01 05:53:51 csoutheren
* Added option to show list of registered capabilities
*
* Revision 1.7 2004/05/23 12:38:40 rjongbloed
* Tidied up the output format of the codec listing
*
* Revision 1.6 2004/05/18 22:29:17 csoutheren
* Added trace commands
*
* Revision 1.5 2004/05/18 07:08:42 csoutheren
* Fixed problem with help being displayed in wrong places
*
* Revision 1.4 2004/05/18 00:05:15 rjongbloed
* Fixed Win32 compatibility
*
* Revision 1.3 2004/05/12 13:42:16 csoutheren
* Added more functions
*
* Revision 1.2 2004/05/11 14:07:34 csoutheren
* Updated to display all plugin codec information
*
* Revision 1.1 2004/05/11 01:19:37 csoutheren
* Initial version
*
*/
#include <ptlib.h>
#ifdef __GNUC__
#define H323_STATIC_LIB
#endif
#include <h323.h>
class CodecInfo : public PProcess
{
PCLASSINFO(CodecInfo, PProcess)
public:
CodecInfo();
void Main();
};
#define new PNEW
PCREATE_PROCESS(CodecInfo)
///////////////////////////////////////////////////////////////
CodecInfo::CodecInfo()
: PProcess("Post Increment", "CodecInfo")
{
}
PString DisplayLicenseType(int type)
{
PString str;
switch (type) {
case PluginCodec_Licence_None:
str = "No license";
break;
case PluginCodec_License_GPL:
str = "GPL";
break;
case PluginCodec_License_MPL:
str = "MPL";
break;
case PluginCodec_License_Freeware:
str = "Freeware";
break;
case PluginCodec_License_ResearchAndDevelopmentUseOnly:
str = "Research and development use only";
break;
case PluginCodec_License_BSD:
str = "BSD";
break;
default:
if (type <= PluginCodec_License_NoRoyalties)
str = "No royalty license";
else
str = "Requires royalties";
break;
}
return str;
}
PString DisplayableString(const char * str)
{
if (str == NULL)
return PString("(none)");
return PString(str);
}
PString DisplayLicenseInfo(PluginCodec_information * info)
{
PStringStream str;
if (info == NULL)
str << " None" << endl;
else {
str << " License" << endl
<< " Timestamp: " << PTime().AsString(PTime::RFC1123) << endl
<< " Source" << endl
<< " Author: " << DisplayableString(info->sourceAuthor) << endl
<< " Version: " << DisplayableString(info->sourceVersion) << endl
<< " Email: " << DisplayableString(info->sourceEmail) << endl
<< " URL: " << DisplayableString(info->sourceURL) << endl
<< " Copyright: " << DisplayableString(info->sourceCopyright) << endl
<< " License: " << DisplayableString(info->sourceLicense) << endl
<< " License Type: " << DisplayLicenseType(info->sourceLicenseCode) << endl
<< " Codec" << endl
<< " Description: " << DisplayableString(info->codecDescription) << endl
<< " Author: " << DisplayableString(info->codecAuthor) << endl
<< " Version: " << DisplayableString(info->codecVersion) << endl
<< " Email: " << DisplayableString(info->codecEmail) << endl
<< " URL: " << DisplayableString(info->codecURL) << endl
<< " Copyright: " << DisplayableString(info->codecCopyright) << endl
<< " License: " << DisplayableString(info->codecLicense) << endl
<< " License Type: " << DisplayLicenseType(info->codecLicenseCode) << endl;
}
return str;
}
void DisplayCodecDefn(PluginCodec_Definition & defn)
{
cout << " Version: " << defn.version << endl
<< DisplayLicenseInfo(defn.info)
<< " Flags: ";
switch (defn.flags & PluginCodec_MediaTypeMask) {
case PluginCodec_MediaTypeAudio:
cout << "Audio";
break;
case PluginCodec_MediaTypeVideo:
cout << "Video";
break;
case PluginCodec_MediaTypeAudioStreamed:
cout << "Streamed audio (" << ((defn.flags & PluginCodec_BitsPerSampleMask) >> PluginCodec_BitsPerSamplePos) << " bits per sample)";
break;
default:
cout << "unknown type " << (defn.flags & PluginCodec_MediaTypeMask) << endl;
break;
}
cout << ", " << ((defn.flags & PluginCodec_InputTypeRTP) ? "RTP input" : "raw input");
cout << ", " << ((defn.flags & PluginCodec_OutputTypeRTP) ? "RTP output" : "raw output");
cout << ", " << ((defn.flags & PluginCodec_RTPTypeExplicit) ? "explicit" : "dynamic") << " RTP payload";
cout << endl;
cout << " Description: " << defn.descr << endl
<< " Source format: " << defn.sourceFormat << endl
<< " Dest format: " << defn.destFormat << endl
<< " Userdata: " << (void *)defn.userData << endl
<< " Sample rate: " << defn.sampleRate << endl
<< " Bits/sec: " << defn.bitsPerSec << endl
<< " Ns/frame: " << defn.nsPerFrame << endl
<< " Samples/frame: " << defn.samplesPerFrame << endl
<< " Bytes/frame: " << defn.bytesPerFrame << endl
<< " Frames/packet: " << defn.recommendedFramesPerPacket << endl
<< " Frames/packet (max): " << defn.maxFramesPerPacket << endl
<< " RTP payload: ";
if (defn.flags & PluginCodec_RTPTypeExplicit)
cout << (int)defn.rtpPayload << endl;
else
cout << "(not used)";
cout << endl
<< " SDP format: " << DisplayableString(defn.sdpFormat) << endl;
cout << " Create function: " << (void *)defn.createCodec << endl
<< " Destroy function: " << (void *)defn.destroyCodec << endl
<< " Encode function: " << (void *)defn.codecFunction << endl;
cout << " Codec controls: ";
if (defn.codecControls == NULL)
cout << "(none)" << endl;
else {
cout << endl;
PluginCodec_ControlDefn * ctls = defn.codecControls;
while (ctls->name != NULL) {
cout << " " << ctls->name << "(" << (void *)ctls->control << ")" << endl;
++ctls;
}
}
static char * capabilityNames[] = {
"not defined",
"programmed",
"nonStandard",
"generic",
// audio codecs
"G.711 Alaw 64k",
"G.711 Alaw 56k",
"G.711 Ulaw 64k",
"G.711 Ulaw 56k",
"G.722 64k",
"G.722 56k",
"G.722 48k",
"G.723.1",
"G.728",
"G.729",
"G.729 Annex A",
"is11172",
"is13818 Audio",
"G.729 Annex B",
"G.729 Annex A and Annex B",
"G.723.1 Annex C",
"GSM Full Rate",
"GSM Half Rate",
"GSM Enhanced Full Rate",
"G.729 Extensions",
// video codecs
"H.261",
"H.262",
"H.263",
"is11172"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -